use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder in project openflowplugin by opendaylight.
the class MockPlugin method getSwitchFeatures.
protected void getSwitchFeatures() {
GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder();
featuresBuilder.setVersion((short) 4);
featuresBuilder.setXid(3L);
GetFeaturesInput featuresInput = featuresBuilder.build();
try {
LOGGER.debug("Requesting features ");
RpcResult<GetFeaturesOutput> rpcResult = adapter.getFeatures(featuresInput).get(2500, TimeUnit.MILLISECONDS);
if (rpcResult.isSuccessful()) {
byte[] byteArray = rpcResult.getResult().getDatapathId().toByteArray();
LOGGER.debug("DatapathId: {}", Arrays.toString(byteArray));
} else {
RpcError rpcError = rpcResult.getErrors().iterator().next();
LOGGER.warn("rpcResult failed", rpcError.getCause());
}
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOGGER.error("getSwitchFeatures() exception caught: ", e.getMessage(), e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder in project openflowplugin by opendaylight.
the class GetFeaturesInputMessageFactoryTest method testV13.
/**
* Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO.
*/
@Test
public void testV13() throws Exception {
GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();
BufferHelper.setupHeader(gfib, EncodeConstants.OF13_VERSION_ID);
GetFeaturesInput gfi = gfib.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
featuresFactory.serialize(gfi, out);
BufferHelper.checkHeaderV13(out, FEATURES_REQUEST_MESSAGE_CODE_TYPE, 8);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder in project openflowplugin by opendaylight.
the class OF10FeaturesRequestMessageFactory method deserialize.
@Override
public GetFeaturesInput deserialize(ByteBuf rawMessage) {
GetFeaturesInputBuilder builder = new GetFeaturesInputBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder in project openflowplugin by opendaylight.
the class GetFeaturesInputMessageFactoryTest method testV10.
/**
* Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO.
*/
@Test
public void testV10() throws Exception {
GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();
BufferHelper.setupHeader(gfib, EncodeConstants.OF10_VERSION_ID);
GetFeaturesInput gfi = gfib.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
featuresFactory.serialize(gfi, out);
BufferHelper.checkHeaderV10(out, FEATURES_REQUEST_MESSAGE_CODE_TYPE, 8);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder in project openflowplugin by opendaylight.
the class HandshakeManagerImpl method postHandshake.
/**
* after handshake set features, register to session.
*
* @param proposedVersion proposed openflow version
* @param xid transaction id
*/
protected void postHandshake(final Short proposedVersion, final Long xid) {
// set version
version = proposedVersion;
LOG.debug("version set: {}", proposedVersion);
// request features
GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder();
featuresBuilder.setVersion(version).setXid(xid);
LOG.debug("sending feature request for version={} and xid={}", version, xid);
Future<RpcResult<GetFeaturesOutput>> featuresFuture = connectionAdapter.getFeatures(featuresBuilder.build());
Futures.addCallback(JdkFutureAdapters.listenInPoolThread(featuresFuture), new FutureCallback<RpcResult<GetFeaturesOutput>>() {
@Override
public void onSuccess(@Nonnull RpcResult<GetFeaturesOutput> rpcFeatures) {
LOG.trace("features are back");
if (rpcFeatures.isSuccessful()) {
GetFeaturesOutput featureOutput = rpcFeatures.getResult();
LOG.debug("obtained features: datapathId={}", featureOutput.getDatapathId());
LOG.debug("obtained features: auxiliaryId={}", featureOutput.getAuxiliaryId());
LOG.trace("handshake SETTLED: version={}, datapathId={}, auxiliaryId={}", version, featureOutput.getDatapathId(), featureOutput.getAuxiliaryId());
handshakeListener.onHandshakeSuccessful(featureOutput, proposedVersion);
} else {
// handshake failed
LOG.warn("issuing disconnect during handshake [{}]", connectionAdapter.getRemoteAddress());
for (RpcError rpcError : rpcFeatures.getErrors()) {
LOG.debug("handshake - features failure [{}]: i:{} | m:{} | s:{}", xid, rpcError.getInfo(), rpcError.getMessage(), rpcError.getSeverity(), rpcError.getCause());
}
handshakeListener.onHandshakeFailure();
}
LOG.debug("postHandshake DONE");
}
@Override
public void onFailure(Throwable throwable) {
LOG.warn("getting feature failed seriously [{}, addr:{}]: {}", xid, connectionAdapter.getRemoteAddress(), throwable.getMessage());
LOG.trace("DETAIL of sending of hello failure:", throwable);
}
}, MoreExecutors.directExecutor());
LOG.debug("future features [{}] hooked ..", xid);
}
Aggregations