Search in sources :

Example 1 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.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 2 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.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 3 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.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 4 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.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 5 with Close

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

the class TxchainBaWrite method executeList.

@Override
public void executeList() {
    final BindingTransactionChain chain = bindingDataBroker.createTransactionChain(this);
    final LogicalDatastoreType dsType = getDataStoreType();
    WriteTransaction tx = chain.newWriteOnlyTransaction();
    int txSubmitted = 0;
    int writeCnt = 0;
    for (OuterList element : this.list) {
        InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class).child(OuterList.class, element.getKey());
        if (oper == StartTestInput.Operation.PUT) {
            tx.put(dsType, iid, element);
        } else {
            tx.merge(dsType, iid, element);
        }
        writeCnt++;
        if (writeCnt == writesPerTx) {
            txSubmitted++;
            Futures.addCallback(tx.submit(), new FutureCallback<Void>() {

                @Override
                public void onSuccess(final Void result) {
                    txOk++;
                }

                @Override
                public void onFailure(final Throwable t) {
                    LOG.error("Transaction failed, {}", t);
                    txError++;
                }
            });
            tx = chain.newWriteOnlyTransaction();
            writeCnt = 0;
        }
    }
    // We need to empty the transaction chain before closing it
    try {
        txSubmitted++;
        tx.submit().checkedGet();
        txOk++;
    } catch (final TransactionCommitFailedException e) {
        LOG.error("Transaction failed", e);
        txError++;
    }
    try {
        chain.close();
    } catch (final IllegalStateException e) {
        LOG.error("Transaction close failed,", e);
    }
    LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError));
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) BindingTransactionChain(org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain) OuterList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) TestExec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)

Aggregations

Test (org.junit.Test)23 InetSocketAddress (java.net.InetSocketAddress)12 Before (org.junit.Before)11 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)9 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)8 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)8 TimeUnit (java.util.concurrent.TimeUnit)7 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)7 Optional (com.google.common.base.Optional)6 ChannelFuture (io.netty.channel.ChannelFuture)6 ChannelHandler (io.netty.channel.ChannelHandler)6 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)6 Notification (org.opendaylight.yangtools.yang.binding.Notification)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 Channel (io.netty.channel.Channel)4 List (java.util.List)4 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)4 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4