Search in sources :

Example 66 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project openflowplugin by opendaylight.

the class NodeConnectorInventoryEventTranslatorTest method testNodeConnectorCreationLinkDown.

/**
 * Test that checks that nothing is called when port appeared in inventory in link down state.
 */
@Test
public void testNodeConnectorCreationLinkDown() {
    FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(true, false).build();
    DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, ID, fcnc);
    translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
    verifyZeroInteractions(eventsObserver);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) Test(org.junit.Test)

Example 67 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project openflowplugin by opendaylight.

the class NodeConnectorInventoryEventTranslatorTest method testNodeConnectorCreationAdminDown.

/**
 * Test that checks that nothing is called when port appeared in inventory in admin down state.
 */
@Test
public void testNodeConnectorCreationAdminDown() {
    FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(false, true).build();
    DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, ID, fcnc);
    translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
    verifyZeroInteractions(eventsObserver);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) Test(org.junit.Test)

Example 68 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project openflowplugin by opendaylight.

the class NodeConnectorInventoryEventTranslatorTest method testNodeConnectorUpdateToAdminDown.

/**
 * Test that checks if {@link NodeConnectorEventsObserver#nodeConnectorRemoved} is called
 * for each FlowCapableNodeConnector item with administrative down state removed in
 * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification}.
 */
@Test
public void testNodeConnectorUpdateToAdminDown() {
    FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(false, true).build();
    DataTreeModification dataTreeModification = setupDataTreeChange(SUBTREE_MODIFIED, NODE_CONNECTOR_INSTANCE_IDENTIFIER, fcnc);
    translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
    verify(eventsObserver).nodeConnectorRemoved(ID);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) Test(org.junit.Test)

Example 69 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project openflowplugin by opendaylight.

the class QueueStatisticsToNotificationTransformer method transformToNotification.

/**
 * Transform statistics to notification.
 *
 * @param mpReplyList   raw multipart response from device
 * @param deviceInfo    device state
 * @param ofVersion     device version
 * @param emulatedTxId  emulated transaction Id
 * @return notification containing flow stats
 */
public static QueueStatisticsUpdate transformToNotification(final List<MultipartReply> mpReplyList, final DeviceInfo deviceInfo, final OpenflowVersion ofVersion, final TransactionId emulatedTxId) {
    QueueStatisticsUpdateBuilder notification = new QueueStatisticsUpdateBuilder();
    notification.setId(deviceInfo.getNodeId());
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    notification.setQueueIdAndStatisticsMap(new ArrayList<>());
    for (MultipartReply mpReply : mpReplyList) {
        MultipartReplyQueueCase caseBody = (MultipartReplyQueueCase) mpReply.getMultipartReplyBody();
        MultipartReplyQueue replyBody = caseBody.getMultipartReplyQueue();
        for (QueueStats queueStats : replyBody.getQueueStats()) {
            QueueIdAndStatisticsMapBuilder statsBuilder = new QueueIdAndStatisticsMapBuilder();
            statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(deviceInfo.getDatapathId(), queueStats.getPortNo(), ofVersion));
            statsBuilder.setTransmissionErrors(new Counter64(queueStats.getTxErrors()));
            statsBuilder.setTransmittedBytes(new Counter64(queueStats.getTxBytes()));
            statsBuilder.setTransmittedPackets(new Counter64(queueStats.getTxPackets()));
            DurationBuilder durationBuilder = new DurationBuilder();
            durationBuilder.setSecond(new Counter32(queueStats.getDurationSec()));
            durationBuilder.setNanosecond(new Counter32(queueStats.getDurationNsec()));
            statsBuilder.setDuration(durationBuilder.build());
            statsBuilder.setQueueId(new QueueId(queueStats.getQueueId()));
            notification.getQueueIdAndStatisticsMap().add(statsBuilder.build());
        }
    }
    return notification.build();
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) QueueIdAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder) MultipartReplyQueueCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId) QueueStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats) MultipartReplyQueue(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue) QueueStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdateBuilder) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)

Example 70 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State 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

ArrayList (java.util.ArrayList)31 Test (org.junit.Test)28 BigInteger (java.math.BigInteger)27 List (java.util.List)15 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)14 Collections (java.util.Collections)13 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)13 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 Optional (com.google.common.base.Optional)11 Inject (javax.inject.Inject)11 Singleton (javax.inject.Singleton)11 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)10 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)10 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)10 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)10 FutureCallback (com.google.common.util.concurrent.FutureCallback)9 ByteBuf (io.netty.buffer.ByteBuf)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)9