asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mhub...@apache.org
Subject asterixdb git commit: [NO ISSUE][REPL] Ensure Thread Safety of ReplicaManager
Date Mon, 19 Feb 2018 16:49:59 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 914be5ade -> c587da107


[NO ISSUE][REPL] Ensure Thread Safety of ReplicaManager

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Ensure thread safety of ReplicaManager to eliminate
  possible concurrent modifications between reading
  and modifying current replicas.

Change-Id: Ied7549436f7d721341c6699231a202545bac6252
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2402
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/c587da10
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/c587da10
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/c587da10

Branch: refs/heads/master
Commit: c587da107c004fa8a5830a41d515f9eb1a1b48f3
Parents: 914be5a
Author: Murtadha Hubail <mhubail@apache.org>
Authored: Mon Feb 19 08:29:14 2018 +0300
Committer: Murtadha Hubail <mhubail@apache.org>
Committed: Mon Feb 19 08:49:23 2018 -0800

----------------------------------------------------------------------
 .../main/java/org/apache/asterix/app/nc/ReplicaManager.java  | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c587da10/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/ReplicaManager.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/ReplicaManager.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/ReplicaManager.java
index 30416a3..c821c56 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/ReplicaManager.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/ReplicaManager.java
@@ -40,9 +40,11 @@ import org.apache.hyracks.api.config.IApplicationConfig;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.control.common.controllers.NCConfig;
 import org.apache.hyracks.storage.common.LocalResource;
+import org.apache.hyracks.util.annotations.ThreadSafe;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
+@ThreadSafe
 public class ReplicaManager implements IReplicaManager {
     private static final Logger LOGGER = LogManager.getLogger();
 
@@ -86,13 +88,13 @@ public class ReplicaManager implements IReplicaManager {
     }
 
     @Override
-    public List<IPartitionReplica> getReplicas(int partition) {
+    public synchronized List<IPartitionReplica> getReplicas(int partition) {
         return replicas.entrySet().stream().filter(e -> e.getKey().getPartition() == partition).map(Map.Entry::getValue)
                 .collect(Collectors.toList());
     }
 
     @Override
-    public Set<Integer> getPartitions() {
+    public synchronized Set<Integer> getPartitions() {
         return Collections.unmodifiableSet(partitions);
     }
 
@@ -110,7 +112,7 @@ public class ReplicaManager implements IReplicaManager {
     }
 
     @Override
-    public void release(int partition) throws HyracksDataException {
+    public synchronized void release(int partition) throws HyracksDataException {
         if (!partitions.contains(partition)) {
             return;
         }


Mime
View raw message