Create an implementaion of IntentIdGenerator
- Define interface to allocate IdBlock in IdBlockAllocator
- Implement IdBlockAllocatorBasedIntentIdGenerator
- Refactor IdBlock class
Change-Id: I21fa21ae625e3d7e137a7f846bb5a0c1bdb8df9a
diff --git a/src/main/java/net/onrc/onos/core/util/IdBlockAllocator.java b/src/main/java/net/onrc/onos/core/util/IdBlockAllocator.java
new file mode 100644
index 0000000..3c38205
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/util/IdBlockAllocator.java
@@ -0,0 +1,23 @@
+package net.onrc.onos.core.util;
+
+import net.onrc.onos.core.registry.IdBlock;
+
+/**
+ * An interface that gives unique ID spaces.
+ */
+public interface IdBlockAllocator {
+ /**
+ * Allocates a unique Id Block.
+ *
+ * @return Id Block.
+ */
+ IdBlock allocateUniqueIdBlock();
+
+ /**
+ * Allocates next unique id and retrieve a new range of ids if needed.
+ *
+ * @param range range to use for the identifier
+ * @return Id Block.
+ */
+ IdBlock allocateUniqueIdBlock(long range);
+}