- private void applyModifyTransactionRequest(final ModifyTransactionRequest request,
- final @Nullable Consumer<Response<?, ?>> callback) {
- for (TransactionModification mod : request.getModifications()) {
- if (mod instanceof TransactionWrite) {
- modification.write(mod.getPath(), ((TransactionWrite)mod).getData());
- } else if (mod instanceof TransactionMerge) {
- modification.merge(mod.getPath(), ((TransactionMerge)mod).getData());
- } else if (mod instanceof TransactionDelete) {
- modification.delete(mod.getPath());
- } else {
- throw new IllegalArgumentException("Unsupported modification " + mod);
+ private boolean handleReadRequest(final TransactionRequest<?> request,
+ @Nullable final Consumer<Response<?, ?>> callback) {
+ // Note we delay completion of read requests to limit the scope at which the client can run, as they have
+ // listeners, which we do not want to execute while we are reconnecting.
+ if (request instanceof ReadTransactionRequest) {
+ final YangInstanceIdentifier path = ((ReadTransactionRequest) request).getPath();
+ final Optional<NormalizedNode<?, ?>> result = readOnlyView().readNode(path);
+ if (callback != null) {
+ // XXX: FB does not see that callback is final, on stack and has be check for non-null.
+ final Consumer<Response<?, ?>> fbIsStupid = Preconditions.checkNotNull(callback);
+ executeInActor(() -> fbIsStupid.accept(new ReadTransactionSuccess(request.getTarget(),
+ request.getSequence(), result)));