You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/09/08 14:45:50 UTC
[08/50] ignite git commit: Fix binary mode handling
Fix binary mode handling
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8a441034
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8a441034
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8a441034
Branch: refs/heads/ignite-3199-1
Commit: 8a441034898a924277c048516c74c4d1a46a6d38
Parents: 31c586a
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Sep 5 17:06:22 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon Sep 5 17:06:22 2016 +0300
----------------------------------------------------------------------
.../platform/cache/PlatformCache.java | 30 +++++++++++---------
.../platform/websession/LockEntryProcessor.java | 24 +++++++---------
2 files changed, 26 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a441034/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
index 3550e8a..93c2436 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.platform.cache;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.cache.CacheMetrics;
import org.apache.ignite.cache.CachePartialUpdateException;
@@ -211,9 +210,12 @@ public class PlatformCache extends PlatformAbstractTarget {
/** */
public static final int OP_INVOKE_INTERNAL_SESSION_SET_AND_UNLOCK = 3;
- /** Underlying JCache. */
+ /** Underlying JCache in binary mode. */
private final IgniteCacheProxy cache;
+ /** Initial JCache (not in binary mode). */
+ private final IgniteCache cacheRaw;
+
/** Whether this cache is created with "keepBinary" flag on the other side. */
private final boolean keepBinary;
@@ -242,7 +244,9 @@ public class PlatformCache extends PlatformAbstractTarget {
public PlatformCache(PlatformContext platformCtx, IgniteCache cache, boolean keepBinary) {
super(platformCtx);
- this.cache = (IgniteCacheProxy)cache;
+ cacheRaw = cache;
+
+ this.cache = (IgniteCacheProxy)cache.withKeepBinary();
this.keepBinary = keepBinary;
}
@@ -255,7 +259,7 @@ public class PlatformCache extends PlatformAbstractTarget {
if (cache.delegate().skipStore())
return this;
- return new PlatformCache(platformCtx, cache.withSkipStore(), keepBinary);
+ return new PlatformCache(platformCtx, cacheRaw.withSkipStore(), keepBinary);
}
/**
@@ -267,7 +271,7 @@ public class PlatformCache extends PlatformAbstractTarget {
if (keepBinary)
return this;
- return new PlatformCache(platformCtx, cache.withKeepBinary(), true);
+ return new PlatformCache(platformCtx, cacheRaw.withKeepBinary(), true);
}
/**
@@ -279,7 +283,7 @@ public class PlatformCache extends PlatformAbstractTarget {
* @return Cache.
*/
public PlatformCache withExpiryPolicy(final long create, final long update, final long access) {
- IgniteCache cache0 = cache.withExpiryPolicy(new InteropExpiryPolicy(create, update, access));
+ IgniteCache cache0 = cacheRaw.withExpiryPolicy(new InteropExpiryPolicy(create, update, access));
return new PlatformCache(platformCtx, cache0, keepBinary);
}
@@ -293,7 +297,7 @@ public class PlatformCache extends PlatformAbstractTarget {
if (cache.isAsync())
return this;
- return new PlatformCache(platformCtx, (IgniteCache)cache.withAsync(), keepBinary);
+ return new PlatformCache(platformCtx, (IgniteCache)cacheRaw.withAsync(), keepBinary);
}
/**
@@ -307,7 +311,7 @@ public class PlatformCache extends PlatformAbstractTarget {
if (opCtx != null && opCtx.noRetries())
return this;
- return new PlatformCache(platformCtx, cache.withNoRetries(), keepBinary);
+ return new PlatformCache(platformCtx, cacheRaw.withNoRetries(), keepBinary);
}
/** {@inheritDoc} */
@@ -475,7 +479,7 @@ public class PlatformCache extends PlatformAbstractTarget {
case OP_INVOKE_INTERNAL_SESSION_LOCK: {
LockInfo lockInfo = (LockInfo)args[1];
- Object res = cache.invoke(key, new LockEntryProcessor(), lockInfo);
+ Object res = cacheRaw.invoke(key, new LockEntryProcessor(), lockInfo);
return writeResult(mem, res);
}
@@ -483,17 +487,15 @@ public class PlatformCache extends PlatformAbstractTarget {
case OP_INVOKE_INTERNAL_SESSION_UNLOCK: {
LockInfo lockInfo = (LockInfo)args[1];
- cache.invoke(key, new UnlockEntryProcessor(), lockInfo);
+ cacheRaw.invoke(key, new UnlockEntryProcessor(), lockInfo);
return FALSE;
}
case OP_INVOKE_INTERNAL_SESSION_SET_AND_UNLOCK:
- BinaryObject binData = (BinaryObject)args[1]; // Cache is in binary mode.
-
- SessionStateData data = binData.deserialize();
+ SessionStateData data = (SessionStateData)args[1];
- cache.invoke(key, new SetAndUnlockEntryProcessor(), data);
+ cacheRaw.invoke(key, new SetAndUnlockEntryProcessor(), data);
return FALSE;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a441034/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 0f0822b..4f01cb6 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
@@ -17,10 +17,7 @@
package org.apache.ignite.internal.processors.platform.websession;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.cache.CacheEntryProcessor;
-import org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSnapTreeMap;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.MutableEntry;
@@ -29,9 +26,9 @@ import java.sql.Timestamp;
/**
* Entry processor that locks web session data.
*/
-public class LockEntryProcessor implements CacheEntryProcessor<String, BinaryObject, Object> {
+public class LockEntryProcessor implements CacheEntryProcessor<String, SessionStateData, Object> {
/** {@inheritDoc} */
- @Override public Object process(MutableEntry<String, BinaryObject> entry, Object... objects)
+ @Override public Object process(MutableEntry<String, SessionStateData> entry, Object... objects)
throws EntryProcessorException {
// Arg contains lock info: node id + thread id
// Return result is either BinarizableSessionStateStoreData (when not locked) or lockAge (when locked)
@@ -39,13 +36,13 @@ public class LockEntryProcessor implements CacheEntryProcessor<String, BinaryObj
if (!entry.exists())
return null;
- BinaryObject data = entry.getValue();
+ SessionStateData data = entry.getValue();
assert data != null;
- if (data.field("LockNodeId") != null) {
+ if (data.getLockNodeId() != null) {
// Already locked: return lock time.
- Object lockTime = data.field("LockTime");
+ Timestamp lockTime = data.getLockTime();
assert lockTime != null;
@@ -55,13 +52,12 @@ public class LockEntryProcessor implements CacheEntryProcessor<String, BinaryObj
LockInfo lockInfo = (LockInfo)objects[0];
// Not locked: lock and return result
- final BinaryObjectBuilder builder = data.toBuilder();
+ data.setLockNodeId(lockInfo.getLockNodeId());
+ data.setLockId(lockInfo.getLockId());
+ data.setLockTime(lockInfo.getLockTime());
- builder.setField("LockNodeId", lockInfo.getLockNodeId());
- builder.setField("LockId", lockInfo.getLockId());
- builder.setField("LockTime", lockInfo.getLockTime());
-
- entry.setValue(builder.build());
+ // Apply.
+ entry.setValue(data);
return data;
}