You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/02/23 04:53:01 UTC

[GitHub] [incubator-inlong] pocozh opened a new pull request #2670: [INLONG-2568][DataProxy] Support dynamically getting TubeMq config from Manager

pocozh opened a new pull request #2670:
URL: https://github.com/apache/incubator-inlong/pull/2670


   
   ### Title Name: [INLONG-2568][DataProxy] Support dynamically getting TubeMq config from Manager
   
   Fixes #2568 
   
   ### Modifications
   
   1. Manager support TubeMq config info
   2. MetaSink support to be dynamically configured with config info from Manager
   3. MetaSink support multi-clusters dispatch
   4. Improve the update method of pulsar clients when pulsar service urls change
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2670: [INLONG-2568][DataProxy] Support dynamically getting TubeMq config from Manager

Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-inlong] pocozh commented on a change in pull request #2670: [INLONG-2568][DataProxy] Support dynamically getting TubeMq config from Manager

Posted by GitBox <gi...@apache.org>.
pocozh commented on a change in pull request #2670:
URL: https://github.com/apache/incubator-inlong/pull/2670#discussion_r813546045



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/sink/PulsarSink.java
##########
@@ -283,21 +291,28 @@ public void diffSetPublish(PulsarClientService pulsarClientService, Set<String>
      * @param originalCluster
      * @param endCluster
      */
-    public void diffRestartPulsarClient(Set<String> originalCluster, Set<String> endCluster) {
-        if (!originalCluster.equals(endCluster)) {
-            logger.info("pulsarConfig has changed, close current pulsarClientService and restart");
-            pulsarClientService.close();
-
-            pulsarCluster = configManager.getPulsarUrl2Token();
-            configManager.getPulsarConfig().setUrl2token(pulsarCluster);
-            pulsarClientService.initCreateConnection(this);
-            try {
-                initTopicSet(pulsarClientService, new HashSet<String>(topicProperties.values()));
-            } catch (Exception e) {
-                logger.info("pulsar sink restart, publish topic fail.", e);
-            }
+    public void diffUpdatePulsarClient(PulsarClientService pulsarClientService, Map<String, String> originalCluster,
+                                       Map<String, String> endCluster) {
+        MapDifference<String, String> mapDifference = Maps.difference(originalCluster, endCluster);
+        if (mapDifference.areEqual()) {
+            return;
+        }
 
+        logger.info("pulsarConfig has changed, close unused url clients and start new url clients");
+        Map<String, String> needToStart = new HashMap<>();
+        Map<String, String> needToClose = new HashMap<>();
+        needToClose.putAll(mapDifference.entriesOnlyOnLeft());
+        needToStart.putAll(mapDifference.entriesOnlyOnRight());
+        Map<String, MapDifference.ValueDifference<String>> differentToken = mapDifference.entriesDiffering();
+        for (String url : differentToken.keySet()) {
+            needToClose.put(url, originalCluster.get(url));
+            needToStart.put(url, endCluster.get(url));//token changed
         }
+
+        pulsarClientService.updatePulsarClients(this, needToClose, needToStart,

Review comment:
       There is a resend mechanism in sendMessage method. If its send operation is not completed when a pulsar client is closed, current event will be added into resendQueue to resend. 




-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2670: [INLONG-2568][DataProxy] Support dynamically getting TubeMq config from Manager

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2670:
URL: https://github.com/apache/incubator-inlong/pull/2670#discussion_r813636803



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/sink/PulsarSink.java
##########
@@ -283,21 +291,28 @@ public void diffSetPublish(PulsarClientService pulsarClientService, Set<String>
      * @param originalCluster
      * @param endCluster
      */
-    public void diffRestartPulsarClient(Set<String> originalCluster, Set<String> endCluster) {
-        if (!originalCluster.equals(endCluster)) {
-            logger.info("pulsarConfig has changed, close current pulsarClientService and restart");
-            pulsarClientService.close();
-
-            pulsarCluster = configManager.getPulsarUrl2Token();
-            configManager.getPulsarConfig().setUrl2token(pulsarCluster);
-            pulsarClientService.initCreateConnection(this);
-            try {
-                initTopicSet(pulsarClientService, new HashSet<String>(topicProperties.values()));
-            } catch (Exception e) {
-                logger.info("pulsar sink restart, publish topic fail.", e);
-            }
+    public void diffUpdatePulsarClient(PulsarClientService pulsarClientService, Map<String, String> originalCluster,
+                                       Map<String, String> endCluster) {
+        MapDifference<String, String> mapDifference = Maps.difference(originalCluster, endCluster);
+        if (mapDifference.areEqual()) {
+            return;
+        }
 
+        logger.info("pulsarConfig has changed, close unused url clients and start new url clients");
+        Map<String, String> needToStart = new HashMap<>();
+        Map<String, String> needToClose = new HashMap<>();
+        needToClose.putAll(mapDifference.entriesOnlyOnLeft());
+        needToStart.putAll(mapDifference.entriesOnlyOnRight());
+        Map<String, MapDifference.ValueDifference<String>> differentToken = mapDifference.entriesDiffering();
+        for (String url : differentToken.keySet()) {
+            needToClose.put(url, originalCluster.get(url));
+            needToStart.put(url, endCluster.get(url));//token changed
         }
+
+        pulsarClientService.updatePulsarClients(this, needToClose, needToStart,

Review comment:
       The method "resendEvent" only is invoked in catchException and handleMessageSendException.
   No catchException and handleMessageSendException when a pulsar client is closed.
   




-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2670: [INLONG-2568][DataProxy] Support dynamically getting TubeMq config from Manager

Posted by GitBox <gi...@apache.org>.
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:
       Two producer will be created and initted, and one producer will never be closed.




-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2670: [INLONG-2568][DataProxy] Support dynamically getting TubeMq config from Manager

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2670:
URL: https://github.com/apache/incubator-inlong/pull/2670#discussion_r813489361



##########
File path: inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/DataProxyClusterServiceImpl.java
##########
@@ -264,16 +279,17 @@ public ProxyPulsarDTO getConfigV2(String dataproxyClusterName) {
          */

Review comment:
       It is not suggested to use "/* */ in code block.

##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/sink/PulsarSink.java
##########
@@ -283,21 +291,28 @@ public void diffSetPublish(PulsarClientService pulsarClientService, Set<String>
      * @param originalCluster
      * @param endCluster
      */
-    public void diffRestartPulsarClient(Set<String> originalCluster, Set<String> endCluster) {
-        if (!originalCluster.equals(endCluster)) {
-            logger.info("pulsarConfig has changed, close current pulsarClientService and restart");
-            pulsarClientService.close();
-
-            pulsarCluster = configManager.getPulsarUrl2Token();
-            configManager.getPulsarConfig().setUrl2token(pulsarCluster);
-            pulsarClientService.initCreateConnection(this);
-            try {
-                initTopicSet(pulsarClientService, new HashSet<String>(topicProperties.values()));
-            } catch (Exception e) {
-                logger.info("pulsar sink restart, publish topic fail.", e);
-            }
+    public void diffUpdatePulsarClient(PulsarClientService pulsarClientService, Map<String, String> originalCluster,
+                                       Map<String, String> endCluster) {
+        MapDifference<String, String> mapDifference = Maps.difference(originalCluster, endCluster);
+        if (mapDifference.areEqual()) {
+            return;
+        }
 
+        logger.info("pulsarConfig has changed, close unused url clients and start new url clients");
+        Map<String, String> needToStart = new HashMap<>();
+        Map<String, String> needToClose = new HashMap<>();
+        needToClose.putAll(mapDifference.entriesOnlyOnLeft());
+        needToStart.putAll(mapDifference.entriesOnlyOnRight());
+        Map<String, MapDifference.ValueDifference<String>> differentToken = mapDifference.entriesDiffering();
+        for (String url : differentToken.keySet()) {
+            needToClose.put(url, originalCluster.get(url));
+            needToStart.put(url, endCluster.get(url));//token changed
         }
+
+        pulsarClientService.updatePulsarClients(this, needToClose, needToStart,

Review comment:
       It is not enough that pulsar client only use two status "start and close".
   Closing status is necessary for waiting the completion of sending messages.
   

##########
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:
       Miss the close operation of topic producer, it will lost the messages in the producer buffer.

##########
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:
       The operation of "pulsarClients.put(url, client)" must move after the init opeartion of topic producer.
   It maybe have crash of the init opeartion of topic producer between sendMessage and updatePulsarClients.

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

Review comment:
       This comment is not fit for the method name "updatePulsarClients"




-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-inlong] pocozh commented on a change in pull request #2670: [INLONG-2568][DataProxy] Support dynamically getting TubeMq config from Manager

Posted by GitBox <gi...@apache.org>.
pocozh commented on a change in pull request #2670:
URL: https://github.com/apache/incubator-inlong/pull/2670#discussion_r813552095



##########
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:
       done




-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-inlong] pocozh commented on a change in pull request #2670: [INLONG-2568][DataProxy] Support dynamically getting TubeMq config from Manager

Posted by GitBox <gi...@apache.org>.
pocozh commented on a change in pull request #2670:
URL: https://github.com/apache/incubator-inlong/pull/2670#discussion_r813532439



##########
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:
       In sendMessage method, dispatching message to topic producer is based on producerInfoMap(topic->producer), instead of pulsarClients. So, if a producer is not initialized, it will not be allocated to send message.




-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-inlong] pocozh commented on a change in pull request #2670: [INLONG-2568][DataProxy] Support dynamically getting TubeMq config from Manager

Posted by GitBox <gi...@apache.org>.
pocozh commented on a change in pull request #2670:
URL: https://github.com/apache/incubator-inlong/pull/2670#discussion_r813546045



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/sink/PulsarSink.java
##########
@@ -283,21 +291,28 @@ public void diffSetPublish(PulsarClientService pulsarClientService, Set<String>
      * @param originalCluster
      * @param endCluster
      */
-    public void diffRestartPulsarClient(Set<String> originalCluster, Set<String> endCluster) {
-        if (!originalCluster.equals(endCluster)) {
-            logger.info("pulsarConfig has changed, close current pulsarClientService and restart");
-            pulsarClientService.close();
-
-            pulsarCluster = configManager.getPulsarUrl2Token();
-            configManager.getPulsarConfig().setUrl2token(pulsarCluster);
-            pulsarClientService.initCreateConnection(this);
-            try {
-                initTopicSet(pulsarClientService, new HashSet<String>(topicProperties.values()));
-            } catch (Exception e) {
-                logger.info("pulsar sink restart, publish topic fail.", e);
-            }
+    public void diffUpdatePulsarClient(PulsarClientService pulsarClientService, Map<String, String> originalCluster,
+                                       Map<String, String> endCluster) {
+        MapDifference<String, String> mapDifference = Maps.difference(originalCluster, endCluster);
+        if (mapDifference.areEqual()) {
+            return;
+        }
 
+        logger.info("pulsarConfig has changed, close unused url clients and start new url clients");
+        Map<String, String> needToStart = new HashMap<>();
+        Map<String, String> needToClose = new HashMap<>();
+        needToClose.putAll(mapDifference.entriesOnlyOnLeft());
+        needToStart.putAll(mapDifference.entriesOnlyOnRight());
+        Map<String, MapDifference.ValueDifference<String>> differentToken = mapDifference.entriesDiffering();
+        for (String url : differentToken.keySet()) {
+            needToClose.put(url, originalCluster.get(url));
+            needToStart.put(url, endCluster.get(url));//token changed
         }
+
+        pulsarClientService.updatePulsarClients(this, needToClose, needToStart,

Review comment:
       There is a resend mechanism in sendMessage method. If its send operation is not completed when a pulsar client is closed, current event will be added into resendQueue for resend. 




-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-inlong] dockerzhang merged pull request #2670: [INLONG-2568][DataProxy] Support dynamically getting TubeMq config from Manager

Posted by GitBox <gi...@apache.org>.
dockerzhang merged pull request #2670:
URL: https://github.com/apache/incubator-inlong/pull/2670


   


-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org