IDs for MatchAction objects using block allocation

Modified MatchActionId and MatchActionOperationsId to
use longs as IDs and to use ID block allocation to
create them.

Change-Id: I757b353a94a498f624df345cbc16975714db15b3
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsIdGeneratorWithIdBlockAllocator.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsIdGeneratorWithIdBlockAllocator.java
new file mode 100644
index 0000000..d1d5240
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionOperationsIdGeneratorWithIdBlockAllocator.java
@@ -0,0 +1,37 @@
+package net.onrc.onos.core.matchaction;
+
+import net.onrc.onos.core.util.IdBlock;
+import net.onrc.onos.core.util.IdBlockAllocator;
+import net.onrc.onos.core.util.UnavailableIdException;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Generates a global unique MatchActionIdId.
+ */
+public class MatchActionOperationsIdGeneratorWithIdBlockAllocator
+        implements MatchActionOperationsIdGenerator {
+
+        private final IdBlockAllocator allocator;
+        private IdBlock idBlock;
+
+        /**
+          * Creates a FlowId generator instance using specified ID block allocator.
+          *
+          * @param allocator the ID block allocator to be used
+          */
+        public MatchActionOperationsIdGeneratorWithIdBlockAllocator(IdBlockAllocator allocator) {
+            this.allocator = checkNotNull(allocator);
+            this.idBlock = allocator.allocateUniqueIdBlock();
+        }
+
+        @Override
+        public synchronized MatchActionOperationsId getNewId() {
+            try {
+                return new MatchActionOperationsId(idBlock.getNextId());
+            } catch (UnavailableIdException e) {
+                idBlock = allocator.allocateUniqueIdBlock();
+                return new MatchActionOperationsId(idBlock.getNextId());
+            }
+        }
+}