import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalPortService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
OpendaylightGroupStatisticsService, //
OpendaylightMeterStatisticsService, //
OpendaylightFlowStatisticsService, //
+ OpendaylightPortStatisticsService, //
+ OpendaylightFlowTableStatisticsService, //
Identifiable<InstanceIdentifier<Node>> {
CompositeObjectRegistration<ModelDrivenSwitch> register(ProviderContext ctx);
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
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.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.PortStatisticsUpdate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.TableUpdated;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.slf4j.Logger;
addMessagePopListener(SwitchFlowRemoved.class, notificationPopListener);
addMessagePopListener(TableUpdated.class, notificationPopListener);
+
//Notification registration for flow statistics
addMessagePopListener(FlowsStatisticsUpdate.class, notificationPopListener);
addMessagePopListener(AggregateFlowStatisticsUpdate.class, notificationPopListener);
+
//Notification registrations for group-statistics
addMessagePopListener(GroupStatisticsUpdated.class, notificationPopListener);
addMessagePopListener(GroupFeaturesUpdated.class, notificationPopListener);
addMessagePopListener(MeterConfigStatsUpdated.class, notificationPopListener);
addMessagePopListener(MeterFeaturesUpdated.class, notificationPopListener);
-
+ //Notification registration for port-statistics
+ addMessagePopListener(PortStatisticsUpdate.class, notificationPopListener);
+
+ //Notification registration for flow-table statistics
+ addMessagePopListener(FlowTableStatisticsUpdate.class, notificationPopListener);
+
// Push the updated Listeners to Session Manager which will be then picked up by ConnectionConductor eventually
OFSessionUtil.getSessionManager().setTranslatorMapping(messageTranslators);
OFSessionUtil.getSessionManager().setPopListenerMapping(popListeners);
import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
private RoutedRpcRegistration<OpendaylightMeterStatisticsService> meterStatisticsRegistration;
+ private RoutedRpcRegistration<OpendaylightPortStatisticsService> portStatisticsRegistration;
+
+ private RoutedRpcRegistration<OpendaylightFlowTableStatisticsService> flowTableStatisticsRegistration;
+
protected final SessionContext sessionContext;
protected AbstractModelDrivenSwitch(InstanceIdentifier<Node> identifier,SessionContext conductor) {
meterStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
builder.add(meterStatisticsRegistration);
+ portStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightPortStatisticsService.class, this);
+ portStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
+ builder.add(portStatisticsRegistration);
+
+ flowTableStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowTableStatisticsService.class, this);
+ flowTableStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
+ builder.add(flowTableStatisticsRegistration);
+
return builder.toInstance();
}
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
import org.opendaylight.openflowplugin.openflow.md.core.session.IMessageDispatchService;
import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder;
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.group.service.rev130918.AddGroupOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures;
//import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features.TableFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllPortsStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllPortsStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllPortsStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetPortStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetPortStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetPortStatisticsOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
RpcResult<GetMeterStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
return Futures.immediateFuture(rpcResult);
}
+
+ @Override
+ public Future<RpcResult<GetAllPortsStatisticsOutput>> getAllPortsStatistics(GetAllPortsStatisticsInput arg0) {
+
+ //Generate xid to associate it with the request
+ Long xid = this.getSessionContext().getNextXid();
+
+ LOG.info("Prepare port statistics request for all ports of node {} - TrasactionId - {}",arg0.getNode().getValue(),xid);
+
+ // Create multipart request header
+ MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
+ mprInput.setType(MultipartType.OFPMPPORTSTATS);
+ mprInput.setVersion(version);
+ mprInput.setXid(xid);
+ mprInput.setFlags(new MultipartRequestFlags(false));
+
+ // Create multipart request body to fetch stats for all the port of the node
+ MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder();
+ MultipartRequestPortStatsBuilder mprPortStatsBuilder = new MultipartRequestPortStatsBuilder();
+ //Select all ports
+ //TODO :need to change once i rebase on latest code.
+ mprPortStatsBuilder.setPortNo(OpenflowEnumConstant.OFPP_ANY);
+ caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
+
+ //Set request body to main multipart request
+ mprInput.setMultipartRequestBody(caseBuilder.build());
+
+ //Send the request, no cookies associated, use any connection
+ LOG.debug("Send port statistics request :{}",mprPortStatsBuilder.build().toString());
+ this.messageService.multipartRequest(mprInput.build(), null);
+
+ // Prepare rpc return output. Set xid and send it back.
+ GetAllPortsStatisticsOutputBuilder output = new GetAllPortsStatisticsOutputBuilder();
+ output.setTransactionId(generateTransactionId(xid));
+
+ Collection<RpcError> errors = Collections.emptyList();
+ RpcResult<GetAllPortsStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ @Override
+ public Future<RpcResult<GetPortStatisticsOutput>> getPortStatistics(GetPortStatisticsInput arg0) {
+ //Generate xid to associate it with the request
+ Long xid = this.getSessionContext().getNextXid();
+
+ LOG.info("Prepare port statistics request for port {} of node {} - TrasactionId - {}",arg0.getNodeConnectorId(), arg0.getNode().getValue(),xid);
+
+ // Create multipart request header
+ MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
+ mprInput.setType(MultipartType.OFPMPPORTSTATS);
+ mprInput.setVersion(version);
+ mprInput.setXid(xid);
+ mprInput.setFlags(new MultipartRequestFlags(false));
+
+ // Create multipart request body to fetch stats for all the port of the node
+ MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder();
+ MultipartRequestPortStatsBuilder mprPortStatsBuilder = new MultipartRequestPortStatsBuilder();
+
+ //Set specific port
+ mprPortStatsBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(arg0.getNodeConnectorId()));
+ caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
+
+ //Set request body to main multipart request
+ mprInput.setMultipartRequestBody(caseBuilder.build());
+
+ //Send the request, no cookies associated, use any connection
+ LOG.debug("Send port statistics request :{}",mprPortStatsBuilder.build().toString());
+ this.messageService.multipartRequest(mprInput.build(), null);
+
+ // Prepare rpc return output. Set xid and send it back.
+ GetPortStatisticsOutputBuilder output = new GetPortStatisticsOutputBuilder();
+ output.setTransactionId(generateTransactionId(xid));
+
+ Collection<RpcError> errors = Collections.emptyList();
+ RpcResult<GetPortStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
+ return Futures.immediateFuture(rpcResult);
+ }
private TransactionId generateTransactionId(Long xid){
String stringXid =xid.toString();
Collection<RpcError> errors = Collections.emptyList();
RpcResult<UpdateTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
return Futures.immediateFuture(rpcResult);
-
}
@Override
//Generate xid to associate it with the request
Long xid = this.getSessionContext().getNextXid();
- LOG.debug("Prepare statistics request to get stats for flow {} for switch tables {} - Transaction id - {}"
+ LOG.info("Prepare statistics request to get stats for flow {} for switch tables {} - Transaction id - {}"
,arg0.getMatch().toString(),arg0.getTableId(),xid);
// Create multipart request header
//Generate xid to associate it with the request
Long xid = this.getSessionContext().getNextXid();
- LOG.debug("Prepare aggregate flow statistics request to get aggregate flow stats for all the flow installed on switch table {} - Transaction id - {}"
+ LOG.info("Prepare aggregate flow statistics request to get aggregate flow stats for all the flow installed on switch table {} - Transaction id - {}"
,arg0.getTableId().getValue(),xid);
// Create multipart request header
mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
//Send the request, no cookies associated, use any connection
- LOG.debug("Send request for to the switch :{}",multipartRequestAggregateCaseBuilder.build().toString());
+ LOG.debug("Send request to the switch :{}",multipartRequestAggregateCaseBuilder.build().toString());
this.messageService.multipartRequest(mprInput.build(), null);
// Prepare rpc return output. Set xid and send it back.
return Futures.immediateFuture(rpcResult);
}
+ @Override
+ public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(GetFlowTablesStatisticsInput arg0) {
+ //Generate xid to associate it with the request
+ Long xid = this.getSessionContext().getNextXid();
+
+ LOG.info("Prepare flow table statistics request to get flow table stats for all tables " +
+ "from node {}- Transaction id - {}",arg0.getNode(),xid);
+
+ // Create multipart request header
+ MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
+ mprInput.setType(MultipartType.OFPMPTABLE);
+ mprInput.setVersion(version);
+ mprInput.setXid(xid);
+ mprInput.setFlags(new MultipartRequestFlags(false));
+
+ // Create multipart request body for fetch all the group stats
+ MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder ();
+ MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
+ multipartRequestTableBuilder.setEmpty(true);
+ multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
+
+ //Set request body to main multipart request
+ mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
+
+ //Send the request, no cookies associated, use any connection
+ LOG.debug("Send request to the switch :{}",multipartRequestTableCaseBuilder.build().toString());
+ this.messageService.multipartRequest(mprInput.build(), null);
+
+ // Prepare rpc return output. Set xid and send it back.
+ GetFlowTablesStatisticsOutputBuilder output = new GetFlowTablesStatisticsOutputBuilder();
+ output.setTransactionId(generateTransactionId(xid));
+
+ Collection<RpcError> errors = Collections.emptyList();
+ RpcResult<GetFlowTablesStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
+ return Futures.immediateFuture(rpcResult);
+ }
+
@Override
public Future<RpcResult<GetAllFlowStatisticsOutput>> getAllFlowStatistics(GetAllFlowStatisticsInput arg0) {
//TODO: Depricated, need to clean it up. Sal-Compatibility layes is dependent on it.
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupStatsResponseConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterStatsResponseConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
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.AggregateFlowStatisticsUpdateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder;
+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.group.statistics.rev131111.GroupDescStatsUpdatedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdatedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterKbps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterPktps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterStats;
+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.DurationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.PacketsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.PortStatisticsUpdateBuilder;
+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.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
logger.info("Converted aggregate flow statistics : {}",message.build().toString());
listDataObject.add(message.build());
return listDataObject;
+ }
+ case OFPMPPORTSTATS: {
+
+ logger.info("Received port statistics multipart response");
+
+ PortStatisticsUpdateBuilder message = new PortStatisticsUpdateBuilder();
+ message.setId(node);
+ message.setMoreReplies(mpReply.getFlags().isOFPMPFREQMORE());
+ message.setTransactionId(generateTransactionId(mpReply.getXid()));
+
+ MultipartReplyPortStatsCase caseBody = (MultipartReplyPortStatsCase)mpReply.getMultipartReplyBody();
+ MultipartReplyPortStats replyBody = caseBody.getMultipartReplyPortStats();
+ List<NodeConnectorStatisticsAndPortNumberMap> statsMap =
+ new ArrayList<NodeConnectorStatisticsAndPortNumberMap>();
+ for (PortStats portStats: replyBody.getPortStats()){
+
+ NodeConnectorStatisticsAndPortNumberMapBuilder statsBuilder =
+ new NodeConnectorStatisticsAndPortNumberMapBuilder();
+ statsBuilder.setNodeConnectorId(
+ InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(sc.getFeatures().getDatapathId(),
+ portStats.getPortNo()));
+
+ BytesBuilder bytesBuilder = new BytesBuilder();
+ bytesBuilder.setReceived(portStats.getRxBytes());
+ bytesBuilder.setTransmitted(portStats.getTxBytes());
+ statsBuilder.setBytes(bytesBuilder.build());
+
+ PacketsBuilder packetsBuilder = new PacketsBuilder();
+ packetsBuilder.setReceived(portStats.getRxPackets());
+ packetsBuilder.setTransmitted(portStats.getTxPackets());
+ statsBuilder.setPackets(packetsBuilder.build());
+
+ DurationBuilder durationBuilder = new DurationBuilder();
+ durationBuilder.setSecond(new Counter32(portStats.getDurationSec()));
+ durationBuilder.setNanosecond(new Counter32(portStats.getDurationNsec()));
+ statsBuilder.setDuration(durationBuilder.build());
+
+ statsBuilder.setCollisionCount(portStats.getCollisions());
+ statsBuilder.setKey(new NodeConnectorStatisticsAndPortNumberMapKey(statsBuilder.getNodeConnectorId()));
+ statsBuilder.setReceiveCrcError(portStats.getRxCrcErr());
+ statsBuilder.setReceiveDrops(portStats.getRxDropped());
+ statsBuilder.setReceiveErrors(portStats.getRxErrors());
+ statsBuilder.setReceiveFrameError(portStats.getRxFrameErr());
+ statsBuilder.setReceiveOverRunError(portStats.getRxOverErr());
+ statsBuilder.setTransmitDrops(portStats.getTxDropped());
+ statsBuilder.setTransmitErrors(portStats.getTxErrors());
+ statsMap.add(statsBuilder.build());
+ }
+ message.setNodeConnectorStatisticsAndPortNumberMap(statsMap);
+
+ logger.debug("Converted ports statistics : {}",message.build().toString());
+
+ listDataObject.add(message.build());
+ return listDataObject;
}
case OFPMPGROUP:{
logger.info("Received group statistics multipart reponse");
//Send update notification to all the listeners
return listDataObject;
}
+ case OFPMPTABLE: {
+ logger.info("Received flow table statistics reponse from openflow {} switch",msg.getVersion()==1?"1.0":"1.3+");
+
+ FlowTableStatisticsUpdateBuilder message = new FlowTableStatisticsUpdateBuilder();
+ message.setId(node);
+ message.setMoreReplies(mpReply.getFlags().isOFPMPFREQMORE());
+ message.setTransactionId(generateTransactionId(mpReply.getXid()));
+
+ MultipartReplyTableCase caseBody = (MultipartReplyTableCase)mpReply.getMultipartReplyBody();
+ MultipartReplyTable replyBody = caseBody.getMultipartReplyTable();
+ List<TableStats> swTablesStats = replyBody.getTableStats();
+
+ List<FlowTableAndStatisticsMap> salFlowStats = new ArrayList<FlowTableAndStatisticsMap>();
+ for(TableStats swTableStats : swTablesStats){
+ FlowTableAndStatisticsMapBuilder statisticsBuilder = new FlowTableAndStatisticsMapBuilder();
+
+ statisticsBuilder.setActiveFlows(new Counter32(swTableStats.getActiveCount()));
+ statisticsBuilder.setPacketsLookedUp(new Counter64(swTableStats.getLookupCount()));
+ statisticsBuilder.setPacketsMatched(new Counter64(swTableStats.getMatchedCount()));
+ statisticsBuilder.setTableId(new TableId(swTableStats.getTableId()));
+ salFlowStats.add(statisticsBuilder.build());
+ }
+
+ message.setFlowTableAndStatisticsMap(salFlowStats);
+
+ logger.info("Converted flow table statistics : {}",message.build().toString());
+ listDataObject.add(message.build());
+ return listDataObject;
+ }
+
default:
return listDataObject;
}
public static NodeConnectorId nodeConnectorIdfromDatapathPortNo(BigInteger datapathid, Long portNo) {
return new NodeConnectorId(OF_URI_PREFIX + datapathid + ":" + portNo);
}
+
+ public static Long portNumberfromNodeConnectorId(NodeConnectorId ncId) {
+ String[] split = ncId.getValue().split(":");
+ return Long.getLong(split[split.length-1]);
+ }
+
public static NodeConnectorRef nodeConnectorRefFromDatapathIdPortno(BigInteger datapathId, Long portNo) {
return new NodeConnectorRef(nodeConnectorInstanceIdentifierFromDatapathIdPortno(datapathId, portNo));