final FutureDataFactory<? super T> dataFactory, final YangInstanceIdentifier path)
throws RestconfDocumentedException {
try {
- final T result = listenableFuture.get();
- dataFactory.setResult(result);
- LOG.trace("Transaction({}) SUCCESSFUL", txType);
+ listenableFuture.get();
} catch (InterruptedException e) {
dataFactory.setFailureStatus();
LOG.warn("Transaction({}) FAILED!", txType, e);
throw new RestconfDocumentedException("Transaction failed", e);
}
}
+
+ LOG.trace("Transaction({}) SUCCESSFUL", txType);
}
}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.restconf.nb.rfc8040.rests.utils;
-
-import java.util.Optional;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-final class NormalizedNodeFactory extends FutureDataFactory<Optional<NormalizedNode>> {
- @Nullable NormalizedNode build() {
- return result.orElse(null);
- }
-}
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Optional;
+import java.util.concurrent.ExecutionException;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
*/
static @Nullable NormalizedNode readDataViaTransaction(final @NonNull RestconfStrategy strategy,
final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- return extractReadData(strategy, path, strategy.read(store, path));
+ return extractReadData(path, strategy.read(store, path));
}
/**
private static @Nullable NormalizedNode readDataViaTransaction(final @NonNull RestconfStrategy strategy,
final @NonNull LogicalDatastoreType store, final @NonNull YangInstanceIdentifier path,
final @NonNull List<YangInstanceIdentifier> fields) {
- return extractReadData(strategy, path, strategy.read(store, path, fields));
+ return extractReadData(path, strategy.read(store, path, fields));
}
- private static NormalizedNode extractReadData(final RestconfStrategy strategy,
- final YangInstanceIdentifier path, final ListenableFuture<Optional<NormalizedNode>> dataFuture) {
- final var dataFactory = new NormalizedNodeFactory();
- FutureCallbackTx.addCallback(dataFuture, "READ", dataFactory, path);
- return dataFactory.build();
+ private static @Nullable NormalizedNode extractReadData(final YangInstanceIdentifier path,
+ final ListenableFuture<Optional<NormalizedNode>> dataFuture) {
+ try {
+ return dataFuture.get().orElse(null);
+ } catch (ExecutionException e) {
+ throw new RestconfDocumentedException("Failed to access " + path, e);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new RestconfDocumentedException("Interrupted while accessing " + path, e);
+ }
}
/**