Refractored and added generic mdsal datastore apis
[vpnservice.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / vpnservice / mdsalutil / MDSALUtil.java
index 81cfd10df62b9de38c6974e42e66da932332dd08..fea7e624f69b7a55f19556fc85371f114b0a9737 100644 (file)
@@ -17,23 +17,18 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.LinkedBlockingQueue;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
-//import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
-//import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-//import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
-//import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
@@ -65,23 +60,12 @@ import com.google.common.primitives.Ints;
 public class MDSALUtil {
 
     public static final String NODE_PREFIX = "openflow";
-    public static final String SEPARATOR = ":"; // TODO name separtor correctly
-
+    public static final String SEPARATOR = ":";
     private static final Buckets EMPTY_Buckets = new BucketsBuilder().build();
     private static final Instructions EMPTY_Instructions = new InstructionsBuilder().setInstruction(
             new ArrayList<Instruction>()).build();
     private static final Match EMPTY_Matches = new MatchBuilder().build();
 
-    // public static Map<Long, SyncStatus> syncStatusMap = new
-    // ConcurrentHashMap<Long, SyncStatus>();
-    public static Map<Long, LinkedBlockingQueue<Object>> lportMap = new ConcurrentHashMap<Long, LinkedBlockingQueue<Object>>();
-    public static Map<Long, LinkedBlockingQueue<Object>> lportDownMap = new ConcurrentHashMap<Long, LinkedBlockingQueue<Object>>();
-    // public static Map<String, Boolean> ofRefMap = new
-    // ConcurrentHashMap<String, Boolean>();
-    public static Map<Long, Map<String, Boolean>> ofRefMapDpn = new ConcurrentHashMap<Long, Map<String, Boolean>>();
-    public static Map<Long, Map<Integer, String>> ofRefGroupMapDpn = new ConcurrentHashMap<Long, Map<Integer, String>>();
-    public static Map<Long, Map<String, String>> ofRefFlowMapDpn = new ConcurrentHashMap<Long, Map<String, String>>();
-
     public static FlowEntity buildFlowEntity(long dpnId, short tableId, String flowId, int priority, String flowName,
             int idleTimeOut, int hardTimeOut, BigInteger cookie, List<MatchInfo> listMatchInfo,
             List<InstructionInfo> listInstructionInfo) {
@@ -101,19 +85,6 @@ public class MDSALUtil {
         return flowEntity;
     }
 
-    // TODO FIX ME
-    /*
-    public static Flow buildResyncFlow(short tableId, String flowId, int priority, String flowName, int idleTimeOut,
-            int hardTimeOut, BigInteger cookie, List<MatchInfo> listMatchInfo,
-            List<InstructionInfo> listInstructionInfo, boolean isStrict, boolean isResync) {
-        FlowKey key = new FlowKey(new FlowId(flowId));
-        return new FlowBuilder().setMatch(buildMatches(listMatchInfo)).setKey(key)
-                .setPriority(Integer.valueOf(priority)).setInstructions(buildInstructions(listInstructionInfo))
-                .setBarrier(false).setInstallHw(true).setHardTimeout(hardTimeOut).setIdleTimeout(idleTimeOut)
-                .setFlowName(flowName).setTableId(Short.valueOf(tableId)).setStrict(isStrict)
-                .setCookie(new FlowCookie(cookie)).setResyncFlag(isResync).build();
-    }
-    */
     // TODO: CHECK IF THIS IS USED
     public static Flow buildFlow(short tableId, String flowId, int priority, String flowName, int idleTimeOut,
             int hardTimeOut, BigInteger cookie, List<MatchInfo> listMatchInfo, List<InstructionInfo> listInstructionInfo) {
@@ -132,32 +103,6 @@ public class MDSALUtil {
                 .setCookie(new FlowCookie(cookie)).build();
     }
 
- // TODO FIX ME
-    /*
-    public static Flow buildResyncFlow(short tableId, String flowId, int priority, String flowName, int idleTimeOut,
-            int hardTimeOut, BigInteger cookie, List<MatchInfo> listMatchInfo,
-            List<InstructionInfo> listInstructionInfo, boolean isStrict, boolean isResync, boolean isSendFlowRem) {
-        FlowKey key = new FlowKey(new FlowId(flowId));
-        return new FlowBuilder().setMatch(buildMatches(listMatchInfo)).setKey(key)
-                .setPriority(Integer.valueOf(priority)).setInstructions(buildInstructions(listInstructionInfo))
-                .setBarrier(false).setInstallHw(true).setHardTimeout(hardTimeOut).setIdleTimeout(idleTimeOut)
-                .setFlowName(flowName).setTableId(Short.valueOf(tableId)).setStrict(isStrict)
-                .setCookie(new FlowCookie(cookie))
-                .setFlags(new FlowModFlags(false, false, false, false, isSendFlowRem)).setResyncFlag(isResync).build();
-
-    }
-    */
-/*
-    public static Flow buildFlow(short tableId, String flowId, int priority, String flowName, int idleTimeOut,
-            int hardTimeOut, BigInteger cookie, List<MatchInfo> listMatchInfo,
-            List<InstructionInfo> listInstructionInfo, boolean isStrict, boolean isSendFlowRem) {
-        return buildResyncFlow(tableId, flowId, priority, flowName, idleTimeOut, hardTimeOut, cookie, listMatchInfo,
-                listInstructionInfo, isStrict, false, isSendFlowRem);
-
-    }
-*/
-
-
     public static GroupEntity buildGroupEntity(long dpnId, long groupId, String groupName, GroupTypes groupType,
             List<BucketInfo> listBucketInfo) {
 
@@ -171,41 +116,6 @@ public class MDSALUtil {
         return groupEntity;
     }
 
-    // FIXME -- AS ReSync is not required for ODL VPN Service
-    /*
-    public static Group buildGroup(long groupId, String groupName, GroupTypes groupType, List<BucketInfo> listBucketInfo) {
-        return buildGroup(groupId, groupName, groupType, listBucketInfo, false);
-    }
-
-    public static Group buildGroup(long groupId, String groupName, GroupTypes groupType,
-            List<BucketInfo> listBucketInfo, boolean isResync) {
-        return new GroupBuilder().setBuckets(buildBuckets(listBucketInfo)).setKey(new GroupKey(new GroupId(groupId)))
-                .setBarrier(false).setGroupId(new GroupId(Long.valueOf(groupId))).setGroupType(groupType)
-                .setGroupName(groupName).setResyncFlag(isResync).build();
-    }
-*/
-    // Removing --Missing Constraint
-    /*
-    public static GetFlowStatisticsFromFlowTableInput buildGetFlowStatisticsFromFlowTableInput(short tableId,
-            List<MatchInfo> listMatchInfo, long dpnId) {
-        return new GetFlowStatisticsFromFlowTableInputBuilder()
-                .setTableId(Short.valueOf(tableId))
-                .setMatch(buildMatches(listMatchInfo))
-                .setNode(
-                        new NodeRef(InstanceIdentifier.builder(Nodes.class)
-                                .child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId))).toInstance())).build();
-
-    }
-
-    public static GetGroupStatisticsInput buildGetGroupStatistics(long groupId, long dpnId) {
-        return new GetGroupStatisticsInputBuilder()
-                .setGroupId(new GroupId(Long.valueOf(groupId)))
-                .setNode(
-                        new NodeRef(InstanceIdentifier.builder(Nodes.class)
-                                .child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId))).toInstance())).build();
-    }
-    */
-
     public static TransmitPacketInput getPacketOutDefault(List<ActionInfo> actionInfos, byte[] payload, long dpnId) {
         return new TransmitPacketInputBuilder()
                 .setAction(buildActions(actionInfos))