SONAR: Synchronization On Boxed Primitives

Synchronization should not be based on Strings or boxed primitives

Fixes:
 - https://asterix-sonar.ics.uci.edu/issues/search#issues=AVR98lUKuXNBBqjTzg_N
 - https://asterix-sonar.ics.uci.edu/issues/search#issues=AVR98lUKuXNBBqjTzg_O
 - https://asterix-sonar.ics.uci.edu/issues/search#issues=AVR98lUKuXNBBqjTzg_P

Change-Id: I520582cb5a03d775d696ec5b4390b571322e18f7
Reviewed-on: https://asterix-gerrit.ics.uci.edu/853
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ClusterStateWatcher.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ClusterStateWatcher.java
index 2ef8697..f823404 100644
--- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ClusterStateWatcher.java
+++ b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ClusterStateWatcher.java
@@ -25,8 +25,8 @@
 
 //A zookeeper watcher that watches the change in the state of the cluster
 public class ClusterStateWatcher implements Watcher {
-    private static Integer mutex;
-    private static ZooKeeper zk;
+    private final Object mutex = new Object();
+    private final ZooKeeper zk;
     private String clusterStatePath;
     private boolean done = false;
     private ClusterState clusterState = ClusterState.STARTING;
@@ -35,12 +35,9 @@
     private static Logger LOGGER = Logger.getLogger(ClusterStateWatcher.class.getName());
 
     public ClusterStateWatcher(ZooKeeper zk, String clusterName) {
-        if (mutex == null) {
-            mutex = new Integer(-1);
-        }
         this.clusterStatePath = ZooKeeperService.ASTERIX_INSTANCE_BASE_PATH + File.separator + clusterName
                 + ZooKeeperService.ASTERIX_INSTANCE_STATE_PATH;
-        ClusterStateWatcher.zk = zk;
+        this.zk = zk;
     }
 
     public ClusterState waitForClusterStart() throws Exception {