use of org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension in project controller by opendaylight.
the class DOMDataTreeListenerTest method getDOMDataTreeChangeService.
private DOMDataTreeChangeService getDOMDataTreeChangeService() {
final DOMDataBrokerExtension extension = domBroker.getSupportedExtensions().get(DOMDataTreeChangeService.class);
if (extension == null) {
return null;
}
DOMDataTreeChangeService dataTreeChangeService = null;
if (extension instanceof DOMDataTreeChangeService) {
dataTreeChangeService = (DOMDataTreeChangeService) extension;
}
return dataTreeChangeService;
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension in project controller by opendaylight.
the class CrossBrokerMountPointTest method testMountPoint.
@Test
public void testMountPoint() throws ReadFailedException, TimeoutException {
final Integer attrIntValue = 500;
domMountPointService.createMountPoint(TLL_INSTANCE_ID_BI).addService(DOMDataBroker.class, new DOMDataBroker() {
@Override
public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store, final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) {
throw new UnsupportedOperationException();
}
@Override
public DOMDataWriteTransaction newWriteOnlyTransaction() {
throw new UnsupportedOperationException();
}
@Override
public DOMDataReadWriteTransaction newReadWriteTransaction() {
return new DOMDataReadWriteTransaction() {
@Override
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
if (store == LogicalDatastoreType.OPERATIONAL && path.getLastPathArgument().equals(GROUP_STATISTICS_ID_BI.getLastPathArgument())) {
final ContainerNode data = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(AUG_CONT)).withChild(ImmutableNodes.leafNode(QName.create(AUG_CONT, "attr-int"), attrIntValue)).build();
return Futures.immediateCheckedFuture(Optional.<NormalizedNode<?, ?>>of(data));
}
return Futures.immediateFailedCheckedFuture(new ReadFailedException(TLL_NAME, new Exception()));
}
@Override
public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
throw new UnsupportedOperationException();
}
@Override
public Object getIdentifier() {
return this;
}
@Override
public boolean cancel() {
return false;
}
@Override
public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
throw new UnsupportedOperationException();
}
@Override
public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
throw new UnsupportedOperationException();
}
@Override
public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
throw new UnsupportedOperationException();
}
@Override
public CheckedFuture<Void, TransactionCommitFailedException> submit() {
throw new UnsupportedOperationException();
}
};
}
@Override
public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
throw new UnsupportedOperationException();
}
@Override
public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
throw new UnsupportedOperationException();
}
@Override
public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
return Collections.emptyMap();
}
}).register();
final Optional<MountPoint> bindingMountPoint = bindingMountPointService.getMountPoint(TLL_INSTANCE_ID_BA);
assertTrue(bindingMountPoint.isPresent());
final Optional<DataBroker> dataBroker = bindingMountPoint.get().getService(DataBroker.class);
assertTrue(dataBroker.isPresent());
final Optional<Cont> data = dataBroker.get().newReadWriteTransaction().read(LogicalDatastoreType.OPERATIONAL, AUG_CONT_ID_BA).checkedGet(5, TimeUnit.SECONDS);
assertTrue(data.isPresent());
assertEquals(attrIntValue, data.get().getAttrInt());
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension in project bgpcep by opendaylight.
the class AbstractRIBTestSetup method mockedMethods.
@SuppressWarnings("unchecked")
private void mockedMethods() throws Exception {
MockitoAnnotations.initMocks(this);
final ReadOnlyTransaction readTx = mock(ReadOnlyTransaction.class);
doReturn(new listenerRegistration()).when(this.service).registerDataTreeChangeListener(any(DOMDataTreeIdentifier.class), any(ClusteredDOMDataTreeChangeListener.class));
final Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> map = new HashMap<>();
map.put(DOMDataTreeChangeService.class, this.service);
doNothing().when(readTx).close();
final CheckedFuture<Optional<DataObject>, ReadFailedException> readFuture = mock(CheckedFuture.class);
doNothing().when(this.domTransWrite).put(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
doNothing().when(this.domTransWrite).delete(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class));
doNothing().when(this.domTransWrite).merge(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
doReturn(Optional.absent()).when(readFuture).checkedGet();
doReturn(readFuture).when(readTx).read(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class));
doNothing().when(this.domChain).close();
doReturn(this.domTransWrite).when(this.domChain).newWriteOnlyTransaction();
doNothing().when(getTransaction()).put(eq(LogicalDatastoreType.OPERATIONAL), eq(YangInstanceIdentifier.of(BgpRib.QNAME)), any(NormalizedNode.class));
doReturn(map).when(this.dom).getSupportedExtensions();
doReturn(this.domChain).when(this.dom).createTransactionChain(any(BGPPeer.class));
doReturn(this.transWrite).when(this.chain).newWriteOnlyTransaction();
doReturn(false).when(this.o).isPresent();
doReturn(this.o).when(this.future).checkedGet();
doReturn(this.future).when(this.domTransWrite).submit();
doNothing().when(this.future).addListener(any(Runnable.class), any(Executor.class));
doNothing().when(this.transWrite).put(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class), any(DataObject.class), eq(true));
doNothing().when(this.transWrite).put(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class), any(DataObject.class));
doReturn(this.future).when(this.transWrite).submit();
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension in project controller by opendaylight.
the class TracingBroker method getSupportedExtensions.
@Nonnull
@Override
public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> res = delegate.getSupportedExtensions();
DOMDataTreeChangeService treeChangeSvc = (DOMDataTreeChangeService) res.get(DOMDataTreeChangeService.class);
if (treeChangeSvc == null) {
return res;
}
res = new HashMap<>(res);
res.put(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() {
@Nonnull
@Override
public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(@Nonnull DOMDataTreeIdentifier domDataTreeIdentifier, @Nonnull L listener) {
if (isRegistrationWatched(domDataTreeIdentifier.getRootIdentifier(), domDataTreeIdentifier.getDatastoreType(), DataChangeScope.SUBTREE)) {
LOG.warn("{} registration (registerDataTreeChangeListener) for {} from {}.", listener instanceof ClusteredDOMDataTreeChangeListener ? "Clustered" : "Non-clustered", toPathString(domDataTreeIdentifier.getRootIdentifier()), getStackSummary());
}
return treeChangeSvc.registerDataTreeChangeListener(domDataTreeIdentifier, listener);
}
});
return res;
}
Aggregations