Search in sources :

Example 36 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project openflowplugin by opendaylight.

the class DeviceContextImpl method handlePacketInMessage.

private void handlePacketInMessage(final PacketIn packetIn, final Class<?> implementedInterface, final Match match) {
    messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH);
    final ConnectionAdapter connectionAdapter = getPrimaryConnectionContext().getConnectionAdapter();
    if (packetIn == null) {
        LOG.debug("Received a null packet from switch {}", connectionAdapter.getRemoteAddress());
        messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH_TRANSLATE_SRC_FAILURE);
        return;
    }
    final OpenflowVersion openflowVersion = OpenflowVersion.get(deviceInfo.getVersion());
    // Try to get ingress from match
    final NodeConnectorRef nodeConnectorRef = Objects.nonNull(packetIn.getIngress()) ? packetIn.getIngress() : Optional.ofNullable(match).map(Match::getInPort).map(nodeConnectorId -> InventoryDataServiceUtil.portNumberfromNodeConnectorId(openflowVersion, nodeConnectorId)).map(portNumber -> InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(deviceInfo.getDatapathId(), portNumber, openflowVersion)).orElse(null);
    messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH_TRANSLATE_OUT_SUCCESS);
    if (!packetInLimiter.acquirePermit()) {
        LOG.debug("Packet limited");
        // TODO: save packet into emergency slot if possible
        messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH_PACKET_IN_LIMIT_REACHED_AND_DROPPED);
        return;
    }
    final ListenableFuture<?> offerNotification = notificationPublishService.offerNotification(new PacketReceivedBuilder(packetIn).setIngress(nodeConnectorRef).setMatch(MatchUtil.transformMatch(match, org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match.class)).build());
    if (NotificationPublishService.REJECTED.equals(offerNotification)) {
        LOG.debug("notification offer rejected");
        messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH_NOTIFICATION_REJECTED);
        packetInLimiter.drainLowWaterMark();
        packetInLimiter.releasePermit();
        return;
    }
    Futures.addCallback(offerNotification, new FutureCallback<Object>() {

        @Override
        public void onSuccess(final Object result) {
            messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH_PUBLISHED_SUCCESS);
            packetInLimiter.releasePermit();
        }

        @Override
        public void onFailure(final Throwable throwable) {
            messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH_NOTIFICATION_REJECTED);
            LOG.debug("notification offer failed: {}", throwable.getMessage());
            LOG.trace("notification offer failed..", throwable);
            packetInLimiter.releasePermit();
        }
    }, MoreExecutors.directExecutor());
}
Also used : MultipartWriterProvider(org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider) FlowCapableNodeConnectorStatisticsData(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData) DeviceMeterRegistry(org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry) ServiceGroupIdentifier(org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier) Future(java.util.concurrent.Future) Error(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error) PacketInMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) ExtensionConverterProvider(org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) ContextChainState(org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainState) PortStatusMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage) PortGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) FlowCapableNodeConnectorStatisticsDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder) ConnectionAdapter(org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) AbstractDeviceInitializer(org.opendaylight.openflowplugin.impl.device.initialization.AbstractDeviceInitializer) PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived) DataContainer(org.opendaylight.yangtools.yang.binding.DataContainer) MultiMsgCollectorImpl(org.opendaylight.openflowplugin.impl.device.listener.MultiMsgCollectorImpl) ConversionException(org.opendaylight.openflowplugin.extension.api.exception.ConversionException) TransactionChainManager(org.opendaylight.openflowplugin.common.txchain.TransactionChainManager) DeviceInitializerProvider(org.opendaylight.openflowplugin.impl.device.initialization.DeviceInitializerProvider) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) PacketIn(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketIn) Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) Nullable(javax.annotation.Nullable) ContextChainMastershipState(org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainMastershipState) AbstractRequestContext(org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ExtensionConverterProviderKeeper(org.opendaylight.openflowplugin.extension.api.ExtensionConverterProviderKeeper) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) TranslatorKey(org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey) ConvertorMessageFromOFJava(org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava) ContextChainHolder(org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainHolder) DeviceFlowRegistryImpl(org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl) NodeConnectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder) DeviceFlowRegistry(org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) NotificationPublishService(org.opendaylight.controller.md.sal.binding.api.NotificationPublishService) ContextChainMastershipWatcher(org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainMastershipWatcher) ExperimenterMessageFromDevBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.ExperimenterMessageFromDevBuilder) MessagePath(org.opendaylight.openflowplugin.extension.api.path.MessagePath) MessageTranslator(org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator) DeviceContext(org.opendaylight.openflowplugin.api.openflow.device.DeviceContext) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) Collection(java.util.Collection) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) Objects(java.util.Objects) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) List(java.util.List) ContextChain(org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChain) ExperimenterMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage) MessageSpy(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy) HashedWheelTimer(io.netty.util.HashedWheelTimer) MultiMsgCollector(org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector) Optional(java.util.Optional) DeviceMeterRegistryImpl(org.opendaylight.openflowplugin.impl.registry.meter.DeviceMeterRegistryImpl) InventoryDataServiceUtil(org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil) FlowRemoved(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ConvertorExecutor(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) MultipartWriterProviderFactory(org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProviderFactory) DeviceState(org.opendaylight.openflowplugin.api.openflow.device.DeviceState) HashSet(java.util.HashSet) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) RequestContextUtil(org.opendaylight.openflowplugin.impl.services.util.RequestContextUtil) PortReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason) Nonnull(javax.annotation.Nonnull) PortStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatus) MessageTypeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext) DeviceGroupRegistryImpl(org.opendaylight.openflowplugin.impl.registry.group.DeviceGroupRegistryImpl) Logger(org.slf4j.Logger) OFConstants(org.opendaylight.openflowplugin.api.OFConstants) TimeUnit(java.util.concurrent.TimeUnit) DeviceGroupRegistry(org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry) ExperimenterMessageOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice) RequestContext(org.opendaylight.openflowplugin.api.openflow.device.RequestContext) TranslatorLibrary(org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) MatchUtil(org.opendaylight.openflowplugin.impl.util.MatchUtil) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) ConnectionAdapter(org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter) DataObject(org.opendaylight.yangtools.yang.binding.DataObject)

Example 37 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project openflowplugin by opendaylight.

the class OpenflowProtocolListenerFullImpl method onEchoRequestMessage.

@Override
public void onEchoRequestMessage(final EchoRequestMessage echoRequestMessage) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("echo request received: {}", echoRequestMessage.getXid());
    }
    final EchoReplyInputBuilder builder = new EchoReplyInputBuilder();
    builder.setVersion(echoRequestMessage.getVersion());
    builder.setXid(echoRequestMessage.getXid());
    builder.setData(echoRequestMessage.getData());
    connectionAdapter.echoReply(builder.build());
}
Also used : EchoReplyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder)

Example 38 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project openflowplugin by opendaylight.

the class MultipartRequestOnTheFlyCallbackTest method testOnSuccessWithNotMultiNoMultipart.

@Test
public void testOnSuccessWithNotMultiNoMultipart() throws Exception {
    final HelloMessage mockedHelloMessage = mock(HelloMessage.class);
    multipartRequestOnTheFlyCallback.onSuccess(mockedHelloMessage);
    final RpcResult<List<MultipartReply>> expectedRpcResult = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, String.format("Unexpected response type received: %s.", mockedHelloMessage.getClass())).build();
    final RpcResult<List<MultipartReply>> actualResult = dummyRequestContext.getFuture().get();
    assertNotNull(actualResult.getErrors());
    assertEquals(1, actualResult.getErrors().size());
    final RpcError actualError = actualResult.getErrors().iterator().next();
    assertEquals(actualError.getMessage(), String.format("Unexpected response type received: %s.", mockedHelloMessage.getClass()));
    assertEquals(actualError.getErrorType(), RpcError.ErrorType.APPLICATION);
    assertEquals(expectedRpcResult.getResult(), actualResult.getResult());
    assertEquals(expectedRpcResult.isSuccessful(), actualResult.isSuccessful());
    Mockito.verify(mockedDeviceContext, Mockito.never()).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier>any(), Matchers.<DataObject>any());
    Mockito.verify(mockedDeviceContext).submitTransaction();
}
Also used : HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) RpcError(org.opendaylight.yangtools.yang.common.RpcError) List(java.util.List) Test(org.junit.Test)

Example 39 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project openflowplugin by opendaylight.

the class MeterForwarder method remove.

@Override
public Future<RpcResult<RemoveMeterOutput>> remove(final InstanceIdentifier<Meter> identifier, final Meter removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
    LOG.trace("Received the Meter REMOVE request [Tbl id, node Id {} {}", identifier, nodeIdent);
    final RemoveMeterInputBuilder builder = new RemoveMeterInputBuilder(removeDataObj);
    builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
    builder.setMeterRef(new MeterRef(identifier));
    return salMeterService.removeMeter(builder.build());
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) RemoveMeterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder) MeterRef(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef)

Example 40 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project openflowplugin by opendaylight.

the class MeterForwarder method add.

@Override
public Future<RpcResult<AddMeterOutput>> add(final InstanceIdentifier<Meter> identifier, final Meter addDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
    LOG.trace("Received the Meter ADD request [Tbl id, node Id {} {} {}", identifier, nodeIdent, addDataObj);
    final AddMeterInputBuilder builder = new AddMeterInputBuilder(addDataObj);
    builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
    builder.setMeterRef(new MeterRef(identifier));
    return salMeterService.addMeter(builder.build());
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) AddMeterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder) MeterRef(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef)

Aggregations

BigInteger (java.math.BigInteger)26 ArrayList (java.util.ArrayList)20 ExecutionException (java.util.concurrent.ExecutionException)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)13 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)13 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)10 List (java.util.List)10 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)10 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)9 UnknownHostException (java.net.UnknownHostException)8 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)8 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)8 Optional (com.google.common.base.Optional)7 Test (org.junit.Test)7 PacketException (org.opendaylight.openflowplugin.libraries.liblldp.PacketException)7 Collections (java.util.Collections)6 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)6 FutureCallback (com.google.common.util.concurrent.FutureCallback)5 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)5 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)5