Add Id generator implementation to Match Action

Implement the ID generators for MatchActionId
and MatchActionOperationsId

Change-Id: Iee90771999ed79870c0a3b686f6ddb1228440a91
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionComponent.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionComponent.java
index a415316..52e7dd9 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionComponent.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionComponent.java
@@ -22,7 +22,9 @@
 import net.onrc.onos.core.datagrid.IEventChannel;
 import net.onrc.onos.core.datagrid.IEventChannelListener;
 import net.onrc.onos.core.flowprogrammer.IFlowPusherService;
+import net.onrc.onos.core.registry.IControllerRegistryService;
 import net.onrc.onos.core.util.Dpid;
+import net.onrc.onos.core.util.IdBlockAllocator;
 import net.onrc.onos.core.util.IdGenerator;
 import net.onrc.onos.core.util.SwitchPort;
 
@@ -31,7 +33,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 /**
  * Manages Match-Action entries.
  * <p>
@@ -57,16 +58,28 @@
     private Thread coordinator;
     private Thread installer;
     private final IDatagridService datagrid;
+    private IControllerRegistryService registryService;
+
+    private MatchActionIdGeneratorWithIdBlockAllocator matchActionIdGenerator;
+    private MatchActionOperationsIdGeneratorWithIdBlockAllocator matchActionOperationsIdGenerator;
 
     public MatchActionComponent(final IDatagridService newDatagrid,
                                 final IFlowPusherService newPusher,
-                                final IFloodlightProviderService newProvider) {
+                                final IFloodlightProviderService newProvider,
+                                final IControllerRegistryService newRegistryService) {
         datagrid = newDatagrid;
         pusher = newPusher;
         provider = newProvider;
+        registryService = newRegistryService;
     }
 
     public void start() {
+        IdBlockAllocator idBlockAllocator = registryService;
+        matchActionIdGenerator =
+                new MatchActionIdGeneratorWithIdBlockAllocator(idBlockAllocator);
+        matchActionOperationsIdGenerator =
+                new MatchActionOperationsIdGeneratorWithIdBlockAllocator(idBlockAllocator);
+
         installSetChannel = datagrid.createChannel("onos.matchaction.installSetChannel",
                 String.class,
                 MatchActionOperations.class);
@@ -387,12 +400,12 @@
 
     @Override
     public IdGenerator<MatchActionId> getMatchActionIdGenerator() {
-        return null;
+        return matchActionIdGenerator;
     }
 
     @Override
     public IdGenerator<MatchActionOperationsId> getMatchActionOperationsIdGenerator() {
-        return null;
+        return matchActionOperationsIdGenerator;
     }
 
 }
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
index eaf7a39..8255035 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
@@ -1,17 +1,5 @@
 package net.onrc.onos.core.matchaction;
 
-import net.floodlightcontroller.core.IFloodlightProviderService;
-import net.floodlightcontroller.core.module.FloodlightModuleContext;
-import net.floodlightcontroller.core.module.FloodlightModuleException;
-import net.floodlightcontroller.core.module.IFloodlightModule;
-import net.floodlightcontroller.core.module.IFloodlightService;
-import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
-import net.onrc.onos.core.datagrid.IDatagridService;
-import net.onrc.onos.core.flowprogrammer.IFlowPusherService;
-import net.onrc.onos.core.util.IdGenerator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.EventListener;
@@ -21,6 +9,20 @@
 import java.util.Map;
 import java.util.Set;
 
+import net.floodlightcontroller.core.IFloodlightProviderService;
+import net.floodlightcontroller.core.module.FloodlightModuleContext;
+import net.floodlightcontroller.core.module.FloodlightModuleException;
+import net.floodlightcontroller.core.module.IFloodlightModule;
+import net.floodlightcontroller.core.module.IFloodlightService;
+import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
+import net.onrc.onos.core.datagrid.IDatagridService;
+import net.onrc.onos.core.flowprogrammer.IFlowPusherService;
+import net.onrc.onos.core.registry.IControllerRegistryService;
+import net.onrc.onos.core.util.IdGenerator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Floodlight module for Match Action service.
  */
@@ -32,10 +34,6 @@
             .getLogger(MatchActionModule.class);
     private MatchActionComponent matchActionComponent;
 
-
-
-
-
     @Override
     public Collection<Class<? extends IFloodlightService>> getModuleServices() {
         List<Class<? extends IFloodlightService>> services = new ArrayList<>();
@@ -58,6 +56,7 @@
         dependencies.add(IDatagridService.class);
         dependencies.add(IFlowPusherService.class);
         dependencies.add(IFloodlightProviderService.class);
+        dependencies.add(IControllerRegistryService.class);
         return dependencies;
     }
 
@@ -71,8 +70,9 @@
         final IDatagridService datagrid = context.getServiceImpl(IDatagridService.class);
         final IFlowPusherService pusher = context.getServiceImpl(IFlowPusherService.class);
         final IFloodlightProviderService provider = context.getServiceImpl(IFloodlightProviderService.class);
+        final IControllerRegistryService registry = context.getServiceImpl(IControllerRegistryService.class);
 
-        matchActionComponent = new MatchActionComponent(datagrid, pusher, provider);
+        matchActionComponent = new MatchActionComponent(datagrid, pusher, provider, registry);
         log.info("match action component created");
         matchActionComponent.start();
     }
@@ -104,16 +104,12 @@
 
     @Override
     public IdGenerator<MatchActionId> getMatchActionIdGenerator() {
-        // TODO Auto-generated method stub
-        // use MatchActionIdGeneratorWithIdBlockAllocator.
-        return null;
+        return matchActionComponent.getMatchActionIdGenerator();
     }
 
     @Override
     public IdGenerator<MatchActionOperationsId> getMatchActionOperationsIdGenerator() {
-        // TODO Auto-generated method stub
-        // use MatchActionOperationsIdGeneratorWithIdBlockAllocator.
-        return null;
+        return matchActionComponent.getMatchActionOperationsIdGenerator();
     }
 
     @Override
diff --git a/src/test/java/net/onrc/onos/core/matchaction/MatchActionModuleTest.java b/src/test/java/net/onrc/onos/core/matchaction/MatchActionModuleTest.java
index cebf01c..42e5475 100644
--- a/src/test/java/net/onrc/onos/core/matchaction/MatchActionModuleTest.java
+++ b/src/test/java/net/onrc/onos/core/matchaction/MatchActionModuleTest.java
@@ -79,7 +79,7 @@
 
         final int iterations = 5;
         final MatchActionComponent matchActionComponent =
-            new MatchActionComponent(datagridService, null, null);
+            new MatchActionComponent(datagridService, null, null, null);
         final ArrayList<MatchAction> generatedMatchActions = new ArrayList<>();
 
         // Add some test MatchAction objects. 25 will be added, in 5 blocks
@@ -167,7 +167,7 @@
         operations.addOperation(entry);
 
         // Create a module to use to execute the Operations.
-        final MatchActionComponent matchActionComponent = new MatchActionComponent(null, null, null);
+        final MatchActionComponent matchActionComponent = new MatchActionComponent(null, null, null, null);
 
         // Execute the first set of Operations.  This
         // should succeed.
diff --git a/src/test/java/net/onrc/onos/core/matchaction/match/FlowEntryGenerationTest.java b/src/test/java/net/onrc/onos/core/matchaction/match/FlowEntryGenerationTest.java
index 875ddf5..f5b521e 100644
--- a/src/test/java/net/onrc/onos/core/matchaction/match/FlowEntryGenerationTest.java
+++ b/src/test/java/net/onrc/onos/core/matchaction/match/FlowEntryGenerationTest.java
@@ -74,7 +74,7 @@
         final MatchActionOperationsId operationsId = new MatchActionOperationsId(1L);
         final MatchActionId matchActionId = new MatchActionId(1L);
 
-        final MatchActionComponent component = new MatchActionComponent(datagridService, null, null);
+        final MatchActionComponent component = new MatchActionComponent(datagridService, null, null, null);
 
         MACAddress srcMac = new MACAddress(new byte[]{0, 0, 0, 0, 0, 0});
         MACAddress dstMac = new MACAddress(new byte[]{0, 0, 0, 0, 0, 1});