ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [21/38] incubator-ignite git commit: # ignite-41
Date Tue, 23 Dec 2014 08:22:57 GMT
# 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/5731d598
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5731d598
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5731d598

Branch: refs/heads/ignite-1
Commit: 5731d598d36ba8aff4642c4fd871dfb9484ed102
Parents: 570563a
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Dec 19 16:49:05 2014 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Dec 19 18:02:19 2014 +0300

----------------------------------------------------------------------
 .../kernal/managers/GridManagerAdapter.java     | 26 +++++++++------
 .../cache/GridCacheTxLocalAdapter.java          | 33 ++++++++++----------
 .../GridDistributedTxRemoteAdapter.java         |  2 ++
 .../handlers/cache/GridCacheCommandHandler.java |  6 ++--
 .../hadoop/jobtracker/GridHadoopJobTracker.java | 12 ++++---
 .../cache/websession/GridWebSessionFilter.java  | 18 ++++++++---
 .../websession/GridWebSessionListener.java      | 22 ++++++++-----
 .../websession/GridWebSessionSelfTestSuite.java |  2 +-
 8 files changed, 74 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5731d598/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
index 8a8bc0e..e676082 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
@@ -29,11 +29,13 @@ import org.gridgain.grid.util.typedef.*;
 import org.gridgain.grid.util.typedef.internal.*;
 import org.jetbrains.annotations.*;
 
+import javax.cache.expiry.*;
 import java.io.*;
 import java.nio.*;
 import java.util.*;
 
 import static java.util.Arrays.*;
+import static java.util.concurrent.TimeUnit.*;
 import static org.gridgain.grid.kernal.managers.communication.GridIoPolicy.*;
 
 /**
@@ -380,24 +382,28 @@ public abstract class GridManagerAdapter<T extends IgniteSpi>
implements GridMan
 
                     @Nullable @Override public <K, V> V put(String cacheName, K key,
V val, long ttl)
                         throws IgniteCheckedException {
-                        GridCacheEntry<K, V> e = ctx.cache().<K, V>cache(cacheName).entry(key);
+                        if (ttl > 0) {
+                            ExpiryPolicy plc = new TouchedExpiryPolicy(new Duration(MILLISECONDS,
ttl));
 
-                        assert e != null;
+                            IgniteCache<K, V> cache = ctx.cache().<K, V>publicJCache(cacheName).withExpiryPolicy(plc);
 
-                        e.timeToLive(ttl);
-
-                        return e.set(val);
+                            return cache.getAndPut(key, val);
+                        }
+                        else
+                            return ctx.cache().<K, V>cache(cacheName).put(key, val);
                     }
 
                     @Nullable @Override public <K, V> V putIfAbsent(String cacheName,
K key, V val, long ttl)
                         throws IgniteCheckedException {
-                        GridCacheEntry<K, V> e = ctx.cache().<K, V>cache(cacheName).entry(key);
+                        if (ttl > 0) {
+                            ExpiryPolicy plc = new TouchedExpiryPolicy(new Duration(MILLISECONDS,
ttl));
 
-                        assert e != null;
+                            IgniteCache<K, V> cache = ctx.cache().<K, V>publicJCache(cacheName).withExpiryPolicy(plc);
 
-                        e.timeToLive(ttl);
-
-                        return e.setIfAbsent(val);
+                            return cache.getAndPutIfAbsent(key, val);
+                        }
+                        else
+                            return ctx.cache().<K, V>cache(cacheName).putIfAbsent(key,
val);
                     }
 
                     @Nullable @Override public <K, V> V remove(String cacheName, K
key) throws IgniteCheckedException {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5731d598/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
index 3959419..3a5e604 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
@@ -656,6 +656,20 @@ public abstract class GridCacheTxLocalAdapter<K, V> extends GridCacheTxAdapter<K
                                     GridCacheVersion explicitVer = txEntry.drVersion() !=
null ?
                                         txEntry.drVersion() : writeVersion();
 
+                                    if (op == CREATE || op == UPDATE && txEntry.drExpireTime()
== -1L) {
+                                        ExpiryPolicy expiry = txEntry.expiry();
+
+                                        if (expiry == null)
+                                            expiry = cacheCtx.expiry();
+
+                                        if (expiry != null) {
+                                            Duration duration = cached.hasValue() ?
+                                                expiry.getExpiryForUpdate() : expiry.getExpiryForCreation();
+
+                                            txEntry.ttl(GridCacheMapEntry.toTtl(duration));
+                                        }
+                                    }
+
                                     GridDrResolveResult<V> drRes = cacheCtx.dr().resolveTx(cached,
                                         txEntry,
                                         explicitVer,
@@ -672,26 +686,13 @@ public abstract class GridCacheTxLocalAdapter<K, V> extends GridCacheTxAdapter<K
 
                                         if (drRes.isMerge())
                                             explicitVer = writeVersion();
+                                        else if (op == NOOP)
+                                            txEntry.ttl(-1L);
                                     }
-                                    else {
+                                    else
                                         // Nullify explicit version so that innerSet/innerRemove
will work as usual.
                                         explicitVer = null;
 
-                                        if (op == CREATE || op == UPDATE && txEntry.drExpireTime()
== -1L) {
-                                            ExpiryPolicy expiry = txEntry.expiry();
-
-                                            if (expiry == null)
-                                                expiry = cacheCtx.expiry();
-
-                                            if (expiry != null) {
-                                                Duration duration = cached.hasValue() ?
-                                                    expiry.getExpiryForUpdate() : expiry.getExpiryForCreation();
-
-                                                txEntry.ttl(GridCacheMapEntry.toTtl(duration));
-                                            }
-                                        }
-                                    }
-
                                     if (sndTransformedVals || (drRes != null)) {
                                         assert sndTransformedVals && cacheCtx.isReplicated()
|| (drRes != null);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5731d598/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
index ffc8ca6..df6fc49 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
@@ -512,6 +512,8 @@ public class GridDistributedTxRemoteAdapter<K, V> extends GridCacheTxAdapter<K,
 
                                             if (drRes.isMerge())
                                                 explicitVer = writeVersion();
+                                            else if (op == NOOP)
+                                                txEntry.ttl(-1L);
                                         }
                                         else
                                             // Nullify explicit version so that innerSet/innerRemove
will work as usual.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5731d598/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/cache/GridCacheCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/cache/GridCacheCommandHandler.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/cache/GridCacheCommandHandler.java
index 6f34ebd..8c86234 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/cache/GridCacheCommandHandler.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/cache/GridCacheCommandHandler.java
@@ -929,7 +929,7 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
 
         /** {@inheritDoc} */
         @Override public IgniteFuture<?> applyx(GridCacheProjection<Object, Object>
c, GridKernalContext ctx) {
-            if (ttl != null) {
+            if (ttl != null && ttl > 0) {
                 Duration duration = new Duration(TimeUnit.MILLISECONDS, ttl);
 
                 c = ((GridCacheProjectionEx<Object, Object>)c).withExpiryPolicy(new
ModifiedExpiryPolicy(duration));
@@ -966,7 +966,7 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
 
         /** {@inheritDoc} */
         @Override public IgniteFuture<?> applyx(GridCacheProjection<Object, Object>
c, GridKernalContext ctx) {
-            if (ttl != null) {
+            if (ttl != null && ttl > 0) {
                 Duration duration = new Duration(TimeUnit.MILLISECONDS, ttl);
 
                 c = ((GridCacheProjectionEx<Object, Object>)c).withExpiryPolicy(new
ModifiedExpiryPolicy(duration));
@@ -1003,7 +1003,7 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
 
         /** {@inheritDoc} */
         @Override public IgniteFuture<?> applyx(GridCacheProjection<Object, Object>
c, GridKernalContext ctx) {
-            if (ttl != null) {
+            if (ttl != null && ttl > 0) {
                 Duration duration = new Duration(TimeUnit.MILLISECONDS, ttl);
 
                 c = ((GridCacheProjectionEx<Object, Object>)c).withExpiryPolicy(new
ModifiedExpiryPolicy(duration));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5731d598/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/jobtracker/GridHadoopJobTracker.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/jobtracker/GridHadoopJobTracker.java
b/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/jobtracker/GridHadoopJobTracker.java
index ea3797c..239c7a9 100644
--- a/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/jobtracker/GridHadoopJobTracker.java
+++ b/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/jobtracker/GridHadoopJobTracker.java
@@ -120,11 +120,15 @@ public class GridHadoopJobTracker extends GridHadoopComponent {
 
                     jobMetaPrj = prj = sysCache.projection(GridHadoopJobId.class, GridHadoopJobMetadata.class);
 
-                    TouchedExpiryPolicy finishedJobPlc = new TouchedExpiryPolicy(
-                        new Duration(MILLISECONDS, ctx.configuration().getFinishedJobInfoTtl()));
+                    if (ctx.configuration().getFinishedJobInfoTtl() > 0) {
+                        TouchedExpiryPolicy finishedJobPlc = new TouchedExpiryPolicy(
+                            new Duration(MILLISECONDS, ctx.configuration().getFinishedJobInfoTtl()));
 
-                    finishedJobMetaPrj = ((GridCacheProjectionEx<GridHadoopJobId, GridHadoopJobMetadata>)prj).
-                        withExpiryPolicy(finishedJobPlc);
+                        finishedJobMetaPrj = ((GridCacheProjectionEx<GridHadoopJobId,
GridHadoopJobMetadata>)prj).
+                            withExpiryPolicy(finishedJobPlc);
+                    }
+                    else
+                        finishedJobMetaPrj = jobMetaPrj;
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5731d598/modules/web/src/main/java/org/gridgain/grid/cache/websession/GridWebSessionFilter.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/gridgain/grid/cache/websession/GridWebSessionFilter.java
b/modules/web/src/main/java/org/gridgain/grid/cache/websession/GridWebSessionFilter.java
index b615d40..f5c545e 100644
--- a/modules/web/src/main/java/org/gridgain/grid/cache/websession/GridWebSessionFilter.java
+++ b/modules/web/src/main/java/org/gridgain/grid/cache/websession/GridWebSessionFilter.java
@@ -11,17 +11,19 @@ package org.gridgain.grid.cache.websession;
 
 import org.apache.ignite.*;
 import org.apache.ignite.lang.*;
-import org.gridgain.grid.*;
 import org.gridgain.grid.cache.*;
+import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.startup.servlet.*;
 import org.gridgain.grid.util.typedef.*;
 import org.gridgain.grid.util.typedef.internal.*;
 
+import javax.cache.expiry.*;
 import javax.servlet.*;
 import javax.servlet.http.*;
 import java.io.*;
 import java.util.*;
 
+import static java.util.concurrent.TimeUnit.*;
 import static org.gridgain.grid.cache.GridCacheAtomicityMode.*;
 import static org.gridgain.grid.cache.GridCacheMode.*;
 import static org.gridgain.grid.cache.GridCacheTxConcurrency.*;
@@ -363,6 +365,7 @@ public class GridWebSessionFilter implements Filter {
      * @param httpReq HTTP request.
      * @return Cached session.
      */
+    @SuppressWarnings("unchecked")
     private GridWebSession createSession(HttpServletRequest httpReq) {
         HttpSession ses = httpReq.getSession(true);
 
@@ -376,13 +379,18 @@ public class GridWebSessionFilter implements Filter {
         try {
             while (true) {
                 try {
-                    GridCacheEntry<String, GridWebSession> entry = cache.entry(sesId);
+                    GridCacheProjection<String, GridWebSession> cache0;
 
-                    assert entry != null;
+                    if (cached.getMaxInactiveInterval() > 0) {
+                        ExpiryPolicy plc =
+                            new TouchedExpiryPolicy(new Duration(MILLISECONDS, cached.getMaxInactiveInterval()
* 1000));
 
-                    entry.timeToLive(cached.getMaxInactiveInterval() * 1000);
+                        cache0 = ((GridCacheProjectionEx<String, GridWebSession>)cache).withExpiryPolicy(plc);
+                    }
+                    else
+                        cache0 = cache;
 
-                    GridWebSession old = entry.setIfAbsent(cached);
+                    GridWebSession old = cache0.putIfAbsent(sesId, cached);
 
                     if (old != null) {
                         cached = old;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5731d598/modules/web/src/main/java/org/gridgain/grid/cache/websession/GridWebSessionListener.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/gridgain/grid/cache/websession/GridWebSessionListener.java
b/modules/web/src/main/java/org/gridgain/grid/cache/websession/GridWebSessionListener.java
index 5071a2b..0408e19 100644
--- a/modules/web/src/main/java/org/gridgain/grid/cache/websession/GridWebSessionListener.java
+++ b/modules/web/src/main/java/org/gridgain/grid/cache/websession/GridWebSessionListener.java
@@ -10,15 +10,18 @@
 package org.gridgain.grid.cache.websession;
 
 import org.apache.ignite.*;
-import org.gridgain.grid.*;
 import org.gridgain.grid.cache.*;
+import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.util.typedef.*;
 import org.gridgain.grid.util.typedef.internal.*;
 import org.jetbrains.annotations.*;
 
+import javax.cache.expiry.*;
 import java.io.*;
 import java.util.*;
 
+import static java.util.concurrent.TimeUnit.*;
+
 /**
  * Session listener for web sessions caching.
  */
@@ -70,6 +73,7 @@ class GridWebSessionListener {
      * @param updates Updates list.
      * @param maxInactiveInterval Max session inactive interval.
      */
+    @SuppressWarnings("unchecked")
     public void updateAttributes(String sesId, Collection<T2<String, Object>>
updates, int maxInactiveInterval) {
         assert sesId != null;
         assert updates != null;
@@ -80,16 +84,18 @@ class GridWebSessionListener {
         try {
             for (int i = 0; i < retries; i++) {
                 try {
-                    GridCacheEntry<String, GridWebSession> entry = cache.entry(sesId);
-
-                    assert entry != null;
+                    GridCacheProjection<String, GridWebSession> cache0;
 
-                    if (maxInactiveInterval < 0)
-                        maxInactiveInterval = 0;
+                    if (maxInactiveInterval > 0) {
+                        ExpiryPolicy plc =
+                            new TouchedExpiryPolicy(new Duration(MILLISECONDS, maxInactiveInterval
* 1000));
 
-                    entry.timeToLive(maxInactiveInterval * 1000);
+                        cache0 = ((GridCacheProjectionEx<String, GridWebSession>)cache).withExpiryPolicy(plc);
+                    }
+                    else
+                        cache0 = cache;
 
-                    entry.transform(new AttributesUpdated(updates));
+                    cache0.transform(sesId, new AttributesUpdated(updates));
 
                     break;
                 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5731d598/modules/web/src/test/java/org/gridgain/grid/kernal/websession/GridWebSessionSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/web/src/test/java/org/gridgain/grid/kernal/websession/GridWebSessionSelfTestSuite.java
b/modules/web/src/test/java/org/gridgain/grid/kernal/websession/GridWebSessionSelfTestSuite.java
index d960122..c969e47 100644
--- a/modules/web/src/test/java/org/gridgain/grid/kernal/websession/GridWebSessionSelfTestSuite.java
+++ b/modules/web/src/test/java/org/gridgain/grid/kernal/websession/GridWebSessionSelfTestSuite.java
@@ -21,7 +21,7 @@ public class GridWebSessionSelfTestSuite extends TestSuite {
      * @throws Exception Thrown in case of the failure.
      */
     public static TestSuite suite() throws Exception {
-        TestSuite suite = new TestSuite("GridGain Web Sessions Test Suite");
+        TestSuite suite = new TestSuite("Ignite Web Sessions Test Suite");
 
         suite.addTestSuite(GridWebSessionSelfTest.class);
         suite.addTestSuite(WebSessionTransactionalSelfTest.class);


Mime
View raw message