Search in sources :

Example 6 with Notifications

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications in project openflowplugin by opendaylight.

the class Activator method onSessionInitialized.

/**
 * Invoked when consumer is registered to the MD-SAL.
 */
@Override
public void onSessionInitialized(ConsumerContext session) {
    LOG.info("inSessionInitialized() passing");
    /**
     * We create instance of our LearningSwitchManager
     * and set all required dependencies,
     *
     * which are
     *   Data Broker (data storage service) - for configuring flows and reading stored switch state
     *   PacketProcessingService - for sending out packets
     *   NotificationService - for receiving notifications such as packet in.
     */
    learningSwitch = new LearningSwitchManagerMultiImpl();
    learningSwitch.setDataBroker(session.getSALService(DataBroker.class));
    learningSwitch.setPacketProcessingService(session.getRpcService(PacketProcessingService.class));
    learningSwitch.setNotificationService(session.getSALService(NotificationService.class));
    learningSwitch.start();
}
Also used : LearningSwitchManagerMultiImpl(org.opendaylight.openflowplugin.learningswitch.multi.LearningSwitchManagerMultiImpl) NotificationService(org.opendaylight.controller.sal.binding.api.NotificationService) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) PacketProcessingService(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService)

Example 7 with Notifications

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications in project openflowplugin by opendaylight.

the class ConnectionAdapterImplTest method testConsume.

/**
 * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with notifications.
 */
@Test
public void testConsume() {
    DataObject message = new EchoRequestMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message);
    message = new ErrorMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onErrorMessage((ErrorMessage) message);
    message = new ExperimenterMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onExperimenterMessage((ExperimenterMessage) message);
    message = new FlowRemovedMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onFlowRemovedMessage((FlowRemovedMessage) message);
    message = new HelloMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onHelloMessage((HelloMessage) message);
    message = new MultipartReplyMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onMultipartReplyMessage((MultipartReplyMessage) message);
    message = new PacketInMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onPacketInMessage((PacketInMessage) message);
    message = new PortStatusMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onPortStatusMessage((PortStatusMessage) message);
    message = new SwitchIdleEventBuilder().build();
    adapter.consume(message);
    verify(systemListener, times(1)).onSwitchIdleEvent((SwitchIdleEvent) message);
    message = new DisconnectEventBuilder().build();
    adapter.consume(message);
    verify(systemListener, times(1)).onDisconnectEvent((DisconnectEvent) message);
    message = new EchoRequestMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message);
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) DisconnectEventBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder) ExperimenterMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder) PacketInMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) SwitchIdleEventBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder) PortStatusMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) EchoRequestMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder) Test(org.junit.Test)

Example 8 with Notifications

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications in project lispflowmapping by opendaylight.

the class MappingDataListener method onDataTreeChanged.

@Override
public void onDataTreeChanged(Collection<DataTreeModification<Mapping>> changes) {
    for (DataTreeModification<Mapping> change : changes) {
        final DataObjectModification<Mapping> mod = change.getRootNode();
        if (ModificationType.DELETE == mod.getModificationType()) {
            // Process deleted mappings
            final Mapping mapping = mod.getDataBefore();
            // before being persisted, except for cluster slaves
            if (mapping.getOrigin() == MappingOrigin.Southbound && mapSystem.isMaster()) {
                continue;
            }
            LOG.trace("Received deleted data");
            LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
            LOG.trace("Value: {}", mapping);
            final Mapping convertedMapping = convertToBinaryIfNecessary(mapping);
            mapSystem.removeMapping(convertedMapping.getOrigin(), convertedMapping.getMappingRecord().getEid());
        } else if (ModificationType.SUBTREE_MODIFIED == mod.getModificationType() || ModificationType.WRITE == mod.getModificationType()) {
            final Mapping mapping = mod.getDataAfter();
            // SB notifications
            if (mapping.getOrigin() == MappingOrigin.Southbound && mapSystem.isMaster()) {
                continue;
            }
            final Mapping convertedMapping = convertToBinaryIfNecessary(mapping);
            Eid convertedEid = convertedMapping.getMappingRecord().getEid();
            if (ModificationType.SUBTREE_MODIFIED == mod.getModificationType()) {
                LOG.trace("Received update data");
                LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
                LOG.trace("Value: {}", mapping);
                mapSystem.updateMapping(convertedMapping.getOrigin(), convertedEid, new MappingData(convertedMapping.getMappingRecord()));
            } else {
                LOG.trace("Received write data");
                LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
                LOG.trace("Value: {}", mapping);
                mapSystem.addMapping(convertedMapping.getOrigin(), convertedEid, new MappingData(convertedMapping.getMappingRecord()));
            }
        } else {
            LOG.warn("Ignoring unhandled modification type {}", mod.getModificationType());
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Mapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)

Example 9 with Notifications

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications in project genius by opendaylight.

the class InterfaceMetaUtils method deleteBridgeInterfaceEntry.

public void deleteBridgeInterfaceEntry(BridgeEntryKey bridgeEntryKey, List<BridgeInterfaceEntry> bridgeInterfaceEntries, InstanceIdentifier<BridgeEntry> bridgeEntryIid, String interfaceName) {
    BridgeInterfaceEntryKey bridgeInterfaceEntryKey = new BridgeInterfaceEntryKey(interfaceName);
    InstanceIdentifier<BridgeInterfaceEntry> bridgeInterfaceEntryIid = InterfaceMetaUtils.getBridgeInterfaceEntryIdentifier(bridgeEntryKey, bridgeInterfaceEntryKey);
    if (bridgeInterfaceEntries.size() <= 1) {
        batchingUtils.delete(bridgeEntryIid, BatchingUtils.EntityType.DEFAULT_CONFIG);
    } else {
        // No point deleting interface individually if bridge entry is being deleted
        // Note: Will this cause issue in listener code? Does it expect separate notifications for two?
        batchingUtils.delete(bridgeInterfaceEntryIid, BatchingUtils.EntityType.DEFAULT_CONFIG);
    }
}
Also used : BridgeInterfaceEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.bridge.entry.BridgeInterfaceEntryKey) BridgeInterfaceEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.bridge.entry.BridgeInterfaceEntry)

Example 10 with Notifications

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications in project controller by opendaylight.

the class MdsalLowLevelTestProvider method unsubscribeDtcl.

@Override
public Future<RpcResult<UnsubscribeDtclOutput>> unsubscribeDtcl() {
    LOG.debug("Received unsubscribe-dtcl");
    if (idIntsListener == null || dtclReg == null) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Dtcl missing.", "No DataTreeChangeListener registered.");
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
    }
    try {
        idIntsListener.tryFinishProcessing().get(120, TimeUnit.SECONDS);
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "resource-denied-transport", "Unable to finish notification processing in 120 seconds.", "clustering-it", "clustering-it", e);
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
    }
    dtclReg.close();
    dtclReg = null;
    if (!idIntsListener.hasTriggered()) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "No notification received.", "id-ints listener has not received" + "any notifications.");
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
    }
    final DOMDataReadOnlyTransaction rTx = domDataBroker.newReadOnlyTransaction();
    try {
        final Optional<NormalizedNode<?, ?>> readResult = rTx.read(CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID).checkedGet();
        if (!readResult.isPresent()) {
            final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "Final read empty.", "No data read from id-ints list.");
            return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
        }
        return Futures.immediateFuture(RpcResultBuilder.success(new UnsubscribeDtclOutputBuilder().setCopyMatches(idIntsListener.checkEqual(readResult.get()))).build());
    } catch (final ReadFailedException e) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "Read failed.", "Final read from id-ints failed.");
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) UnsubscribeDtclOutput(org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeDtclOutput) DOMDataReadOnlyTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction) RpcError(org.opendaylight.yangtools.yang.common.RpcError) ExecutionException(java.util.concurrent.ExecutionException) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) UnsubscribeDtclOutputBuilder(org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeDtclOutputBuilder) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

Notifications (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications)4 Optional (com.google.common.base.Optional)3 ArrayList (java.util.ArrayList)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3 Test (org.junit.Test)3 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 ByteBuf (io.netty.buffer.ByteBuf)2 Semaphore (java.util.concurrent.Semaphore)2 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)2 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 NotificationService (org.opendaylight.controller.sal.binding.api.NotificationService)2 L2vlan (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan)2 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)2 MonitoringState (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringState)2 MonitoringStateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringStateBuilder)2 CNotification (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotification)2 Rps (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Rps)2 RpsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.RpsBuilder)2