luchunliang commented on a change in pull request #1942: URL: https://github.com/apache/incubator-inlong/pull/1942#discussion_r767378084
########## File path: inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/pulsar/PulsarFederationSinkContext.java ########## @@ -0,0 +1,122 @@ +/** + * 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.inlong.sort.standalone.sink.pulsar; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.flume.Channel; +import org.apache.flume.Context; +import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigHolder; +import org.apache.inlong.sort.standalone.config.pojo.CacheClusterConfig; +import org.apache.inlong.sort.standalone.config.pojo.InlongId; +import org.apache.inlong.sort.standalone.config.pojo.SortTaskConfig; +import org.apache.inlong.sort.standalone.sink.SinkContext; +import org.apache.inlong.sort.standalone.utils.Constants; +import org.slf4j.Logger; +import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory; + +/** + * + * PulsarFederationSinkContext + */ +public class PulsarFederationSinkContext extends SinkContext { + + public static final Logger LOG = InlongLoggerFactory.getLogger(PulsarFederationSinkContext.class); + + private Context producerContext; + private Map<String, String> idTopicMap = new ConcurrentHashMap<>(); + private List<CacheClusterConfig> clusterConfigList = new ArrayList<>(); + + /** + * Constructor + * + * @param sinkName + * @param context + * @param channel + */ + public PulsarFederationSinkContext(String sinkName, Context context, Channel channel) { + super(sinkName, context, channel); + } + + /** + * reload + */ + public void reload() { + super.reload(); + try { + SortTaskConfig newSortTaskConfig = SortClusterConfigHolder.getTaskConfig(taskName); + if (this.sortTaskConfig != null && this.sortTaskConfig.equals(newSortTaskConfig)) { + return; + } + this.sortTaskConfig = newSortTaskConfig; + this.producerContext = new Context(this.sortTaskConfig.getSinkParams()); + // Review comment: add comment -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
