Merge JavaDoc modification and refactor.
diff --git a/src/main/java/net/onrc/onos/registry/controller/StandaloneRegistry.java b/src/main/java/net/onrc/onos/registry/controller/StandaloneRegistry.java
index 7e82bf0..640a49d 100644
--- a/src/main/java/net/onrc/onos/registry/controller/StandaloneRegistry.java
+++ b/src/main/java/net/onrc/onos/registry/controller/StandaloneRegistry.java
@@ -118,12 +118,17 @@
private long blockTop = 0L;
private static final long BLOCK_SIZE = 0x1000000L;
+
+ /**
+ * Returns a block of IDs which are unique and unused.
+ * Range of IDs is fixed size and is assigned incrementally as this method called.
+ */
@Override
- public IdBlock allocateUniqueIdBlock(){
+ public synchronized IdBlock allocateUniqueIdBlock(){
long blockHead = blockTop;
long blockTail = blockTop + BLOCK_SIZE;
- IdBlock block = new IdBlock(blockHead, blockTail, BLOCK_SIZE);
+ IdBlock block = new IdBlock(blockHead, blockTail - 1, BLOCK_SIZE);
blockTop = blockTail;
return block;
diff --git a/src/main/java/net/onrc/onos/registry/controller/ZookeeperRegistry.java b/src/main/java/net/onrc/onos/registry/controller/ZookeeperRegistry.java
index f9fb62e..2d2083f 100644
--- a/src/main/java/net/onrc/onos/registry/controller/ZookeeperRegistry.java
+++ b/src/main/java/net/onrc/onos/registry/controller/ZookeeperRegistry.java
@@ -379,6 +379,12 @@
return data;
}
+ /**
+ * Returns a block of IDs which are unique and unused.
+ * Range of IDs is fixed size and is assigned incrementally as this method called.
+ * Since the range of IDs is managed by Zookeeper in distributed way, this method may block when
+ * requests come up simultaneously.
+ */
public IdBlock allocateUniqueIdBlock(){
try {
AtomicValue<Long> result = null;