ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [01/38] incubator-ignite git commit: # ignite-41
Date Tue, 23 Dec 2014 08:22:37 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1 7b68f5968 -> 4ea573688


# ignite-41


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

Branch: refs/heads/ignite-1
Commit: 7f1b3f0d12cd8d64a74b9bf0700a0aae135a2c53
Parents: d7309f4
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Dec 12 17:54:04 2014 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Dec 12 17:54:04 2014 +0300

----------------------------------------------------------------------
 .../grid/cache/GridCacheConfiguration.java      |   1 +
 .../processors/cache/IgniteCacheTest.java       |   7 ++
 .../expiry/IgniteCacheExpiryPolicyTest.java     | 120 +++++++++++++++++++
 3 files changed, 128 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7f1b3f0d/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
index cb082fb..5e94bf5 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
@@ -380,6 +380,7 @@ public class GridCacheConfiguration extends MutableConfiguration {
         evictSync = cc.isEvictSynchronized();
         evictSyncConcurrencyLvl = cc.getEvictSynchronizedConcurrencyLevel();
         evictSyncTimeout = cc.getEvictSynchronizedTimeout();
+        expiryPolicyFactory = cc.getExpiryPolicyFactory();
         indexingSpiName = cc.getIndexingSpiName();
         interceptor = cc.getInterceptor();
         invalidate = cc.isInvalidate();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7f1b3f0d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTest.java
index a390fad..88abfc4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTest.java
@@ -34,6 +34,13 @@ public class IgniteCacheTest extends GridCommonAbstractTest {
 
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
+        startGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    protected void startGrids() throws Exception {
         int cnt = gridCount();
 
         assert cnt >= 1 : "At least one grid must be started";

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7f1b3f0d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTest.java
new file mode 100644
index 0000000..f72619b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTest.java
@@ -0,0 +1,120 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.apache.ignite.internal.processors.cache.expiry;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.gridgain.grid.cache.*;
+import org.gridgain.grid.util.lang.*;
+import org.gridgain.testframework.*;
+
+import javax.cache.configuration.*;
+import javax.cache.expiry.*;
+import java.util.concurrent.*;
+
+/**
+ *
+ */
+public class IgniteCacheExpiryPolicyTest extends IgniteCacheTest {
+    /** */
+    private Factory<? extends ExpiryPolicy> factory;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    @Override
+    protected int gridCount() {
+        return 2;
+    }
+
+    /**
+     *
+     */
+    private class TestCreatedPolicy implements ExpiryPolicy {
+        /** */
+        private final Duration duration;
+
+        /**
+         * @param ttl TTL for creation.
+         */
+        TestCreatedPolicy(long ttl) {
+            this.duration = new Duration(TimeUnit.MILLISECONDS, ttl);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Duration getExpiryForCreation() {
+            return duration;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Duration getExpiryForAccess() {
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Duration getExpiryForUpdate() {
+            return null;
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCreated() throws Exception {
+        factory = new FactoryBuilder.SingletonFactory<>(new TestCreatedPolicy(1000));
+
+        startGrids();
+
+        final Integer key = 1;
+
+        IgniteCache<Integer, Integer> cache = jcache(0);
+
+        cache.put(1, 1);
+
+        GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                for (int i = 0; i < gridCount(); i++) {
+                    Object val = cache(i).peek(key);
+
+                    log.info("Value [grid=" + i + ", val=" + val + ']');
+
+                    if (val != null)
+                        return false;
+                }
+
+                return false;
+            }
+        }, 2000);
+
+        for (int i = 0; i < gridCount(); i++)
+            assertNull("Unexpected non-null value for grid " + i, cache.get(key));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected GridCacheConfiguration cacheConfiguration(String gridName) throws
Exception {
+        assert factory != null;
+
+        GridCacheConfiguration cfg = super.cacheConfiguration(gridName);
+
+        cfg.setCacheMode(GridCacheMode.PARTITIONED);
+        cfg.setAtomicityMode(GridCacheAtomicityMode.ATOMIC);
+
+        cfg.setExpiryPolicyFactory(factory);
+
+        return cfg;
+    }
+}


Mime
View raw message