Search in sources :

Example 1 with GetFeaturesInputBuilder

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);
    }
}
Also used : GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) GetFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder) RpcError(org.opendaylight.yangtools.yang.common.RpcError) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with GetFeaturesInputBuilder

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);
}
Also used : GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) GetFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 3 with GetFeaturesInputBuilder

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();
}
Also used : GetFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder)

Example 4 with GetFeaturesInputBuilder

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);
}
Also used : GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) GetFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 5 with GetFeaturesInputBuilder

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);
}
Also used : GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) GetFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Aggregations

GetFeaturesInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder)6 GetFeaturesInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput)3 ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)2 RpcError (org.opendaylight.yangtools.yang.common.RpcError)2 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1