ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/2] incubator-ignite git commit: # gg-10561: session expiration (change)
Date Thu, 23 Jul 2015 12:44:56 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-gg-10561 74b8fdb43 -> 55806b9f0


# gg-10561: session expiration (change)


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

Branch: refs/heads/ignite-gg-10561
Commit: 42042ecb035f74b4b653400f13cdcb2f7334bd70
Parents: 74b8fdb
Author: ashutak <ashutak@gridgain.com>
Authored: Thu Jul 23 14:46:17 2015 +0300
Committer: ashutak <ashutak@gridgain.com>
Committed: Thu Jul 23 14:46:17 2015 +0300

----------------------------------------------------------------------
 .../processors/rest/GridRestProcessor.java      | 35 +++++++++++++-------
 1 file changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/42042ecb/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index 3f10f0a..9f7be97 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -811,18 +811,23 @@ public class GridRestProcessor extends GridProcessorAdapter {
      * Session.
      */
     private static class Session {
-        private static final Long EXPIRED_FLAG = -0l;
+        /** Expiration flag. It's a final state of lastToucnTime. */
+        private static final Long EXPIRED_FLAG = 0L;
 
         /** Client id. */
-        volatile UUID clientId;
+        private volatile UUID clientId;
 
         /** Session token id. */
-        volatile UUID sesTokId;
+        private volatile UUID sesTokId;
 
         /** Security context. */
-        volatile SecurityContext secCtx;
+        private volatile SecurityContext secCtx;
 
-        final AtomicLong lastTouchTime = new AtomicLong(U.currentTimeMillis());
+        /**
+         * Time when session is used last time.
+         * If this time was set at EXPIRED_FLAG, then it should never be changed.
+         */
+        private final AtomicLong lastTouchTime = new AtomicLong(U.currentTimeMillis());
 
         /**
          * @return Session token as bytes.
@@ -832,7 +837,9 @@ public class GridRestProcessor extends GridProcessorAdapter {
         }
 
         /**
-         * // TODO javadoc
+         * Checks expiration of session and if expired then sets EXPIRED_FLAG.
+         *
+         * @return <code>True</code> if expired.
          */
         boolean checkExpiration() {
             long time0 = lastTouchTime.get();
@@ -844,18 +851,22 @@ public class GridRestProcessor extends GridProcessorAdapter {
         }
 
         /**
-         * // TODO javadoc
+         * Checks whether session at expired state (EPIRATION_FLAG) or not, if not then tries
to update last touch time.
+         *
          * @return <code>True</code> if expired.
          */
         boolean checkExpirationAndTryUpdateLastTouchTime() {
-            long time0 = lastTouchTime.get();
+            while (true) {
+                long time0 = lastTouchTime.get();
 
-            if (time0 == EXPIRED_FLAG)
-                return true;
+                if (time0 == EXPIRED_FLAG)
+                    return true;
 
-            lastTouchTime.compareAndSet(time0, U.currentTimeMillis());
+                boolean success = lastTouchTime.compareAndSet(time0, U.currentTimeMillis());
 
-            return isExpired();
+                if (success)
+                    return false;
+            }
         }
 
         /**


Mime
View raw message