use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder in project openflowplugin by opendaylight.
the class EchoInputMessageFactoryTest method testData.
/**
* Testing of {@link EchoInputMessageFactory} for correct data serialization.
*/
@Test
public void testData() throws Exception {
byte[] dataToTest = new byte[] { 91, 92, 93, 94, 95, 96, 97, 98 };
EchoInputBuilder eib = new EchoInputBuilder();
BufferHelper.setupHeader(eib, EncodeConstants.OF13_VERSION_ID);
eib.setData(dataToTest);
EchoInput ei = eib.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
echoFactory.serialize(ei, out);
BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8 + dataToTest.length);
byte[] outData = new byte[dataToTest.length];
out.readBytes(outData);
Assert.assertArrayEquals("Wrong - different output data.", dataToTest, outData);
out.release();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder 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.EchoInputBuilder in project openflowplugin by opendaylight.
the class EchoInputMessageFactoryTest method testV13.
/**
* Testing of {@link EchoInputMessageFactory} for correct translation from POJO.
*/
@Test
public void testV13() throws Exception {
EchoInputBuilder eib = new EchoInputBuilder();
BufferHelper.setupHeader(eib, EncodeConstants.OF13_VERSION_ID);
EchoInput ei = eib.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
echoFactory.serialize(ei, out);
BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder in project openflowplugin by opendaylight.
the class EchoInputMessageFactoryTest method testV10.
/**
* Testing of {@link EchoInputMessageFactory} for correct translation from POJO.
*/
@Test
public void testV10() throws Exception {
EchoInputBuilder eib = new EchoInputBuilder();
BufferHelper.setupHeader(eib, EncodeConstants.OF10_VERSION_ID);
EchoInput ei = eib.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
echoFactory.serialize(ei, out);
BufferHelper.checkHeaderV10(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder in project openflowplugin by opendaylight.
the class EchoServiceTest method testSendEcho.
@Test
public void testSendEcho() throws Exception {
EchoInputBuilder sendEchoInput = new EchoInputBuilder();
echoService.handleServiceCall(sendEchoInput);
verify(mockedRequestContextStack).createRequestContext();
}
Aggregations