ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [5/5] incubator-ignite git commit: # ignite-709_3 do not create system caches on client nodes
Date Thu, 14 May 2015 11:58:53 GMT
# ignite-709_3 do not create system caches on client nodes


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

Branch: refs/heads/ignite-709_3
Commit: 7ed0ddf29fc9baae66ca2fb9e3be960e0b7e295b
Parents: 1ede1d0
Author: sboikov <sboikov@gridgain.com>
Authored: Thu May 14 14:58:39 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Thu May 14 14:58:39 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java    | 21 ++++-----
 .../datastructures/DataStructuresProcessor.java | 10 ++++-
 .../IgniteClientDataStructuresAbstractTest.java | 47 ++++++++++++++++++++
 3 files changed, 67 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7ed0ddf2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index e63dd8b..8771515 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -736,13 +736,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         if (marshallerCache() == null) {
             assert ctx.config().isClientMode() : "Marshaller cache is missed on server node.";
 
-            DynamicCacheDescriptor desc = registeredCaches.get(CU.MARSH_CACHE_NAME);
-
-            assert desc != null && desc.cacheConfiguration() != null && desc.cacheType().equals(CacheType.MARSHALLER);
-
-            // On client node user near-only marshaller cache.
-            IgniteInternalFuture<?> fut = dynamicStartCache(desc.cacheConfiguration(),
-                CU.MARSH_CACHE_NAME, new NearCacheConfiguration(), desc.cacheType(), false);
+            // On client node use near-only marshaller cache.
+            IgniteInternalFuture<?> fut = startCacheAsync(CU.MARSH_CACHE_NAME, new
NearCacheConfiguration(), false);
 
             assert fut != null;
 
@@ -2554,7 +2549,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         if (internalCache(CU.UTILITY_CACHE_NAME) != null)
             return new GridFinishedFuture<>();
 
-        return startCacheAsync(CU.UTILITY_CACHE_NAME, true);
+        return startCacheAsync(CU.UTILITY_CACHE_NAME, null, true);
     }
 
     /**
@@ -2634,7 +2629,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @throws IgniteCheckedException If failed.
      */
     private IgniteCache startJCache(String cacheName, boolean failIfNotStarted) throws IgniteCheckedException
{
-        IgniteInternalFuture<?> fut = startCacheAsync(cacheName, failIfNotStarted);
+        IgniteInternalFuture<?> fut = startCacheAsync(cacheName, null, failIfNotStarted);
 
         if (fut != null) {
             fut.get();
@@ -2654,11 +2649,15 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
     /**
      * @param cacheName Cache name.
+     * @param nearCfg Near cache configuration.
      * @param failIfNotStarted If {@code true} throws {@link IllegalArgumentException} if
cache is not started,
      *        otherwise returns {@code null} in this case.
      * @return Future.
      */
-    @Nullable private IgniteInternalFuture<?> startCacheAsync(String cacheName, boolean
failIfNotStarted) {
+    @Nullable public IgniteInternalFuture<?> startCacheAsync(String cacheName,
+        @Nullable NearCacheConfiguration nearCfg,
+        boolean failIfNotStarted)
+    {
         String masked = maskNull(cacheName);
 
         DynamicCacheDescriptor desc = registeredCaches.get(masked);
@@ -2686,6 +2685,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         req.clientStartOnly(true);
 
+        req.nearCacheConfiguration(nearCfg);
+
         return F.first(initiateCacheChanges(F.asList(req)));
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7ed0ddf2/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index b8d5bef..0a90e32 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -123,7 +123,15 @@ public final class DataStructuresProcessor extends GridProcessorAdapter
{
         assert utilityCache != null;
 
         if (atomicCfg != null) {
-            IgniteInternalCache atomicsCache = ctx.cache().getOrStartCache(CU.ATOMICS_CACHE_NAME);
+            IgniteInternalCache atomicsCache = ctx.cache().internalCache(CU.ATOMICS_CACHE_NAME);
+
+            if (atomicsCache == null) {
+                assert ctx.config().isClientMode() : "Atomics cache is missed on server node.";
+
+                ctx.cache().startCacheAsync(CU.ATOMICS_CACHE_NAME, new NearCacheConfiguration(),
true).get();
+
+                atomicsCache = ctx.cache().internalCache(CU.ATOMICS_CACHE_NAME);
+            }
 
             assert atomicsCache != null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7ed0ddf2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
index 175c1e6..db16062 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
@@ -19,13 +19,17 @@ package org.apache.ignite.internal.processors.cache.datastructures;
 
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
 
 import java.util.*;
+import java.util.concurrent.*;
 
 /**
  *
@@ -183,6 +187,49 @@ public abstract class IgniteClientDataStructuresAbstractTest extends
GridCommonA
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testLatch() throws Exception {
+        Ignite clientNode = clientIgnite();
+
+        final Ignite srvNode = serverNode();
+
+        assertNull(clientNode.countDownLatch("latch1", 1, true, false));
+
+        try (IgniteCountDownLatch latch = clientNode.countDownLatch("latch1", 1, true, true))
{
+            assertNotNull(latch);
+
+            assertEquals(1, latch.count());
+
+            IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Object>()
{
+                @Override public Object call() throws Exception {
+                    U.sleep(1000);
+
+                    IgniteCountDownLatch latch0 = srvNode.countDownLatch("latch1", 1, true,
false);
+
+                    assertEquals(1, latch0.count());
+
+                    log.info("Count down latch.");
+
+                    latch0.countDown();
+
+                    assertEquals(0, latch0.count());
+
+                    return null;
+                }
+            });
+
+            log.info("Await latch.");
+
+            assertTrue(latch.await(5000, TimeUnit.MILLISECONDS));
+
+            log.info("Finished wait.");
+
+            fut.get();
+        }
+    }
+
+    /**
      * @return Client node.
      */
     private Ignite clientIgnite() {


Mime
View raw message