use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project genius by opendaylight.
the class TestInterfaceManager method addInterfaceInfo.
public void addInterfaceInfo(InterfaceInfo interfaceInfo) throws TransactionCommitFailedException {
interfaceInfos.put(interfaceInfo.getInterfaceName(), interfaceInfo);
if (optDataBroker.isPresent()) {
// Can't use ifPresent() here because of checked exception from tx.submit().checkedGet();
DataBroker dataBroker = optDataBroker.get();
ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
Interface iface = InterfaceHelper.buildVlanInterfaceFromInfo(interfaceInfo);
// Add the interface to config ds so that if the application reads from configds it finds it there
tx.put(LogicalDatastoreType.CONFIGURATION, InterfaceHelper.buildIId(interfaceInfo.getInterfaceName()), iface);
// Add the interface to oper ds so that if the application reads from configds it finds it there
tx.put(LogicalDatastoreType.OPERATIONAL, InterfaceStateHelper.buildStateInterfaceIid(interfaceInfo.getInterfaceName()), InterfaceStateHelper.buildStateFromInterfaceInfo(interfaceInfo));
tx.submit().checkedGet();
addInterface(iface);
}
}
use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project genius by opendaylight.
the class IdManagerTestModule method configureBindings.
@Override
protected void configureBindings() {
bind(DataImportBootReady.class).annotatedWith(OsgiService.class).toInstance(new DataImportBootReady() {
});
bind(IdManagerService.class).to(IdManager.class);
bind(LockManagerService.class).to(LockManagerServiceImpl.class);
TestIMdsalApiManager mdsalManager = TestIMdsalApiManager.newInstance();
bind(IMdsalApiManager.class).toInstance(mdsalManager);
bind(TestIMdsalApiManager.class).toInstance(mdsalManager);
bind(LockListener.class);
bind(IdPoolListener.class);
bind(JobCoordinatorEventsWaiter.class).to(TestableJobCoordinatorEventsWaiter.class);
DataBroker dataBroker = DataBrokerTestModule.dataBroker();
bind(DataBroker.class).toInstance(dataBroker);
bind(DataBroker.class).annotatedWith(OsgiService.class).toInstance(dataBroker);
}
use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project genius by opendaylight.
the class SingleTransactionDataBroker method syncUpdate.
public static <T extends DataObject> void syncUpdate(DataBroker broker, LogicalDatastoreType datastoreType, InstanceIdentifier<T> path, T data, int maxRetries) throws TransactionCommitFailedException {
RetryingManagedNewTransactionRunner runner = new RetryingManagedNewTransactionRunner(broker, maxRetries);
ListenableFutures.checkedGet(runner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.merge(datastoreType, path, data, true)), SUBMIT_MAPPER);
}
use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project genius by opendaylight.
the class SingleTransactionDataBroker method syncDelete.
public static <T extends DataObject> void syncDelete(DataBroker broker, LogicalDatastoreType datastoreType, InstanceIdentifier<T> path, int maxRetries) throws TransactionCommitFailedException {
RetryingManagedNewTransactionRunner runner = new RetryingManagedNewTransactionRunner(broker, maxRetries);
ListenableFutures.checkedGet(runner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.delete(datastoreType, path)), SUBMIT_MAPPER);
}
use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project genius by opendaylight.
the class SingleTransactionDataBroker method syncWrite.
public static <T extends DataObject> void syncWrite(DataBroker broker, LogicalDatastoreType datastoreType, InstanceIdentifier<T> path, T data, int maxRetries) throws TransactionCommitFailedException {
RetryingManagedNewTransactionRunner runner = new RetryingManagedNewTransactionRunner(broker, maxRetries);
ListenableFutures.checkedGet(runner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(datastoreType, path, data, true)), SUBMIT_MAPPER);
}
Aggregations