Search in sources :

Example 86 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class SalRoleServiceImplTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    Mockito.when(mockDeviceInfo.getNodeId()).thenReturn(testNodeId);
    Mockito.when(mockDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
    short testVersion = 4;
    Mockito.when(mockFeaturesOutput.getVersion()).thenReturn(testVersion);
    Mockito.when(mockDeviceContext.getDeviceState()).thenReturn(mockDeviceState);
    Mockito.when(mockDeviceContext.getDeviceInfo()).thenReturn(mockDeviceInfo);
    Mockito.when(mockDeviceContext.getPrimaryConnectionContext()).thenReturn(mockConnectionContext);
    Mockito.when(mockConnectionContext.getFeatures()).thenReturn(mockFeaturesReply);
    Mockito.when(mockConnectionContext.getNodeId()).thenReturn(testNodeId);
    Mockito.when(mockFeaturesReply.getVersion()).thenReturn(testVersion);
    Mockito.when(mockDeviceContext.getMessageSpy()).thenReturn(mockMessageSpy);
    Mockito.when(mockRequestContextStack.<RoleRequestOutput>createRequestContext()).thenReturn(mockRequestContext);
    Mockito.when(mockRequestContext.getXid()).thenReturn(new Xid(testXid));
    Mockito.when(mockConnectionContext.getOutboundQueueProvider()).thenReturn(mockOutboundQueue);
    Mockito.when(mockDeviceContext.getPrimaryConnectionContext().getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
    NodeKey key = new NodeKey(testNodeId);
    InstanceIdentifier<Node> path = InstanceIdentifier.<Nodes>builder(Nodes.class).<Node, NodeKey>child(Node.class, key).build();
    nodeRef = new NodeRef(path);
}
Also used : RoleRequestOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Before(org.junit.Before)

Example 87 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class StatisticsManagerImplTest method initialization.

@Before
public void initialization() {
    final KeyedInstanceIdentifier<Node, NodeKey> nodePath = KeyedInstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:10")));
    when(mockedPrimConnectionContext.getFeatures()).thenReturn(mockedFeatures);
    when(mockedPrimConnectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);
    when(mockedPrimConnectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
    when(mockedPrimConnectionContext.getNodeId()).thenReturn(NODE_ID);
    when(mockedPrimConnectionContext.getOutboundQueueProvider()).thenReturn(outboundQueue);
    when(mockedDeviceState.isFlowStatisticsAvailable()).thenReturn(Boolean.TRUE);
    when(mockedDeviceState.isGroupAvailable()).thenReturn(Boolean.TRUE);
    when(mockedDeviceState.isMetersAvailable()).thenReturn(Boolean.TRUE);
    when(mockedDeviceState.isPortStatisticsAvailable()).thenReturn(Boolean.TRUE);
    when(mockedDeviceState.isQueueStatisticsAvailable()).thenReturn(Boolean.TRUE);
    when(mockedDeviceState.isTableStatisticsAvailable()).thenReturn(Boolean.TRUE);
    when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
    when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
    when(mockedDeviceInfo.getNodeId()).thenReturn(NODE_ID);
    when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
    when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimConnectionContext);
    when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessagSpy);
    when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl(OFConstants.OFP_VERSION_1_3, dataBroker, nodePath));
    when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
    when(mockedDeviceContext.getMultiMsgCollector(Matchers.<RequestContext<List<MultipartReply>>>any())).thenAnswer(invocation -> {
        currentRequestContext = (RequestContext<List<MultipartReply>>) invocation.getArguments()[0];
        return multiMagCollector;
    });
    when(rpcProviderRegistry.addRpcImplementation(Matchers.eq(StatisticsManagerControlService.class), Matchers.<StatisticsManagerControlService>any())).thenReturn(serviceControlRegistration);
    final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
    final long basicTimerDelay = 3000L;
    final long maximumTimerDelay = 900000L;
    statisticsManager = new StatisticsManagerImpl(new OpenflowProviderConfigBuilder().setBasicTimerDelay(new NonZeroUint32Type(basicTimerDelay)).setMaximumTimerDelay(new NonZeroUint32Type(maximumTimerDelay)).setIsStatisticsPollingOn(false).build(), rpcProviderRegistry, convertorManager, MoreExecutors.newDirectExecutorService());
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) StatisticsManagerControlService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsManagerControlService) OpenflowProviderConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NonZeroUint32Type(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type) List(java.util.List) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) DeviceFlowRegistryImpl(org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl) ConvertorManager(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager) Before(org.junit.Before)

Example 88 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class PacketInDispatcherImpl method onPacketReceived.

@Override
public void onPacketReceived(PacketReceived notification) {
    // find corresponding handler
    /*
         * Notification contains reference to ingress port
         * in a form of path in inventory: /nodes/node/node-connector
         *
         * In order to get path we shorten path to the first node reference
         * by using firstIdentifierOf helper method provided by InstanceIdentifier,
         * this will effectively shorten the path to /nodes/node.
         */
    InstanceIdentifier<?> ingressPort = notification.getIngress().getValue();
    InstanceIdentifier<Node> nodeOfPacket = ingressPort.firstIdentifierOf(Node.class);
    /**
     * We lookup up the the packet-in listener for this node.
     */
    PacketProcessingListener nodeHandler = handlerMapping.get(nodeOfPacket);
    /**
     * If we have packet-processing listener, we delegate notification.
     */
    if (nodeHandler != null) {
        nodeHandler.onPacketReceived(notification);
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) PacketProcessingListener(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener)

Example 89 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class OpenflowpluginStatsTestCommandProvider method _tableStats.

public void _tableStats(CommandInterpreter ci) {
    int tableCount = 0;
    int tableStatsCount = 0;
    List<Node> nodes = getNodes();
    for (Node node2 : nodes) {
        NodeKey nodeKey = node2.getKey();
        InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
        ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
        FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
        if (node != null) {
            List<Table> tables = node.getTable();
            for (Table table2 : tables) {
                tableCount++;
                TableKey tableKey = table2.getKey();
                InstanceIdentifier<Table> tableRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
                Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef);
                if (table != null) {
                    FlowTableStatisticsData data = table.getAugmentation(FlowTableStatisticsData.class);
                    if (null != data) {
                        tableStatsCount++;
                    }
                }
            }
        }
    }
    if (tableCount == tableStatsCount) {
        LOG.debug("tableStats - Success");
    } else {
        LOG.debug("tableStats - Failed");
        LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
    }
}
Also used : Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowTableStatisticsData(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 90 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class OpenflowpluginStatsTestCommandProvider method _aggregateStats.

public void _aggregateStats(CommandInterpreter ci) {
    int aggregateFlowCount = 0;
    int aggerateFlowStatsCount = 0;
    List<Node> nodes = getNodes();
    for (Node node2 : nodes) {
        NodeKey nodeKey = node2.getKey();
        InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
        ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
        FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
        if (node != null) {
            List<Table> tables = node.getTable();
            for (Table table2 : tables) {
                aggregateFlowCount++;
                TableKey tableKey = table2.getKey();
                InstanceIdentifier<Table> tableRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
                Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef);
                if (table != null) {
                    AggregateFlowStatisticsData data = table.getAugmentation(AggregateFlowStatisticsData.class);
                    if (null != data) {
                        aggerateFlowStatsCount++;
                    }
                }
            }
        }
    }
    if (aggregateFlowCount == aggerateFlowStatsCount) {
        LOG.debug("aggregateStats - Success");
    } else {
        LOG.debug("aggregateStats - Failed");
        LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
    }
}
Also used : Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) AggregateFlowStatisticsData(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsData)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)112 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)58 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)56 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)54 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)43 Test (org.junit.Test)21 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)20 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)19 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)19 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)19 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)17 BigInteger (java.math.BigInteger)16 ArrayList (java.util.ArrayList)16 NodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)16 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)15 Before (org.junit.Before)11 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)8 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)7 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)7 Optional (com.google.common.base.Optional)6