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/MatchActionIdGeneratorWithIdBlockAllocator.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionIdGeneratorWithIdBlockAllocator.java
new file mode 100644
index 0000000..2c92ff7
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionIdGeneratorWithIdBlockAllocator.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 MatchActionIdGeneratorWithIdBlockAllocator
+        implements MatchActionIdGenerator {
+
+        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 MatchActionIdGeneratorWithIdBlockAllocator(IdBlockAllocator allocator) {
+            this.allocator = checkNotNull(allocator);
+            this.idBlock = allocator.allocateUniqueIdBlock();
+        }
+
+        @Override
+        public synchronized MatchActionId getNewId() {
+            try {
+                return new MatchActionId(idBlock.getNextId());
+            } catch (UnavailableIdException e) {
+                idBlock = allocator.allocateUniqueIdBlock();
+                return new MatchActionId(idBlock.getNextId());
+            }
+        }
+}