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();
}
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");
}
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);
}
Aggregations