use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class BindingDOMRpcImplementationAdapter method invokeRpc.
@Nonnull
@Override
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
final SchemaPath schemaPath = rpc.getType();
final DataObject bindingInput = input != null ? deserialize(rpc.getType(), input) : null;
final ListenableFuture<RpcResult<?>> bindingResult = invoke(schemaPath, bindingInput);
return transformResult(bindingResult);
}
use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class WildcardedDataChangeListenerTest method testNoChangeOnReplaceWithSameValue.
@Test
public void testNoChangeOnReplaceWithSameValue() throws InterruptedException, TimeoutException, ExecutionException {
DataBroker dataBroker = testContext.getDataBroker();
// We wrote initial state NODE_0_FLOW
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
transaction.put(LogicalDatastoreType.OPERATIONAL, NODE_0_LVU_PATH, LVU, true);
transaction.submit().get(5, TimeUnit.SECONDS);
// We registered DataChangeListener
final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> eventFuture = SettableFuture.create();
dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, DEEP_WILDCARDED_PATH, dataChangeEvent -> eventFuture.set(dataChangeEvent), DataChangeScope.SUBTREE);
assertFalse(eventFuture.isDone());
final WriteTransaction secondTx = dataBroker.newWriteOnlyTransaction();
secondTx.put(LogicalDatastoreType.OPERATIONAL, NODE_0_LVU_PATH, LVU, true);
secondTx.put(LogicalDatastoreType.OPERATIONAL, NODE_1_LVU_PATH, LVU, true);
secondTx.submit().get(5, TimeUnit.SECONDS);
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = eventFuture.get(1000, TimeUnit.MILLISECONDS);
assertNotNull(event);
// Data change should contains NODE_1 Flow - which was added
assertTrue(event.getCreatedData().containsKey(NODE_1_LVU_PATH));
// Data change must not containe NODE_0 Flow which was replaced with same value.
assertFalse(event.getUpdatedData().containsKey(NODE_0_LVU_PATH));
}
use of org.opendaylight.yangtools.yang.binding.DataObject 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.yangtools.yang.binding.DataObject in project bgpcep by opendaylight.
the class NodeChangedListener method onDataTreeChanged.
@Override
public void onDataTreeChanged(final Collection<DataTreeModification<Node>> changes) {
final ReadWriteTransaction trans = this.dataProvider.newReadWriteTransaction();
final Set<InstanceIdentifier<ReportedLsp>> lsps = new HashSet<>();
final Set<InstanceIdentifier<Node>> nodes = new HashSet<>();
final Map<InstanceIdentifier<?>, DataObject> original = new HashMap<>();
final Map<InstanceIdentifier<?>, DataObject> updated = new HashMap<>();
final Map<InstanceIdentifier<?>, DataObject> created = new HashMap<>();
for (final DataTreeModification<?> change : changes) {
final InstanceIdentifier<?> iid = change.getRootPath().getRootIdentifier();
final DataObjectModification<?> rootNode = change.getRootNode();
handleChangedNode(rootNode, iid, lsps, nodes, original, updated, created);
}
// Now walk all nodes, check for removals/additions and cascade them to LSPs
for (final InstanceIdentifier<Node> iid : nodes) {
enumerateLsps(iid, (Node) original.get(iid), lsps);
enumerateLsps(iid, (Node) updated.get(iid), lsps);
enumerateLsps(iid, (Node) created.get(iid), lsps);
}
// We now have list of all affected LSPs. Walk them create/remove them
updateTransaction(trans, lsps, original, updated, created);
Futures.addCallback(JdkFutureAdapters.listenInPoolThread(trans.submit()), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
LOG.trace("Topology change committed successfully");
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Failed to propagate a topology change, target topology became inconsistent", throwable);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yangtools.yang.binding.DataObject in project openflowplugin by opendaylight.
the class ListDeserializerTest method test.
/**
* Tests {@link ListDeserializer#deserializeList(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)}.
*/
@Test
public void test() {
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
List<DataObject> list = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, 42, buffer, keyMaker, registry);
Assert.assertNull("List is not null", list);
}
Aggregations