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:44 UTC
[02/50] ignite git commit: wip
wip
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/be620f20
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/be620f20
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/be620f20
Branch: refs/heads/ignite-3199-1
Commit: be620f204607435f4cbb65f9f109450f2ca2bf59
Parents: 4c12e74
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Sep 5 16:21:57 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon Sep 5 16:21:57 2016 +0300
----------------------------------------------------------------------
.../platform/cache/PlatformCache.java | 13 +++--
.../platform/websession/LockEntryProcessor.java | 4 +-
.../websession/ReleaseEntryProcessor.java | 25 ----------
.../websession/UnlockEntryProcessor.java | 51 ++++++++++++++++++++
4 files changed, 63 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/be620f20/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 6eae5e0..4bf82e8 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
@@ -51,6 +51,7 @@ import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformWriterClosure;
import org.apache.ignite.internal.processors.platform.websession.LockEntryProcessor;
import org.apache.ignite.internal.processors.platform.websession.LockInfo;
+import org.apache.ignite.internal.processors.platform.websession.UnlockEntryProcessor;
import org.apache.ignite.internal.util.GridConcurrentFactory;
import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.typedef.C1;
@@ -468,15 +469,21 @@ public class PlatformCache extends PlatformAbstractTarget {
Object key = args[0];
switch (opCode) {
- case OP_INVOKE_INTERNAL_SESSION_LOCK:
+ case OP_INVOKE_INTERNAL_SESSION_LOCK: {
LockInfo lockInfo = (LockInfo)args[1];
Object res = cache.invoke(key, new LockEntryProcessor(), lockInfo);
return writeResult(mem, res);
+ }
- case OP_INVOKE_INTERNAL_SESSION_UNLOCK:
- break;
+ case OP_INVOKE_INTERNAL_SESSION_UNLOCK: {
+ LockInfo lockInfo = (LockInfo)args[1];
+
+ cache.invoke(key, new UnlockEntryProcessor(), lockInfo);
+
+ return FALSE;
+ }
case OP_INVOKE_INTERNAL_SESSION_SET_AND_UNLOCK:
break;
http://git-wip-us.apache.org/repos/asf/ignite/blob/be620f20/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 9629f9d..5a26aeb 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
@@ -31,8 +31,8 @@ import java.sql.Timestamp;
*/
public class LockEntryProcessor implements CacheEntryProcessor<String, SessionStateData, Object> {
/** {@inheritDoc} */
- @Override public Object process(MutableEntry<String, SessionStateData> entry,
- Object... objects) throws EntryProcessorException {
+ @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)
http://git-wip-us.apache.org/repos/asf/ignite/blob/be620f20/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/ReleaseEntryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/ReleaseEntryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/ReleaseEntryProcessor.java
deleted file mode 100644
index 9e767fa..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/ReleaseEntryProcessor.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.platform.websession;
-
-/**
- * Entry processor that releases web session data.
- */
-public class ReleaseEntryProcessor {
- // TODO
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/be620f20/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
new file mode 100644
index 0000000..12f42a3
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/UnlockEntryProcessor.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.websession;
+
+import org.apache.ignite.cache.CacheEntryProcessor;
+
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+
+/**
+ * Entry processor that unlocks web session data.
+ */
+public class UnlockEntryProcessor implements CacheEntryProcessor<String, SessionStateData, Object> {
+ /** {@inheritDoc} */
+ @Override public Object process(MutableEntry<String, SessionStateData> entry, Object... objects)
+ throws EntryProcessorException {
+ assert entry.exists();
+
+ SessionStateData data = entry.getValue();
+
+ assert data != null;
+ assert data.getLockNodeId() != null;
+
+ LockInfo lockInfo = (LockInfo)objects[0];
+
+ assert data.getLockNodeId() == lockInfo.getLockNodeId();
+ assert data.getLockId() == lockInfo.getLockId();
+
+ // Unlock.
+ data.setLockNodeId(null);
+
+ entry.setValue(data);
+
+ return null;
+ }
+}