luchunliang commented on a change in pull request #2670:
URL: https://github.com/apache/incubator-inlong/pull/2670#discussion_r813638042



##########
File path: 
inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/sink/pulsar/PulsarClientService.java
##########
@@ -299,6 +300,65 @@ private void destroyConnection() {
         logger.debug("closed meta producer");
     }
 
+    /**
+     * close pulsarClients(the related url is removed); start pulsarClients 
for new url, and create producers for them
+     *
+     * @param callBack
+     * @param needToClose url-token map
+     * @param needToStart url-token map
+     * @param topicSet    for new pulsarClient, create these topics' producers
+     */
+    public void updatePulsarClients(CreatePulsarClientCallBack callBack, 
Map<String, String> needToClose,
+                                    Map<String, String> needToStart, 
Set<String> topicSet) {
+        // close
+        for (String url : needToClose.keySet()) {
+            PulsarClient pulsarClient = pulsarClients.get(url);
+            if (pulsarClient != null) {
+                try {
+                    pulsarClient.shutdown();
+                    pulsarClients.remove(url);
+                } catch (PulsarClientException e) {
+                    logger.error("shutdown pulsarClient error in PulsarSink, 
PulsarClientException {}",
+                            e.getMessage());
+                } catch (Exception e) {
+                    logger.error("shutdown pulsarClient error in PulsarSink, 
ex {}", e.getMessage());
+                }
+            }
+        }
+        // new pulsarClient
+        for (Map.Entry<String, String> entry : needToStart.entrySet()) {
+            String url = entry.getKey();
+            String token = entry.getValue();
+            try {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("url = {}, token = {}", url, token);
+                }
+                PulsarClient client = initPulsarClient(url, token);
+                pulsarClients.put(url, client);
+                callBack.handleCreateClientSuccess(url);

Review comment:
       ok

##########
File path: 
inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/sink/pulsar/PulsarClientService.java
##########
@@ -299,6 +300,65 @@ private void destroyConnection() {
         logger.debug("closed meta producer");
     }
 
+    /**
+     * close pulsarClients(the related url is removed); start pulsarClients 
for new url, and create producers for them
+     *
+     * @param callBack
+     * @param needToClose url-token map
+     * @param needToStart url-token map
+     * @param topicSet    for new pulsarClient, create these topics' producers
+     */
+    public void updatePulsarClients(CreatePulsarClientCallBack callBack, 
Map<String, String> needToClose,
+                                    Map<String, String> needToStart, 
Set<String> topicSet) {
+        // close
+        for (String url : needToClose.keySet()) {
+            PulsarClient pulsarClient = pulsarClients.get(url);
+            if (pulsarClient != null) {
+                try {
+                    pulsarClient.shutdown();

Review comment:
       ok




-- 
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]


Reply via email to