ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [44/50] ignite git commit: Create a copy in all processors to support any copyOnRead mode
Date Thu, 08 Sep 2016 14:46:26 GMT
Create a copy in all processors to support any copyOnRead mode


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

Branch: refs/heads/ignite-3199-1
Commit: b02dce3a6f3d298a715251c3b2085402b486b691
Parents: 17cc854
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Thu Sep 8 14:21:57 2016 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Thu Sep 8 14:21:57 2016 +0300

----------------------------------------------------------------------
 .../platform/websession/LockEntryProcessor.java |  2 +-
 .../platform/websession/SessionStateData.java   | 30 ++++++++++++++------
 .../websession/SetAndUnlockEntryProcessor.java  |  2 +-
 .../websession/UnlockEntryProcessor.java        |  2 +-
 4 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b02dce3a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/LockEntryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/LockEntryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/LockEntryProcessor.java
index 06f1035..78148b0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/LockEntryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/LockEntryProcessor.java
@@ -46,7 +46,7 @@ public class LockEntryProcessor implements CacheEntryProcessor<String,
SessionSt
         SessionStateLockInfo lockInfo = (SessionStateLockInfo)args[0];
 
         // Not locked: lock and return result
-        data.lock(lockInfo);
+        data = data.lock(lockInfo);
 
         // Apply.
         entry.setValue(data);

http://git-wip-us.apache.org/repos/asf/ignite/blob/b02dce3a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateData.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateData.java
index 5ccdada..4586c49 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateData.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateData.java
@@ -86,23 +86,25 @@ public class SessionStateData implements Binarylizable {
      *
      * @param lock Lock.
      */
-    public void lock(SessionStateLockInfo lock) {
+    public SessionStateData lock(SessionStateLockInfo lock) {
         assert !isLocked();
 
-        lockId = lock.id();
-        lockNodeId = lock.nodeId();
-        lockTime = lock.time();
+        SessionStateData res = getCopy();
+
+        res.lockId = lock.id();
+        res.lockNodeId = lock.nodeId();
+        res.lockTime = lock.time();
+
+        return res;
     }
 
     /**
      * Clear lock info.
      */
-    public void unlock() {
+    public SessionStateData unlock() {
         assert isLocked();
 
-        lockId = 0;
-        lockNodeId = null;
-        lockTime = null;
+        return getCopy();
     }
 
     /**
@@ -147,4 +149,16 @@ public class SessionStateData implements Binarylizable {
     @Override public String toString() {
         return S.toString(SessionStateData.class, this);
     }
+
+    /**
+     * Gets a copy of this instance with non-lock properties set.
+     */
+    private SessionStateData getCopy() {
+        SessionStateData res = new SessionStateData();
+
+        res.staticObjects = staticObjects;
+        res.items = items;
+        res.timeout = timeout;
+        return res;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b02dce3a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SetAndUnlockEntryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SetAndUnlockEntryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SetAndUnlockEntryProcessor.java
index 19f3a38..62d05cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SetAndUnlockEntryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SetAndUnlockEntryProcessor.java
@@ -49,7 +49,7 @@ public class SetAndUnlockEntryProcessor implements CacheEntryProcessor<String,
S
             throw new IllegalStateException("Can not unlock session data: lock id check failed.");
 
         // Unlock.
-        data.unlock();
+        data = data.unlock();
 
         // Update values.
         data.applyChanges(newData);

http://git-wip-us.apache.org/repos/asf/ignite/blob/b02dce3a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/UnlockEntryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/UnlockEntryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/UnlockEntryProcessor.java
index 655b314..a22c8a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/UnlockEntryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/UnlockEntryProcessor.java
@@ -49,7 +49,7 @@ public class UnlockEntryProcessor implements CacheEntryProcessor<String,
Session
             throw new IllegalStateException("Can not unlock session data: lock id check failed.");
 
         // Unlock.
-        data.unlock();
+        data = data.unlock();
 
         entry.setValue(data);
 


Mime
View raw message