Search in sources :

Example 6 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.

the class LearningSwitchHandlerSimpleImpl method onSwitchAppeared.

@Override
public synchronized void onSwitchAppeared(InstanceIdentifier<Table> appearedTablePath) {
    if (isLearning) {
        LOG.debug("already learning a node, skipping {}", nodeId.getValue());
        return;
    }
    LOG.debug("expected table acquired, learning ..");
    // disable listening - simple learning handles only one node (switch)
    if (registrationPublisher != null) {
        LOG.debug("closing dataTreeChangeListenerRegistration");
        registrationPublisher.getDataTreeChangeListenerRegistration().close();
    }
    isLearning = true;
    tablePath = appearedTablePath;
    nodePath = tablePath.firstIdentifierOf(Node.class);
    nodeId = nodePath.firstKeyOf(Node.class, NodeKey.class).getId();
    mac2portMapping = new HashMap<>();
    // start forwarding all packages to controller
    FlowId flowId = new FlowId(String.valueOf(flowIdInc.getAndIncrement()));
    FlowKey flowKey = new FlowKey(flowId);
    InstanceIdentifier<Flow> flowPath = InstanceIdentifierUtils.createFlowPath(tablePath, flowKey);
    int priority = 0;
    // create flow in table with id = 0, priority = 4 (other params are
    // defaulted in OFDataStoreUtil)
    FlowBuilder allToCtrlFlow = FlowUtils.createFwdAllToControllerFlow(InstanceIdentifierUtils.getTableId(tablePath), priority, flowId);
    LOG.debug("writing packetForwardToController flow");
    dataStoreAccessor.writeFlowToConfig(flowPath, allToCtrlFlow.build());
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 7 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project controller by opendaylight.

the class EventSourceTopologyTest method closeTest.

@Test
public void closeTest() throws Exception {
    constructorTestHelper();
    topicTestHelper();
    Map<TopicId, EventSourceTopic> localMap = getEventSourceTopicMap();
    TopicId topicIdMock = mock(TopicId.class);
    EventSourceTopic eventSourceTopic = EventSourceTopic.create(new NotificationPattern("foo"), "pattern", eventSourceTopology);
    localMap.put(topicIdMock, eventSourceTopic);
    eventSourceTopology.close();
    verify(aggregatorRpcReg, times(1)).close();
    verify(listenerRegistrationMock, times(1)).close();
}
Also used : NotificationPattern(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern) TopicId(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId) Test(org.junit.Test)

Example 8 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project controller by opendaylight.

the class EventSourceTopologyTest method unregisterTest.

@Test
public void unregisterTest() throws Exception {
    topicTestHelper();
    EventSource eventSourceMock = mock(EventSource.class);
    NodeId nodeId = new NodeId("nodeIdValue1");
    nodeKey = new NodeKey(nodeId);
    Map<NodeKey, BindingAwareBroker.RoutedRpcRegistration<EventSourceService>> localMap = getRoutedRpcRegistrations();
    NodeKey nodeKeyMock = mock(NodeKey.class);
    doReturn(nodeKeyMock).when(eventSourceMock).getSourceNodeKey();
    BindingAwareBroker.RoutedRpcRegistration<EventSourceService> routedRpcRegistrationMock = mock(BindingAwareBroker.RoutedRpcRegistration.class);
    localMap.put(nodeKeyMock, routedRpcRegistrationMock);
    eventSourceTopology.unRegister(eventSourceMock);
    verify(routedRpcRegistrationMock, times(1)).close();
}
Also used : BindingAwareBroker(org.opendaylight.controller.sal.binding.api.BindingAwareBroker) EventSource(org.opendaylight.controller.messagebus.spi.EventSource) EventSourceService(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) Test(org.junit.Test)

Example 9 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project controller by opendaylight.

the class EventSourceTopologyTest method destroyTopicTest.

@Test
public void destroyTopicTest() throws Exception {
    topicTestHelper();
    TopicId topicId = new TopicId("topic-id-007");
    Map<TopicId, EventSourceTopic> localMap = getEventSourceTopicMap();
    EventSourceTopic eventSourceTopic = EventSourceTopic.create(new NotificationPattern("foo"), "pattern", eventSourceTopology);
    localMap.put(topicId, eventSourceTopic);
    DestroyTopicInput input = new DestroyTopicInputBuilder().setTopicId(topicId).build();
    eventSourceTopology.destroyTopic(input);
    verify(listenerRegistrationMock, times(1)).close();
}
Also used : NotificationPattern(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern) DestroyTopicInput(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicInput) TopicId(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId) DestroyTopicInputBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicInputBuilder) Test(org.junit.Test)

Example 10 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project bgpcep by opendaylight.

the class BgpTopologyDeployerImpl method registerService.

@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public AbstractRegistration registerService(final TopologyReferenceSingletonService topologyProviderService) {
    final Dictionary<String, String> properties = new Hashtable<>();
    properties.put("topology-id", topologyProviderService.getInstanceIdentifier().firstKeyOf(Topology.class).getTopologyId().getValue());
    final ServiceRegistration<?> registerService = this.context.registerService(new String[] { TopologyReference.class.getName() }, topologyProviderService, properties);
    final ClusterSingletonServiceRegistration registerClusterSingletonService = registerSingletonService(topologyProviderService);
    return new AbstractRegistration() {

        @Override
        protected void removeRegistration() {
            try {
                registerClusterSingletonService.close();
            } catch (final Exception e) {
                LOG.warn("Failed to close ClusterSingletonServiceRegistration {} for TopologyBuilder {}", registerClusterSingletonService, topologyProviderService.getInstanceIdentifier(), e);
            } finally {
                registerService.unregister();
            }
        }
    };
}
Also used : Hashtable(java.util.Hashtable) TopologyReference(org.opendaylight.bgpcep.topology.TopologyReference) AbstractRegistration(org.opendaylight.yangtools.concepts.AbstractRegistration) ClusterSingletonServiceRegistration(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)

Aggregations

Test (org.junit.Test)25 InetSocketAddress (java.net.InetSocketAddress)11 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)9 Before (org.junit.Before)8 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)8 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)6 Optional (com.google.common.base.Optional)5 ChannelFuture (io.netty.channel.ChannelFuture)5 ChannelHandler (io.netty.channel.ChannelHandler)5 TimeUnit (java.util.concurrent.TimeUnit)5 Channel (io.netty.channel.Channel)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ExecutionException (java.util.concurrent.ExecutionException)4 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)4 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)4 Notification (org.opendaylight.yangtools.yang.binding.Notification)4 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4