You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/03/05 09:55:00 UTC

[02/50] [abbrv] incubator-ignite git commit: #ignite-51: IgniteTxEntry implements Message: IgniteTxEntry by codegen.

#ignite-51: IgniteTxEntry implements Message: IgniteTxEntry by codegen.


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

Branch: refs/heads/ignite-user-req
Commit: cc7fab49ec5001d04f58e8298549c3d0c073f7c2
Parents: 954777c
Author: ivasilinets <iv...@gridgain.com>
Authored: Tue Mar 3 19:09:22 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Tue Mar 3 19:09:22 2015 +0300

----------------------------------------------------------------------
 .../cache/transactions/IgniteTxEntry.java       | 111 ++++++++++---------
 .../cache/transactions/TxEntryValueHolder.java  |  37 ++-----
 2 files changed, 71 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc7fab49/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index 7d6e637..0f30e85 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -26,7 +26,6 @@ import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
-import org.apache.ignite.marshaller.optimized.*;
 import org.apache.ignite.plugin.extensions.communication.*;
 import org.jetbrains.annotations.*;
 
@@ -45,7 +44,7 @@ import static org.apache.ignite.internal.processors.cache.GridCacheOperation.*;
  * {@link #equals(Object)} method, as transaction entries should use referential
  * equality.
  */
-public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMarshallable {
+public class IgniteTxEntry implements GridPeerDeployAware, Message {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -55,6 +54,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
 
     /** Owning transaction. */
     @GridToStringExclude
+    @GridDirectTransient
     private IgniteInternalTx tx;
 
     /** Cache key. */
@@ -65,6 +65,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
     private int cacheId;
 
     /** Transient tx key. */
+    @GridDirectTransient
     private IgniteTxKey txKey;
 
     /** Cache value. */
@@ -73,6 +74,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
 
     /** Visible value for peek. */
     @GridToStringInclude
+    @GridDirectTransient
     private TxEntryValueHolder prevVal = new TxEntryValueHolder();
 
     /** Filter bytes. */
@@ -98,6 +100,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
 
     /** Explicit lock version if there is one. */
     @GridToStringInclude
+    @GridDirectTransient
     private GridCacheVersion explicitVer;
 
     /** DHT version. */
@@ -109,6 +112,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
     private IgnitePredicate<Cache.Entry<Object, Object>>[] filters;
 
     /** Flag indicating whether filters passed. Used for fast-commit transactions. */
+    @GridDirectTransient
     private boolean filtersPassed;
 
     /** Flag indicating that filter is set and can not be replaced. */
@@ -131,18 +135,18 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
     private transient UUID nodeId;
 
     /** Flag if this node is a back up node. */
+    @GridDirectTransient
     private boolean locMapped;
 
     /** Group lock entry flag. */
     private boolean grpLock;
 
-    /** Deployment enabled flag. */
-    private boolean depEnabled = true;
-
     /** Expiry policy. */
+    @GridDirectTransient
     private ExpiryPolicy expiryPlc;
 
     /** Expiry policy transfer flag. */
+    @GridDirectTransient
     private boolean transferExpiryPlc;
 
     /**
@@ -188,8 +192,6 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
         key = entry.key();
 
         cacheId = entry.context().cacheId();
-
-        depEnabled = ctx.gridDeploy().enabled();
     }
 
     /**
@@ -235,8 +237,6 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
         key = entry.key();
 
         cacheId = entry.context().cacheId();
-
-        depEnabled = ctx.gridDeploy().enabled();
     }
 
     /**
@@ -296,7 +296,6 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
         cp.conflictExpireTime = conflictExpireTime;
         cp.explicitVer = explicitVer;
         cp.grpLock = grpLock;
-        cp.depEnabled = depEnabled;
         cp.conflictVer = conflictVer;
         cp.expiryPlc = expiryPlc;
 
@@ -688,22 +687,20 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
      */
     public void marshal(GridCacheSharedContext<?, ?> ctx, boolean transferExpiry) throws IgniteCheckedException {
         // Do not serialize filters if they are null.
-        if (depEnabled) {
-            if (transformClosBytes == null && entryProcessorsCol != null)
-                transformClosBytes = CU.marshal(ctx, entryProcessorsCol);
-
-            if (F.isEmptyOrNulls(filters))
-                filterBytes = null;
-            else if (filterBytes == null)
-                filterBytes = CU.marshal(ctx, filters);
-        }
+        if (transformClosBytes == null && entryProcessorsCol != null)
+            transformClosBytes = CU.marshal(ctx, entryProcessorsCol);
+
+        if (F.isEmptyOrNulls(filters))
+            filterBytes = null;
+        else if (filterBytes == null)
+            filterBytes = CU.marshal(ctx, filters);
 
         if (transferExpiry)
             transferExpiryPlc = expiryPlc != null && expiryPlc != this.ctx.expiry();
 
         key.prepareMarshal(context().cacheObjectContext());
 
-        val.marshal(ctx, context(), depEnabled);
+        val.marshal(ctx, context());
     }
 
     /**
@@ -726,22 +723,20 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
             this.ctx = cacheCtx;
         }
 
-        if (depEnabled) {
-            // Unmarshal transform closure anyway if it exists.
-            if (transformClosBytes != null && entryProcessorsCol == null)
-                entryProcessorsCol = ctx.marshaller().unmarshal(transformClosBytes, clsLdr);
+        // Unmarshal transform closure anyway if it exists.
+        if (transformClosBytes != null && entryProcessorsCol == null)
+            entryProcessorsCol = ctx.marshaller().unmarshal(transformClosBytes, clsLdr);
 
-            if (filters == null && filterBytes != null) {
-                filters = ctx.marshaller().unmarshal(filterBytes, clsLdr);
+        if (filters == null && filterBytes != null) {
+            filters = ctx.marshaller().unmarshal(filterBytes, clsLdr);
 
-                if (filters == null)
-                    filters = CU.empty();
-            }
+            if (filters == null)
+                filters = CU.empty();
         }
 
         key.finishUnmarshal(context(), clsLdr);
 
-        val.unmarshal(this.ctx, clsLdr, depEnabled);
+        val.unmarshal(this.ctx, clsLdr);
     }
 
     /**
@@ -771,50 +766,59 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
 
         switch (writer.state()) {
             case 0:
-                if (!writer.writeMessage("key", key))
+                if (!writer.writeInt("cacheId", cacheId))
                     return false;
 
                 writer.incrementState();
+
             case 1:
-                if (!writer.writeInt("cacheId", cacheId))
+                if (!writer.writeLong("conflictExpireTime", conflictExpireTime))
                     return false;
 
                 writer.incrementState();
+
             case 2:
-                if (!writer.writeMessage("val", val))
+                if (!writer.writeMessage("conflictVer", conflictVer))
                     return false;
 
                 writer.incrementState();
+
             case 3:
-                if (!writer.writeLong("ttl", ttl))
+                if (!writer.writeByteArray("filterBytes", filterBytes))
                     return false;
 
                 writer.incrementState();
+
             case 4:
-                if (!writer.writeMessage("conflictVer", conflictVer))
+                if (!writer.writeBoolean("grpLock", grpLock))
                     return false;
 
                 writer.incrementState();
+
             case 5:
-                if (!writer.writeBoolean("grpLock", grpLock))
+                if (!writer.writeMessage("key", key))
                     return false;
 
                 writer.incrementState();
+
             case 6:
                 if (!writer.writeByteArray("transformClosBytes", transformClosBytes))
                     return false;
 
                 writer.incrementState();
+
             case 7:
-                if (!writer.writeByteArray("filterBytes", filterBytes))
+                if (!writer.writeLong("ttl", ttl))
                     return false;
 
                 writer.incrementState();
+
             case 8:
-                if (!(writer.writeLong("conflictExpireTime", conflictExpireTime)))
+                if (!writer.writeMessage("val", val))
                     return false;
 
                 writer.incrementState();
+
         }
 
         return true;
@@ -829,46 +833,53 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
 
         switch (reader.state()) {
             case 0:
-                key = reader.readMessage("key");
+                cacheId = reader.readInt("cacheId");
+
                 if (!reader.isLastRead())
                     return false;
 
                 reader.incrementState();
+
             case 1:
-                cacheId = reader.readInt("cacheId");
+                conflictExpireTime = reader.readLong("conflictExpireTime");
 
                 if (!reader.isLastRead())
                     return false;
 
                 reader.incrementState();
+
             case 2:
-                val = reader.readMessage("val");
+                conflictVer = reader.readMessage("conflictVer");
 
                 if (!reader.isLastRead())
                     return false;
 
                 reader.incrementState();
+
             case 3:
-                ttl = reader.readLong("ttl");
+                filterBytes = reader.readByteArray("filterBytes");
 
                 if (!reader.isLastRead())
                     return false;
 
                 reader.incrementState();
+
             case 4:
-                conflictVer = reader.readMessage("conflictVer");
+                grpLock = reader.readBoolean("grpLock");
 
                 if (!reader.isLastRead())
                     return false;
 
                 reader.incrementState();
+
             case 5:
-                grpLock = reader.readBoolean("grpLock");
+                key = reader.readMessage("key");
 
                 if (!reader.isLastRead())
                     return false;
 
                 reader.incrementState();
+
             case 6:
                 transformClosBytes = reader.readByteArray("transformClosBytes");
 
@@ -876,22 +887,23 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
                     return false;
 
                 reader.incrementState();
+
             case 7:
-                filterBytes = reader.readByteArray("filterBytes");
+                ttl = reader.readLong("ttl");
 
                 if (!reader.isLastRead())
                     return false;
 
                 reader.incrementState();
+
             case 8:
-                conflictExpireTime = reader.readLong("conflictExpireTime");
+                val = reader.readMessage("val");
 
                 if (!reader.isLastRead())
                     return false;
 
                 reader.incrementState();
 
-
         }
 
         return true;
@@ -908,11 +920,6 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
     }
 
     /** {@inheritDoc} */
-    @Override public Object ggClassId() {
-        return GG_CLASS_ID;
-    }
-
-    /** {@inheritDoc} */
     @Override public Class<?> deployClass() {
         ClassLoader clsLdr = getClass().getClassLoader();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc7fab49/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
index 5a4689c..2cd0c37 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache.transactions;
 
 import org.apache.ignite.*;
+import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.plugin.extensions.communication.*;
@@ -44,6 +45,7 @@ public class TxEntryValueHolder implements Message {
     private boolean hasWriteVal;
 
     /** Flag indicating that value has been set for read. */
+    @GridDirectTransient
     private boolean hasReadVal;
 
     /**
@@ -121,10 +123,9 @@ public class TxEntryValueHolder implements Message {
     /**
      * @param sharedCtx Shared cache context.
      * @param ctx Cache context.
-     * @param depEnabled Deployment enabled flag.
      * @throws org.apache.ignite.IgniteCheckedException If marshaling failed.
      */
-    public void marshal(GridCacheSharedContext<?, ?> sharedCtx, GridCacheContext<?, ?> ctx, boolean depEnabled)
+    public void marshal(GridCacheSharedContext<?, ?> sharedCtx, GridCacheContext<?, ?> ctx)
         throws IgniteCheckedException {
         if (hasWriteVal && val != null)
             val.prepareMarshal(ctx.cacheObjectContext());
@@ -143,10 +144,9 @@ public class TxEntryValueHolder implements Message {
     /**
      * @param ctx Cache context.
      * @param ldr Class loader.
-     * @param depEnabled Deployment enabled flag.
      * @throws org.apache.ignite.IgniteCheckedException If unmarshalling failed.
      */
-    public void unmarshal(GridCacheContext<?, ?> ctx, ClassLoader ldr, boolean depEnabled) throws IgniteCheckedException {
+    public void unmarshal(GridCacheContext<?, ?> ctx, ClassLoader ldr) throws IgniteCheckedException {
         if (val != null)
             val.finishUnmarshal(ctx, ldr);
 
@@ -235,24 +235,18 @@ public class TxEntryValueHolder implements Message {
 
         switch (writer.state()) {
             case 0:
-                if (!writer.writeBoolean("hasReadVal", hasReadVal))
-                    return false;
-
-                writer.incrementState();
-
-            case 1:
                 if (!writer.writeBoolean("hasWriteVal", hasWriteVal))
                     return false;
 
                 writer.incrementState();
 
-            case 2:
+            case 1:
                 if (!writer.writeByte("op", op != null ? (byte)op.ordinal() : -1))
                     return false;
 
                 writer.incrementState();
 
-            case 3:
+            case 2:
                 if (!writer.writeMessage("val", val))
                     return false;
 
@@ -272,7 +266,7 @@ public class TxEntryValueHolder implements Message {
 
         switch (reader.state()) {
             case 0:
-                hasReadVal = reader.readBoolean("hasReadVal");
+                hasWriteVal = reader.readBoolean("hasWriteVal");
 
                 if (!reader.isLastRead())
                     return false;
@@ -280,25 +274,18 @@ public class TxEntryValueHolder implements Message {
                 reader.incrementState();
 
             case 1:
-                hasWriteVal = reader.readBoolean("hasWriteVal");
-
-                if (!reader.isLastRead())
-                    return false;
+                byte opOrd;
 
-                reader.incrementState();
-
-            case 2:
-                byte opOrd = reader.readByte("op");
+                opOrd = reader.readByte("op");
 
                 if (!reader.isLastRead())
                     return false;
 
-                if (opOrd != -1)
-                    op = GridCacheOperation.fromOrdinal(opOrd);
+                op = GridCacheOperation.fromOrdinal(opOrd);
 
                 reader.incrementState();
 
-            case 3:
+            case 2:
                 val = reader.readMessage("val");
 
                 if (!reader.isLastRead())
@@ -318,6 +305,6 @@ public class TxEntryValueHolder implements Message {
 
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
-        return 4;
+        return 3;
     }
 }