-/**
- * Copyright IBM Corporation, 2013. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
package org.opendaylight.openflowplugin.test;
import java.util.Iterator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
+ private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginStatsTestCommandProvider.class);
private DataProviderService dataProviderService;
private final BundleContext ctx;
public void onSessionInitiated(ProviderContext session) {
dataProviderService = session.getSALService(DataProviderService.class);
ctx.registerService(CommandProvider.class.getName(), this, null);
-
+
}
public void _portStats(CommandInterpreter ci) {
if(nodeConnectorCount == nodeConnectorStatsCount)
{
- ci.println("portStats - Success");
+ LOG.debug("portStats - Success");
}
else
{
- ci.println("portStats - Failed");
- ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ LOG.debug("portStats - Failed");
+ LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}
if(nodeConnectorCount == nodeConnectorDescStatsCount)
{
- ci.println("portDescStats - Success");
+ LOG.debug("portDescStats - Success");
}
else
{
- ci.println("portDescStats - Failed");
- ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ LOG.debug("portDescStats - Failed");
+ LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}
if(null != data)
{
flowStatsCount++;
+ LOG.debug("--------------------------------------------");
+ ci.print(data);
}
}
}
if(flowCount == flowStatsCount)
{
- ci.println("flowStats - Success");
+ LOG.debug("flowStats - Success");
}
else
{
- ci.println("flowStats - Failed");
- ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ LOG.debug("flowStats - Failed");
+ LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}
+
public void _tableStats(CommandInterpreter ci) {
int tableCount = 0;
if(tableCount == tableStatsCount)
{
- ci.println("tableStats - Success");
+ LOG.debug("tableStats - Success");
}
else
{
- ci.println("tableStats - Failed");
- ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ LOG.debug("tableStats - Failed");
+ LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}
public void _groupStats(CommandInterpreter ci) {
int groupCount = 0;
int groupStatsCount = 0;
+ NodeGroupStatistics data = null;
List<Node> nodes = getNodes();
for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext();) {
NodeKey nodeKey = iterator.next().getKey();
GroupKey groupKey = iterator2.next().getKey();
InstanceIdentifier<Group> groupRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey).toInstance();
Group group = (Group)dataProviderService.readOperationalData(groupRef);
- NodeGroupStatistics data = group.getAugmentation(NodeGroupStatistics.class);
+ data = group.getAugmentation(NodeGroupStatistics.class);
if(null != data)
{
groupStatsCount++;
if(groupCount == groupStatsCount)
{
- ci.println("---------------------groupStats - Success-------------------------------");
+ LOG.debug("---------------------groupStats - Success-------------------------------");
+ }
+ else
+ {
+ LOG.debug("------------------------------groupStats - Failed--------------------------");
+ LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ }
+ }
+
+ public void _groupDescStats(CommandInterpreter ci) {
+ int groupCount = 0;
+ int groupDescStatsCount = 0;
+ NodeGroupDescStats data = null;
+ List<Node> nodes = getNodes();
+ for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext();) {
+ NodeKey nodeKey = iterator.next().getKey();
+ InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).toInstance();
+ FlowCapableNode node = (FlowCapableNode)dataProviderService.readOperationalData(nodeRef);
+
+ List<Group> groups = node.getGroup();
+ for (Iterator<Group> iterator2 = groups.iterator(); iterator2.hasNext();) {
+ groupCount++;
+ GroupKey groupKey = iterator2.next().getKey();
+ InstanceIdentifier<Group> groupRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey).toInstance();
+ Group group = (Group)dataProviderService.readOperationalData(groupRef);
+ data = group.getAugmentation(NodeGroupDescStats.class);
+ if(null != data)
+ {
+ groupDescStatsCount++;
+ }
+ }
+ }
+
+ if(groupCount == groupDescStatsCount)
+ {
+ LOG.debug("---------------------groupDescStats - Success-------------------------------");
}
else
{
- ci.println("------------------------------groupStats - Failed--------------------------");
- ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ LOG.debug("------------------------------groupDescStats - Failed--------------------------");
+ LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}
public void _meterStats(CommandInterpreter ci) {
int meterCount = 0;
int meterStatsCount = 0;
+ NodeMeterStatistics data = null;
List<Node> nodes = getNodes();
for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext();) {
NodeKey nodeKey = iterator.next().getKey();
MeterKey meterKey = iterator2.next().getKey();
InstanceIdentifier<Meter> meterRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Meter.class, meterKey).toInstance();
Meter meter = (Meter)dataProviderService.readOperationalData(meterRef);
- NodeMeterStatistics data = meter.getAugmentation(NodeMeterStatistics.class);
+ data = meter.getAugmentation(NodeMeterStatistics.class);
if(null != data)
{
meterStatsCount++;
if(meterCount == meterStatsCount)
{
- ci.println("---------------------------meterStats - Success-------------------------------------");
+ LOG.debug("---------------------------meterStats - Success-------------------------------------");
}
else
{
- ci.println("----------------------------meterStats - Failed-------------------------------------");
- ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ LOG.debug("----------------------------meterStats - Failed-------------------------------------");
+ LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}
-
+
+ public void _meterConfigStats(CommandInterpreter ci) {
+ int meterCount = 0;
+ int meterConfigStatsCount = 0;
+ NodeMeterConfigStats data = null;
+ List<Node> nodes = getNodes();
+ for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext();) {
+ NodeKey nodeKey = iterator.next().getKey();
+ InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).toInstance();
+ FlowCapableNode node = (FlowCapableNode)dataProviderService.readOperationalData(nodeRef);
+
+ List<Meter> meters = node.getMeter();
+ for (Iterator<Meter> iterator2 = meters.iterator(); iterator2.hasNext();) {
+ meterCount++;
+ MeterKey meterKey = iterator2.next().getKey();
+ InstanceIdentifier<Meter> meterRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Meter.class, meterKey).toInstance();
+ Meter meter = (Meter)dataProviderService.readOperationalData(meterRef);
+ data = meter.getAugmentation(NodeMeterConfigStats.class);
+ if(null != data)
+ {
+ meterConfigStatsCount++;
+ }
+ }
+ }
+
+ if(meterCount == meterConfigStatsCount)
+ {
+ LOG.debug("---------------------------meterConfigStats - Success-------------------------------------");
+ ci.print(data);
+ }
+ else
+ {
+ LOG.debug("----------------------------meterConfigStats - Failed-------------------------------------");
+ LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ }
+ }
+
public void _aggregateStats(CommandInterpreter ci) {
int aggregateFlowCount = 0;
if(aggregateFlowCount == aggerateFlowStatsCount)
{
- ci.println("aggregateStats - Success");
+ LOG.debug("aggregateStats - Success");
}
else
{
- ci.println("aggregateStats - Failed");
- ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ LOG.debug("aggregateStats - Failed");
+ LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}
if(descCount == descStatsCount)
{
- ci.println("descStats - Success");
+ LOG.debug("descStats - Success");
}
else
{
- ci.println("descStats - Failed");
- ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ LOG.debug("descStats - Failed");
+ LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}