1) Implemented statistics adaptor (IPluginOutReadService, IPluginInReadService ) interfaces in sal-compatibility layer
2) Minor change in Port-Statistis
3) Fixed FlowStatisticsAdaptor.java - Flow Statistics rpc/notifications were changed and that effected the class
Change-Id: Ie0a2170efa5338389f80cb0a586500297320b387
Signed-off-by: Anil Vishnoi <avishnoi@in.ibm.com>
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey
import org.apache.felix.dm.Component
import java.util.Arrays
-import org.opendaylight.yangtools.yang.binding.NotificationListener
import java.util.Dictionary
import java.util.Hashtable
import org.opendaylight.controller.sal.utils.GlobalConstants
import org.opendaylight.controller.sal.discovery.IDiscoveryService
import org.opendaylight.controller.sal.topology.IPluginOutTopologyService
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryService
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService
class ComponentActivator extends ComponentActivatorAbstractBase implements BindingAwareConsumer {
// Inventory Service
inventory.dataService = session.getSALService(DataBrokerService);
inventory.flowStatisticsService = session.getRpcService(OpendaylightFlowStatisticsService);
+ inventory.flowTableStatisticsService = session.getRpcService(OpendaylightFlowTableStatisticsService);
+ inventory.nodeConnectorStatisticsService = session.getRpcService(OpendaylightPortStatisticsService);
inventory.topologyDiscovery = session.getRpcService(FlowTopologyDiscoveryService);
+ inventory.dataProviderService = session.getSALService(DataProviderService)
subscribe.registerNotificationListener(dataPacket)
add(
createServiceDependency() //
.setService(IPluginOutReadService) //
- .setCallbacks("setReadPublisher", "setReadPublisher") //
+ .setCallbacks("setReadPublisher", "unsetReadPublisher") //
.setRequired(false))
add(
createServiceDependency() //
package org.opendaylight.controller.sal.compatibility;
-import com.google.common.net.InetAddresses;
-import org.opendaylight.controller.sal.core.NodeConnector;
+import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.CRUDP;
+import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.ETHERNET_ARP;
+import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.TCP;
+import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.UDP;
+import static org.opendaylight.controller.sal.match.MatchType.DL_DST;
+import static org.opendaylight.controller.sal.match.MatchType.DL_SRC;
+import static org.opendaylight.controller.sal.match.MatchType.DL_TYPE;
+
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+
import org.opendaylight.controller.sal.match.Match;
import org.opendaylight.controller.sal.match.MatchField;
import org.opendaylight.controller.sal.match.MatchType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-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.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-
-import static org.opendaylight.controller.sal.compatibility.NodeMapping.toNodeConnectorRef;
-import static org.opendaylight.controller.sal.compatibility.NodeMapping.toNodeRef;
-import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.CRUDP;
-import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.ETHERNET_ARP;
-import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.TCP;
-import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.UDP;
-import static org.opendaylight.controller.sal.match.MatchType.DL_DST;
-import static org.opendaylight.controller.sal.match.MatchType.DL_SRC;
-import static org.opendaylight.controller.sal.match.MatchType.DL_TYPE;
+import com.google.common.net.InetAddresses;
public class FromSalConversionsUtils {
}
- public static GetNodeConnectorStatisticsInput nodeConnectorStatistics(
- NodeConnector connector) {
- GetNodeConnectorStatisticsInputBuilder target = new GetNodeConnectorStatisticsInputBuilder();
-
- NodeRef nodeRef = toNodeRef(connector.getNode());
- target.setNode(nodeRef);
-
- NodeConnectorRef nodeConnectorRef = toNodeConnectorRef(connector);
- target.setNodeConnector(nodeConnectorRef);
-
- return target.build();
- }
-
+ @SuppressWarnings("unused")
private static Address addressFromAction(InetAddress inetAddress) {
String strInetAddresss = InetAddresses.toAddrString(inetAddress);
if (inetAddress instanceof Inet4Address) {
MatchField vlan = sourceMatch.getField(MatchType.DL_VLAN);
if (vlan != null && vlan.getValue() != null) {
VlanIdBuilder vlanIDBuilder = new VlanIdBuilder();
- vlanIDBuilder.setVlanId(new VlanId((int) (NetUtils
+ vlanIDBuilder.setVlanId(new VlanId((NetUtils
.getUnsignedShort((short) vlan.getValue()))));
vlanMatchBuild.setVlanId(vlanIDBuilder.build());
}
.setIpv6Destination(new Ipv6Prefix(inetDstAddressString));
return layer6MatchBuild.build();
}
+
+ public static boolean flowEquals(Flow statsFlow, Flow storedFlow) {
+ if (statsFlow.getClass() != storedFlow.getClass()) {
+ return false;
+ }
+ if (statsFlow.getBufferId()== null) {
+ if (storedFlow.getBufferId() != null) {
+ return false;
+ }
+ } else if(!statsFlow.getBufferId().equals(storedFlow.getBufferId())) {
+ return false;
+ }
+ if (statsFlow.getContainerName()== null) {
+ if (storedFlow.getContainerName()!= null) {
+ return false;
+ }
+ } else if(!statsFlow.getContainerName().equals(storedFlow.getContainerName())) {
+ return false;
+ }
+ if (statsFlow.getCookie()== null) {
+ if (storedFlow.getCookie()!= null) {
+ return false;
+ }
+ } else if(!statsFlow.getCookie().equals(storedFlow.getCookie())) {
+ return false;
+ }
+ if (statsFlow.getMatch()== null) {
+ if (storedFlow.getMatch() != null) {
+ return false;
+ }
+ } else if(!statsFlow.getMatch().equals(storedFlow.getMatch())) {
+ return false;
+ }
+ if (statsFlow.getCookie()== null) {
+ if (storedFlow.getCookie()!= null) {
+ return false;
+ }
+ } else if(!statsFlow.getCookie().equals(storedFlow.getCookie())) {
+ return false;
+ }
+ if (statsFlow.getHardTimeout() == null) {
+ if (storedFlow.getHardTimeout() != null) {
+ return false;
+ }
+ } else if(!statsFlow.getHardTimeout().equals(storedFlow.getHardTimeout() )) {
+ return false;
+ }
+ if (statsFlow.getIdleTimeout()== null) {
+ if (storedFlow.getIdleTimeout() != null) {
+ return false;
+ }
+ } else if(!statsFlow.getIdleTimeout().equals(storedFlow.getIdleTimeout())) {
+ return false;
+ }
+ if (statsFlow.getPriority() == null) {
+ if (storedFlow.getPriority() != null) {
+ return false;
+ }
+ } else if(!statsFlow.getPriority().equals(storedFlow.getPriority())) {
+ return false;
+ }
+ if (statsFlow.getTableId() == null) {
+ if (storedFlow.getTableId() != null) {
+ return false;
+ }
+ } else if(!statsFlow.getTableId().equals(storedFlow.getTableId())) {
+ return false;
+ }
+ return true;
+ }
+
}
import static extension org.opendaylight.controller.sal.common.util.Arguments.*
import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*
-import static org.opendaylight.controller.sal.compatibility.MDFlowMapping.*
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef
import org.opendaylight.controller.sal.reader.FlowOnNode
import org.opendaylight.controller.sal.reader.NodeDescription
import org.slf4j.LoggerFactory
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsInputBuilder
import java.util.ArrayList
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllNodeConnectorStatisticsInputBuilder
import org.opendaylight.controller.sal.inventory.IPluginInInventoryService
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener
import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkUtilizationNormal
import org.opendaylight.controller.sal.topology.TopoEdgeUpdate
import org.opendaylight.controller.sal.discovery.IDiscoveryService
-
-class InventoryAndReadAdapter implements IPluginInTopologyService, IPluginInReadService, IPluginInInventoryService, OpendaylightInventoryListener, FlowTopologyDiscoveryListener {
+import org.opendaylight.controller.sal.reader.IPluginOutReadService
+import java.util.List
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsListener
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsListener
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate
+import org.opendaylight.controller.sal.reader.NodeTableStatistics
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatistics
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder
+
+class InventoryAndReadAdapter implements IPluginInTopologyService,
+ IPluginInReadService,
+ IPluginInInventoryService,
+ OpendaylightInventoryListener,
+ FlowTopologyDiscoveryListener,
+ OpendaylightFlowStatisticsListener,
+ OpendaylightFlowTableStatisticsListener,
+ OpendaylightPortStatisticsListener {
private static val LOG = LoggerFactory.getLogger(InventoryAndReadAdapter);
+ private static val OPENFLOWV10_TABLE_ID = new Integer(0).shortValue;
@Property
DataBrokerService dataService;
+ @Property
+ DataProviderService dataProviderService;
+
@Property
OpendaylightFlowStatisticsService flowStatisticsService;
+ @Property
+ OpendaylightPortStatisticsService nodeConnectorStatisticsService;
+
+ @Property
+ OpendaylightFlowTableStatisticsService flowTableStatisticsService;
+
@Property
IPluginOutInventoryService inventoryPublisher;
@Property
FlowTopologyDiscoveryService topologyDiscovery;
+
+ @Property
+ List<IPluginOutReadService> statisticsPublisher = new ArrayList<IPluginOutReadService>();
+
+ def setReadPublisher(IPluginOutReadService listener) {
+ statisticsPublisher.add(listener);
+ }
+
+ def unsetReadPublisher (IPluginOutReadService listener) {
+ if( listener != null)
+ statisticsPublisher.remove(listener);
+ }
+
+ protected def startChange() {
+ return dataProviderService.beginTransaction;
+ }
override getTransmitRate(NodeConnector connector) {
val nodeConnector = readFlowCapableNodeConnector(connector.toNodeConnectorRef);
}
override readAllFlow(Node node, boolean cached) {
- val input = new GetAllFlowStatisticsInputBuilder;
- input.setNode(node.toNodeRef);
- val result = flowStatisticsService.getAllFlowStatistics(input.build)
- val statistics = result.get.result;
val output = new ArrayList<FlowOnNode>();
- for (stat : statistics.flowStatistics) {
- // FIXME: Create FlowOnNode
- }
+ val tableRef = InstanceIdentifier.builder(Nodes)
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node, InventoryMapping.toNodeKey(node))
+ .augmentation(FlowCapableNode).child(Table, new TableKey(OPENFLOWV10_TABLE_ID)).toInstance();
+
+ val it = this.startChange();
+
+ val table= it.readConfigurationData(tableRef) as Table;
+
+ if(table != null){
+ LOG.info("Number of flows installed in table 0 of node {} : {}",node,table.flow.size);
+
+ for(flow : table.flow){
+
+ val adsalFlow = ToSalConversionsUtils.toFlow(flow);
+ val statsFromDataStore = flow.getAugmentation(FlowStatisticsData) as FlowStatisticsData;
+
+ if(statsFromDataStore != null){
+ val it = new FlowOnNode(adsalFlow);
+ byteCount = statsFromDataStore.flowStatistics.byteCount.value.longValue;
+ packetCount = statsFromDataStore.flowStatistics.packetCount.value.longValue;
+ durationSeconds = statsFromDataStore.flowStatistics.duration.second.value.intValue;
+ durationNanoseconds = statsFromDataStore.flowStatistics.duration.nanosecond.value.intValue;
+
+ output.add(it);
+ }
+ }
+ }
+
+ //TODO (main): Shell we send request to the switch? It will make async request to the switch.
+ // Once plugin receive response, it will let adaptor know through onFlowStatisticsUpdate()
+ // If we assume that md-sal statistics manager will always be running, then its not required
+ // But if not, then sending request will collect the latest data for adaptor atleast.
+ val input = new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
+ input.setNode(node.toNodeRef);
+ flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(input.build)
+
return output;
}
override readAllNodeConnector(Node node, boolean cached) {
- val input = new GetAllNodeConnectorStatisticsInputBuilder();
+
+ val ret = new ArrayList<NodeConnectorStatistics>();
+ val nodeRef = InstanceIdentifier.builder(Nodes)
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node, InventoryMapping.toNodeKey(node))
+ .toInstance();
+
+ val provider = this.startChange();
+
+ val dsNode= provider.readConfigurationData(nodeRef) as org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+
+ if(dsNode != null){
+
+ for (dsNodeConnector : dsNode.nodeConnector){
+ val nodeConnectorRef = InstanceIdentifier.builder(Nodes)
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node, InventoryMapping.toNodeKey(node))
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector, dsNodeConnector.key)
+ .toInstance();
+
+ val nodeConnectorFromDS = provider.readConfigurationData(nodeConnectorRef) as org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+
+ if(nodeConnectorFromDS != null){
+ val nodeConnectorStatsFromDs = nodeConnectorFromDS.getAugmentation(FlowCapableNodeConnectorStatisticsData) as FlowCapableNodeConnectorStatistics;
+
+ ret.add(toNodeConnectorStatistics(nodeConnectorStatsFromDs.flowCapableNodeConnectorStatistics,dsNode.id,dsNodeConnector.id));
+ }
+ }
+ }
+
+ //TODO: Refer TODO (main)
+ val input = new GetAllNodeConnectorsStatisticsInputBuilder();
input.setNode(node.toNodeRef);
- val result = flowStatisticsService.getAllNodeConnectorStatistics(input.build());
- val statistics = result.get.result.nodeConnectorStatistics;
- val ret = new ArrayList<NodeConnectorStatistics>();
- for (stat : statistics) {
- ret.add(stat.toNodeConnectorStatistics())
- }
+ nodeConnectorStatisticsService.getAllNodeConnectorsStatistics(input.build());
return ret;
}
override readAllNodeTable(Node node, boolean cached) {
- throw new UnsupportedOperationException("TODO: auto-generated method stub")
+ val ret = new ArrayList<NodeTableStatistics>();
+
+ val dsFlowCapableNode= readFlowCapableNode(node.toNodeRef)
+
+ if(dsFlowCapableNode != null){
+
+ for (table : dsFlowCapableNode.table){
+
+ val tableStats = table.getAugmentation(FlowTableStatisticsData) as FlowTableStatisticsData;
+
+ if(tableStats != null){
+ ret.add(toNodeTableStatistics(tableStats.flowTableStatistics,table.id,node));
+ }
+ }
+ }
+
+ //TODO: Refer TODO (main)
+ val input = new GetFlowTablesStatisticsInputBuilder();
+ input.setNode(node.toNodeRef);
+ flowTableStatisticsService.getFlowTablesStatistics(input.build);
+ return ret;
}
override readDescription(Node node, boolean cached) {
- val capableNode = readFlowCapableNode(node.toNodeRef)
-
- val it = new NodeDescription()
- manufacturer = capableNode.manufacturer
- serialNumber = capableNode.serialNumber
- software = capableNode.software
- description = capableNode.description
-
- return it;
- }
-
- override readFlow(Node node, Flow flow, boolean cached) {
- val input = flowStatisticsInput(node, flow);
- val output = flowStatisticsService.getFlowStatistics(input);
-
- try {
- val statistics = output.get().getResult();
- if (statistics != null) {
- val it = new FlowOnNode(flow);
- byteCount = statistics.byteCount.value.longValue
- durationNanoseconds = statistics.duration.getNanosecond().getValue().intValue();
- durationSeconds = statistics.duration.getSecond().getValue().intValue();
- packetCount = statistics.getPacketCount().getValue().longValue();
- return it;
- }
- } catch (Exception e) {
- LOG.error("Read flow not processed", e);
- }
- return null;
+ return toNodeDescription(node.toNodeRef);
+ }
+
+ override readFlow(Node node, Flow targetFlow, boolean cached) {
+ var FlowOnNode ret= null;
+
+ val tableRef = InstanceIdentifier.builder(Nodes)
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node, InventoryMapping.toNodeKey(node))
+ .augmentation(FlowCapableNode).child(Table, new TableKey(OPENFLOWV10_TABLE_ID)).toInstance();
+
+ val it = this.startChange();
+
+ val table= it.readConfigurationData(tableRef) as Table;
+
+ if(table != null){
+ LOG.info("Number of flows installed in table 0 of node {} : {}",node,table.flow.size);
+
+ for(mdsalFlow : table.flow){
+ if(FromSalConversionsUtils.flowEquals(mdsalFlow, MDFlowMapping.toMDSalflow(targetFlow))){
+ val statsFromDataStore = mdsalFlow.getAugmentation(FlowStatisticsData) as FlowStatisticsData;
+
+ if(statsFromDataStore != null){
+ LOG.debug("Found matching flow in the data store flow table ");
+ val it = new FlowOnNode(targetFlow);
+ byteCount = statsFromDataStore.flowStatistics.byteCount.value.longValue;
+ packetCount = statsFromDataStore.flowStatistics.packetCount.value.longValue;
+ durationSeconds = statsFromDataStore.flowStatistics.duration.second.value.intValue;
+ durationNanoseconds = statsFromDataStore.flowStatistics.duration.nanosecond.value.intValue;
+
+ ret = it;
+ }
+ }
+ }
+ }
+
+ //TODO: Refer TODO (main)
+ val input = new GetFlowStatisticsFromFlowTableInputBuilder;
+ input.setNode(node.toNodeRef);
+ input.fieldsFrom(MDFlowMapping.toMDSalflow(targetFlow));
+ flowStatisticsService.getFlowStatisticsFromFlowTable(input.build)
+
+ return ret;
+
}
override readNodeConnector(NodeConnector connector, boolean cached) {
+ var NodeConnectorStatistics nodeConnectorStatistics = null;
+
+ val nodeConnectorRef = InstanceIdentifier.builder(Nodes)
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node, InventoryMapping.toNodeKey(connector.node))
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector, InventoryMapping.toNodeConnectorKey(connector))
+ .toInstance();
+ val provider = this.startChange();
+
+ val nodeConnectorFromDS = provider.readConfigurationData(nodeConnectorRef) as org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+
+ if(nodeConnectorFromDS != null){
+ val nodeConnectorStatsFromDs = nodeConnectorFromDS.getAugmentation(FlowCapableNodeConnectorStatisticsData) as FlowCapableNodeConnectorStatistics;
+ if(nodeConnectorStatsFromDs != null) {
+ nodeConnectorStatistics = toNodeConnectorStatistics(nodeConnectorStatsFromDs.flowCapableNodeConnectorStatistics,
+ InventoryMapping.toNodeKey(connector.node).id,
+ InventoryMapping.toNodeConnectorKey(connector).id);
+ }
+ }
+
+ //TODO: Refer TODO (main)
+ val input = new GetNodeConnectorStatisticsInputBuilder();
+ input.setNode(connector.node.toNodeRef);
+ input.setNodeConnectorId(InventoryMapping.toNodeConnectorKey(connector).id);
+ nodeConnectorStatisticsService.getNodeConnectorStatistics(input.build());
+ return nodeConnectorStatistics;
+ }
- val getNodeConnectorStatisticsInput = FromSalConversionsUtils.nodeConnectorStatistics(connector);
- val future = flowStatisticsService.getNodeConnectorStatistics(getNodeConnectorStatisticsInput);
- try {
- val rpcResult = future.get();
- val output = rpcResult.getResult();
-
- if (output != null) {
- return output.toNodeConnectorStatistics;
- }
- } catch (Exception e) {
- LOG.error("Read node connector not processed", e);
- }
-
- return null;
+ override readNodeTable(NodeTable nodeTable, boolean cached) {
+ var NodeTableStatistics nodeStats = null
+
+ val tableRef = InstanceIdentifier.builder(Nodes)
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node, InventoryMapping.toNodeKey(nodeTable.node))
+ .augmentation(FlowCapableNode).child(Table, new TableKey(nodeTable.ID as Short)).toInstance();
+
+ val it = this.startChange();
+
+ val table= it.readConfigurationData(tableRef) as Table;
+
+ if(table != null){
+ val tableStats = table.getAugmentation(FlowTableStatisticsData) as FlowTableStatisticsData;
+
+ if(tableStats != null){
+ nodeStats = toNodeTableStatistics(tableStats.flowTableStatistics,table.id,nodeTable.node);
+ }
+ }
+
+ //TODO: Refer TODO (main)
+ val input = new GetFlowTablesStatisticsInputBuilder();
+ input.setNode(nodeTable.node.toNodeRef);
+ flowTableStatisticsService.getFlowTablesStatistics(input.build);
+
+ return nodeStats;
}
override onNodeConnectorRemoved(NodeConnectorRemoved update) {
override onNodeRemoved(NodeRemoved notification) {
val properties = Collections.<org.opendaylight.controller.sal.core.Property>emptySet();
- val org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> identifier = notification.nodeRef.value as org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>;
inventoryPublisher.updateNode(notification.nodeRef.toADNode, UpdateType.REMOVED, properties);
}
updateType = UpdateType.ADDED;
}
inventoryPublisher.updateNode(notification.nodeRef.toADNode, updateType, properties);
+
+ //Notify the listeners of IPluginOutReadService
+
+ for (statsPublisher : statisticsPublisher){
+ val nodeRef = InstanceIdentifier.builder(Nodes).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node,new NodeKey(notification.id)).toInstance;
+ statsPublisher.descriptionStatisticsUpdated(nodeRef.toADNode,toNodeDescription(notification.nodeRef));
+ }
}
override getNodeProps() {
return null;
}
- override readNodeTable(NodeTable table, boolean cached) {
- throw new UnsupportedOperationException("TODO: auto-generated method stub")
- }
-
private def FlowCapableNode readFlowCapableNode(NodeRef ref) {
val dataObject = dataService.readOperationalData(ref.value as InstanceIdentifier<? extends DataObject>);
val node = dataObject.checkInstanceOf(
return node.getAugmentation(FlowCapableNodeConnector);
}
- private static def toNodeConnectorStatistics(
- org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.NodeConnectorStatistics output) {
- val it = new NodeConnectorStatistics
-
- collisionCount = output.getCollisionCount().longValue();
- receiveCRCErrorCount = output.getReceiveCrcError().longValue();
- receiveFrameErrorCount = output.getReceiveFrameError().longValue();
- receiveOverRunErrorCount = output.getReceiveOverRunError().longValue();
+ private def toNodeConnectorStatistics(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.NodeConnectorStatistics nodeConnectorStatistics, NodeId nodeId, NodeConnectorId nodeConnectorId) {
+
+ val it = new NodeConnectorStatistics();
+
+ receivePacketCount = nodeConnectorStatistics.packets.received.longValue;
+ transmitPacketCount = nodeConnectorStatistics.packets.transmitted.longValue;
+
+ receiveByteCount = nodeConnectorStatistics.bytes.received.longValue;
+ transmitByteCount = nodeConnectorStatistics.bytes.transmitted.longValue;
+
+ receiveDropCount = nodeConnectorStatistics.receiveDrops.longValue;
+ transmitDropCount = nodeConnectorStatistics.transmitDrops.longValue;
+
+ receiveErrorCount = nodeConnectorStatistics.receiveErrors.longValue;
+ transmitErrorCount = nodeConnectorStatistics.transmitErrors.longValue;
+
+ receiveFrameErrorCount = nodeConnectorStatistics.receiveFrameError.longValue;
+ receiveOverRunErrorCount = nodeConnectorStatistics.receiveOverRunError.longValue;
+ receiveCRCErrorCount = nodeConnectorStatistics.receiveCrcError.longValue;
+ collisionCount = nodeConnectorStatistics.collisionCount.longValue;
+
+ val nodeConnectorRef = InstanceIdentifier.builder(Nodes)
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node,new NodeKey(nodeId))
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector,new NodeConnectorKey(nodeConnectorId)).toInstance;
+
+ nodeConnector = NodeMapping.toADNodeConnector(new NodeConnectorRef(nodeConnectorRef));
+
+ return it;
+ }
- receiveDropCount = output.getReceiveDrops().longValue();
- receiveErrorCount = output.getReceiveErrors().longValue();
- receivePacketCount = output.getPackets().getReceived().longValue();
- receiveByteCount = output.getBytes().getReceived().longValue();
+ private def toNodeTableStatistics(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics tableStats,
+ Short tableId,Node node){
+ var it = new NodeTableStatistics();
+
+ activeCount = tableStats.activeFlows.value.intValue;
+ lookupCount = tableStats.packetsLookedUp.value.intValue;
+ matchedCount = tableStats.packetsMatched.value.intValue;
+ name = tableId.toString;
+ nodeTable = new NodeTable(NodeMapping.MD_SAL_TYPE,tableId,node);
+ return it;
+ }
+
+ private def toNodeDescription(NodeRef nodeRef){
+ val capableNode = readFlowCapableNode(nodeRef);
- transmitDropCount = output.getTransmitDrops().longValue();
- transmitErrorCount = output.getTransmitErrors().longValue();
- transmitPacketCount = output.getPackets().getTransmitted().longValue();
- transmitByteCount = output.getBytes().getTransmitted().longValue();
+ val it = new NodeDescription()
+ manufacturer = capableNode.manufacturer
+ serialNumber = capableNode.serialNumber
+ software = capableNode.software
+ description = capableNode.description
+
return it;
- }
+ }
override sollicitRefresh() {
topologyDiscovery.solicitRefresh
def Edge toADEdge(Link link) {
new Edge(link.source.toADNodeConnector,link.destination.toADNodeConnector)
}
-
+
+ /*
+ * OpendaylightFlowStatisticsListener interface implementation
+ */
+ override onAggregateFlowStatisticsUpdate(AggregateFlowStatisticsUpdate notification) {
+ throw new UnsupportedOperationException("TODO: auto-generated method stub")
+ }
+
+ override onFlowsStatisticsUpdate(FlowsStatisticsUpdate notification) {
+
+ val adsalFlowsStatistics = new ArrayList<FlowOnNode>();
+
+ for(flowStats : notification.flowAndStatisticsMapList){
+ if(flowStats.tableId == 0)
+ adsalFlowsStatistics.add(toFlowOnNode(flowStats));
+ }
+
+ for (statsPublisher : statisticsPublisher){
+ val nodeRef = InstanceIdentifier.builder(Nodes).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node,new NodeKey(notification.id)).toInstance;
+ statsPublisher.nodeFlowStatisticsUpdated(nodeRef.toADNode,adsalFlowsStatistics);
+ }
+
+ }
+ /*
+ * OpendaylightFlowTableStatisticsListener interface implementation
+ */
+ override onFlowTableStatisticsUpdate(FlowTableStatisticsUpdate notification) {
+ var adsalFlowTableStatistics = new ArrayList<NodeTableStatistics>();
+
+ for(stats : notification.flowTableAndStatisticsMap){
+ if (stats.tableId.value == 0){
+ val it = new NodeTableStatistics();
+ activeCount = stats.activeFlows.value.intValue;
+ lookupCount = stats.packetsLookedUp.value.longValue;
+ matchedCount = stats.packetsMatched.value.longValue;
+
+ adsalFlowTableStatistics.add(it);
+ }
+ }
+ for (statsPublisher : statisticsPublisher){
+ val nodeRef = InstanceIdentifier.builder(Nodes).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node,new NodeKey(notification.id)).toInstance;
+ statsPublisher.nodeTableStatisticsUpdated(nodeRef.toADNode,adsalFlowTableStatistics);
+ }
+ }
+
+ /*
+ * OpendaylightPortStatisticsUpdate interface implementation
+ */
+ override onNodeConnectorStatisticsUpdate(NodeConnectorStatisticsUpdate notification) {
+
+ val adsalPortStatistics = new ArrayList<NodeConnectorStatistics>();
+
+ for(nodeConnectorStatistics : notification.nodeConnectorStatisticsAndPortNumberMap){
+ adsalPortStatistics.add(toNodeConnectorStatistics(nodeConnectorStatistics,notification.id,nodeConnectorStatistics.nodeConnectorId));
+ }
+
+ for (statsPublisher : statisticsPublisher){
+ val nodeRef = InstanceIdentifier.builder(Nodes).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node,new NodeKey(notification.id)).toInstance;
+ statsPublisher.nodeConnectorStatisticsUpdated(nodeRef.toADNode,adsalPortStatistics);
+ }
+
+ }
+
+ private static def toFlowOnNode (FlowAndStatisticsMapList flowAndStatsMap){
+
+ val it = new FlowOnNode(ToSalConversionsUtils.toFlow(flowAndStatsMap));
+
+ byteCount = flowAndStatsMap.byteCount.value.longValue;
+ packetCount = flowAndStatsMap.packetCount.value.longValue;
+ durationSeconds = flowAndStatsMap.duration.second.value.intValue;
+ durationNanoseconds = flowAndStatsMap.duration.nanosecond.value.intValue;
+
+ return it;
+ }
}
import java.net.Inet4Address
import java.net.Inet6Address
import java.util.ArrayList
-import java.util.List
import org.opendaylight.controller.sal.action.Controller
import org.opendaylight.controller.sal.action.Drop
import org.opendaylight.controller.sal.action.Flood
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsInputBuilder
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder
public class MDFlowMapping {
return it.build;
}
- public static def flowStatisticsInput(Node sourceNode, Flow sourceFlow) {
- val source = flowAdded(sourceFlow);
- val it = new GetFlowStatisticsInputBuilder(source as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
- node = sourceNode.toNodeRef();
- return it.build();
- }
-
public static def removeFlowInput(Node sourceNode, Flow sourceFlow) {
val source = flowAdded(sourceFlow);
val it = new RemoveFlowInputBuilder(source as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
}
return new MacAddress(sb.toString());
}
+
+ public static def toMDSalflow(Flow sourceFlow) {
+ if (sourceFlow == null)
+ throw new IllegalArgumentException();
+ val it = new FlowBuilder();
+
+ hardTimeout = sourceFlow.hardTimeout as int
+ idleTimeout = sourceFlow.idleTimeout as int
+ cookie = BigInteger.valueOf(sourceFlow.id)
+ priority = sourceFlow.priority as int
+
+ val sourceActions = sourceFlow.actions;
+ val targetActions = new ArrayList<Action>();
+ for (sourceAction : sourceActions) {
+ targetActions.add(sourceAction.toAction());
+ }
+ instructions = targetActions.toApplyInstruction();
+ match = sourceFlow.match.toMatch();
+ return it.build();
+ }
+
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId
+
public class NodeMapping {
public static val MD_SAL_TYPE = "MD_SAL";
private static val NODE_CLASS = org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
- private static val NODECONNECTOR_CLASS = org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.
- NodeConnector;
+ private static val NODECONNECTOR_CLASS = org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
private new() {
throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
val connectorKey = item.getKey().checkInstanceOf(NodeConnectorKey);
return new NodeConnector(MD_SAL_TYPE, connectorKey.getId().getValue().toString(), node);
}
-
+
public static def toNodeRef(Node node) {
checkArgument(MD_SAL_TYPE.equals(node.getType()));
var nodeId = node.ID.checkInstanceOf(String)
val nodePath = InstanceIdentifier.builder().node(Nodes).child(NODE_CLASS, nodeKey).toInstance();
return new NodeRef(nodePath);
}
-
+
public static def toNodeConnectorRef(NodeConnector nodeConnector) {
val node = nodeConnector.node.toNodeRef();
val nodePath = node.getValue() as InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node>
public static def toADNode(NodeRef node) throws ConstructionException {
return toADNode(node.getValue());
}
-
+
}
package org.opendaylight.controller.sal.compatibility;
-import com.google.common.net.InetAddresses;
+import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.CRUDP;
+import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.ETHERNET_ARP;
+import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.TCP;
+import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.UDP;
+import static org.opendaylight.controller.sal.match.MatchType.DL_DST;
+import static org.opendaylight.controller.sal.match.MatchType.DL_SRC;
+import static org.opendaylight.controller.sal.match.MatchType.DL_TYPE;
+import static org.opendaylight.controller.sal.match.MatchType.DL_VLAN;
+import static org.opendaylight.controller.sal.match.MatchType.DL_VLAN_PR;
+import static org.opendaylight.controller.sal.match.MatchType.NW_DST;
+import static org.opendaylight.controller.sal.match.MatchType.NW_PROTO;
+import static org.opendaylight.controller.sal.match.MatchType.NW_SRC;
+import static org.opendaylight.controller.sal.match.MatchType.NW_TOS;
+import static org.opendaylight.controller.sal.match.MatchType.TP_DST;
+import static org.opendaylight.controller.sal.match.MatchType.TP_SRC;
+
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import org.opendaylight.controller.sal.action.Controller;
import org.opendaylight.controller.sal.action.Drop;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
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.action.types.rev131112.ActionList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.ETHERNET_ARP;
-import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.CRUDP;
-import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.TCP;
-import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.UDP;
-import static org.opendaylight.controller.sal.match.MatchType.DL_DST;
-import static org.opendaylight.controller.sal.match.MatchType.DL_SRC;
-import static org.opendaylight.controller.sal.match.MatchType.DL_TYPE;
-import static org.opendaylight.controller.sal.match.MatchType.DL_VLAN;
-import static org.opendaylight.controller.sal.match.MatchType.DL_VLAN_PR;
-import static org.opendaylight.controller.sal.match.MatchType.NW_DST;
-import static org.opendaylight.controller.sal.match.MatchType.NW_PROTO;
-import static org.opendaylight.controller.sal.match.MatchType.NW_SRC;
-import static org.opendaylight.controller.sal.match.MatchType.NW_TOS;
-import static org.opendaylight.controller.sal.match.MatchType.TP_DST;
-import static org.opendaylight.controller.sal.match.MatchType.TP_SRC;
+import com.google.common.net.InetAddresses;
public class ToSalConversionsUtils {
private static void fillFromArp(Match target, ArpMatch source) {
Ipv4Prefix sourceAddress = source.getArpSourceTransportAddress();
if (sourceAddress != null) {
- target.setField(NW_SRC, (InetAddress) inetAddressFrom(sourceAddress), null);
+ target.setField(NW_SRC, inetAddressFrom(sourceAddress), null);
}
Ipv4Prefix destAddress = source.getArpTargetTransportAddress();
if (destAddress != null) {
- target.setField(NW_DST, (InetAddress) inetAddressFrom(destAddress), null);
+ target.setField(NW_DST, inetAddressFrom(destAddress), null);
}
ArpSourceHardwareAddress sourceHwAddress = source.getArpSourceHardwareAddress();
if (sourceHwAddress != null) {
private static void fillFromIpv6(Match target, Ipv6Match source) {
Ipv6Prefix sourceAddress = source.getIpv6Source();
if (sourceAddress != null) {
- target.setField(NW_SRC, (InetAddress) inetAddressFrom(sourceAddress), null);
+ target.setField(NW_SRC, inetAddressFrom(sourceAddress), null);
}
Ipv6Prefix destAddress = source.getIpv6Destination();
if (destAddress != null) {
- target.setField(NW_DST, (InetAddress) inetAddressFrom(destAddress), null);
+ target.setField(NW_DST, inetAddressFrom(destAddress), null);
}
}
private static void fillFromIpv4(Match target, Ipv4Match source) {
Ipv4Prefix sourceAddress = source.getIpv4Source();
if (sourceAddress != null) {
- target.setField(NW_SRC, (InetAddress) inetAddressFrom(sourceAddress), null);
+ target.setField(NW_SRC, inetAddressFrom(sourceAddress), null);
}
Ipv4Prefix destAddress = source.getIpv4Destination();
if (destAddress != null) {
- target.setField(NW_DST, (InetAddress) inetAddressFrom(destAddress), null);
+ target.setField(NW_DST, inetAddressFrom(destAddress), null);
}
}
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.controller.sal.common.util.Futures;
import org.opendaylight.controller.sal.common.util.Rpcs;
+import org.opendaylight.controller.sal.compatibility.FromSalConversionsUtils;
+import org.opendaylight.controller.sal.compatibility.InventoryMapping;
import org.opendaylight.controller.sal.compatibility.NodeMapping;
import org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils;
import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
import org.opendaylight.controller.sal.reader.NodeDescription;
import org.opendaylight.controller.sal.reader.NodeTableStatistics;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllNodeConnectorStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllNodeConnectorStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllNodeConnectorStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowTableStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowTableStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowTableStatisticsOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.NodeConnectorStatisticsUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.all.flow.statistics.output.FlowStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.all.flow.statistics.output.FlowStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.all.node.connector.statistics.output.NodeConnectorStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.statistics.Duration;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.statistics.DurationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.Bytes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.BytesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.Packets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.PacketsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, IReadServiceListener {
+public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, IReadServiceListener{
private static final Logger LOG = LoggerFactory.getLogger(FlowStatisticsAdapter.class);
private IReadService readDelegate;
private NotificationProviderService notifier;
@Override
- public Future<RpcResult<GetAllFlowStatisticsOutput>> getAllFlowStatistics(GetAllFlowStatisticsInput input) {
- GetAllFlowStatisticsOutput rpcResultType = null;
- boolean rpcResultBool = false;
-
- try {
- Node adNode = NodeMapping.toADNode(input.getNode());
- List<FlowOnNode> flowsOnNode = readDelegate.readAllFlows(adNode);
- List<FlowStatistics> flowsStatistics = toOdFlowsStatistics(flowsOnNode);
- GetAllFlowStatisticsOutputBuilder builder = new GetAllFlowStatisticsOutputBuilder();
- rpcResultType = builder.setFlowStatistics(flowsStatistics).build();
- rpcResultBool = true;
- } catch (ConstructionException e) {
- LOG.error(e.getMessage());
- }
+ public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
+ GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
+ //TODO: No supported API exist in AD-SAL, it can either be implemented by fetching all the stats of the flows and
+ // generating aggregate flow statistics out of those individual flow stats.
+ return null;
+ }
- return Futures.immediateFuture(Rpcs.getRpcResult(rpcResultBool, rpcResultType, null));
+ @Override
+ public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
+ GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
+ //TODO: No supported API exist in AD-SAL, it can either be implemented by fetching all the stats of the flows and
+ // generating aggregate flow statistics out of those individual flow stats.
+ return null;
}
@Override
- public Future<RpcResult<GetAllNodeConnectorStatisticsOutput>> getAllNodeConnectorStatistics(
- GetAllNodeConnectorStatisticsInput input) {
- GetAllNodeConnectorStatisticsOutput rpcResultType = null;
+ public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
+ GetAllFlowStatisticsFromFlowTableInput input) {
+ GetAllFlowStatisticsFromFlowTableOutput rpcResultType = null;
boolean rpcResultBool = false;
try {
Node adNode = NodeMapping.toADNode(input.getNode());
- List<NodeConnectorStatistics> nodesConnectorStatistics = readDelegate.readNodeConnectors(adNode);
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.all.node.connector.statistics.output.NodeConnectorStatistics> odNodesConnectorStatistics;
- odNodesConnectorStatistics = toOdNodesConnectorStatistics(nodesConnectorStatistics);
- GetAllNodeConnectorStatisticsOutputBuilder builder = new GetAllNodeConnectorStatisticsOutputBuilder();
- rpcResultType = builder.setNodeConnectorStatistics(odNodesConnectorStatistics).build();
+ List<FlowOnNode> flowsOnNode = readDelegate.readAllFlows(adNode);
+ List<FlowAndStatisticsMapList> flowsStatistics = toOdFlowsStatistics(flowsOnNode);
+ GetAllFlowStatisticsFromFlowTableOutputBuilder builder = new GetAllFlowStatisticsFromFlowTableOutputBuilder();
+ builder.setTransactionId(new TransactionId(new BigInteger("0")));
+ rpcResultType = builder.setFlowAndStatisticsMapList(flowsStatistics).build();
+
rpcResultBool = true;
} catch (ConstructionException e) {
LOG.error(e.getMessage());
return Futures.immediateFuture(Rpcs.getRpcResult(rpcResultBool, rpcResultType, null));
}
+ /**
+ * Essentially this API will return the same result as getAllFlowStatisticsFromFlowTable
+ */
@Override
- public Future<RpcResult<GetFlowStatisticsOutput>> getFlowStatistics(GetFlowStatisticsInput input) {
- GetFlowStatisticsOutput rpcResultType = null;
+ public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
+ GetAllFlowsStatisticsFromAllFlowTablesInput input) {
+
+ GetAllFlowsStatisticsFromAllFlowTablesOutput rpcResultType = null;
boolean rpcResultBool = false;
try {
- Node node = NodeMapping.toADNode(input.getNode());
- Flow flow = ToSalConversionsUtils.toFlow(input);
- FlowOnNode readFlow = readDelegate.readFlow(node, flow);
- FlowStatistics flowOnNodeToFlowStatistics = toOdFlowStatistics(readFlow);
- rpcResultType = new GetFlowStatisticsOutputBuilder(flowOnNodeToFlowStatistics).build();
+ Node adNode = NodeMapping.toADNode(input.getNode());
+ List<FlowOnNode> flowsOnNode = readDelegate.readAllFlows(adNode);
+ List<FlowAndStatisticsMapList> flowsStatistics = toOdFlowsStatistics(flowsOnNode);
+ GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder builder = new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder();
+ builder.setTransactionId(new TransactionId(new BigInteger("0")));
+ rpcResultType = builder.setFlowAndStatisticsMapList(flowsStatistics).build();
+
rpcResultBool = true;
} catch (ConstructionException e) {
LOG.error(e.getMessage());
}
@Override
- public Future<RpcResult<GetFlowTableStatisticsOutput>> getFlowTableStatistics(GetFlowTableStatisticsInput input) {
- GetFlowTableStatisticsOutput rpcResultType = null;
+ public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
+ GetFlowStatisticsFromFlowTableInput input) {
+ GetFlowStatisticsFromFlowTableOutput rpcResultType = null;
boolean rpcResultBool = false;
try {
Node node = NodeMapping.toADNode(input.getNode());
- List<NodeTableStatistics> nodesTable = readDelegate.readNodeTable(node);
- NodeTableStatistics nodeTable = null;
- if (!nodesTable.isEmpty()) {
- nodeTable = nodesTable.get(0);
- rpcResultType = toOdTableStatistics(nodeTable);
- rpcResultBool = true;
- }
- } catch (ConstructionException e) {
- LOG.error(e.getMessage());
- }
-
- return Futures.immediateFuture(Rpcs.getRpcResult(rpcResultBool, rpcResultType, null));
- }
-
- @Override
- public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
- GetNodeConnectorStatisticsInput input) {
- GetNodeConnectorStatisticsOutput rpcResultType = null;
- boolean rpcResultBool = false;
-
- NodeConnectorRef nodeConnector = input.getNodeConnector();
- try {
- NodeConnectorStatistics nodeConnectorStats = readDelegate.readNodeConnector(NodeMapping
- .toADNodeConnector(nodeConnector));
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.all.node.connector.statistics.output.NodeConnectorStatistics odNodeConnectorStatistics = toOdNodeConnectorStatistics(nodeConnectorStats);
- rpcResultType = new GetNodeConnectorStatisticsOutputBuilder(odNodeConnectorStatistics).build();
+ Flow flow = ToSalConversionsUtils.toFlow(input);
+ FlowOnNode readFlow = readDelegate.readFlow(node, flow);
+ List<FlowAndStatisticsMapList> flowOnNodeToFlowStatistics = new ArrayList<FlowAndStatisticsMapList>();
+ flowOnNodeToFlowStatistics.add(toOdFlowStatistics(readFlow));
+ rpcResultType = new GetFlowStatisticsFromFlowTableOutputBuilder().setFlowAndStatisticsMapList(flowOnNodeToFlowStatistics).build();
rpcResultBool = true;
} catch (ConstructionException e) {
LOG.error(e.getMessage());
}
@Override
- public void descriptionStatisticsUpdated(Node node, NodeDescription nodeDescription) {
-
- // TODO which *StatisticsUpdated interface should be used?
-
+ public void nodeFlowStatisticsUpdated(Node node, List<FlowOnNode> flowStatsList) {
+ List<FlowAndStatisticsMapList> flowStatistics = toOdFlowsStatistics(flowStatsList);
+ FlowsStatisticsUpdateBuilder flowsStatisticsUpdateBuilder = new FlowsStatisticsUpdateBuilder();
+ flowsStatisticsUpdateBuilder.setFlowAndStatisticsMapList(flowStatistics);
+ flowsStatisticsUpdateBuilder.setMoreReplies(false);
+ flowsStatisticsUpdateBuilder.setTransactionId(null);
+ flowsStatisticsUpdateBuilder.setId(InventoryMapping.toNodeKey(node).getId());
+ notifier.publish(flowsStatisticsUpdateBuilder.build());
}
@Override
public void nodeConnectorStatisticsUpdated(Node node, List<NodeConnectorStatistics> ncStatsList) {
- for (NodeConnectorStatistics ndConStats : ncStatsList) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.all.node.connector.statistics.output.NodeConnectorStatistics odNodeConnectorStatistics;
- odNodeConnectorStatistics = toOdNodeConnectorStatistics(ndConStats);
- NodeConnectorStatisticsUpdatedBuilder statisticsBuilder = new NodeConnectorStatisticsUpdatedBuilder(
- odNodeConnectorStatistics);
- notifier.publish(statisticsBuilder.build());
- }
- }
-
- @Override
- public void nodeFlowStatisticsUpdated(Node node, List<FlowOnNode> flowStatsList) {
- for (FlowOnNode flowOnNode : flowStatsList) {
- FlowStatistics flowStatistics = toOdFlowStatistics(flowOnNode);
- FlowStatisticsUpdatedBuilder statisticsBuilder = new FlowStatisticsUpdatedBuilder(flowStatistics);
- notifier.publish(statisticsBuilder.build());
- }
+ NodeConnectorStatisticsUpdateBuilder nodeConnectorStatisticsUpdateBuilder = new NodeConnectorStatisticsUpdateBuilder();
+ List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatistics = toOdNodeConnectorStatistics(ncStatsList);
+
+ nodeConnectorStatisticsUpdateBuilder.setNodeConnectorStatisticsAndPortNumberMap(nodeConnectorStatistics);
+ nodeConnectorStatisticsUpdateBuilder.setMoreReplies(false);
+ nodeConnectorStatisticsUpdateBuilder.setTransactionId(null);
+ nodeConnectorStatisticsUpdateBuilder.setId(InventoryMapping.toNodeKey(node).getId());
+ notifier.publish(nodeConnectorStatisticsUpdateBuilder.build());
}
@Override
public void nodeTableStatisticsUpdated(Node node, List<NodeTableStatistics> tableStatsList) {
- // TODO : Not implemented by AD-SAL.
+
+ FlowTableStatisticsUpdateBuilder flowTableStatisticsUpdateBuilder = new FlowTableStatisticsUpdateBuilder();
+
+ List<FlowTableAndStatisticsMap> flowTableStatistics = toOdFlowTableStatistics(tableStatsList);
+ flowTableStatisticsUpdateBuilder.setFlowTableAndStatisticsMap(flowTableStatistics);
+ flowTableStatisticsUpdateBuilder.setMoreReplies(false);
+ flowTableStatisticsUpdateBuilder.setTransactionId(null);
+ flowTableStatisticsUpdateBuilder.setId(InventoryMapping.toNodeKey(node).getId());
+ notifier.publish(flowTableStatisticsUpdateBuilder.build());
+}
+
+ @Override
+ public void descriptionStatisticsUpdated(Node node, NodeDescription nodeDescription) {
+ // TODO which *StatisticsUpdated interface should be used?
+
}
- private List<FlowStatistics> toOdFlowsStatistics(List<FlowOnNode> flowsOnNode) {
- List<FlowStatistics> flowsStatistics = new ArrayList<>();
+ private List<FlowAndStatisticsMapList> toOdFlowsStatistics(List<FlowOnNode> flowsOnNode) {
+ List<FlowAndStatisticsMapList> flowsStatistics = new ArrayList<>();
for (FlowOnNode flowOnNode : flowsOnNode) {
flowsStatistics.add(toOdFlowStatistics(flowOnNode));
}
return flowsStatistics;
}
- private FlowStatistics toOdFlowStatistics(FlowOnNode flowOnNode) {
- FlowStatisticsBuilder builder = new FlowStatisticsBuilder();
+ private FlowAndStatisticsMapList toOdFlowStatistics(FlowOnNode flowOnNode) {
+ FlowAndStatisticsMapListBuilder builder = new FlowAndStatisticsMapListBuilder();
builder.setByteCount(toCounter64(flowOnNode.getByteCount()));
builder.setPacketCount(toCounter64(flowOnNode.getPacketCount()));
builder.setDuration(extractDuration(flowOnNode));
-
+ builder.setMatch(FromSalConversionsUtils.toMatch(flowOnNode.getFlow().getMatch()));
+ builder.setPriority((int)flowOnNode.getFlow().getPriority());
+ builder.setHardTimeout((int)flowOnNode.getFlow().getHardTimeout());
+ builder.setIdleTimeout((int)flowOnNode.getFlow().getIdleTimeout());
+ //TODO: actions to instruction conversion
+ builder.setInstructions(null);
return builder.build();
}
- private Duration extractDuration(FlowOnNode flowOnNode) {
+ private org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.Duration extractDuration(FlowOnNode flowOnNode) {
DurationBuilder builder = new DurationBuilder();
- builder.setNanosecond(toCounter64(flowOnNode.getDurationNanoseconds()));
- builder.setSecond(toCounter64(flowOnNode.getDurationSeconds()));
+ builder.setNanosecond(new Counter32((long)flowOnNode.getDurationNanoseconds()));
+ builder.setSecond(new Counter32((long)flowOnNode.getDurationSeconds()));
return builder.build();
}
return new Counter64(byteCountBigInt);
}
- private Counter64 toCounter64(int num) {
- String byteCountStr = String.valueOf(num);
- BigInteger byteCountBigInt = new BigInteger(byteCountStr);
- return new Counter64(byteCountBigInt);
- }
-
- private List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.all.node.connector.statistics.output.NodeConnectorStatistics> toOdNodesConnectorStatistics(
- List<NodeConnectorStatistics> nodesConnectorStatistics) {
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.all.node.connector.statistics.output.NodeConnectorStatistics> odNodesConnectorStatistics = new ArrayList<>();
- for (NodeConnectorStatistics nodeConnectorStatistics : nodesConnectorStatistics) {
- odNodesConnectorStatistics.add(toOdNodeConnectorStatistics(nodeConnectorStatistics));
+ private List<FlowTableAndStatisticsMap> toOdFlowTableStatistics(List<NodeTableStatistics> tableStatsList) {
+
+ List<FlowTableAndStatisticsMap> flowTableStatsMap = new ArrayList<FlowTableAndStatisticsMap>();
+ for (NodeTableStatistics nodeTableStatistics : tableStatsList) {
+ FlowTableAndStatisticsMapBuilder flowTableAndStatisticsMapBuilder = new FlowTableAndStatisticsMapBuilder();
+ flowTableAndStatisticsMapBuilder.setActiveFlows(new Counter32((long) nodeTableStatistics.getActiveCount()));
+ flowTableAndStatisticsMapBuilder.setPacketsLookedUp(toCounter64(nodeTableStatistics.getLookupCount()));
+ flowTableAndStatisticsMapBuilder.setPacketsMatched(toCounter64(nodeTableStatistics.getMatchedCount()));
+ flowTableAndStatisticsMapBuilder.setActiveFlows(new Counter32((long) nodeTableStatistics.getActiveCount()));
+ flowTableAndStatisticsMapBuilder.setTableId(new TableId((short)nodeTableStatistics.getNodeTable().getID()));
+ flowTableStatsMap.add(flowTableAndStatisticsMapBuilder.build());
}
- return odNodesConnectorStatistics;
+
+ return flowTableStatsMap;
}
- private org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.all.node.connector.statistics.output.NodeConnectorStatistics toOdNodeConnectorStatistics(
- NodeConnectorStatistics ndConStats) {
- NodeConnectorStatisticsBuilder builder = new NodeConnectorStatisticsBuilder();
-
- builder.setBytes(extractBytes(ndConStats));
- builder.setCollisionCount(toBI(ndConStats.getCollisionCount()));
- builder.setDuration(null);
- builder.setPackets(extractPackets(ndConStats));
- builder.setReceiveCrcError(toBI(ndConStats.getReceiveCRCErrorCount()));
- builder.setReceiveDrops(toBI(ndConStats.getReceiveDropCount()));
- builder.setReceiveErrors(toBI(ndConStats.getReceiveErrorCount()));
- builder.setReceiveFrameError(toBI(ndConStats.getReceiveFrameErrorCount()));
- builder.setReceiveOverRunError(toBI(ndConStats.getReceiveOverRunErrorCount()));
- builder.setTransmitDrops(toBI(ndConStats.getTransmitDropCount()));
- builder.setTransmitErrors(toBI(ndConStats.getTransmitErrorCount()));
-
- return builder.build();
+ private List<NodeConnectorStatisticsAndPortNumberMap> toOdNodeConnectorStatistics(
+ List<NodeConnectorStatistics> ncStatsList) {
+ List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatisticsList = new ArrayList<NodeConnectorStatisticsAndPortNumberMap>();
+ for(NodeConnectorStatistics ofNodeConnectorStatistics : ncStatsList){
+ NodeConnectorStatisticsAndPortNumberMapBuilder nodeConnectorStatisticsAndPortNumberMapBuilder = new NodeConnectorStatisticsAndPortNumberMapBuilder();
+
+ nodeConnectorStatisticsAndPortNumberMapBuilder.setBytes(extractBytes(ofNodeConnectorStatistics));
+ nodeConnectorStatisticsAndPortNumberMapBuilder.setCollisionCount(toBI(ofNodeConnectorStatistics.getCollisionCount()));
+ nodeConnectorStatisticsAndPortNumberMapBuilder.setDuration(null);
+ nodeConnectorStatisticsAndPortNumberMapBuilder.setPackets(extractPackets(ofNodeConnectorStatistics));
+ nodeConnectorStatisticsAndPortNumberMapBuilder.setReceiveCrcError(toBI(ofNodeConnectorStatistics.getReceiveCRCErrorCount()));
+ nodeConnectorStatisticsAndPortNumberMapBuilder.setReceiveDrops(toBI(ofNodeConnectorStatistics.getReceiveDropCount()));
+ nodeConnectorStatisticsAndPortNumberMapBuilder.setReceiveErrors(toBI(ofNodeConnectorStatistics.getReceiveErrorCount()));
+ nodeConnectorStatisticsAndPortNumberMapBuilder.setReceiveFrameError(toBI(ofNodeConnectorStatistics.getReceiveFrameErrorCount()));
+ nodeConnectorStatisticsAndPortNumberMapBuilder.setReceiveOverRunError(toBI(ofNodeConnectorStatistics.getReceiveOverRunErrorCount()));
+ nodeConnectorStatisticsAndPortNumberMapBuilder.setTransmitDrops(toBI(ofNodeConnectorStatistics.getTransmitDropCount()));
+ nodeConnectorStatisticsAndPortNumberMapBuilder.setTransmitErrors(toBI(ofNodeConnectorStatistics.getTransmitErrorCount()));
+ nodeConnectorStatisticsList.add(nodeConnectorStatisticsAndPortNumberMapBuilder.build());
+ }
+
+ return nodeConnectorStatisticsList;
}
private BigInteger toBI(long num) {
return builder.build();
}
- private GetFlowTableStatisticsOutput toOdTableStatistics(NodeTableStatistics nodeTable) {
- GetFlowTableStatisticsOutputBuilder builder = new GetFlowTableStatisticsOutputBuilder();
-
- builder.setActive(toCounter64(nodeTable.getActiveCount()));
- builder.setLookup(toCounter64(nodeTable.getLookupCount()));
- builder.setMatched(toCounter64(nodeTable.getMatchedCount()));
-
- return builder.build();
- }
-
- @Override
- public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
- GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
- GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
- GetAllFlowStatisticsFromFlowTableInput input) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
- GetAllFlowsStatisticsFromAllFlowTablesInput input) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
- GetFlowStatisticsFromFlowTableInput input) {
- // TODO Auto-generated method stub
- return null;
- }
-
}
}
}
- // RPC calls to fetch flow statistics
+ // RPC calls to fetch aggregate flow statistics
rpc get-aggregate-flow-statistics-from-flow-table-for-all-flows {
description "Fetch aggregate statistics for all the flows present in the specific flow table of the switch";
input {
uses stat-types:aggregate-flow-statistics;
uses tr:transaction-aware;
}
-
- //Keeping flow statistics RPC call for backward compatibility for sal-compatibility layer --START
- rpc get-flow-statistics {
- input {
- uses inv:node-context-ref;
- uses flow-types:flow;
- }
- output {
- uses flow-types:flow-statistics;
- }
- }
-
- rpc get-all-flow-statistics {
- input {
- uses inv:node-context-ref;
- }
- output {
- list flow-statistics {
- uses flow-types:flow-statistics;
- }
- }
- }
-
- notification flow-statistics-updated {
- uses flow-types:flow-statistics;
- }
-
- //Keeping flow statistics RPC call for backward compatibility for sal-compatibility layer --END
-
- //RPC call to fetch node connector statistics
- rpc get-node-connector-statistics {
- input {
- uses inv:node-context-ref;
- leaf node-connector {
- type inv:node-connector-ref;
- }
- }
- output {
- uses stat-types:node-connector-statistics;
- }
- }
-
- rpc get-all-node-connector-statistics {
- input {
- uses inv:node-context-ref;
- }
- output {
- list node-connector-statistics {
- uses stat-types:node-connector-statistics;
- }
- }
- }
-
- rpc get-flow-table-statistics {
- input {
- uses inv:node-context-ref;
- }
- output {
- uses flow-types:flow-table-statistics;
- }
- }
-
- notification flow-table-statistics-updated {
- leaf flow-table {
- type flow:flow-table-ref;
- }
- uses flow-types:flow-table-statistics;
- }
-
- notification node-connector-statistics-updated {
- uses stat-types:node-connector-statistics;
- }
}
}
// RPC calls
- rpc get-all-ports-statistics {
- description "Get statistics for all the ports from the node";
+ rpc get-all-node-connectors-statistics {
+ description "Get statistics for all node connectors from the node";
input {
uses inv:node-context-ref;
}
output {
- uses stat-types:node-connector-statistics;
+ uses node-connector-statistics-and-port-number-map;
uses tr:transaction-aware;
}
}
- rpc get-port-statistics {
- description "Get statistics for given port from the node";
+ rpc get-node-connector-statistics {
+ description "Get statistics for given node connector from the node";
input {
uses inv:node-context-ref;
leaf node-connector-id {
}
}
- //Notification for port statistics update
+ //Notification for node connector statistics update
grouping node-connector-statistics-and-port-number-map {
- description "List of flow and statistics map";
+ description "List of map - node connectors and their statistics";
list node-connector-statistics-and-port-number-map {
key "node-connector-id";
leaf node-connector-id {
}
}
- notification port-statistics-update {
+ notification node-connector-statistics-update {
leaf moreReplies {
type boolean;
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-/*
- * TODO: Handle multipart messages with following flag true
- * OFPMPF_REPLY_MORE = 1 << 0
- * Better accumulate all the messages and update local cache
- * and configurational data store
- */
+
package org.opendaylight.controller.md.statistics.manager;
import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllPortsStatisticsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllPortsStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
InstanceIdentifier<Node> targetInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class,targetNode.getKey()).toInstance();
NodeRef targetNodeRef = new NodeRef(targetInstanceId);
- System.out.println("ANIL: Target Node object ::"+targetNode.toString());
-
- System.out.println("ANIL: FlowCapableNode augmentations ::"+targetNode.getAugmentation(FlowCapableNode.class));
-
try {
sendAggregateFlowsStatsFromAllTablesRequest(targetNode.getKey());
sendAllFlowsStatsFromAllTablesRequest(targetNodeRef);
- sendAllPortStatisticsRequest(targetNodeRef);
+ sendAllNodeConnectorsStatisticsRequest(targetNodeRef);
sendAllFlowTablesStatisticsRequest(targetNodeRef);
try{
sendAllGroupStatisticsRequest(targetNodeRef);
- Thread.sleep(1000);
sendAllMeterStatisticsRequest(targetNodeRef);
- Thread.sleep(1000);
sendGroupDescriptionRequest(targetNodeRef);
- Thread.sleep(1000);
sendMeterConfigStatisticsRequest(targetNodeRef);
- Thread.sleep(1000);
}catch(Exception e){
spLogger.error("Exception occured while sending statistics requests : {}", e);
}
}
- private void sendAllPortStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
+ private void sendAllNodeConnectorsStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
- final GetAllPortsStatisticsInputBuilder input = new GetAllPortsStatisticsInputBuilder();
+ final GetAllNodeConnectorsStatisticsInputBuilder input = new GetAllNodeConnectorsStatisticsInputBuilder();
input.setNode(targetNode);
- Future<RpcResult<GetAllPortsStatisticsOutput>> response =
- portStatsService.getAllPortsStatistics(input.build());
+ Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> response =
+ portStatsService.getAllNodeConnectorsStatistics(input.build());
this.multipartMessageManager.addTxIdToRequestTypeEntry(response.get().getResult().getTransactionId()
, StatsRequestType.ALL_PORT);
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsDataBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowTableStatisticsUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.NodeConnectorStatisticsUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.aggregate.flow.statistics.AggregateFlowStatisticsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.GenericStatistics;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.PortStatisticsUpdate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatisticsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
}
@Override
- public void onPortStatisticsUpdate(PortStatisticsUpdate notification) {
+ public void onNodeConnectorStatisticsUpdate(NodeConnectorStatisticsUpdate notification) {
//Check if response is for the request statistics-manager sent.
if(this.statisticsManager.getMultipartMessageManager().removeTxId(notification.getTransactionId()) == null)
return;
}
- @Override
- public void onFlowStatisticsUpdated(FlowStatisticsUpdated notification) {
- // TODO Auto-generated method stub
- //TODO: Depricated, will clean it up once sal-compatibility is fixed.
- //Sal-Compatibility code usage this notification event.
-
- }
-
- @Override
- public void onFlowTableStatisticsUpdated(FlowTableStatisticsUpdated notification) {
- // TODO Auto-generated method stub
- //TODO: Need to implement it yet
-
- }
-
- @Override
- public void onNodeConnectorStatisticsUpdated(NodeConnectorStatisticsUpdated notification) {
- // TODO Auto-generated method stub
- //TODO: Need to implement it yet
-
- }
-
private NodeRef getNodeRef(NodeKey nodeKey){
InstanceIdentifierBuilder<?> builder = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey);
return new NodeRef(builder.toInstance());