Search in sources :

Example 21 with Features

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features 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)

Example 22 with Features

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features 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);
    }
}
Also used : EchoOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput) InetSocketAddress(java.net.InetSocketAddress) FeaturesReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply) EchoInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Date(java.util.Date)

Example 23 with Features

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.

the class BuildSwitchCapabilitiesOF10 method build.

@Override
public SwitchFeatures build(GetFeaturesOutput features) {
    SwitchFeaturesBuilder builderSwFeatures = new SwitchFeaturesBuilder();
    builderSwFeatures.setMaxBuffers(features.getBuffers());
    builderSwFeatures.setMaxTables(features.getTables());
    List<Class<? extends FeatureCapability>> capabilities = new ArrayList<>();
    if (features.getCapabilitiesV10().isOFPCARPMATCHIP()) {
        capabilities.add(FlowFeatureCapabilityArpMatchIp.class);
    }
    if (features.getCapabilitiesV10().isOFPCFLOWSTATS()) {
        capabilities.add(FlowFeatureCapabilityFlowStats.class);
    }
    if (features.getCapabilitiesV10().isOFPCIPREASM()) {
        capabilities.add(FlowFeatureCapabilityIpReasm.class);
    }
    if (features.getCapabilitiesV10().isOFPCPORTSTATS()) {
        capabilities.add(FlowFeatureCapabilityPortStats.class);
    }
    if (features.getCapabilitiesV10().isOFPCQUEUESTATS()) {
        capabilities.add(FlowFeatureCapabilityQueueStats.class);
    }
    if (features.getCapabilitiesV10().isOFPCRESERVED()) {
        capabilities.add(FlowFeatureCapabilityReserved.class);
    }
    if (features.getCapabilitiesV10().isOFPCSTP()) {
        capabilities.add(FlowFeatureCapabilityStp.class);
    }
    if (features.getCapabilitiesV10().isOFPCTABLESTATS()) {
        capabilities.add(FlowFeatureCapabilityTableStats.class);
    }
    builderSwFeatures.setCapabilities(capabilities);
    return builderSwFeatures.build();
}
Also used : FeatureCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FeatureCapability) ArrayList(java.util.ArrayList) SwitchFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SwitchFeaturesBuilder)

Example 24 with Features

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.

the class MultipartTableFeaturesSerializerInjector method injectSerializers.

/**
 * Injects multipart table features serializers into provided
 * {@link org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider}.
 *
 * @param provider OpenflowJava serializer extension provider
 */
static void injectSerializers(final SerializerExtensionProvider provider) {
    // Inject new message serializers here using injector created by createInjector method
    final Function<Class<? extends TableFeaturePropType>, Consumer<OFSerializer<TableFeaturePropType>>> injector = createInjector(provider, EncodeConstants.OF13_VERSION_ID);
    injector.apply(Instructions.class).accept(new InstructionsTablePropertySerializer());
    injector.apply(InstructionsMiss.class).accept(new InstructionsMissTablePropertySerializer());
    injector.apply(NextTable.class).accept(new NextTableTablePropertySerializer());
    injector.apply(NextTableMiss.class).accept(new NextTableMissTablePropertySerializer());
    injector.apply(ApplyActions.class).accept(new ApplyActionsTablePropertySerializer());
    injector.apply(ApplyActionsMiss.class).accept(new ApplyActionsMissTablePropertySerializer());
    injector.apply(WriteActions.class).accept(new WriteActionsTablePropertySerializer());
    injector.apply(WriteActionsMiss.class).accept(new WriteActionsMissTablePropertySerializer());
    injector.apply(Match.class).accept(new MatchTablePropertySerializer());
    injector.apply(Wildcards.class).accept(new WildcardsTablePropertySerializer());
    injector.apply(WriteSetfield.class).accept(new WriteSetfieldTablePropertySerializer());
    injector.apply(WriteSetfieldMiss.class).accept(new WriteSetfieldMissTablePropertySerializer());
    injector.apply(ApplySetfield.class).accept(new ApplySetfieldTablePropertySerializer());
    injector.apply(ApplySetfieldMiss.class).accept(new ApplySetfieldMissTablePropertySerializer());
// TODO: Add support for experimenters
}
Also used : InstructionsTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.InstructionsTablePropertySerializer) WriteSetfieldTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.WriteSetfieldTablePropertySerializer) ApplyActionsTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.ApplyActionsTablePropertySerializer) WriteSetfieldMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss) ApplyActionsMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match) ApplySetfieldMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss) Consumer(java.util.function.Consumer) ApplyActionsMissTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.ApplyActionsMissTablePropertySerializer) WildcardsTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.WildcardsTablePropertySerializer) WriteActions(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions) WriteActionsMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss) WriteSetfieldMissTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.WriteSetfieldMissTablePropertySerializer) ApplyActions(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions) NextTable(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTable) NextTableMissTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.NextTableMissTablePropertySerializer) MatchTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.MatchTablePropertySerializer) InstructionsMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss) Instructions(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Instructions) ApplySetfieldMissTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.ApplySetfieldMissTablePropertySerializer) InstructionsMissTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.InstructionsMissTablePropertySerializer) WriteActionsTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.WriteActionsTablePropertySerializer) ApplySetfield(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield) NextTableMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss) ApplySetfieldTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.ApplySetfieldTablePropertySerializer) TableFeaturePropType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType) WriteActionsMissTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.WriteActionsMissTablePropertySerializer) NextTableTablePropertySerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.NextTableTablePropertySerializer) WriteSetfield(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield) Wildcards(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards)

Example 25 with Features

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.

the class TableFeaturesConvertor method toTableProperties.

private static List<TableFeatureProperties> toTableProperties(final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties tableProperties) {
    if (tableProperties == null) {
        return Collections.emptyList();
    }
    List<TableFeatureProperties> ofTablePropertiesList = new ArrayList<>();
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy(tableProperties.getTableFeatureProperties());
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties property : sortedTableProperties) {
        TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType propType = property.getTableFeaturePropType();
        setTableFeatureProperty(propType);
        if (propType instanceof Instructions) {
            setTableFeatureProperty((Instructions) propType, propBuilder);
        } else if (propType instanceof InstructionsMiss) {
            setTableFeatureProperty((InstructionsMiss) propType, propBuilder);
        } else if (propType instanceof NextTable) {
            setTableFeatureProperty((NextTable) propType, propBuilder);
        } else if (propType instanceof NextTableMiss) {
            setTableFeatureProperty((NextTableMiss) propType, propBuilder);
        } else if (propType instanceof WriteActions) {
            setTableFeatureProperty((WriteActions) propType, propBuilder);
        } else if (propType instanceof WriteActionsMiss) {
            setTableFeatureProperty((WriteActionsMiss) propType, propBuilder);
        } else if (propType instanceof ApplyActions) {
            setTableFeatureProperty((ApplyActions) propType, propBuilder);
        } else if (propType instanceof ApplyActionsMiss) {
            setTableFeatureProperty((ApplyActionsMiss) propType, propBuilder);
        } else if (propType instanceof Match) {
            setTableFeatureProperty((Match) propType, propBuilder);
        } else if (propType instanceof Wildcards) {
            setTableFeatureProperty((Wildcards) propType, propBuilder);
        } else if (propType instanceof WriteSetfield) {
            setTableFeatureProperty((WriteSetfield) propType, propBuilder);
        } else if (propType instanceof WriteSetfieldMiss) {
            setTableFeatureProperty((WriteSetfieldMiss) propType, propBuilder);
        } else if (propType instanceof ApplySetfield) {
            setTableFeatureProperty((ApplySetfield) propType, propBuilder);
        } else if (propType instanceof ApplySetfieldMiss) {
            setTableFeatureProperty((ApplySetfieldMiss) propType, propBuilder);
        }
        // Experimenter and Experimenter miss Table features are unhandled
        ofTablePropertiesList.add(propBuilder.build());
    }
    return ofTablePropertiesList;
}
Also used : TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) ArrayList(java.util.ArrayList) WriteSetfieldMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss) ApplyActionsMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match) ApplySetfieldMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss) TableFeaturePropertiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder) WriteActions(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions) WriteActionsMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss) TableFeaturePropType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType) ApplyActions(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions) NextTable(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTable) InstructionsMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss) Instructions(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Instructions) ApplySetfield(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield) NextTableMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss) WriteSetfield(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield) Wildcards(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards)

Aggregations

Test (org.junit.Test)15 ArrayList (java.util.ArrayList)9 ByteBuf (io.netty.buffer.ByteBuf)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)5 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)5 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)5 MultipartReplyTableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures)4 BigInteger (java.math.BigInteger)3 PortState (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState)3 TableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures)3 Before (org.junit.Before)2 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)2 PortNumberUni (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni)2 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)2 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)2 PortConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig)2 PortFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures)2 TableConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig)2 MultipartReplyPortDescCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase)2 MultipartReplyTableFeaturesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase)2