You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2020/02/03 03:12:11 UTC

[GitHub] [hbase] bharathv commented on a change in pull request #934: HBASE-23568: Improve Threading of Replication

bharathv commented on a change in pull request #934: HBASE-23568: Improve Threading of Replication
URL: https://github.com/apache/hbase/pull/934#discussion_r373907685
 
 

 ##########
 File path: hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
 ##########
 @@ -304,31 +318,56 @@ private void initializeWALEntryFilter(UUID peerClusterId) {
     this.walEntryFilter = new ChainWALEntryFilter(filters);
   }
 
-  private void tryStartNewShipper(String walGroupId, PriorityBlockingQueue<Path> queue) {
-    workerThreads.compute(walGroupId, (key, value) -> {
-      if (value != null) {
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(
-              "{} Someone has beat us to start a worker thread for wal group {}",
-              logPeerId(), key);
-        }
-        return value;
-      } else {
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("{} Starting up worker for wal group {}", logPeerId(), key);
+  /**
+   * Synchronized method so that only one item is inserted at a time. Should be the only place that
+   * insertions are performed on the workerThreads data structure.
+   *
+   * @param walGroupId The WAL group ID
+   * @param queue The queue of paths to process
+   */
+  private synchronized void tryStartNewShipper(final String walGroupId,
+      final PriorityBlockingQueue<Path> queue) {
+
+    if (workerThreads.containsKey(walGroupId)) {
+      return;
+    }
+
+    LOG.debug("{} Register worker for wallGroupID {}", logPeerId(), walGroupId);
 
 Review comment:
   nit: I think you need a isDebugEnabled() check because logPeerId() has an unnecessary string construction when debug log is not enabled.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services