Search in sources :

Example 1 with TransactionChainManager

use of org.opendaylight.openflowplugin.common.txchain.TransactionChainManager in project openflowplugin by opendaylight.

the class TransactionChainManagerTest method setUp.

@Before
public void setUp() throws Exception {
    final ReadOnlyTransaction readOnlyTx = Mockito.mock(ReadOnlyTransaction.class);
    final CheckedFuture<Optional<Node>, ReadFailedException> noExistNodeFuture = Futures.immediateCheckedFuture(Optional.<Node>absent());
    Mockito.when(readOnlyTx.read(LogicalDatastoreType.OPERATIONAL, nodeKeyIdent)).thenReturn(noExistNodeFuture);
    Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTx);
    Mockito.when(dataBroker.createTransactionChain(Matchers.any(TransactionChainListener.class))).thenReturn(txChain);
    nodeId = new NodeId("h2g2:42");
    nodeKeyIdent = DeviceStateUtil.createNodeInstanceIdentifier(nodeId);
    Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
    Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
    txChainManager = new TransactionChainManager(dataBroker, nodeId.getValue());
    Mockito.when(txChain.newReadWriteTransaction()).thenReturn(writeTx);
    path = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
    Mockito.when(writeTx.submit()).thenReturn(Futures.<Void, TransactionCommitFailedException>immediateCheckedFuture(null));
    txChainManager.activateTransactionManager();
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Optional(com.google.common.base.Optional) TransactionChainListener(org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) TransactionChainManager(org.opendaylight.openflowplugin.common.txchain.TransactionChainManager) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Before(org.junit.Before)

Example 2 with TransactionChainManager

use of org.opendaylight.openflowplugin.common.txchain.TransactionChainManager in project openflowplugin by opendaylight.

the class FlowCapableTopologyProvider method start.

/**
 * Gets called on start of a bundle.
 */
public void start() {
    final TopologyKey key = new TopologyKey(new TopologyId(TOPOLOGY_ID));
    final InstanceIdentifier<Topology> path = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, key);
    final FlowCapableTopologyExporter listener = new FlowCapableTopologyExporter(processor, path);
    this.listenerRegistration = notificationService.registerNotificationListener(listener);
    this.transactionChainManager = new TransactionChainManager(dataBroker, TOPOLOGY_PROVIDER);
    this.transactionChainManager.activateTransactionManager();
    this.transactionChainManager.initialSubmitWriteTransaction();
    if (!isFlowTopologyExist(path)) {
        transactionChainManager.writeToTransaction(LogicalDatastoreType.OPERATIONAL, path, new TopologyBuilder().setKey(key).build(), true);
        transactionChainManager.submitTransaction();
    }
    LOG.info("FlowCapableTopologyProvider started");
}
Also used : TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) 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) TransactionChainManager(org.opendaylight.openflowplugin.common.txchain.TransactionChainManager) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)

Example 3 with TransactionChainManager

use of org.opendaylight.openflowplugin.common.txchain.TransactionChainManager in project openflowplugin by opendaylight.

the class DeviceContextImpl method lazyTransactionManagerInitialization.

@VisibleForTesting
void lazyTransactionManagerInitialization() {
    if (!this.initialized.get()) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Transaction chain manager for node {} created", deviceInfo);
        }
        this.transactionChainManager = new TransactionChainManager(dataBroker, deviceInfo.getNodeId().getValue());
        this.deviceFlowRegistry = new DeviceFlowRegistryImpl(deviceInfo.getVersion(), dataBroker, deviceInfo.getNodeInstanceIdentifier());
        this.deviceGroupRegistry = new DeviceGroupRegistryImpl();
        this.deviceMeterRegistry = new DeviceMeterRegistryImpl();
    }
    transactionChainManager.activateTransactionManager();
    initialized.set(true);
}
Also used : DeviceGroupRegistryImpl(org.opendaylight.openflowplugin.impl.registry.group.DeviceGroupRegistryImpl) TransactionChainManager(org.opendaylight.openflowplugin.common.txchain.TransactionChainManager) DeviceMeterRegistryImpl(org.opendaylight.openflowplugin.impl.registry.meter.DeviceMeterRegistryImpl) DeviceFlowRegistryImpl(org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

TransactionChainManager (org.opendaylight.openflowplugin.common.txchain.TransactionChainManager)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Optional (com.google.common.base.Optional)1 Before (org.junit.Before)1 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 TransactionChainListener (org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener)1 DeviceFlowRegistryImpl (org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl)1 DeviceGroupRegistryImpl (org.opendaylight.openflowplugin.impl.registry.group.DeviceGroupRegistryImpl)1 DeviceMeterRegistryImpl (org.opendaylight.openflowplugin.impl.registry.meter.DeviceMeterRegistryImpl)1 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)1 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)1 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)1 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)1 TopologyId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)1 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)1 TopologyBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder)1 TopologyKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey)1