ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/5] incubator-ignite git commit: # ignite-901 WIP
Date Fri, 03 Jul 2015 14:42:45 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-901 4b90d91ab -> 8cafff66f


# ignite-901 WIP


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/33a0816c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/33a0816c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/33a0816c

Branch: refs/heads/ignite-901
Commit: 33a0816c9e7a98148285e69ec72af1dc2e078eb1
Parents: c4abdf4
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Jul 3 15:02:02 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Jul 3 15:02:02 2015 +0300

----------------------------------------------------------------------
 ...IgniteClientReconnectDiscoveryStateTest.java |   9 +-
 .../IgniteClientReconnectServicesTest.java      | 139 +++++++++++++++++++
 .../IgniteClientReconnectTestSuite.java         |   1 +
 3 files changed, 147 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33a0816c/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectDiscoveryStateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectDiscoveryStateTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectDiscoveryStateTest.java
index f1019fb..77927a7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectDiscoveryStateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectDiscoveryStateTest.java
@@ -36,13 +36,18 @@ public class IgniteClientReconnectDiscoveryStateTest extends IgniteClientReconne
         return 3;
     }
 
+    /** {@inheritDoc} */
+    @Override protected int clientCount() {
+        return 1;
+    }
+
     /**
      * @throws Exception If failed.
      */
     public void testReconnect() throws Exception {
-        clientMode = true;
+        final Ignite client = ignite(serverCount());
 
-        final Ignite client = startGrid(serverCount());
+        assertTrue(client.cluster().localNode().isClient());
 
         long topVer = 4;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33a0816c/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectServicesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectServicesTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectServicesTest.java
new file mode 100644
index 0000000..e79f2aa
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectServicesTest.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import org.apache.ignite.*;
+import org.apache.ignite.events.*;
+import org.apache.ignite.internal.processors.service.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.services.*;
+
+import java.util.concurrent.*;
+
+import static java.util.concurrent.TimeUnit.*;
+import static org.apache.ignite.events.EventType.*;
+
+/**
+ * TODO IGNITE-901: fail after disconnect, disconnect when operation in progress, service
deployed on client.
+ */
+public class IgniteClientReconnectServicesTest extends IgniteClientReconnectAbstractTest
{
+    /** {@inheritDoc} */
+    @Override protected int serverCount() {
+        return 1;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected int clientCount() {
+        return 1;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testReconnect() throws Exception {
+        Ignite client = grid(serverCount());
+
+        assertTrue(client.cluster().localNode().isClient());
+
+        IgniteServices services = client.services();
+
+        services.deployClusterSingleton("s1", new TestServiceImpl());
+
+        TestService srvc = services.serviceProxy("s1", TestService.class, false);
+
+        assertNotNull(srvc);
+
+        assertEquals((Object) 2L, srvc.test());
+
+        Ignite srv = clientRouter(client);
+
+        TestTcpDiscoverySpi srvSpi = spi(srv);
+
+        final CountDownLatch reconnectLatch = new CountDownLatch(1);
+
+        client.events().localListen(new IgnitePredicate<Event>() {
+            @Override public boolean apply(Event evt) {
+                if (evt.type() == EVT_CLIENT_NODE_DISCONNECTED)
+                    info("Disconnected: " + evt);
+                else if (evt.type() == EVT_CLIENT_NODE_RECONNECTED) {
+                    info("Reconnected: " + evt);
+
+                    reconnectLatch.countDown();
+                }
+
+                return true;
+            }
+        }, EVT_CLIENT_NODE_DISCONNECTED, EVT_CLIENT_NODE_RECONNECTED);
+
+        srvSpi.failNode(client.cluster().localNode().id(), null);
+
+        assertTrue(reconnectLatch.await(5000, MILLISECONDS));
+
+        CountDownLatch latch = new CountDownLatch(1);
+
+        DummyService.exeLatch("s2", latch);
+
+        services.deployClusterSingleton("s2", new DummyService());
+
+        assertTrue(latch.await(5000, TimeUnit.MILLISECONDS));
+
+        assertEquals((Object) 4L, srvc.test());
+    }
+
+    /**
+     *
+     */
+    public static interface TestService {
+        /**
+         * @return Topology version.
+         */
+        public Long test();
+    }
+
+    /**
+     *
+     */
+    public static class TestServiceImpl implements Service, TestService {
+        /** */
+        @IgniteInstanceResource
+        private Ignite ignite;
+
+        /** {@inheritDoc} */
+        @Override public void cancel(ServiceContext ctx) {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void init(ServiceContext ctx) throws Exception {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void execute(ServiceContext ctx) throws Exception {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public Long test() {
+            assertFalse(ignite.cluster().localNode().isClient());
+
+            return ignite.cluster().topologyVersion();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33a0816c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java
index affbb54..2cfaa56 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java
@@ -40,6 +40,7 @@ public class IgniteClientReconnectTestSuite extends TestSuite {
         suite.addTestSuite(IgniteClientReconnectComputeTest.class);
         suite.addTestSuite(IgniteClientReconnectAtomicsTest.class);
         suite.addTestSuite(IgniteClientReconnectCollectionsTest.class);
+        suite.addTestSuite(IgniteClientReconnectServicesTest.class);
 
         return suite;
     }


Mime
View raw message