ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptupit...@apache.org
Subject ignite git commit: Refactoring data exchange
Date Fri, 09 Sep 2016 10:09:03 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-3199-1 a7ff62424 -> 930b73eb1


Refactoring data exchange


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

Branch: refs/heads/ignite-3199-1
Commit: 930b73eb17bac14243ae3c3d48fc7b838b4a1cb9
Parents: a7ff624
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Fri Sep 9 13:08:51 2016 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Fri Sep 9 13:08:51 2016 +0300

----------------------------------------------------------------------
 .../platform/cache/PlatformCacheInvoker.java    | 25 ++++--------
 .../websession/PlatformDotnetSessionData.java   | 42 ++++++++++++++------
 .../IgniteSessionStateStoreProvider.cs          | 10 +----
 .../Impl/Binary/Marshaller.cs                   |  4 +-
 4 files changed, 42 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/930b73eb/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheInvoker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheInvoker.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheInvoker.java
index 74b7983..6962359 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheInvoker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheInvoker.java
@@ -66,29 +66,20 @@ public class PlatformCacheInvoker {
             }
 
             case OP_SESSION_SET_AND_UNLOCK:
-                UUID lockNodeId = reader.readUuid();
-                long lockId = reader.readLong();
-
                 PlatformDotnetSessionSetAndUnlockProcessor proc;
 
                 if (reader.readBoolean()) {
-                    boolean isDiff = !reader.readBoolean();
-
-                    int count = reader.readInt();
-
-                    Map<String, byte[]> entries = new TreeMap<>();
+                    PlatformDotnetSessionData data = reader.readObject();
 
-                    for (int i = 0; i < count; i++)
-                        entries.put(reader.readString(), reader.readByteArray());
-
-                    byte[] staticData = reader.readByteArray();
-                    int timeout = reader.readInt();
-
-                    proc = new PlatformDotnetSessionSetAndUnlockProcessor(lockNodeId, lockId,
entries, isDiff,
-                        staticData, timeout);
+                    proc = new PlatformDotnetSessionSetAndUnlockProcessor(data.lockNodeId(),
data.lockId(), data.items(), data.isDiff(),
+                        data.staticObjects(), data.timeout());
                 }
-                else
+                else {
+                    UUID lockNodeId = reader.readUuid();
+                    long lockId = reader.readLong();
+
                     proc = new PlatformDotnetSessionSetAndUnlockProcessor(lockNodeId, lockId);
+                }
 
                 cache.invoke(key, proc);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/930b73eb/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/PlatformDotnetSessionData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/PlatformDotnetSessionData.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/PlatformDotnetSessionData.java
index 85ceec8..23bfe4c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/PlatformDotnetSessionData.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/PlatformDotnetSessionData.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 
 import java.sql.Timestamp;
 import java.util.Map;
+import java.util.TreeMap;
 import java.util.UUID;
 
 /**
@@ -38,6 +39,9 @@ public class PlatformDotnetSessionData implements Binarylizable {
     /** Items. */
     private Map<String, byte[]> items;
 
+    /** Diff flag. */
+    private boolean isDiff;
+
     /** Static objects. */
     @GridToStringExclude
     private byte[] staticObjects;
@@ -62,6 +66,13 @@ public class PlatformDotnetSessionData implements Binarylizable {
     }
 
     /**
+     * @return Diff flag.
+     */
+    public boolean isDiff() {
+        return isDiff;
+    }
+
+    /**
      * @return Static objects.
      */
     public byte[] staticObjects() {
@@ -104,15 +115,6 @@ public class PlatformDotnetSessionData implements Binarylizable {
     }
 
     /**
-     * Ctor.
-     *
-     * @param timeout Timeout.
-     */
-    public PlatformDotnetSessionData(int timeout) {
-        this.timeout = timeout;
-    }
-
-    /**
      * Locks the session state data.
      *
      * @param lockNodeId Lock node ID.
@@ -196,10 +198,11 @@ public class PlatformDotnetSessionData implements Binarylizable {
      * @return Copied state data.
      */
     private PlatformDotnetSessionData copyWithoutLockInfo() {
-        PlatformDotnetSessionData res = new PlatformDotnetSessionData(timeout);
+        PlatformDotnetSessionData res = new PlatformDotnetSessionData();
 
         res.staticObjects = staticObjects;
         res.items = items;
+        res.timeout = timeout;
 
         return res;
     }
@@ -212,7 +215,15 @@ public class PlatformDotnetSessionData implements Binarylizable {
         raw.writeUuid(lockNodeId);
         raw.writeLong(lockId);
         raw.writeTimestamp(lockTime);
-        raw.writeObject(items);
+
+        raw.writeBoolean(isDiff);
+        raw.writeInt(items.size());
+
+        for (Map.Entry<String, byte[]> e : items.entrySet()) {
+            raw.writeString(e.getKey());
+            raw.writeByteArray(e.getValue());
+        }
+
         raw.writeByteArray(staticObjects);
     }
 
@@ -224,7 +235,14 @@ public class PlatformDotnetSessionData implements Binarylizable {
         lockNodeId = raw.readUuid();
         lockId = raw.readLong();
         lockTime = raw.readTimestamp();
-        items = raw.readObject();
+
+        items = new TreeMap<>();
+        isDiff = !raw.readBoolean();
+        int count = raw.readInt();
+
+        for (int i = 0; i < count; i++)
+            items.put(raw.readString(), raw.readByteArray());
+
         staticObjects = raw.readByteArray();
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/930b73eb/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 1b85fd9..f36a0d2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs
@@ -461,8 +461,8 @@ namespace Apache.Ignite.AspNet
         {
             ((ICacheInternal) Cache).Invoke<object>((int) Op.Unlock, w =>
             {
-                WriteLockInfo(w, lockId);
                 w.WriteBoolean(false);  // Only unlock.
+                WriteLockInfo(w, lockId);
                 w.WriteString(key);
             });
         }
@@ -478,15 +478,9 @@ namespace Apache.Ignite.AspNet
 
             ((ICacheInternal) cache).Invoke<object>((int) Op.SetAndUnlock, w =>
             {
-                WriteLockInfo(w, data.LockId);
                 w.WriteBoolean(true);  // Unlock and update.
                 w.WriteString(key);
-
-                // TODO: Refactor
-                data.Items.WriteBinary((IBinaryWriter) w);
-
-                w.WriteByteArray(data.StaticObjects);
-                w.WriteInt(data.Timeout);
+                w.WriteObject(data);
             });
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/930b73eb/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
index e3b9cea..2bf6dbb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -596,8 +596,8 @@ namespace Apache.Ignite.Core.Impl.Binary
             AddSystemType(0, r => new AffinityKey(r), "affKey");
             AddSystemType(BinaryUtils.TypePlatformJavaObjectFactoryProxy, r => new PlatformJavaObjectFactoryProxy());
             AddSystemType(0, r => new ObjectInfoHolder(r));
-            AddSystemType(0, r => new SessionStateData(r), "PlatformDotnetSessionData");
-            AddSystemType(0, r => new SessionStateLockResult(r), "PlatformDotnetSessionLockResult");
+            AddSystemType(0, r => new SessionStateData(r), typeNameOverride: "PlatformDotnetSessionData");
+            AddSystemType(0, r => new SessionStateLockResult(r), typeNameOverride: "PlatformDotnetSessionLockResult");
         }
     }
 }


Mime
View raw message