Updated Flow Services Adapter,started inventory adapter. 13/1813/2
authorTony Tkacik <ttkacik@cisco.com>
Thu, 10 Oct 2013 18:37:03 +0000 (20:37 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 10 Oct 2013 20:53:17 +0000 (20:53 +0000)
Change-Id: Ie369f20445df872fec16bd4b9cc6318460f21573
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ADSALUtils.java [new file with mode: 0644]
opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/FromSalConversionsUtils.java
opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/NodeInventoryAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/impl/MdOpendaylightFlowStatisticsServiceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/impl/MdSalFlowServiceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestFromSalConversionsUtils.java

diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ADSALUtils.java b/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ADSALUtils.java
new file mode 100644 (file)
index 0000000..c2a6b07
--- /dev/null
@@ -0,0 +1,14 @@
+package org.opendaylight.controller.sal.compability;
+
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+
+public class ADSALUtils {
+
+    
+    
+    public static NodeConnector adSalNodeConnector(NodeConnectorId id) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+}
index 4ffa45adf34a13f27cb11e6d8e16ce48ac9336b5..2e96062564c5d208b50276e18d7ebfb7cdc2cfc3 100644 (file)
@@ -14,6 +14,9 @@ import java.util.List;
 
 import org.opendaylight.controller.sal.action.*;
 import org.opendaylight.controller.sal.core.NodeConnector;
 
 import org.opendaylight.controller.sal.action.*;
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.Node;
+
+
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.match.Match;
 import org.opendaylight.controller.sal.match.MatchField;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.match.Match;
 import org.opendaylight.controller.sal.match.MatchField;
@@ -21,8 +24,15 @@ import org.opendaylight.controller.sal.match.MatchType;
 import org.opendaylight.controller.sal.utils.NetUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.*;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.controller.sal.utils.NetUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.*;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.*;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.VlanCfi;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.*;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.VlanCfi;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.*;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.Address;
@@ -30,6 +40,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.addres
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.address.Ipv6Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.address.Ipv6Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
@@ -49,10 +61,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819
 
 import com.google.common.net.InetAddresses;
 
 
 import com.google.common.net.InetAddresses;
 
-import static org.opendaylight.controller.sal.compability.ProtocolConstants.ETHERNET_ARP;
-import static org.opendaylight.controller.sal.compability.ProtocolConstants.SCTP;
-import static org.opendaylight.controller.sal.compability.ProtocolConstants.TCP;
-import static org.opendaylight.controller.sal.compability.ProtocolConstants.UDP;
+
+
+
+import static org.opendaylight.controller.sal.compability.ProtocolConstants.*;
+import static org.opendaylight.controller.sal.compability.NodeInventoryAdapter.*;
 
 public class FromSalConversionsUtils {
 
 
 public class FromSalConversionsUtils {
 
@@ -60,30 +73,100 @@ public class FromSalConversionsUtils {
 
     }
 
 
     }
 
-    public static FlowAdded flowFrom(Flow sourceFlow) {
-        if (sourceFlow != null) {
-            final FlowAddedBuilder targetFlow = new FlowAddedBuilder();
+    public static FlowAdded flowAdded(Flow sourceFlow) {
+        if (sourceFlow == null)
+            throw new IllegalArgumentException();
+        final FlowAddedBuilder targetFlow = new FlowAddedBuilder();
+        targetFlow.setHardTimeout((int) sourceFlow.getHardTimeout());
+        targetFlow.setIdleTimeout((int) sourceFlow.getIdleTimeout());
+        targetFlow.setPriority((int) sourceFlow.getPriority());
+        targetFlow
+                .setCookie(new BigInteger(String.valueOf(sourceFlow.getId())));
+
+        List<org.opendaylight.controller.sal.action.Action> sourceActions = sourceFlow
+                .getActions();
+        List<Action> targetActions = new ArrayList<>();
+        for (org.opendaylight.controller.sal.action.Action sourceAction : sourceActions) {
+            targetActions.add(action(sourceAction));
+        }
+        targetFlow.setAction(targetActions);
+        targetFlow.setMatch(match(sourceFlow.getMatch()));
+        return targetFlow.build();
 
 
-            targetFlow.setHardTimeout((int) sourceFlow.getHardTimeout());
-            targetFlow.setIdleTimeout((int) sourceFlow.getIdleTimeout());
-            targetFlow.setPriority((int) sourceFlow.getPriority());
-            targetFlow.setCookie(new BigInteger(String.valueOf(sourceFlow.getId())));
+    }
 
 
-            List<org.opendaylight.controller.sal.action.Action> sourceActions = sourceFlow.getActions();
-            List<Action> targetActions = new ArrayList<>();
-            for (org.opendaylight.controller.sal.action.Action sourceAction : sourceActions) {
-                targetActions.add(actionFrom(sourceAction));
-            }
-            targetFlow.setAction(targetActions);
+    public static GetFlowStatisticsInput flowStatisticsInput(
+            Node node,Flow sourceFlow) {
+        GetFlowStatisticsInputBuilder ret = new GetFlowStatisticsInputBuilder();
+        FlowAdded source = flowAdded(sourceFlow);
+        ret.setAction(source.getAction());
+        ret.setCookie(source.getCookie());
+        ret.setAction(source.getAction());
+        ret.setCookie(source.getCookie());
+        ret.setHardTimeout(source.getHardTimeout());
+        ret.setMatch(source.getMatch());
+        ret.setPriority(source.getPriority());
+        ret.setNode(nodeRef(node));
+        return ret.build();
+    }
 
 
-            targetFlow.setMatch(matchFrom(sourceFlow.getMatch()));
+    public static RemoveFlowInput removeFlowInput(Node node,Flow sourceFlow) {
+        RemoveFlowInputBuilder ret = new RemoveFlowInputBuilder();
+        FlowAdded source = flowAdded(sourceFlow);
+        ret.setAction(source.getAction());
+        ret.setCookie(source.getCookie());
+        ret.setAction(source.getAction());
+        ret.setCookie(source.getCookie());
+        ret.setHardTimeout(source.getHardTimeout());
+        ret.setMatch(source.getMatch());
+        ret.setPriority(source.getPriority());
+        ret.setNode(nodeRef(node));
+        return ret.build();
+    }
+    
+    public static AddFlowInput addFlowInput(Node node,Flow sourceFlow) {
+        AddFlowInputBuilder ret = new AddFlowInputBuilder();
+        FlowAdded source = flowAdded(sourceFlow);
+        ret.setAction(source.getAction());
+        ret.setCookie(source.getCookie());
+        ret.setAction(source.getAction());
+        ret.setCookie(source.getCookie());
+        ret.setHardTimeout(source.getHardTimeout());
+        ret.setMatch(source.getMatch());
+        ret.setPriority(source.getPriority());
+        ret.setNode(nodeRef(node));
+        return ret.build();
+    }
 
 
-            return targetFlow.build();
-        }
-        return null;
+    public static UpdateFlowInput updateFlowInput(Node node, Flow oldFlow, Flow newFlow){
+        UpdateFlowInputBuilder ret = new UpdateFlowInputBuilder();
+        FlowAdded source = flowAdded(newFlow);
+        ret.setAction(source.getAction());
+        ret.setCookie(source.getCookie());
+        ret.setAction(source.getAction());
+        ret.setCookie(source.getCookie());
+        ret.setHardTimeout(source.getHardTimeout());
+        ret.setMatch(source.getMatch());
+        ret.setPriority(source.getPriority());
+        ret.setNode(nodeRef(node));
+        return ret.build();
     }
 
     }
 
-    private static Action actionFrom(org.opendaylight.controller.sal.action.Action sourceAction) {
+    public static GetNodeConnectorStatisticsInput nodeConnectorStatistics(
+            NodeConnector connector) {
+        GetNodeConnectorStatisticsInputBuilder target = new GetNodeConnectorStatisticsInputBuilder();
+
+        NodeRef nodeRef = nodeRef(connector.getNode());
+        target.setNode(nodeRef);
+
+        NodeConnectorRef nodeConnectorRef = nodeConnectorRef(connector);
+        target.setNodeConnector(nodeConnectorRef);
+
+        return target.build();
+    }
+
+    private static Action action(
+            org.opendaylight.controller.sal.action.Action sourceAction) {
 
         ActionBuilder targetActionBuilder = new ActionBuilder();
         org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.Action targetAction = null;
 
         ActionBuilder targetActionBuilder = new ActionBuilder();
         org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.Action targetAction = null;
@@ -104,7 +187,8 @@ public class FromSalConversionsUtils {
             NodeConnector nodeConnector = ((Output) sourceAction).getPort();
 
             OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
             NodeConnector nodeConnector = ((Output) sourceAction).getPort();
 
             OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
-            outputActionBuilder.setOutputNodeConnector(nodeConnectorToUri(nodeConnector));
+            outputActionBuilder
+                    .setOutputNodeConnector(nodeConnectorToUri(nodeConnector));
             targetAction = outputActionBuilder.build();
 
         } else if (sourceAction instanceof PopVlan) {
             targetAction = outputActionBuilder.build();
 
         } else if (sourceAction instanceof PopVlan) {
@@ -122,19 +206,22 @@ public class FromSalConversionsUtils {
             SetDlDst setDlDst = (SetDlDst) sourceAction;
             SetDlDstActionBuilder setDlDstActionBuilder = new SetDlDstActionBuilder();
 
             SetDlDst setDlDst = (SetDlDst) sourceAction;
             SetDlDstActionBuilder setDlDstActionBuilder = new SetDlDstActionBuilder();
 
-            setDlDstActionBuilder.setAddress(new MacAddress(new String(setDlDst.getDlAddress())));
+            setDlDstActionBuilder.setAddress(new MacAddress(new String(setDlDst
+                    .getDlAddress())));
             targetAction = setDlDstActionBuilder.build();
         } else if (sourceAction instanceof SetDlSrc) {
             SetDlSrc setDlSrc = (SetDlSrc) sourceAction;
             SetDlSrcActionBuilder setDlSrcActionBuilder = new SetDlSrcActionBuilder();
 
             targetAction = setDlDstActionBuilder.build();
         } else if (sourceAction instanceof SetDlSrc) {
             SetDlSrc setDlSrc = (SetDlSrc) sourceAction;
             SetDlSrcActionBuilder setDlSrcActionBuilder = new SetDlSrcActionBuilder();
 
-            setDlSrcActionBuilder.setAddress(new MacAddress(new String(setDlSrc.getDlAddress())));
+            setDlSrcActionBuilder.setAddress(new MacAddress(new String(setDlSrc
+                    .getDlAddress())));
             targetAction = setDlSrcActionBuilder.build();
         } else if (sourceAction instanceof SetDlType) {
             SetDlType setDlType = (SetDlType) sourceAction;
             SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
 
             targetAction = setDlSrcActionBuilder.build();
         } else if (sourceAction instanceof SetDlType) {
             SetDlType setDlType = (SetDlType) sourceAction;
             SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
 
-            setDlTypeActionBuilder.setDlType(new EtherType(new Long(setDlType.getDlType())));
+            setDlTypeActionBuilder.setDlType(new EtherType(new Long(setDlType
+                    .getDlType())));
             targetAction = setDlTypeActionBuilder.build();
         } else if (sourceAction instanceof SetNextHop) {
             SetNextHop setNextHop = (SetNextHop) sourceAction;
             targetAction = setDlTypeActionBuilder.build();
         } else if (sourceAction instanceof SetNextHop) {
             SetNextHop setNextHop = (SetNextHop) sourceAction;
@@ -184,7 +271,8 @@ public class FromSalConversionsUtils {
             SetVlanCfi setVlanCfi = (SetVlanCfi) sourceAction;
             SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
 
             SetVlanCfi setVlanCfi = (SetVlanCfi) sourceAction;
             SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
 
-            setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(setVlanCfi.getCfi()));
+            setVlanCfiActionBuilder
+                    .setVlanCfi(new VlanCfi(setVlanCfi.getCfi()));
 
             targetAction = setVlanCfiActionBuilder.build();
         } else if (sourceAction instanceof SetVlanId) {
 
             targetAction = setVlanCfiActionBuilder.build();
         } else if (sourceAction instanceof SetVlanId) {
@@ -198,7 +286,8 @@ public class FromSalConversionsUtils {
             SetVlanPcp setVlanPcp = (SetVlanPcp) sourceAction;
             SetVlanPcpActionBuilder setVlanPcpActionBuilder = new SetVlanPcpActionBuilder();
 
             SetVlanPcp setVlanPcp = (SetVlanPcp) sourceAction;
             SetVlanPcpActionBuilder setVlanPcpActionBuilder = new SetVlanPcpActionBuilder();
 
-            setVlanPcpActionBuilder.setVlanPcp(new VlanPcp((short) setVlanPcp.getPcp()));
+            setVlanPcpActionBuilder.setVlanPcp(new VlanPcp((short) setVlanPcp
+                    .getPcp()));
 
             targetAction = setVlanPcpActionBuilder.build();
         } else if (sourceAction instanceof SwPath) {
 
             targetAction = setVlanPcpActionBuilder.build();
         } else if (sourceAction instanceof SwPath) {
@@ -229,14 +318,14 @@ public class FromSalConversionsUtils {
         return null;
     }
 
         return null;
     }
 
-    private static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.Match matchFrom(
+    private static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.Match match(
             Match sourceMatch) {
         if (sourceMatch != null) {
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.MatchBuilder targetBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.MatchBuilder();
 
             Match sourceMatch) {
         if (sourceMatch != null) {
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.MatchBuilder targetBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.MatchBuilder();
 
-            targetBuilder.setEthernetMatch(ethernetMatchFrom(sourceMatch));
-            targetBuilder.setIpMatch(ipMatchFrom(sourceMatch));
-            targetBuilder.setVlanMatch(vlanMatchFrom(sourceMatch));
+            targetBuilder.setEthernetMatch(ethernetMatch(sourceMatch));
+            targetBuilder.setIpMatch(ipMatch(sourceMatch));
+            targetBuilder.setVlanMatch(vlanMatch(sourceMatch));
             targetBuilder.setLayer3Match(layer3Match(sourceMatch));
             targetBuilder.setLayer4Match(layer4Match(sourceMatch));
 
             targetBuilder.setLayer3Match(layer3Match(sourceMatch));
             targetBuilder.setLayer4Match(layer4Match(sourceMatch));
 
@@ -266,14 +355,16 @@ public class FromSalConversionsUtils {
     private static Layer4Match Layer4MatchAsSctp(final Match sourceMatch) {
         SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
 
     private static Layer4Match Layer4MatchAsSctp(final Match sourceMatch) {
         SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
 
-        Integer sourcePort = transportPortFrom(sourceMatch, MatchType.TP_SRC);
-        Integer destinationPort = transportPortFrom(sourceMatch, MatchType.TP_DST);
+        Integer sourcePort = transportPort(sourceMatch, MatchType.TP_SRC);
+        Integer destinationPort = transportPort(sourceMatch,
+                MatchType.TP_DST);
 
         if (sourcePort != null) {
             sctpMatchBuilder.setSctpSourcePort(new PortNumber(sourcePort));
         }
         if (destinationPort != null) {
 
         if (sourcePort != null) {
             sctpMatchBuilder.setSctpSourcePort(new PortNumber(sourcePort));
         }
         if (destinationPort != null) {
-            sctpMatchBuilder.setSctpDestinationPort(new PortNumber(destinationPort));
+            sctpMatchBuilder.setSctpDestinationPort(new PortNumber(
+                    destinationPort));
         }
 
         return sctpMatchBuilder.build();
         }
 
         return sctpMatchBuilder.build();
@@ -282,15 +373,17 @@ public class FromSalConversionsUtils {
     private static Layer4Match Layer4MatchAsUdp(final Match sourceMatch) {
         UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
 
     private static Layer4Match Layer4MatchAsUdp(final Match sourceMatch) {
         UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
 
-        Integer sourcePort = transportPortFrom(sourceMatch, MatchType.TP_SRC);
-        Integer destinationPort = transportPortFrom(sourceMatch, MatchType.TP_DST);
+        Integer sourcePort = transportPort(sourceMatch, MatchType.TP_SRC);
+        Integer destinationPort = transportPort(sourceMatch,
+                MatchType.TP_DST);
 
         if (sourcePort != null) {
             udpMatchBuilder.setUdpSourcePort(new PortNumber(sourcePort));
         }
 
         if (destinationPort != null) {
 
         if (sourcePort != null) {
             udpMatchBuilder.setUdpSourcePort(new PortNumber(sourcePort));
         }
 
         if (destinationPort != null) {
-            udpMatchBuilder.setUdpDestinationPort(new PortNumber(destinationPort));
+            udpMatchBuilder.setUdpDestinationPort(new PortNumber(
+                    destinationPort));
         }
 
         return udpMatchBuilder.build();
         }
 
         return udpMatchBuilder.build();
@@ -299,87 +392,99 @@ public class FromSalConversionsUtils {
     private static Layer4Match Layer4MatchAsTcp(final Match sourceMatch) {
         TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
 
     private static Layer4Match Layer4MatchAsTcp(final Match sourceMatch) {
         TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
 
-        Integer sourcePort = transportPortFrom(sourceMatch, MatchType.TP_SRC);
-        Integer destinationPort = transportPortFrom(sourceMatch, MatchType.TP_DST);
+        Integer sourcePort = transportPort(sourceMatch, MatchType.TP_SRC);
+        Integer destinationPort = transportPort(sourceMatch,
+                MatchType.TP_DST);
 
         if (sourcePort != null) {
             tcpMatchBuilder.setTcpSourcePort(new PortNumber(sourcePort));
         }
         if (destinationPort != null) {
 
         if (sourcePort != null) {
             tcpMatchBuilder.setTcpSourcePort(new PortNumber(sourcePort));
         }
         if (destinationPort != null) {
-            tcpMatchBuilder.setTcpDestinationPort(new PortNumber(destinationPort));
+            tcpMatchBuilder.setTcpDestinationPort(new PortNumber(
+                    destinationPort));
         }
 
         return tcpMatchBuilder.build();
     }
 
         }
 
         return tcpMatchBuilder.build();
     }
 
-    private static Integer transportPortFrom(final Match sourceMatch, final MatchType matchType) {
+    private static Integer transportPort(final Match sourceMatch,
+            final MatchType matchType) {
         MatchField transportPort = sourceMatch.getField(matchType);
         if (transportPort != null && transportPort.getValue() != null
                 && transportPort.getValue().getClass().equals(Short.class)) {
         MatchField transportPort = sourceMatch.getField(matchType);
         if (transportPort != null && transportPort.getValue() != null
                 && transportPort.getValue().getClass().equals(Short.class)) {
-            return new Integer(NetUtils.getUnsignedShort((short) transportPort.getValue()));
+            return new Integer(NetUtils.getUnsignedShort((short) transportPort
+                    .getValue()));
         }
         return null;
     }
 
         }
         return null;
     }
 
-    private static VlanMatch vlanMatchFrom(final Match sourceMatch) {
+    private static VlanMatch vlanMatch(final Match sourceMatch) {
         VlanMatchBuilder vlanMatchBuild = new VlanMatchBuilder();
 
         MatchField vlan = sourceMatch.getField(MatchType.DL_VLAN);
         if (vlan != null && vlan.getValue() != null) {
             VlanIdBuilder vlanIDBuilder = new VlanIdBuilder();
         VlanMatchBuilder vlanMatchBuild = new VlanMatchBuilder();
 
         MatchField vlan = sourceMatch.getField(MatchType.DL_VLAN);
         if (vlan != null && vlan.getValue() != null) {
             VlanIdBuilder vlanIDBuilder = new VlanIdBuilder();
-            vlanIDBuilder.setVlanId(new VlanId((int) (NetUtils.getUnsignedShort((short) vlan.getValue()))));
+            vlanIDBuilder.setVlanId(new VlanId((int) (NetUtils
+                    .getUnsignedShort((short) vlan.getValue()))));
             vlanMatchBuild.setVlanId(vlanIDBuilder.build());
         }
 
         MatchField vlanPriority = sourceMatch.getField(MatchType.DL_VLAN_PR);
         if (vlanPriority != null && vlanPriority.getValue() != null) {
             vlanMatchBuild.setVlanId(vlanIDBuilder.build());
         }
 
         MatchField vlanPriority = sourceMatch.getField(MatchType.DL_VLAN_PR);
         if (vlanPriority != null && vlanPriority.getValue() != null) {
-            vlanMatchBuild.setVlanPcp(new VlanPcp((short) ((byte) vlanPriority.getValue())));
+            vlanMatchBuild.setVlanPcp(new VlanPcp((short) ((byte) vlanPriority
+                    .getValue())));
         }
 
         return vlanMatchBuild.build();
     }
 
         }
 
         return vlanMatchBuild.build();
     }
 
-    private static IpMatch ipMatchFrom(final Match sourceMatch) {
+    private static IpMatch ipMatch(final Match sourceMatch) {
         IpMatchBuilder targetIpMatchBuild = new IpMatchBuilder();
         MatchField networkTos = sourceMatch.getField(MatchType.NW_TOS);
         if (networkTos != null && networkTos.getValue() != null) {
         IpMatchBuilder targetIpMatchBuild = new IpMatchBuilder();
         MatchField networkTos = sourceMatch.getField(MatchType.NW_TOS);
         if (networkTos != null && networkTos.getValue() != null) {
-            Dscp dscp = new Dscp((short) (NetUtils.getUnsignedByte((Byte) networkTos.getValue())));
+            Dscp dscp = new Dscp(
+                    (short) (NetUtils.getUnsignedByte((Byte) networkTos
+                            .getValue())));
             targetIpMatchBuild.setIpDscp(dscp);
         }
 
         MatchField protocol = sourceMatch.getField(MatchType.NW_PROTO);
         if (protocol != null && protocol.getValue() != null) {
             targetIpMatchBuild.setIpDscp(dscp);
         }
 
         MatchField protocol = sourceMatch.getField(MatchType.NW_PROTO);
         if (protocol != null && protocol.getValue() != null) {
-            targetIpMatchBuild.setIpProtocol((short) ((byte) protocol.getValue()));
+            targetIpMatchBuild.setIpProtocol((short) ((byte) protocol
+                    .getValue()));
         }
 
         return targetIpMatchBuild.build();
 
     }
 
         }
 
         return targetIpMatchBuild.build();
 
     }
 
-    private static EthernetMatch ethernetMatchFrom(final Match sourceMatch) {
+    private static EthernetMatch ethernetMatch(final Match sourceMatch) {
         final EthernetMatchBuilder targetEthMatchBuild = new EthernetMatchBuilder();
 
         EthernetSourceBuilder ethSourBuild = new EthernetSourceBuilder()
         final EthernetMatchBuilder targetEthMatchBuild = new EthernetMatchBuilder();
 
         EthernetSourceBuilder ethSourBuild = new EthernetSourceBuilder()
-                .setAddress(ethernetSourceAddressFrom(sourceMatch));
+                .setAddress(ethernetSourceAddress(sourceMatch));
         targetEthMatchBuild.setEthernetSource(ethSourBuild.build());
 
         EthernetDestinationBuilder ethDestBuild = new EthernetDestinationBuilder()
         targetEthMatchBuild.setEthernetSource(ethSourBuild.build());
 
         EthernetDestinationBuilder ethDestBuild = new EthernetDestinationBuilder()
-                .setAddress(ethernetDestAddressFrom(sourceMatch));
+                .setAddress(ethernetDestAddress(sourceMatch));
         targetEthMatchBuild.setEthernetDestination(ethDestBuild.build());
 
         final MatchField dataLinkType = sourceMatch.getField(MatchType.DL_TYPE);
         if (dataLinkType != null && dataLinkType.getValue() != null) {
         targetEthMatchBuild.setEthernetDestination(ethDestBuild.build());
 
         final MatchField dataLinkType = sourceMatch.getField(MatchType.DL_TYPE);
         if (dataLinkType != null && dataLinkType.getValue() != null) {
-            EtherType etherType = new EtherType(new Long(NetUtils.getUnsignedShort((Short) dataLinkType.getValue())));
-            EthernetTypeBuilder ethType = new EthernetTypeBuilder().setType(etherType);
+            EtherType etherType = new EtherType(new Long(
+                    NetUtils.getUnsignedShort((Short) dataLinkType.getValue())));
+            EthernetTypeBuilder ethType = new EthernetTypeBuilder()
+                    .setType(etherType);
             targetEthMatchBuild.setEthernetType(ethType.build());
         }
         return targetEthMatchBuild.build();
     }
 
             targetEthMatchBuild.setEthernetType(ethType.build());
         }
         return targetEthMatchBuild.build();
     }
 
-    private static MacAddress ethernetSourceAddressFrom(final Match sourceMatch) {
+    private static MacAddress ethernetSourceAddress(final Match sourceMatch) {
         final MatchField dataLinkSource = sourceMatch.getField(DL_SRC);
         if (dataLinkSource != null && dataLinkSource.getValue() != null) {
         final MatchField dataLinkSource = sourceMatch.getField(DL_SRC);
         if (dataLinkSource != null && dataLinkSource.getValue() != null) {
-            return new MacAddress(new MacAddress(new String((byte[]) dataLinkSource.getValue())));
+            return new MacAddress(new MacAddress(new String(
+                    (byte[]) dataLinkSource.getValue())));
         }
         return null;
 
         }
         return null;
 
@@ -398,32 +503,40 @@ public class FromSalConversionsUtils {
             inetDestAddress = (InetAddress) (netDest.getValue());
         }
 
             inetDestAddress = (InetAddress) (netDest.getValue());
         }
 
-        if ((inetSourceAddress instanceof Inet4Address) && (inetDestAddress instanceof Inet4Address)) {
+        if ((inetSourceAddress instanceof Inet4Address)
+                && (inetDestAddress instanceof Inet4Address)) {
             MatchField dataLinkType = sourceMatch.getField(DL_TYPE);
             Short dLType = null;
             if (dataLinkType != null && dataLinkType.getValue() != null) {
                 dLType = (Short) (dataLinkType.getValue());
             }
             if (dLType != null && dLType.equals(ETHERNET_ARP)) {
             MatchField dataLinkType = sourceMatch.getField(DL_TYPE);
             Short dLType = null;
             if (dataLinkType != null && dataLinkType.getValue() != null) {
                 dLType = (Short) (dataLinkType.getValue());
             }
             if (dLType != null && dLType.equals(ETHERNET_ARP)) {
-                return setLayer3MatchAsArp(sourceMatch, (Inet4Address) inetSourceAddress,
+                return setLayer3MatchAsArp(sourceMatch,
+                        (Inet4Address) inetSourceAddress,
                         (Inet4Address) inetDestAddress);
             } else {
                         (Inet4Address) inetDestAddress);
             } else {
-                return setLayer3MatchAsIpv4((Inet4Address) inetSourceAddress, (Inet4Address) inetDestAddress);
+                return setLayer3MatchAsIpv4((Inet4Address) inetSourceAddress,
+                        (Inet4Address) inetDestAddress);
             }
             }
-        } else if ((inetSourceAddress instanceof Inet6Address) && (inetDestAddress instanceof Inet6Address)) {
-            return setLayer3MatchAsIpv6((Inet6Address) inetSourceAddress, (Inet6Address) inetDestAddress);
+        } else if ((inetSourceAddress instanceof Inet6Address)
+                && (inetDestAddress instanceof Inet6Address)) {
+            return setLayer3MatchAsIpv6((Inet6Address) inetSourceAddress,
+                    (Inet6Address) inetDestAddress);
         }
 
         return null;
 
     }
 
         }
 
         return null;
 
     }
 
-    private static Layer3Match setLayer3MatchAsArp(final Match sourceMatch, final Inet4Address inetSourceAddress,
+    private static Layer3Match setLayer3MatchAsArp(final Match sourceMatch,
+            final Inet4Address inetSourceAddress,
             final Inet4Address inetDestAddress) {
             final Inet4Address inetDestAddress) {
-        String inetSourceAddressStr = InetAddresses.toAddrString(inetSourceAddress);
+        String inetSourceAddressStr = InetAddresses
+                .toAddrString(inetSourceAddress);
         Ipv4Prefix ipv4SourcePrefix = new Ipv4Prefix(inetSourceAddressStr);
 
         Ipv4Prefix ipv4SourcePrefix = new Ipv4Prefix(inetSourceAddressStr);
 
-        String inetDestAddressValue = InetAddresses.toAddrString(inetDestAddress);
+        String inetDestAddressValue = InetAddresses
+                .toAddrString(inetDestAddress);
         Ipv4Prefix ipv4DestPrefix = new Ipv4Prefix(inetDestAddressValue);
 
         ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
         Ipv4Prefix ipv4DestPrefix = new Ipv4Prefix(inetDestAddressValue);
 
         ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
@@ -432,45 +545,60 @@ public class FromSalConversionsUtils {
         arpMatchBuilder.setArpTargetTransportAddress(ipv4DestPrefix);
 
         ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new ArpSourceHardwareAddressBuilder();
         arpMatchBuilder.setArpTargetTransportAddress(ipv4DestPrefix);
 
         ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new ArpSourceHardwareAddressBuilder();
-        arpSourceHardwareAddressBuilder.setAddress(ethernetSourceAddressFrom(sourceMatch));
-        arpMatchBuilder.setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder.build());
+        arpSourceHardwareAddressBuilder
+                .setAddress(ethernetSourceAddress(sourceMatch));
+        arpMatchBuilder
+                .setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder
+                        .build());
 
         ArpTargetHardwareAddressBuilder arpTargetHardwareAddressBuilder = new ArpTargetHardwareAddressBuilder();
 
         ArpTargetHardwareAddressBuilder arpTargetHardwareAddressBuilder = new ArpTargetHardwareAddressBuilder();
-        arpTargetHardwareAddressBuilder.setAddress(ethernetDestAddressFrom(sourceMatch));
-        arpMatchBuilder.setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder.build());
+        arpTargetHardwareAddressBuilder
+                .setAddress(ethernetDestAddress(sourceMatch));
+        arpMatchBuilder
+                .setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder
+                        .build());
 
         return arpMatchBuilder.build();
 
     }
 
 
         return arpMatchBuilder.build();
 
     }
 
-    private static MacAddress ethernetDestAddressFrom(final Match sourceMatch) {
+    private static MacAddress ethernetDestAddress(final Match sourceMatch) {
         final MatchField dataLinkDest = sourceMatch.getField(DL_DST);
         if (dataLinkDest != null && dataLinkDest.getValue() != null) {
         final MatchField dataLinkDest = sourceMatch.getField(DL_DST);
         if (dataLinkDest != null && dataLinkDest.getValue() != null) {
-            return new MacAddress(new String((byte[]) (dataLinkDest.getValue())));
+            return new MacAddress(
+                    new String((byte[]) (dataLinkDest.getValue())));
         }
         return null;
     }
 
         }
         return null;
     }
 
-    private static Layer3Match setLayer3MatchAsIpv4(final Inet4Address inetSourceAddress,
+    private static Layer3Match setLayer3MatchAsIpv4(
+            final Inet4Address inetSourceAddress,
             final Inet4Address inetDestAddress) {
             final Inet4Address inetDestAddress) {
-        String inetSrcAddressString = InetAddresses.toAddrString(inetSourceAddress);
-        String inetDstAddressString = InetAddresses.toAddrString(inetDestAddress);
+        String inetSrcAddressString = InetAddresses
+                .toAddrString(inetSourceAddress);
+        String inetDstAddressString = InetAddresses
+                .toAddrString(inetDestAddress);
 
         Ipv4MatchBuilder layer4MatchBuild = new Ipv4MatchBuilder();
         layer4MatchBuild.setIpv4Source(new Ipv4Prefix(inetSrcAddressString));
 
         Ipv4MatchBuilder layer4MatchBuild = new Ipv4MatchBuilder();
         layer4MatchBuild.setIpv4Source(new Ipv4Prefix(inetSrcAddressString));
-        layer4MatchBuild.setIpv4Destination(new Ipv4Prefix(inetDstAddressString));
+        layer4MatchBuild
+                .setIpv4Destination(new Ipv4Prefix(inetDstAddressString));
         return layer4MatchBuild.build();
 
     }
 
         return layer4MatchBuild.build();
 
     }
 
-    private static Layer3Match setLayer3MatchAsIpv6(final Inet6Address inetSourceAddress,
+    private static Layer3Match setLayer3MatchAsIpv6(
+            final Inet6Address inetSourceAddress,
             final Inet6Address inetDestAddress) {
             final Inet6Address inetDestAddress) {
-        String inetSrcAddressString = InetAddresses.toAddrString(inetSourceAddress);
-        String inetDstAddressString = InetAddresses.toAddrString(inetDestAddress);
+        String inetSrcAddressString = InetAddresses
+                .toAddrString(inetSourceAddress);
+        String inetDstAddressString = InetAddresses
+                .toAddrString(inetDestAddress);
         Ipv6MatchBuilder layer6MatchBuild = new Ipv6MatchBuilder();
 
         layer6MatchBuild.setIpv6Source(new Ipv6Prefix(inetSrcAddressString));
         Ipv6MatchBuilder layer6MatchBuild = new Ipv6MatchBuilder();
 
         layer6MatchBuild.setIpv6Source(new Ipv6Prefix(inetSrcAddressString));
-        layer6MatchBuild.setIpv6Destination(new Ipv6Prefix(inetDstAddressString));
+        layer6MatchBuild
+                .setIpv6Destination(new Ipv6Prefix(inetDstAddressString));
         return layer6MatchBuild.build();
     }
 
         return layer6MatchBuild.build();
     }
 
diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/NodeInventoryAdapter.java b/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/NodeInventoryAdapter.java
new file mode 100644 (file)
index 0000000..4692faa
--- /dev/null
@@ -0,0 +1,74 @@
+package org.opendaylight.controller.sal.compability;
+
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
+
+import static org.opendaylight.controller.sal.compability.ADSALUtils.*;
+
+public class NodeInventoryAdapter implements OpendaylightInventoryListener {
+    
+    IPluginOutInventoryService adSalPublisher;
+    
+    public static final String MD_SAL_TYPE = "MD_SAL";
+    
+    @Override
+    public void onNodeConnectorRemoved(NodeConnectorRemoved notification) {
+        
+    }
+    
+    @Override
+    public void onNodeConnectorUpdated(NodeConnectorUpdated notification) {
+        // FIMXE
+    }
+
+    @Override
+    public void onNodeRemoved(NodeRemoved notification) {
+     // FIMXE
+    }
+    
+    @Override
+    public void onNodeUpdated(NodeUpdated notification) {
+     // FIMXE
+    }
+
+    public static NodeRef nodeRef(Node node) {
+        if(false == MD_SAL_TYPE.equals(node.getType())) {
+            throw new IllegalArgumentException();
+        }
+        NodeKey nodeKey = (NodeKey) node.getID();
+        InstanceIdentifier<?> nodePath = InstanceIdentifier.builder().node(Nodes.class) //
+                .node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class, nodeKey).toInstance();
+        return new NodeRef(nodePath);
+    }
+
+    // TODO: implement correct conversion
+    public static NodeConnectorRef nodeConnectorRef(
+            NodeConnector nodeConnector) {
+        NodeRef node = nodeRef(nodeConnector.getNode());
+        NodeConnectorKey connectorKey = (NodeConnectorKey) nodeConnector.getID();
+        InstanceIdentifier path = InstanceIdentifier.builder(node.getValue()) //
+                .node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector.class, connectorKey).toInstance();
+        return new NodeConnectorRef(path);
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/impl/MdOpendaylightFlowStatisticsServiceAdapter.java b/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/impl/MdOpendaylightFlowStatisticsServiceAdapter.java
new file mode 100644 (file)
index 0000000..9a72952
--- /dev/null
@@ -0,0 +1,159 @@
+package org.opendaylight.controller.sal.compability.impl;
+
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import org.opendaylight.controller.sal.compability.FromSalConversionsUtils;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.NodeTable;
+import org.opendaylight.controller.sal.flowprogrammer.Flow;
+import org.opendaylight.controller.sal.reader.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.statistics.Duration;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MdOpendaylightFlowStatisticsServiceAdapter implements IPluginInReadService {
+
+    private static final Logger LOG = LoggerFactory.getLogger(MdOpendaylightFlowStatisticsServiceAdapter.class);
+    private OpendaylightFlowStatisticsService opendaylightFlowStatisticsService;
+
+    @Override
+    public FlowOnNode readFlow(Node node, Flow flow, boolean cached) {
+        FlowOnNode result = null;
+
+        GetFlowStatisticsInput getFlowStatisticsInput = FromSalConversionsUtils.flowStatisticsInput(node,flow);
+        Future<RpcResult<GetFlowStatisticsOutput>> futureStatisticsOutput = opendaylightFlowStatisticsService
+                .getFlowStatistics(getFlowStatisticsInput);
+
+        RpcResult<GetFlowStatisticsOutput> rpcResultStatisticsOutput;
+        GetFlowStatisticsOutput getFlowStatisticsOutput;
+        try {
+            rpcResultStatisticsOutput = futureStatisticsOutput.get();
+            if (rpcResultStatisticsOutput != null) {
+                getFlowStatisticsOutput = rpcResultStatisticsOutput.getResult();
+                if (getFlowStatisticsOutput != null) {
+
+                    long byteCount = getFlowStatisticsOutput.getByteCount().getValue().longValue();
+
+                    Duration duration = getFlowStatisticsOutput.getDuration();
+                    int nanoseconds = duration.getNanosecond().getValue().intValue();
+                    int seconds = duration.getSecond().getValue().intValue();
+                    long packetCount = getFlowStatisticsOutput.getPacketCount().getValue().longValue();
+
+                    result = new FlowOnNode(flow);
+                    result.setByteCount(byteCount);
+                    result.setDurationNanoseconds(nanoseconds);
+                    result.setDurationSeconds(seconds);
+                    result.setPacketCount(packetCount);
+                    return result;
+                }
+            }
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Read flow not processed", e);
+        }
+        return null;
+    }
+
+    @Override
+    public List<FlowOnNode> readAllFlow(Node node, boolean cached) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public NodeDescription readDescription(Node node, boolean cached) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public NodeConnectorStatistics readNodeConnector(NodeConnector connector, boolean cached) {
+        NodeConnectorStatistics result = null;
+        GetNodeConnectorStatisticsInput getNodeConnectorStatisticsInput = FromSalConversionsUtils
+                .nodeConnectorStatistics(connector);
+        Future<RpcResult<GetNodeConnectorStatisticsOutput>> future = opendaylightFlowStatisticsService
+                .getNodeConnectorStatistics(getNodeConnectorStatisticsInput);
+        try {
+            RpcResult<GetNodeConnectorStatisticsOutput> rpcResult = future.get();
+            if (rpcResult != null) {
+                GetNodeConnectorStatisticsOutput getNodeConnectorStatisticsOutput = rpcResult.getResult();
+
+                if (getNodeConnectorStatisticsOutput != null) {
+                    result = new NodeConnectorStatistics();
+
+                    long colisionCount = getNodeConnectorStatisticsOutput.getCollisionCount().longValue();
+                    long receiveCrcErrorCount = getNodeConnectorStatisticsOutput.getReceiveCrcError().longValue();
+                    long receiveFrameErrorCount = getNodeConnectorStatisticsOutput.getReceiveFrameError().longValue();
+                    long receiveOverRunError = getNodeConnectorStatisticsOutput.getReceiveOverRunError().longValue();
+
+                    long receiveDropCount = getNodeConnectorStatisticsOutput.getReceiveDrops().longValue();
+                    long receiveErrorCount = getNodeConnectorStatisticsOutput.getReceiveErrors().longValue();
+                    long receivePacketCount = getNodeConnectorStatisticsOutput.getPackets().getReceived().longValue();
+                    long receivedByteCount = getNodeConnectorStatisticsOutput.getBytes().getReceived().longValue();
+
+                    long transmitDropCount = getNodeConnectorStatisticsOutput.getTransmitDrops().longValue();
+                    long transmitErrorCount = getNodeConnectorStatisticsOutput.getTransmitErrors().longValue();
+                    long transmitPacketCount = getNodeConnectorStatisticsOutput.getPackets().getTransmitted()
+                            .longValue();
+                    long transmitByteCount = getNodeConnectorStatisticsOutput.getBytes().getTransmitted().longValue();
+
+                    result.setCollisionCount(colisionCount);
+                    result.setReceiveByteCount(receivedByteCount);
+                    result.setReceiveCRCErrorCount(receiveCrcErrorCount);
+                    result.setReceiveDropCount(receiveDropCount);
+                    result.setReceiveErrorCount(receiveErrorCount);
+                    result.setReceiveFrameErrorCount(receiveFrameErrorCount);
+                    result.setReceiveOverRunErrorCount(receiveOverRunError);
+                    result.setReceivePacketCount(receivePacketCount);
+                    result.setTransmitByteCount(transmitByteCount);
+                    result.setTransmitDropCount(transmitDropCount);
+                    result.setTransmitErrorCount(transmitErrorCount);
+                    result.setTransmitPacketCount(transmitPacketCount);
+                    return result;
+                }
+            }
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Read node connector not processed", e);
+        }
+
+        return result;
+
+    }
+
+    @Override
+    public List<NodeConnectorStatistics> readAllNodeConnector(Node node, boolean cached) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public NodeTableStatistics readNodeTable(NodeTable table, boolean cached) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public List<NodeTableStatistics> readAllNodeTable(Node node, boolean cached) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public long getTransmitRate(NodeConnector connector) {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public OpendaylightFlowStatisticsService getOpendaylightFlowStatisticsService() {
+        return opendaylightFlowStatisticsService;
+    }
+
+    public void setOpendaylightFlowStatisticsService(OpendaylightFlowStatisticsService opendaylightFlowStatisticsService) {
+        this.opendaylightFlowStatisticsService = opendaylightFlowStatisticsService;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/impl/MdSalFlowServiceAdapter.java b/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/impl/MdSalFlowServiceAdapter.java
new file mode 100644 (file)
index 0000000..ae8888f
--- /dev/null
@@ -0,0 +1,125 @@
+package org.opendaylight.controller.sal.compability.impl;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.flowprogrammer.Flow;
+import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
+import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.opendaylight.controller.sal.compability.FromSalConversionsUtils.*;
+
+public class MdSalFlowServiceAdapter implements IPluginInFlowProgrammerService {
+
+    private static final Logger LOG = LoggerFactory
+            .getLogger(MdSalFlowServiceAdapter.class);
+    private SalFlowService delegate;
+
+    public SalFlowService getDelegate() {
+        return delegate;
+    }
+
+    public void setDelegate(SalFlowService delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    // node isn't used in the method
+    public Status addFlow(Node node, Flow flow) {
+        AddFlowInput input = addFlowInput(node, flow);
+        Future<RpcResult<Void>> future = delegate.addFlow(input);
+        RpcResult<Void> result;
+        try {
+            result = future.get();
+            return toStatus(result); // how get status from result? conversion?
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Flow Add not processed", e);
+            return new Status(StatusCode.INTERNALERROR);
+        }
+    }
+
+    @Override
+    // old Flow - what it the purpose?
+    public Status modifyFlow(Node node, Flow oldFlow, Flow newFlow) {
+        UpdateFlowInput input = updateFlowInput(node,oldFlow,newFlow);
+        Future<RpcResult<Void>> future = delegate.updateFlow(input);
+        RpcResult<Void> result;
+        try {
+            result = future.get();
+            return toStatus(result);
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Flow Modify not processed", e);
+            return new Status(StatusCode.INTERNALERROR);
+        }
+    }
+
+    @Override
+    public Status removeFlow(Node node, Flow flow) {
+        RemoveFlowInput input = removeFlowInput(node,flow);
+        Future<RpcResult<Void>> future = delegate.removeFlow(input);
+        RpcResult<Void> result;
+        try {
+            result = future.get();
+            return toStatus(result);
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Flow Modify not processed", e);
+            return new Status(StatusCode.INTERNALERROR);
+        }
+    }
+
+    @Override
+    public Status addFlowAsync(Node node, Flow flow, long rid) {
+        AddFlowInput input = addFlowInput(node, flow);
+        delegate.addFlow(input);
+        return new Status(StatusCode.SUCCESS);
+    }
+
+    @Override
+    public Status modifyFlowAsync(Node node, Flow oldFlow, Flow newFlow,
+            long rid) {
+        UpdateFlowInput input = updateFlowInput(node,oldFlow,newFlow);
+        delegate.updateFlow(input);
+        return new Status(StatusCode.SUCCESS);
+    }
+
+    @Override
+    public Status removeFlowAsync(Node node, Flow flow, long rid) {
+        RemoveFlowInput input = removeFlowInput(node,flow);
+        delegate.removeFlow(input);
+        return new Status(StatusCode.SUCCESS);
+    }
+
+    @Override
+    public Status removeAllFlows(Node node) {
+        throw new UnsupportedOperationException("Not present in MD-SAL");
+    }
+
+    @Override
+    public Status syncSendBarrierMessage(Node node) {
+        
+        return null;
+    }
+
+    @Override
+    public Status asyncSendBarrierMessage(Node node) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    private Status toStatus(RpcResult<Void> result) {
+        if(result.isSuccessful()) {
+            return new Status(StatusCode.SUCCESS);
+        } else {
+            return new Status(StatusCode.INTERNALERROR);
+        }
+    }
+}
index aa3950db45f318eec5a88767bcbf66f9e9ca4233..64fa4d0e46cc74c4c0044cbb6a41e13956d17c6c 100644 (file)
@@ -40,29 +40,29 @@ public class TestFromSalConversionsUtils {
     public void testFromSalConversion() {
 
         Flow salFlow = prepareSalFlowCommon();
     public void testFromSalConversion() {
 
         Flow salFlow = prepareSalFlowCommon();
-        NodeFlow odNodeFlow = FromSalConversionsUtils.flowFrom(salFlow);
+        NodeFlow odNodeFlow = FromSalConversionsUtils.flowAdded(salFlow);
 
         checkOdFlow(odNodeFlow);
 
 
         checkOdFlow(odNodeFlow);
 
-        odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.other));
+        odNodeFlow = FromSalConversionsUtils.flowAdded(prepareSalMatch(salFlow, MtchType.other));
         checkOdMatch(odNodeFlow.getMatch(), MtchType.other);
 
         checkOdMatch(odNodeFlow.getMatch(), MtchType.other);
 
-        odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.arp));
+        odNodeFlow = FromSalConversionsUtils.flowAdded(prepareSalMatch(salFlow, MtchType.arp));
         checkOdMatch(odNodeFlow.getMatch(), MtchType.arp);
 
         checkOdMatch(odNodeFlow.getMatch(), MtchType.arp);
 
-        odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.ipv4));
+        odNodeFlow = FromSalConversionsUtils.flowAdded(prepareSalMatch(salFlow, MtchType.ipv4));
         checkOdMatch(odNodeFlow.getMatch(), MtchType.ipv4);
 
         checkOdMatch(odNodeFlow.getMatch(), MtchType.ipv4);
 
-        odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.ipv6));
+        odNodeFlow = FromSalConversionsUtils.flowAdded(prepareSalMatch(salFlow, MtchType.ipv6));
         checkOdMatch(odNodeFlow.getMatch(), MtchType.ipv6);
 
         checkOdMatch(odNodeFlow.getMatch(), MtchType.ipv6);
 
-        odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.sctp));
+        odNodeFlow = FromSalConversionsUtils.flowAdded(prepareSalMatch(salFlow, MtchType.sctp));
         checkOdMatch(odNodeFlow.getMatch(), MtchType.sctp);
 
         checkOdMatch(odNodeFlow.getMatch(), MtchType.sctp);
 
-        odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.tcp));
+        odNodeFlow = FromSalConversionsUtils.flowAdded(prepareSalMatch(salFlow, MtchType.tcp));
         checkOdMatch(odNodeFlow.getMatch(), MtchType.tcp);
 
         checkOdMatch(odNodeFlow.getMatch(), MtchType.tcp);
 
-        odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.udp));
+        odNodeFlow = FromSalConversionsUtils.flowAdded(prepareSalMatch(salFlow, MtchType.udp));
         checkOdMatch(odNodeFlow.getMatch(), MtchType.udp);
     }
 
         checkOdMatch(odNodeFlow.getMatch(), MtchType.udp);
     }