use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project genius by opendaylight.
the class ResourceManagerTestModule method configureBindings.
@Override
protected void configureBindings() throws Exception {
DataBroker dataBroker = DataBrokerTestModule.dataBroker();
bind(DataBroker.class).toInstance(dataBroker);
bind(DataImportBootReady.class).toInstance(new DataImportBootReady() {
});
bind(LockManagerService.class).to(LockManagerServiceImpl.class);
bind(LockListener.class);
bind(IdManagerService.class).to(IdManager.class);
bind(ResourceManagerService.class).to(ResourceManager.class);
}
use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project controller by opendaylight.
the class DataServiceIT method test.
/**
* Ignored this, because classes here are constructed from
* very different class loader as MD-SAL is run into,
* this is code is run from different classloader.
*
* @throws Exception
*/
@Test
public void test() throws Exception {
BindingAwareConsumer consumer = session -> dataBroker = session.getSALService(DataBroker.class);
broker.registerConsumer(consumer);
assertNotNull(dataBroker);
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
assertNotNull(transaction);
InstanceIdentifier<UnorderedList> node1 = createNodeRef("0");
Optional<UnorderedList> node = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).checkedGet(5, TimeUnit.SECONDS);
assertFalse(node.isPresent());
UnorderedList nodeData1 = createNode("0");
transaction.put(LogicalDatastoreType.OPERATIONAL, node1, nodeData1);
transaction.submit().checkedGet(5, TimeUnit.SECONDS);
Optional<UnorderedList> readedData = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).checkedGet(5, TimeUnit.SECONDS);
assertTrue(readedData.isPresent());
assertEquals(nodeData1.getKey(), readedData.get().getKey());
final WriteTransaction transaction2 = dataBroker.newWriteOnlyTransaction();
assertNotNull(transaction2);
transaction2.delete(LogicalDatastoreType.OPERATIONAL, node1);
transaction2.submit().checkedGet(5, TimeUnit.SECONDS);
Optional<UnorderedList> readedData2 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).checkedGet(5, TimeUnit.SECONDS);
assertFalse(readedData2.isPresent());
}
use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project controller by opendaylight.
the class ConcurrentImplicitCreateTest method testConcurrentCreate.
@Test
public void testConcurrentCreate() throws InterruptedException, ExecutionException, TimeoutException {
DataBroker dataBroker = testContext.getDataBroker();
WriteTransaction fooTx = dataBroker.newWriteOnlyTransaction();
WriteTransaction barTx = dataBroker.newWriteOnlyTransaction();
fooTx.put(LogicalDatastoreType.OPERATIONAL, FOO_PATH, new TopLevelListBuilder().setKey(FOO_KEY).build());
barTx.put(LogicalDatastoreType.OPERATIONAL, BAR_PATH, new TopLevelListBuilder().setKey(BAR_KEY).build());
fooTx.submit().get(5, TimeUnit.SECONDS);
barTx.submit().get(5, TimeUnit.SECONDS);
}
use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project controller by opendaylight.
the class WildcardedDataChangeListenerTest method testSeparateWrites.
@Test
public void testSeparateWrites() throws InterruptedException, TimeoutException, ExecutionException {
DataBroker dataBroker = testContext.getDataBroker();
final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> eventFuture = SettableFuture.create();
dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, DEEP_WILDCARDED_PATH, dataChangeEvent -> eventFuture.set(dataChangeEvent), DataChangeScope.SUBTREE);
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
transaction.put(LogicalDatastoreType.OPERATIONAL, NODE_0_CWU_PATH, CWU, true);
transaction.put(LogicalDatastoreType.OPERATIONAL, NODE_0_LVU_PATH, LVU, true);
transaction.put(LogicalDatastoreType.OPERATIONAL, NODE_1_LVU_PATH, LVU, true);
transaction.submit().get(5, TimeUnit.SECONDS);
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = eventFuture.get(1000, TimeUnit.MILLISECONDS);
validateEvent(event);
}
use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project controller by opendaylight.
the class DeleteNestedAugmentationListenParentTest method deleteChildListenParent.
@Test
public void deleteChildListenParent() throws InterruptedException, ExecutionException, TimeoutException {
DataBroker dataBroker = testContext.getDataBroker();
final WriteTransaction initTx = dataBroker.newWriteOnlyTransaction();
initTx.put(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, createList11(), true);
initTx.submit().get(5, TimeUnit.SECONDS);
final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> event = SettableFuture.create();
dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, change -> event.set(change), DataChangeScope.SUBTREE);
final WriteTransaction deleteTx = dataBroker.newWriteOnlyTransaction();
deleteTx.delete(LogicalDatastoreType.OPERATIONAL, LIST11_PATH.augmentation(List11SimpleAugment.class));
deleteTx.submit().get(5, TimeUnit.SECONDS);
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> receivedEvent = event.get();
assertFalse(receivedEvent.getRemovedPaths().contains(TLL_COMPLEX_AUGMENT_PATH));
}
Aggregations