Search in sources :

Example 1 with PacketProcessingService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService in project openflowplugin by opendaylight.

the class MultipleLearningSwitchHandlerFacadeImpl method onSwitchAppeared.

@Override
public synchronized void onSwitchAppeared(InstanceIdentifier<Table> appearedTablePath) {
    LOG.debug("expected table acquired, learning ..");
    /**
     * appearedTablePath is in form of /nodes/node/node-id/table/table-id
     * so we shorten it to /nodes/node/node-id to get identifier of switch.
     */
    InstanceIdentifier<Node> nodePath = InstanceIdentifierUtils.getNodePath(appearedTablePath);
    /**
     * We check if we already initialized dispatcher for that node,
     * if not we create new handler for switch.
     */
    if (!packetInDispatcher.getHandlerMapping().containsKey(nodePath)) {
        // delegate this node (owning appearedTable) to SimpleLearningSwitchHandler
        LearningSwitchHandlerSimpleImpl simpleLearningSwitch = new LearningSwitchHandlerSimpleImpl(dataStoreAccessor, packetProcessingService, null);
        /**
         * We propagate table event to newly instantiated instance of learning switch
         */
        simpleLearningSwitch.onSwitchAppeared(appearedTablePath);
        /**
         * We update mapping of already instantiated LearningSwitchHanlders
         */
        packetInDispatcher.getHandlerMapping().put(nodePath, simpleLearningSwitch);
    }
}
Also used : LearningSwitchHandlerSimpleImpl(org.opendaylight.openflowplugin.learningswitch.LearningSwitchHandlerSimpleImpl) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)

Example 2 with PacketProcessingService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService in project genius by opendaylight.

the class AlivenessMonitorTest method setUp.

@SuppressWarnings("unchecked")
@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    when(idManager.createIdPool(any(CreateIdPoolInput.class))).thenReturn(Futures.immediateFuture(RpcResultBuilder.<Void>success().build()));
    AlivenessProtocolHandlerRegistry alivenessProtocolHandlerRegistry = new AlivenessProtocolHandlerRegistryImpl();
    alivenessMonitor = new AlivenessMonitor(dataBroker, idManager, notificationPublishService, alivenessProtocolHandlerRegistry);
    arpHandler = new AlivenessProtocolHandlerARP(dataBroker, interfaceManager, alivenessProtocolHandlerRegistry, arpService);
    lldpHandler = new AlivenessProtocolHandlerLLDP(dataBroker, alivenessProtocolHandlerRegistry, packetProcessingService);
    mockId = 1L;
    when(idManager.allocateId(any(AllocateIdInput.class))).thenReturn(Futures.immediateFuture(RpcResultBuilder.success(new AllocateIdOutputBuilder().setIdValue(mockId++).build()).build()));
    when(idManager.releaseId(any(ReleaseIdInput.class))).thenReturn(Futures.immediateFuture(RpcResultBuilder.<Void>success().build()));
    doReturn(readTx).when(dataBroker).newReadOnlyTransaction();
    doReturn(writeTx).when(dataBroker).newWriteOnlyTransaction();
    doReturn(readWriteTx).when(dataBroker).newReadWriteTransaction();
    doNothing().when(writeTx).put(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class), any(DataObject.class));
    doReturn(Futures.immediateCheckedFuture(null)).when(writeTx).submit();
    doReturn(Futures.immediateCheckedFuture(null)).when(readWriteTx).submit();
}
Also used : DataObject(org.opendaylight.yangtools.yang.binding.DataObject) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) AllocateIdOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutputBuilder) AlivenessProtocolHandlerLLDP(org.opendaylight.genius.alivenessmonitor.protocols.internal.AlivenessProtocolHandlerLLDP) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) AlivenessProtocolHandlerRegistry(org.opendaylight.genius.alivenessmonitor.protocols.AlivenessProtocolHandlerRegistry) ReleaseIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput) AlivenessProtocolHandlerRegistryImpl(org.opendaylight.genius.alivenessmonitor.protocols.internal.AlivenessProtocolHandlerRegistryImpl) AlivenessMonitor(org.opendaylight.genius.alivenessmonitor.internal.AlivenessMonitor) AlivenessProtocolHandlerARP(org.opendaylight.genius.alivenessmonitor.protocols.internal.AlivenessProtocolHandlerARP) Before(org.junit.Before)

Example 3 with PacketProcessingService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService in project openflowplugin by opendaylight.

the class LLDPSpeakerTest method setUp.

@Before
public void setUp() throws NoSuchAlgorithmException, PacketException {
    byte[] lldpFrame = LLDPUtil.buildLldpFrame(new NodeId("openflow:1"), new NodeConnectorId("openflow:1:1"), MAC_ADDRESS, 1L);
    packetInput = new TransmitPacketInputBuilder().setEgress(new NodeConnectorRef(ID)).setNode(new NodeRef(ID.firstIdentifierOf(Node.class))).setPayload(lldpFrame).build();
    when(scheduledExecutorService.scheduleAtFixedRate(any(Runnable.class), anyLong(), anyLong(), any(TimeUnit.class))).thenReturn(scheduledSpeakerTask);
    lldpSpeaker = new LLDPSpeaker(packetProcessingService, scheduledExecutorService, null, entityOwnershipService);
    when(entityOwnershipService.getOwnershipState(any())).thenReturn(Optional.of(EntityOwnershipState.IS_OWNER));
    lldpSpeaker.setOperationalStatus(OperStatus.RUN);
    doReturn(RpcResultBuilder.success().buildFuture()).when(packetProcessingService).transmitPacket(any());
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) TimeUnit(java.util.concurrent.TimeUnit) Before(org.junit.Before)

Example 4 with PacketProcessingService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService in project openflowplugin by opendaylight.

the class LearningSwitchManagerMultiImpl method start.

/**
 * Starts learning switch.
 */
@Override
public void start() {
    LOG.debug("start() -->");
    FlowCommitWrapper dataStoreAccessor = new FlowCommitWrapperImpl(data);
    PacketInDispatcherImpl packetInDispatcher = new PacketInDispatcherImpl();
    MultipleLearningSwitchHandlerFacadeImpl learningSwitchHandler = new MultipleLearningSwitchHandlerFacadeImpl(dataStoreAccessor, packetProcessingService, packetInDispatcher);
    packetInRegistration = notificationService.registerNotificationListener(packetInDispatcher);
    WakeupOnNode wakeupListener = new WakeupOnNode();
    wakeupListener.setLearningSwitchHandler(learningSwitchHandler);
    final InstanceIdentifier<Table> instanceIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class).child(Table.class);
    final DataTreeIdentifier<Table> dataTreeIdentifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
    dataTreeChangeListenerRegistration = data.registerDataTreeChangeListener(dataTreeIdentifier, wakeupListener);
    LOG.debug("start() <--");
}
Also used : DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowCommitWrapper(org.opendaylight.openflowplugin.learningswitch.FlowCommitWrapper) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) WakeupOnNode(org.opendaylight.openflowplugin.learningswitch.WakeupOnNode) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) FlowCommitWrapperImpl(org.opendaylight.openflowplugin.learningswitch.FlowCommitWrapperImpl)

Example 5 with PacketProcessingService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService 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)

Aggregations

Before (org.junit.Before)2 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)2 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)2 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)2 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)2 TimeUnit (java.util.concurrent.TimeUnit)1 Test (org.junit.Test)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 DataTreeIdentifier (org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier)1 NotificationService (org.opendaylight.controller.sal.binding.api.NotificationService)1 AlivenessMonitor (org.opendaylight.genius.alivenessmonitor.internal.AlivenessMonitor)1 AlivenessProtocolHandlerRegistry (org.opendaylight.genius.alivenessmonitor.protocols.AlivenessProtocolHandlerRegistry)1 AlivenessProtocolHandlerARP (org.opendaylight.genius.alivenessmonitor.protocols.internal.AlivenessProtocolHandlerARP)1 AlivenessProtocolHandlerLLDP (org.opendaylight.genius.alivenessmonitor.protocols.internal.AlivenessProtocolHandlerLLDP)1 AlivenessProtocolHandlerRegistryImpl (org.opendaylight.genius.alivenessmonitor.protocols.internal.AlivenessProtocolHandlerRegistryImpl)1 FlowCommitWrapper (org.opendaylight.openflowplugin.learningswitch.FlowCommitWrapper)1 FlowCommitWrapperImpl (org.opendaylight.openflowplugin.learningswitch.FlowCommitWrapperImpl)1 LearningSwitchHandlerSimpleImpl (org.opendaylight.openflowplugin.learningswitch.LearningSwitchHandlerSimpleImpl)1 WakeupOnNode (org.opendaylight.openflowplugin.learningswitch.WakeupOnNode)1 LearningSwitchManagerMultiImpl (org.opendaylight.openflowplugin.learningswitch.multi.LearningSwitchManagerMultiImpl)1