use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply in project openflowplugin by opendaylight.
the class StatisticsContextImpMockInitiation method initialize.
@Before
public void initialize() {
mockedDeviceContext = mock(DeviceContext.class);
mockedStatisticsGatheringService = mock(StatisticsGatheringService.class);
mockedStatisticsOnFlyGatheringService = mock(StatisticsGatheringOnTheFlyService.class);
mockedConnectionContext = mock(ConnectionContext.class);
mockedDeviceState = mock(DeviceState.class);
mockedDeviceInfo = mock(DeviceInfo.class);
mockedStatisticsManager = mock(StatisticsManager.class);
mockedMastershipWatcher = mock(ContextChainMastershipWatcher.class);
final FeaturesReply mockedFeatures = mock(FeaturesReply.class);
final MessageSpy mockedMessageSpy = mock(MessageSpy.class);
final OutboundQueue mockedOutboundQueue = mock(OutboundQueue.class);
final DeviceManager mockedDeviceManager = mock(DeviceManager.class);
when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessageSpy);
when(mockedDeviceState.isTableStatisticsAvailable()).thenReturn(isTable);
when(mockedDeviceState.isFlowStatisticsAvailable()).thenReturn(isFlow);
when(mockedDeviceState.isGroupAvailable()).thenReturn(isGroup);
when(mockedDeviceState.isMetersAvailable()).thenReturn(isMeter);
when(mockedDeviceState.isPortStatisticsAvailable()).thenReturn(isPort);
when(mockedDeviceState.isQueueStatisticsAvailable()).thenReturn(isQueue);
when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_ID);
when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessageSpy);
when(mockedDeviceInfo.getNodeId()).thenReturn(DUMMY_NODE_ID.getKey().getId());
when(mockedConnectionContext.getNodeId()).thenReturn(DUMMY_NODE_ID.getKey().getId());
when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeatures);
when(mockedConnectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
when(mockedConnectionContext.getOutboundQueueProvider()).thenReturn(mockedOutboundQueue);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply in project openflowplugin by opendaylight.
the class OF10DeviceInitializerTest method setUp.
@Before
public void setUp() throws Exception {
final KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier = DeviceStateUtil.createNodeInstanceIdentifier(new NodeId("openflow:1"));
deviceInitializer = new OF10DeviceInitializer();
when(featuresReply.getCapabilitiesV10()).thenReturn(capabilitiesV10);
when(featuresReply.getPhyPort()).thenReturn(Collections.singletonList(new PhyPortBuilder().setPortNo(42L).build()));
when(connectionContext.getFeatures()).thenReturn(featuresReply);
when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
when(deviceContext.getDeviceState()).thenReturn(deviceState);
when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
when(translatorLibrary.lookupTranslator(any())).thenReturn(messageTranslator);
when(deviceContext.oook()).thenReturn(translatorLibrary);
when(requestContext.getXid()).thenReturn(new Xid(42L));
when(requestContext.getFuture()).thenReturn(RpcResultBuilder.success().buildFuture());
when(deviceContext.createRequestContext()).thenReturn(requestContext);
when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply in project openflowplugin by opendaylight.
the class SystemNotificationsListenerImpl method executeOnSwitchIdleEvent.
@SuppressWarnings("checkstyle:IllegalCatch")
private void executeOnSwitchIdleEvent() {
boolean shouldBeDisconnected = true;
final InetSocketAddress remoteAddress = connectionContext.getConnectionAdapter().getRemoteAddress();
if (ConnectionContext.CONNECTION_STATE.WORKING.equals(connectionContext.getConnectionState())) {
FeaturesReply features = connectionContext.getFeatures();
LOG.info("Switch Idle state occurred, node={}|auxId={}", remoteAddress, features.getAuxiliaryId());
connectionContext.changeStateToTimeouting();
EchoInputBuilder builder = new EchoInputBuilder();
builder.setVersion(features.getVersion());
builder.setXid(ECHO_XID.getValue());
Future<RpcResult<EchoOutput>> echoReplyFuture = connectionContext.getConnectionAdapter().echo(builder.build());
try {
RpcResult<EchoOutput> echoReplyValue = echoReplyFuture.get(echoReplyTimeout, TimeUnit.MILLISECONDS);
if (echoReplyValue.isSuccessful() && Objects.equals(echoReplyValue.getResult().getXid(), ECHO_XID.getValue())) {
connectionContext.changeStateToWorking();
shouldBeDisconnected = false;
} else {
logErrors(remoteAddress, echoReplyValue);
}
} catch (Exception e) {
if (LOG.isWarnEnabled()) {
LOG.warn("Exception while waiting for echoReply from [{}] in TIMEOUTING state: {}", remoteAddress, e.getMessage());
}
if (LOG.isTraceEnabled()) {
LOG.trace("Exception while waiting for echoReply from [{}] in TIMEOUTING state: {}", remoteAddress, e);
}
}
}
if (shouldBeDisconnected) {
if (LOG.isInfoEnabled()) {
LOG.info("ConnectionEvent:Closing connection as device is idle. Echo sent at {}. Device:{}, NodeId:{}", new Date(System.currentTimeMillis() - echoReplyTimeout), remoteAddress, connectionContext.getSafeNodeIdForLOG());
}
connectionContext.closeConnection(true);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorTest method prepareMocks.
private MultipartReplyMessage prepareMocks(DeviceContext mockedDeviceContext, MultipartReplyBody multipartReplyBody, final MultipartType multipartType) {
ConnectionContext mockedConnectionContext = mock(ConnectionContext.class);
FeaturesReply mockedFeaturesReply = mock(FeaturesReply.class);
when(mockedFeaturesReply.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
when(mockedFeaturesReply.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
DeviceInfo deviceInfo = mock(DeviceInfo.class);
when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
when(deviceInfo.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
when(mockedDeviceContext.getDeviceInfo()).thenReturn(deviceInfo);
when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeaturesReply);
when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
MultipartReplyMessage multipartReplyMessage = mock(MultipartReplyMessage.class);
when(multipartReplyMessage.getType()).thenReturn(multipartType);
when(multipartReplyMessage.getFlags()).thenReturn(new MultipartRequestFlags(true));
when(multipartReplyMessage.getXid()).thenReturn(DUMMY_XID);
when(multipartReplyMessage.getMultipartReplyBody()).thenReturn(multipartReplyBody);
return multipartReplyMessage;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply in project openflowplugin by opendaylight.
the class DeviceInitializationUtilTest method setUp.
@Before
public void setUp() throws Exception {
when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_II);
when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null));
when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
when(connectionAdapter.getRemoteAddress()).thenReturn(INET_SOCKET_ADDRESS);
when(featuresReply.getTables()).thenReturn(TABLES);
when(featuresReply.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
when(featuresReply.getCapabilities()).thenReturn(new Capabilities(false, false, false, false, false, false, false));
when(connectionContext.getFeatures()).thenReturn(featuresReply);
when(connectionContext.getConnectionAdapter()).thenReturn(connectionAdapter);
}
Aggregations