ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [41/50] ignite git commit: Return LockEntryResult from LockEntryProcessor
Date Thu, 08 Sep 2016 14:46:23 GMT
Return LockEntryResult from LockEntryProcessor


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

Branch: refs/heads/ignite-3199-1
Commit: ddae6acdecced9717fad6c84479d87f9b65b61c7
Parents: 348e5d4
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Thu Sep 8 13:54:52 2016 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Thu Sep 8 13:54:52 2016 +0300

----------------------------------------------------------------------
 .../platform/websession/LockEntryProcessor.java |   6 +-
 .../websession/SessionStateLockEntryResult.java | 100 -------------------
 .../websession/SessionStateLockResult.java      | 100 +++++++++++++++++++
 .../IgniteSessionStateStoreProvider.cs          |  14 +--
 .../Apache.Ignite.Core.csproj                   |   2 +-
 .../Impl/AspNet/SessionStateLockEntryResult.cs  |  76 --------------
 .../Impl/AspNet/SessionStateLockResult.cs       |  84 ++++++++++++++++
 7 files changed, 195 insertions(+), 187 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ddae6acd/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 ea53271..751ed48 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
@@ -37,14 +37,14 @@ public class LockEntryProcessor implements CacheEntryProcessor<String,
SessionSt
         // Return result is either BinarizableSessionStateStoreData (when not locked) or
lockAge (when locked)
 
         if (!entry.exists())
-            return null;
+            return null;  // TODO: ?
 
         SessionStateData data = entry.getValue();
 
         assert data != null;
 
         if (data.isLocked())
-            return new SessionStateLockEntryResult(false, null, data.lockTime());
+            return new SessionStateLockResult(false, null, data.lockTime());
 
         SessionStateLockInfo lockInfo = (SessionStateLockInfo)args[0];
 
@@ -54,7 +54,7 @@ public class LockEntryProcessor implements CacheEntryProcessor<String,
SessionSt
         // Apply.
         entry.setValue(data);
 
-        return new SessionStateLockEntryResult(true, data, null);
+        return new SessionStateLockResult(true, data, null);
     }
 
     /** {@inheritDoc */

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddae6acd/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateLockEntryResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateLockEntryResult.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateLockEntryResult.java
deleted file mode 100644
index 28e0a6b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateLockEntryResult.java
+++ /dev/null
@@ -1,100 +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;
-
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryRawReader;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-import java.sql.Timestamp;
-
-/**
- * Result of the {@link LockEntryProcessor} execution.
- */
-@SuppressWarnings({"AssignmentToDateFieldFromParameter", "ReturnOfDateField"})
-public class SessionStateLockEntryResult implements Binarylizable {
-    /** Success flag. */
-    private boolean success;
-
-    /** Data. */
-    private SessionStateData data;
-
-    /** Lock time. */
-    private Timestamp lockTime;
-
-    /**
-     * Ctor.
-     *
-     * @param success Success flag.
-     * @param data Session data.
-     * @param lockTime Lock time.
-     */
-    public SessionStateLockEntryResult(boolean success, SessionStateData data, Timestamp
lockTime) {
-        this.success = success;
-        this.data = data;
-        this.lockTime = lockTime;
-    }
-
-    /**
-     * @return Success flag.
-     */
-    public boolean success() {
-        return success;
-    }
-
-    /**
-     * @return Session state data.
-     */
-    public SessionStateData data() {
-        return data;
-    }
-
-    /**
-     * @return Lock time.
-     */
-    public Timestamp lockTime() {
-        return lockTime;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
-        BinaryRawWriter raw = writer.rawWriter();
-
-        raw.writeBoolean(success);
-        raw.writeObject(data);
-        raw.writeTimestamp(lockTime);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
-        BinaryRawReader raw = reader.rawReader();
-
-        success = raw.readBoolean();
-        data = raw.readObject();
-        lockTime = raw.readTimestamp();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(SessionStateLockEntryResult.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddae6acd/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateLockResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateLockResult.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateLockResult.java
new file mode 100644
index 0000000..7b531b4
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateLockResult.java
@@ -0,0 +1,100 @@
+/*
+ * 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.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+import java.sql.Timestamp;
+
+/**
+ * Result of the {@link LockEntryProcessor} execution.
+ */
+@SuppressWarnings({"AssignmentToDateFieldFromParameter", "ReturnOfDateField"})
+public class SessionStateLockResult implements Binarylizable {
+    /** Success flag. */
+    private boolean success;
+
+    /** Data. */
+    private SessionStateData data;
+
+    /** Lock time. */
+    private Timestamp lockTime;
+
+    /**
+     * Ctor.
+     *
+     * @param success Success flag.
+     * @param data Session data.
+     * @param lockTime Lock time.
+     */
+    public SessionStateLockResult(boolean success, SessionStateData data, Timestamp lockTime)
{
+        this.success = success;
+        this.data = data;
+        this.lockTime = lockTime;
+    }
+
+    /**
+     * @return Success flag.
+     */
+    public boolean success() {
+        return success;
+    }
+
+    /**
+     * @return Session state data.
+     */
+    public SessionStateData data() {
+        return data;
+    }
+
+    /**
+     * @return Lock time.
+     */
+    public Timestamp lockTime() {
+        return lockTime;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+        BinaryRawWriter raw = writer.rawWriter();
+
+        raw.writeBoolean(success);
+        raw.writeObject(data);
+        raw.writeTimestamp(lockTime);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+        BinaryRawReader raw = reader.rawReader();
+
+        success = raw.readBoolean();
+        data = raw.readObject();
+        lockTime = raw.readTimestamp();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(SessionStateLockResult.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddae6acd/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs
b/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs
index fdbd528..2408f75 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs
@@ -238,16 +238,16 @@ namespace Apache.Ignite.AspNet
                 return null;
             }
 
-            var data = lockResult as SessionStateData;
-
-            if (data == null)
+            if (!lockResult.Success)
             {
                 // Already locked.
                 Log("GetItemExclusive already locked", id, context);
 
                 locked = true;
 
-                lockAge = DateTime.UtcNow - (DateTime)lockResult;
+                Debug.Assert(lockResult.LockTime != null);
+
+                lockAge = DateTime.UtcNow - lockResult.LockTime.Value;
 
                 return null;
             }
@@ -256,7 +256,7 @@ namespace Apache.Ignite.AspNet
 
             locked = false;
 
-            return new IgniteSessionStateStoreData(data);
+            return new IgniteSessionStateStoreData(lockResult.Data);
         }
 
         /// <summary>
@@ -432,9 +432,9 @@ namespace Apache.Ignite.AspNet
         /// <summary>
         /// Locks the item.
         /// </summary>
-        private object LockItem(string key, long lockId)
+        private SessionStateLockResult LockItem(string key, long lockId)
         {
-            return ((ICacheInternal) Cache).Invoke<object>((int) Op.Lock, key, GetLockInfo(lockId));
+            return ((ICacheInternal) Cache).Invoke<SessionStateLockResult>((int) Op.Lock,
key, GetLockInfo(lockId));
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddae6acd/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 2e9a683..f546c21 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -91,7 +91,7 @@
     <Compile Include="Discovery\Tcp\Package-Info.cs" />
     <Compile Include="Discovery\Tcp\Static\Package-Info.cs" />
     <Compile Include="Impl\AspNet\SessionStateData.cs" />
-    <Compile Include="Impl\AspNet\SessionStateLockEntryResult.cs" />
+    <Compile Include="Impl\AspNet\SessionStateLockResult.cs" />
     <Compile Include="Impl\AspNet\SessionStateLockInfo.cs" />
     <Compile Include="Impl\Binary\BinaryReflectiveSerializerInternal.cs" />
     <Compile Include="Impl\Binary\IBinarySerializerInternal.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddae6acd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/AspNet/SessionStateLockEntryResult.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/AspNet/SessionStateLockEntryResult.cs
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/AspNet/SessionStateLockEntryResult.cs
deleted file mode 100644
index 6aa2955..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/AspNet/SessionStateLockEntryResult.cs
+++ /dev/null
@@ -1,76 +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.
- */
-
-namespace Apache.Ignite.Core.Impl.AspNet
-{
-    using System;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Binary;
-
-    /// <summary>
-    /// Result of the session state lock processor.
-    /// </summary>
-    public class SessionStateLockEntryResult
-    {
-        /** Success flag. */
-        private readonly bool _success;
-
-        /** Session state data. */
-        private readonly SessionStateData _data;
-
-        /** Lock time. */
-        private readonly DateTime? _lockTime;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="SessionStateLockEntryResult"/>
class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public SessionStateLockEntryResult(IBinaryRawReader reader)
-        {
-            _success = reader.ReadBoolean();
-            _data = reader.ReadObject<SessionStateData>();
-            _lockTime = reader.ReadTimestamp();
-
-            Debug.Assert(_success ^ (_data == null));
-            Debug.Assert(_success ^ (_lockTime != null));
-        }
-
-        /// <summary>
-        /// Gets a value indicating whether lock succeeded.
-        /// </summary>
-        public bool Success
-        {
-            get { return _success; }
-        }
-
-        /// <summary>
-        /// Gets the data. Null when <see cref="Success"/> is <c>false</c>.
-        /// </summary>
-        public SessionStateData Data
-        {
-            get { return _data; }
-        }
-
-        /// <summary>
-        /// Gets the lock time. Null when <see cref="Success"/> is <c>true</c>.
-        /// </summary>
-        public DateTime? LockTime
-        {
-            get { return _lockTime; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddae6acd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/AspNet/SessionStateLockResult.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/AspNet/SessionStateLockResult.cs
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/AspNet/SessionStateLockResult.cs
new file mode 100644
index 0000000..4bf483c
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/AspNet/SessionStateLockResult.cs
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.AspNet
+{
+    using System;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Result of the session state lock processor.
+    /// </summary>
+    public class SessionStateLockResult
+    {
+        /** Success flag. */
+        private readonly bool _success;
+
+        /** Session state data. */
+        private readonly SessionStateData _data;
+
+        /** Lock time. */
+        private readonly DateTime? _lockTime;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="SessionStateLockResult"/>
class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public SessionStateLockResult(IBinaryRawReader reader)
+        {
+            _success = reader.ReadBoolean();
+            _data = reader.ReadObject<SessionStateData>();
+            _lockTime = reader.ReadTimestamp();
+
+            Debug.Assert(_success ^ (_data == null));
+            Debug.Assert(_success ^ (_lockTime != null));
+        }
+
+        /// <summary>
+        /// Gets a value indicating whether lock succeeded.
+        /// </summary>
+        public bool Success
+        {
+            get { return _success; }
+        }
+
+        /// <summary>
+        /// Gets the data. Null when <see cref="Success"/> is <c>false</c>.
+        /// </summary>
+        public SessionStateData Data
+        {
+            get { return _data; }
+        }
+
+        /// <summary>
+        /// Gets the lock time. Null when <see cref="Success"/> is <c>true</c>.
+        /// </summary>
+        public DateTime? LockTime
+        {
+            get { return _lockTime; }
+        }
+
+        /// <summary>
+        /// Returns a <see cref="string" /> that represents this instance.
+        /// </summary>
+        public override string ToString()
+        {
+            return string.Format("{0} [Success={1}]", GetType().Name, _success);
+        }
+    }
+}


Mime
View raw message