Fix issues found by FindBugs: ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD
http://findbugs.sourceforge.net/bugDescriptions.html#ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD
Change-Id: I6a2c7b9e47f8933c77e42cea355c77406485beb9
diff --git a/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java b/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
index 504e661..070850d 100755
--- a/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
+++ b/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
@@ -96,8 +96,10 @@
// instead of a ramdon generator.
//
private static Random randomGenerator = new Random();
- private static int nextUniqueIdPrefix = 0;
- private static int nextUniqueIdSuffix = 0;
+ private static long nextUniqueIdPrefix = 0;
+ // NOTE: The 0xffffffffL value is used by the Unique ID generator for
+ // initialization purpose.
+ private static long nextUniqueIdSuffix = 0xffffffffL;
private final BlockingQueue<SwitchLeaderEvent> switchLeadershipEvents =
new LinkedBlockingQueue<SwitchLeaderEvent>();
@@ -502,7 +504,7 @@
} else {
nextUniqueIdSuffix++;
}
- long result = (long) nextUniqueIdPrefix << 32;
+ long result = nextUniqueIdPrefix << 32;
result = result | (0xffffffffL & nextUniqueIdSuffix);
return result;
}
@@ -550,12 +552,6 @@
}
log.info("Setting Zookeeper connection string to {}", this.connectionString);
- //
- // Initialize the Unique ID generator
- // TODO: This must be replaced by Zookeeper-based allocation
- //
- nextUniqueIdPrefix = randomGenerator.nextInt();
-
restApi = context.getServiceImpl(IRestApiService.class);
switches = new ConcurrentHashMap<String, SwitchLeadershipData>();