summaryrefslogtreecommitdiffstats
path: root/infra/rpc
diff options
context:
space:
mode:
authorMichal Cmarada <mcmarada@cisco.com>2019-04-08 11:37:45 +0200
committerMichal Cmarada <mcmarada@cisco.com>2019-04-08 11:37:45 +0200
commitb16cea20258ba537db7c0755208c82ab93331ff7 (patch)
tree8a5a3c87069b9ce700c34323e75ff434e7acae97 /infra/rpc
parent23979469bcf8cd312cb3ec9e9e548003110f68f4 (diff)
HONEYCOMB-443: ODL bump to Neon
- bumps ODL dependencies to neon - migrates guava optional to java.utils.optional Change-Id: Ibdaa365c7e21a341103aba88dfd67277e40d2969 Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Diffstat (limited to 'infra/rpc')
-rw-r--r--infra/rpc/api/src/main/java/io/fd/honeycomb/rpc/RpcException.java2
-rw-r--r--infra/rpc/impl/src/main/java/io/fd/honeycomb/rpc/HoneycombDOMRpcService.java24
-rw-r--r--infra/rpc/impl/src/main/java/io/fd/honeycomb/rpc/RpcRegistryBuilder.java2
-rw-r--r--infra/rpc/impl/src/test/java/io/fd/honeycomb/rpc/HoneycombDOMRpcServiceTest.java5
-rw-r--r--infra/rpc/impl/src/test/java/io/fd/honeycomb/rpc/RpcRegistryBuilderTest.java5
5 files changed, 17 insertions, 21 deletions
diff --git a/infra/rpc/api/src/main/java/io/fd/honeycomb/rpc/RpcException.java b/infra/rpc/api/src/main/java/io/fd/honeycomb/rpc/RpcException.java
index 907ce6c15..72d1a8835 100644
--- a/infra/rpc/api/src/main/java/io/fd/honeycomb/rpc/RpcException.java
+++ b/infra/rpc/api/src/main/java/io/fd/honeycomb/rpc/RpcException.java
@@ -17,7 +17,7 @@
package io.fd.honeycomb.rpc;
import com.google.common.annotations.Beta;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
+import org.opendaylight.mdsal.dom.api.DOMRpcException;
@Beta
public class RpcException extends DOMRpcException {
diff --git a/infra/rpc/impl/src/main/java/io/fd/honeycomb/rpc/HoneycombDOMRpcService.java b/infra/rpc/impl/src/main/java/io/fd/honeycomb/rpc/HoneycombDOMRpcService.java
index d951ff962..49a8b4346 100644
--- a/infra/rpc/impl/src/main/java/io/fd/honeycomb/rpc/HoneycombDOMRpcService.java
+++ b/infra/rpc/impl/src/main/java/io/fd/honeycomb/rpc/HoneycombDOMRpcService.java
@@ -18,19 +18,18 @@ package io.fd.honeycomb.rpc;
import static net.javacrumbs.futureconverter.java8guava.FutureConverter.toListenableFuture;
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -39,9 +38,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
public final class HoneycombDOMRpcService implements DOMRpcService {
- private static final Function<? super Exception, DOMRpcException> ANY_EX_TO_RPC_EXCEPTION_MAPPER =
- e -> (e instanceof DOMRpcException) ? (DOMRpcException) e : new RpcException("RPC failed", e);
-
private final BindingNormalizedNodeSerializer serializer;
private final RpcRegistry rpcRegistry;
@@ -53,8 +49,8 @@ public final class HoneycombDOMRpcService implements DOMRpcService {
@Nonnull
@Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull final SchemaPath schemaPath,
- @Nullable final NormalizedNode<?, ?> normalizedNode) {
+ public FluentFuture<DOMRpcResult> invokeRpc(@Nonnull final SchemaPath schemaPath,
+ @Nullable final NormalizedNode<?, ?> normalizedNode) {
DataObject input = null;
if (normalizedNode != null) {
// RPC input is optional
@@ -63,7 +59,7 @@ public final class HoneycombDOMRpcService implements DOMRpcService {
}
final CompletableFuture<DataObject> result = rpcRegistry.invoke(schemaPath, input).toCompletableFuture();
final ListenableFuture<DOMRpcResult> output = getDOMRpcResult(toListenableFuture(result));
- return Futures.makeChecked(output, ANY_EX_TO_RPC_EXCEPTION_MAPPER);
+ return FluentFuture.from(output);
}
private ListenableFuture<DOMRpcResult> getDOMRpcResult(final ListenableFuture<DataObject> invoke) {
@@ -76,7 +72,7 @@ public final class HoneycombDOMRpcService implements DOMRpcService {
outputNode = serializer.toNormalizedNodeRpcData(output);
}
return new DefaultDOMRpcResult(outputNode);
- });
+ }, MoreExecutors.directExecutor());
}
@Nonnull
diff --git a/infra/rpc/impl/src/main/java/io/fd/honeycomb/rpc/RpcRegistryBuilder.java b/infra/rpc/impl/src/main/java/io/fd/honeycomb/rpc/RpcRegistryBuilder.java
index ca6441ee8..aba79ad13 100644
--- a/infra/rpc/impl/src/main/java/io/fd/honeycomb/rpc/RpcRegistryBuilder.java
+++ b/infra/rpc/impl/src/main/java/io/fd/honeycomb/rpc/RpcRegistryBuilder.java
@@ -22,7 +22,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.slf4j.Logger;
diff --git a/infra/rpc/impl/src/test/java/io/fd/honeycomb/rpc/HoneycombDOMRpcServiceTest.java b/infra/rpc/impl/src/test/java/io/fd/honeycomb/rpc/HoneycombDOMRpcServiceTest.java
index 7b27fec4e..c47590887 100644
--- a/infra/rpc/impl/src/test/java/io/fd/honeycomb/rpc/HoneycombDOMRpcServiceTest.java
+++ b/infra/rpc/impl/src/test/java/io/fd/honeycomb/rpc/HoneycombDOMRpcServiceTest.java
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.when;
import java.net.URI;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -74,13 +75,13 @@ public class HoneycombDOMRpcServiceTest {
assertEquals(outputBi, service.invokeRpc(path, node).get().getResult());
}
- @Test(expected = RpcException.class)
+ @Test(expected = ExecutionException.class)
public void testInvokeRpcFailed() throws Exception {
final CompletableFuture future = new CompletableFuture();
future.completeExceptionally(new RuntimeException());
when(registry.invoke(path, input)).thenReturn(future);
- service.invokeRpc(path, node).checkedGet();
+ service.invokeRpc(path, node).get();
}
private ContainerNode mockContainerNode(final QName nn1) {
diff --git a/infra/rpc/impl/src/test/java/io/fd/honeycomb/rpc/RpcRegistryBuilderTest.java b/infra/rpc/impl/src/test/java/io/fd/honeycomb/rpc/RpcRegistryBuilderTest.java
index d021555b8..4c7686fa1 100644
--- a/infra/rpc/impl/src/test/java/io/fd/honeycomb/rpc/RpcRegistryBuilderTest.java
+++ b/infra/rpc/impl/src/test/java/io/fd/honeycomb/rpc/RpcRegistryBuilderTest.java
@@ -20,13 +20,12 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.net.URI;
-import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@@ -68,7 +67,7 @@ public class RpcRegistryBuilderTest {
}
@Test
- public void testServiceNotFound() throws ExecutionException, InterruptedException {
+ public void testServiceNotFound() {
final SchemaPath id = SchemaPath.ROOT.createChild(QName.create(namespace, "c"));
final DataObject request = Mockito.mock(DataObject.class);