You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ir...@apache.org on 2018/05/22 13:45:57 UTC
ignite git commit: IGNITE-8501 Retry on GridServiceNotFoundException
in GridServiceProxy needs to be fixed - Fixes #4004.
Repository: ignite
Updated Branches:
refs/heads/master ce8e31e28 -> 7c2fe6472
IGNITE-8501 Retry on GridServiceNotFoundException in GridServiceProxy needs to be fixed - Fixes #4004.
Signed-off-by: Ivan Rakov <ir...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7c2fe647
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7c2fe647
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7c2fe647
Branch: refs/heads/master
Commit: 7c2fe6472ecaa940ded38649d0a40abea99f383f
Parents: ce8e31e
Author: Stanislav Lukyanov <st...@gmail.com>
Authored: Tue May 22 16:43:45 2018 +0300
Committer: Ivan Rakov <ir...@apache.org>
Committed: Tue May 22 16:43:45 2018 +0300
----------------------------------------------------------------------
.../processors/service/GridServiceProxy.java | 22 +++++--
...GridServiceProxyClientReconnectSelfTest.java | 62 +++++++++++++++++++-
2 files changed, 78 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c2fe647/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
index c5a2cee..eb75a5b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
@@ -206,13 +206,25 @@ public class GridServiceProxy<T> implements Serializable {
throw e;
}
catch (IgniteCheckedException e) {
- // Rethrow original service method exception so that calling user code can handle it correctly.
- ServiceProxyException svcProxyE = X.cause(e, ServiceProxyException.class);
+ // Check if ignorable exceptions are in the cause chain.
+ Throwable ignorableCause = X.cause(e, GridServiceNotFoundException.class);
- if (svcProxyE != null)
- throw svcProxyE.getCause();
+ if (ignorableCause == null)
+ ignorableCause = X.cause(e, ClusterTopologyCheckedException.class);
- throw U.convertException(e);
+ if (ignorableCause != null) {
+ if (log.isDebugEnabled())
+ log.debug("Service was not found or topology changed (will retry): " + ignorableCause.getMessage());
+ }
+ else {
+ // Rethrow original service method exception so that calling user code can handle it correctly.
+ ServiceProxyException svcProxyE = X.cause(e, ServiceProxyException.class);
+
+ if (svcProxyE != null)
+ throw svcProxyE.getCause();
+
+ throw U.convertException(e);
+ }
}
catch (Exception e) {
throw new IgniteException(e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c2fe647/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java
index d2fda2f..5fdcdc4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java
@@ -82,13 +82,49 @@ public class GridServiceProxyClientReconnectSelfTest extends GridCommonAbstractT
startGrid("server");
- assert latch.await(10, TimeUnit.SECONDS);
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
client.services().deployClusterSingleton("my-service", new MyServiceImpl());
assertEquals(42, proxy.hello());
}
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClientReconnectLongServiceInit() throws Exception {
+ startGrid("server");
+
+ Ignite client = startGrid("client");
+
+ client.services().deployClusterSingleton("my-service", new MyLongInitServiceImpl());
+
+ MyService proxy = client.services().serviceProxy("my-service", MyService.class, false);
+
+ assertEquals(9001, proxy.hello());
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ client.events().localListen(new IgnitePredicate<Event>() {
+ @Override public boolean apply(Event event) {
+ latch.countDown();
+
+ return true;
+ }
+ }, EventType.EVT_CLIENT_NODE_RECONNECTED);
+
+ stopGrid("server");
+
+ startGrid("server");
+
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
+
+ client.services().deployClusterSingleton("my-service", new MyLongInitServiceImpl());
+
+ assertEquals(9001, proxy.hello());
+ }
+
/**
*/
private interface MyService extends Service {
@@ -121,4 +157,28 @@ public class GridServiceProxyClientReconnectSelfTest extends GridCommonAbstractT
// No-op.
}
}
+
+ /**
+ */
+ private static class MyLongInitServiceImpl implements MyService {
+ /** {@inheritDoc} */
+ @Override public int hello() {
+ return 9001;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cancel(ServiceContext ctx) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(ServiceContext ctx) throws Exception {
+ Thread.sleep(5_000);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+ }
}