We are not using the transform(), do not wrap the futures we are using.
Change-Id: Iaf061e2d9a0feb867373265d33afd200d8beab48
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import static java.util.Objects.requireNonNull;
-import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import java.util.Optional;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@Override
public ListenableFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store,
final YangInstanceIdentifier path) {
- try (DOMDataTreeReadTransaction tx = dataBroker.newReadOnlyTransaction()) {
+ try (var tx = dataBroker.newReadOnlyTransaction()) {
return tx.read(store, path);
}
}
}
@Override
- public FluentFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- try (DOMDataTreeReadTransaction tx = dataBroker.newReadOnlyTransaction()) {
+ public ListenableFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+ try (var tx = dataBroker.newReadOnlyTransaction()) {
return tx.exists(store, path);
}
}
import static java.util.Objects.requireNonNull;
-import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
}
@Override
- public FluentFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- return remapException(read(store, path))
- .transform(optionalNode -> optionalNode != null && optionalNode.isPresent(),
- MoreExecutors.directExecutor());
+ public ListenableFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+ return Futures.transform(remapException(read(store, path)),
+ optionalNode -> optionalNode != null && optionalNode.isPresent(),
+ MoreExecutors.directExecutor());
}
- private static <T> FluentFuture<T> remapException(final ListenableFuture<T> input) {
- final SettableFuture<T> ret = SettableFuture.create();
+ private static <T> ListenableFuture<T> remapException(final ListenableFuture<T> input) {
+ final var ret = SettableFuture.<T>create();
Futures.addCallback(input, new FutureCallback<T>() {
-
@Override
public void onSuccess(final T result) {
ret.set(result);
: new ReadFailedException("NETCONF operation failed", cause));
}
}, MoreExecutors.directExecutor());
- return FluentFuture.from(ret);
+ return ret;
}
}
*/
package org.opendaylight.restconf.nb.rfc8040.rests.transactions;
-import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import java.util.Optional;
* @param path the data object path
* @return a FluentFuture containing the result of the check
*/
- public abstract FluentFuture<Boolean> exists(LogicalDatastoreType store, YangInstanceIdentifier path);
+ public abstract ListenableFuture<Boolean> exists(LogicalDatastoreType store, YangInstanceIdentifier path);
}
package org.opendaylight.restconf.nb.rfc8040.rests.utils;
import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.ListenableFuture;
import java.net.URI;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
* @param isExistsFuture if checked data exists
* @param path Path to be checked
*/
- public static void checkItemDoesNotExists(final FluentFuture<Boolean> isExistsFuture,
+ public static void checkItemDoesNotExists(final ListenableFuture<Boolean> isExistsFuture,
final YangInstanceIdentifier path) {
final FutureDataFactory<Boolean> response = new FutureDataFactory<>();
FutureCallbackTx.addCallback(isExistsFuture, POST_TX_TYPE, response);
package org.opendaylight.restconf.nb.rfc8040.rests.utils;
import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.ListenableFuture;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.opendaylight.mdsal.common.api.CommitInfo;
final RestconfStrategy strategy, final WriteDataParams params) {
final YangInstanceIdentifier path = payload.getInstanceIdentifierContext().getInstanceIdentifier();
- final FluentFuture<Boolean> existsFuture = strategy.exists(LogicalDatastoreType.CONFIGURATION, path);
+ final ListenableFuture<Boolean> existsFuture = strategy.exists(LogicalDatastoreType.CONFIGURATION, path);
final FutureDataFactory<Boolean> existsResponse = new FutureDataFactory<>();
FutureCallbackTx.addCallback(existsFuture, PUT_TX_TYPE, existsResponse);