use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class DataStoreAppConfigMetadata method init.
@Override
@SuppressWarnings("unchecked")
public void init(final ExtendedBlueprintContainer container) {
super.init(container);
Class<DataObject> appConfigBindingClass;
try {
Class<?> bindingClass = container.getBundleContext().getBundle().loadClass(appConfigBindingClassName);
if (!DataObject.class.isAssignableFrom(bindingClass)) {
throw new ComponentDefinitionException(String.format("%s: Specified app config binding class %s does not extend %s", logName(), appConfigBindingClassName, DataObject.class.getName()));
}
appConfigBindingClass = (Class<DataObject>) bindingClass;
} catch (final ClassNotFoundException e) {
throw new ComponentDefinitionException(String.format("%s: Error loading app config binding class %s", logName(), appConfigBindingClassName), e);
}
bindingContext = BindingContext.create(logName(), appConfigBindingClass, appConfigListKeyValue);
}
use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class DataStoreAppConfigMetadata method onAppConfigChanged.
private void onAppConfigChanged(final Collection<DataTreeModification<DataObject>> changes) {
for (DataTreeModification<DataObject> change : changes) {
DataObjectModification<DataObject> changeRoot = change.getRootNode();
ModificationType type = changeRoot.getModificationType();
LOG.debug("{}: onAppConfigChanged: {}, {}", logName(), type, change.getRootPath());
if (type == ModificationType.SUBTREE_MODIFIED || type == ModificationType.WRITE) {
DataObject newAppConfig = changeRoot.getDataAfter();
LOG.debug("New app config instance: {}, previous: {}", newAppConfig, currentAppConfig);
if (!setInitialAppConfig(Optional.of(newAppConfig)) && !Objects.equals(currentAppConfig, newAppConfig)) {
LOG.debug("App config was updated");
if (appConfigUpdateStrategy == UpdateStrategy.RELOAD) {
restartContainer();
}
}
} else if (type == ModificationType.DELETE) {
LOG.debug("App config was deleted");
if (appConfigUpdateStrategy == UpdateStrategy.RELOAD) {
restartContainer();
}
}
}
}
use of org.opendaylight.yangtools.yang.binding.DataObject 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.yangtools.yang.binding.DataObject 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));
}
use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class WriteParentListenAugmentTest method writeNodeListenAugment.
@Test
public void writeNodeListenAugment() throws Exception {
final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> event = SettableFuture.create();
DataBroker dataBroker = testContext.getDataBroker();
ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> dclRegistration = dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, AUGMENT_WILDCARDED_PATH, change -> event.set(change), DataChangeScope.SUBTREE);
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
TopLevelList tll = new TopLevelListBuilder().setKey(TLL_KEY).addAugmentation(TreeComplexUsesAugment.class, treeComplexUsesAugment("one")).build();
transaction.put(LogicalDatastoreType.OPERATIONAL, TLL_INSTANCE_ID_BA, tll, true);
transaction.submit().get(5, TimeUnit.SECONDS);
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> receivedEvent = event.get(1000, TimeUnit.MILLISECONDS);
assertTrue(receivedEvent.getCreatedData().containsKey(AUGMENT_TLL_PATH));
dclRegistration.close();
final WriteTransaction transaction2 = dataBroker.newWriteOnlyTransaction();
transaction2.put(LogicalDatastoreType.OPERATIONAL, AUGMENT_TLL_PATH, treeComplexUsesAugment("two"));
transaction2.submit().get(5, TimeUnit.SECONDS);
TreeComplexUsesAugment readedAug = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, AUGMENT_TLL_PATH).get(5, TimeUnit.SECONDS).get();
assertEquals("two", readedAug.getContainerWithUses().getLeafFromGrouping());
}
Aggregations