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);
}
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());
}
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);
}
}
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.");
}
}
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.");
}
}
Aggregations