hililiwei commented on code in PR #7360: URL: https://github.com/apache/iceberg/pull/7360#discussion_r1170120689
########## flink/v1.17/flink/src/main/java/org/apache/iceberg/flink/sink/shuffle/DataStatisticsCoordinatorProvider.java: ########## @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.flink.sink.shuffle; + +import java.io.Serializable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import javax.annotation.Nullable; +import org.apache.flink.annotation.VisibleForTesting; +import org.apache.flink.runtime.jobgraph.OperatorID; +import org.apache.flink.runtime.operators.coordination.OperatorCoordinator; +import org.apache.flink.runtime.operators.coordination.RecreateOnResetOperatorCoordinator; +import org.apache.flink.util.FatalExitExceptionHandler; +import org.jetbrains.annotations.NotNull; + +public class DataStatisticsCoordinatorProvider<K extends Serializable> + extends RecreateOnResetOperatorCoordinator.Provider { + + private final String operatorName; + private final DataStatisticsFactory<K> dataStatisticsFactory; + + public DataStatisticsCoordinatorProvider( + String operatorName, OperatorID operatorID, DataStatisticsFactory<K> dataStatisticsFactory) { + super(operatorID); + this.operatorName = operatorName; + this.dataStatisticsFactory = dataStatisticsFactory; + } + + @Override + public OperatorCoordinator getCoordinator(OperatorCoordinator.Context context) { + DataStatisticsCoordinatorProvider.CoordinatorExecutorThreadFactory coordinatorThreadFactory = + new DataStatisticsCoordinatorProvider.CoordinatorExecutorThreadFactory( + "DataStatisticsCoordinator-" + operatorName, context.getUserCodeClassloader()); + ExecutorService coordinatorExecutor = + Executors.newSingleThreadExecutor(coordinatorThreadFactory); + DataStatisticsCoordinatorContext<K> dataStatisticsCoordinatorContext = Review Comment: nit: I suggest that we can create the `DataStatisticsCoordinatorContext` in the open method of `DataStatisticsCoordinator`, and let `DataStatisticsCoordinator` manage the `ExecutorService` uniformly. The advantages of doing this are that it can enhance the code hierarchy and make the management of thread pool more clear and explicit. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org