ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [09/50] [abbrv] incubator-ignite git commit: # ignite-42
Date Thu, 22 Jan 2015 14:47:00 GMT
# ignite-42


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

Branch: refs/heads/ignite-35
Commit: 05ef302cfcc1b3390de47aa80fe4ebeddb2c919f
Parents: b463cfa
Author: sboikov <semen.boikov@inria.fr>
Authored: Tue Jan 20 00:19:55 2015 +0300
Committer: sboikov <semen.boikov@inria.fr>
Committed: Tue Jan 20 00:19:55 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheStoreManager.java | 18 ++--
 .../cache/GridCacheLifecycleAwareSelfTest.java  |  9 ++
 .../cache/GridCacheReloadSelfTest.java          |  1 -
 .../processors/cache/GridCacheTestStore.java    |  1 -
 ...actQueueFailoverDataConsistencySelfTest.java |  6 ++
 .../GridCacheSetFailoverAbstractSelfTest.java   |  6 ++
 ...ePartitionedBasicStoreMultiNodeSelfTest.java | 98 ++++++++++----------
 .../GridAbstractLifecycleAwareSelfTest.java     |  7 ++
 8 files changed, 89 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/05ef302c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
index ed95bbd..c9ca7e4 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
@@ -689,19 +689,25 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K,
V> {
 
     /**
      * @param tx Current transaction.
-     * @return {@code True} if
+     * @return {@code True} if thread local session was initialized.
      */
     private boolean initSession(@Nullable IgniteTx tx) {
-        if (!sesEnabled || tx == null)
+        if (!sesEnabled)
             return false;
 
-        SessionData ses = ((GridMetadataAware)tx).meta(SES_ATTR);
+        SessionData ses;
 
-        if (ses == null) {
-            ses = new SessionData(tx);
+        if (tx != null) {
+            ses = ((GridMetadataAware)tx).meta(SES_ATTR);
 
-            ((GridMetadataAware)tx).addMeta(SES_ATTR, ses);
+            if (ses == null) {
+                ses = new SessionData(tx);
+
+                ((GridMetadataAware)tx).addMeta(SES_ATTR, ses);
+            }
         }
+        else
+            ses = new SessionData(null);
 
         sesHolder.set(ses);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/05ef302c/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheLifecycleAwareSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheLifecycleAwareSelfTest.java
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheLifecycleAwareSelfTest.java
index 4857e7b..a5b5b9c 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheLifecycleAwareSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheLifecycleAwareSelfTest.java
@@ -24,6 +24,7 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.lifecycle.LifecycleAware;
+import org.apache.ignite.resources.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.gridgain.grid.cache.*;
 import org.gridgain.grid.cache.affinity.*;
@@ -69,6 +70,14 @@ public class GridCacheLifecycleAwareSelfTest extends GridAbstractLifecycleAwareS
             lifecycleAware.stop();
         }
 
+        /**
+         * @param cacheName Cache name.
+         */
+        @IgniteCacheNameResource
+        public void setCacheName(String cacheName) {
+            lifecycleAware.cacheName(cacheName);
+        }
+
         /** {@inheritDoc} */
         @Nullable @Override public Object load(Object key) {
             return null;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/05ef302c/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheReloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheReloadSelfTest.java
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheReloadSelfTest.java
index 5c29b01..aa8521a 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheReloadSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheReloadSelfTest.java
@@ -38,7 +38,6 @@ import static org.gridgain.grid.cache.GridCacheDistributionMode.*;
  * Checks that GridCacheProjection.reload() operations are performed correctly.
  */
 public class GridCacheReloadSelfTest extends GridCommonAbstractTest {
-
     /** Maximum allowed number of cache entries. */
     public static final int MAX_CACHE_ENTRIES = 500;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/05ef302c/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTestStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTestStore.java
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTestStore.java
index 0203f75..c783f6c 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTestStore.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTestStore.java
@@ -20,7 +20,6 @@ package org.gridgain.grid.kernal.processors.cache;
 import org.apache.ignite.*;
 import org.apache.ignite.cache.store.*;
 import org.apache.ignite.lang.*;
-import org.apache.ignite.resources.*;
 import org.apache.ignite.transactions.*;
 import org.gridgain.grid.*;
 import org.gridgain.grid.kernal.processors.cache.transactions.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/05ef302c/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java
index 230db3e..de29b39 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java
@@ -18,6 +18,7 @@
 package org.gridgain.grid.kernal.processors.cache.datastructures;
 
 import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.store.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.lang.*;
 import org.gridgain.grid.cache.*;
@@ -84,6 +85,11 @@ public abstract class GridCacheAbstractQueueFailoverDataConsistencySelfTest
exte
     }
 
     /** {@inheritDoc} */
+    @Override protected CacheStore<?, ?> cacheStore() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
     @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception
{
         CacheConfiguration ccfg = super.cacheConfiguration(gridName);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/05ef302c/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java
index f1f973c..e00bea2 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java
@@ -19,6 +19,7 @@ package org.gridgain.grid.kernal.processors.cache.datastructures;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.store.*;
 import org.apache.ignite.lang.*;
 import org.gridgain.grid.cache.datastructures.*;
 import org.gridgain.grid.kernal.*;
@@ -70,6 +71,11 @@ public class GridCacheSetFailoverAbstractSelfTest extends GridCacheAbstractSelfT
     }
 
     /** {@inheritDoc} */
+    @Override protected CacheStore<?, ?> cacheStore() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
     @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception
{
         CacheConfiguration ccfg = super.cacheConfiguration(gridName);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/05ef302c/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
index 7bf5eaf..a994d4b 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
@@ -50,11 +50,12 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA
     private static final int GRID_CNT = 3;
 
     /** Cache store. */
-    private static final GridCacheTestStore store = new GridCacheTestStore();
+    private static List<GridCacheTestStore> stores;
 
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
-        store.resetTimestamp();
+        for (GridCacheTestStore store : stores)
+            store.resetTimestamp();
     }
 
     /** {@inheritDoc} */
@@ -62,17 +63,22 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA
         for (int i = 0; i < GRID_CNT; i++)
             cache(i).removeAll();
 
-        store.reset();
+        for (GridCacheTestStore store : stores)
+            store.reset();
     }
 
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
+        stores = Collections.synchronizedList(new ArrayList<GridCacheTestStore>());
+
         startGridsMultiThreaded(GRID_CNT);
     }
 
     /** {@inheritDoc} */
     @Override protected void afterTestsStopped() throws Exception {
         stopAllGrids();
+
+        stores = null;
     }
 
     /** {@inheritDoc} */
@@ -94,6 +100,10 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA
         cc.setAtomicityMode(TRANSACTIONAL);
         cc.setBackups(1);
 
+        GridCacheTestStore store = new GridCacheTestStore();
+
+        stores.add(store);
+
         cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store));
         cc.setReadThrough(true);
         cc.setWriteThrough(true);
@@ -135,12 +145,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends
GridCommonA
 
         assertNull(cache.put(key, "val"));
 
-        assertEquals(1, store.getLoadCount());
-        assertEquals(1, store.getPutCount());
-
-        Collection<IgniteTx> txs = store.transactions();
-
-        assertEquals(1, txs.size());
+        checkStoreUsage(1, 1, 0, 1);
     }
 
     /**
@@ -168,12 +173,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends
GridCommonA
 
         assertNull(cache.put(key, "val"));
 
-        assertEquals(1, store.getLoadCount());
-        assertEquals(1, store.getPutCount());
-
-        Collection<IgniteTx> txs = store.transactions();
-
-        assertEquals(1, txs.size());
+        checkStoreUsage(1, 1, 0, 1);
     }
 
     /**
@@ -201,12 +201,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends
GridCommonA
 
         assertNull(cache.put(key, "val"));
 
-        assertEquals(1, store.getLoadCount());
-        assertEquals(1, store.getPutCount());
-
-        Collection<IgniteTx> txs = store.transactions();
-
-        assertEquals(1, txs.size());
+        checkStoreUsage(1, 1, 0, 1);
     }
 
     /**
@@ -234,12 +229,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends
GridCommonA
 
         assertNull(cache.putIfAbsent(key, "val"));
 
-        assertEquals(1, store.getLoadCount());
-        assertEquals(1, store.getPutCount());
-
-        Collection<IgniteTx> txs = store.transactions();
-
-        assertEquals(1, txs.size());
+        checkStoreUsage(1, 1, 0, 1);
     }
 
     /**
@@ -267,12 +257,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends
GridCommonA
 
         assertNull(cache.putIfAbsent(key, "val"));
 
-        assertEquals(1, store.getLoadCount());
-        assertEquals(1, store.getPutCount());
-
-        Collection<IgniteTx> txs = store.transactions();
-
-        assertEquals(1, txs.size());
+        checkStoreUsage(1, 1, 0, 1);
     }
 
     /**
@@ -300,12 +285,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends
GridCommonA
 
         assertNull(cache.putIfAbsent(key, "val"));
 
-        assertEquals(1, store.getLoadCount());
-        assertEquals(1, store.getPutCount());
-
-        Collection<IgniteTx> txs = store.transactions();
-
-        assertEquals(1, txs.size());
+        checkStoreUsage(1, 1, 0, 1);
     }
 
     /**
@@ -321,11 +301,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends
GridCommonA
 
         cache.putAll(map);
 
-        assertEquals(1, store.getPutAllCount());
-
-        Collection<IgniteTx> txs = store.transactions();
-
-        assertEquals(1, txs.size());
+        checkStoreUsage(-1, 0, 1, 1);
     }
 
     /**
@@ -346,12 +322,36 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends
GridCommonA
             tx.commit();
         }
 
-        assertEquals(4, store.getLoadCount());
-        assertEquals(0, store.getPutCount());
-        assertEquals(1, store.getPutAllCount());
+        checkStoreUsage(4, 0, 1, 1);
+    }
+
+    /**
+     * @param expLoad Expected load calls.
+     * @param expPut Expected put calls.
+     * @param expPutAll Expected putAll calls.
+     * @param expTxs Expected number of transactions.
+     */
+    private void checkStoreUsage(int expLoad, int expPut, int expPutAll, int expTxs) {
+        int load = 0;
+        int put = 0;
+        int putAll = 0;
+        int txs = 0;
+
+        for (GridCacheTestStore store : stores) {
+            load += store.getLoadCount();
+
+            put += store.getPutCount();
+
+            putAll += store.getPutAllCount();
+
+            txs += store.transactions().size();
+        }
 
-        Collection<IgniteTx> txs = store.transactions();
+        if (expLoad != -1)
+            assertEquals(expLoad, load);
 
-        assertEquals(1, txs.size());
+        assertEquals(expPut, put);
+        assertEquals(expPutAll, putAll);
+        assertEquals(expTxs, txs);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/05ef302c/modules/core/src/test/java/org/gridgain/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java
b/modules/core/src/test/java/org/gridgain/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java
index efa0d76..613d081 100644
--- a/modules/core/src/test/java/org/gridgain/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java
@@ -80,6 +80,13 @@ public abstract class GridAbstractLifecycleAwareSelfTest extends GridCommonAbstr
         public int stopCount() {
             return stopCnt.get();
         }
+
+        /**
+         * @param cacheName Cache name.
+         */
+        public void cacheName(String cacheName) {
+            this.cacheName = cacheName;
+        }
     }
 
     /**


Mime
View raw message