ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [08/22] incubator-ignite git commit: #ignite-51: IgniteTxEntry implements Message: TxEntryValueHolder to upper level.
Date Wed, 04 Mar 2015 13:26:43 GMT
#ignite-51: IgniteTxEntry implements Message: TxEntryValueHolder to upper level.


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

Branch: refs/heads/ignite-51
Commit: 22df51c8b866585c838f22b3e664f837a8a976e1
Parents: 8d617ea
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Tue Mar 3 18:52:29 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Tue Mar 3 18:52:29 2015 +0300

----------------------------------------------------------------------
 .../communication/GridIoMessageFactory.java     |   2 +-
 .../cache/transactions/IgniteTxEntry.java       | 292 +----------------
 .../cache/transactions/TxEntryValueHolder.java  | 319 +++++++++++++++++++
 3 files changed, 323 insertions(+), 290 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22df51c8/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
index 2126d86..f12a9bf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
@@ -540,7 +540,7 @@ public class GridIoMessageFactory implements MessageFactory {
                 break;
 
             case 98:
-                msg = new IgniteTxEntry.TxEntryValueHolder();
+                msg = new TxEntryValueHolder();
 
                 break;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22df51c8/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 03f70db..7d6e637 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
@@ -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.processors.cache.version.*;
 import org.apache.ignite.internal.util.lang.*;
@@ -79,6 +80,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
 
     /** Transform. */
     @GridToStringInclude
+    @GridDirectTransient
     private Collection<T2<EntryProcessor<Object, Object, Object>, Object[]>>
entryProcessorsCol;
 
     /** Transform closure bytes. */
@@ -103,6 +105,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message, OptimizedMar
 
     /** Put filters. */
     @GridToStringInclude
+    @GridDirectTransient
     private IgnitePredicate<Cache.Entry<Object, Object>>[] filters;
 
     /** Flag indicating whether filters passed. Used for fast-commit transactions. */
@@ -930,293 +933,4 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message,
OptimizedMar
         return GridToStringBuilder.toString(IgniteTxEntry.class, this, "xidVer", tx == null
? "null" : tx.xidVersion());
     }
 
-    /**
-     * Auxiliary class to hold value, value-has-been-set flag, value update operation, value
bytes.
-     */
-    public static class TxEntryValueHolder implements Message {
-        /** */
-        @GridToStringInclude
-        private CacheObject val;
-
-        /** */
-        @GridToStringInclude
-        private GridCacheOperation op = NOOP;
-
-        /** Flag indicating that value has been set for write. */
-        private boolean hasWriteVal;
-
-        /** Flag indicating that value has been set for read. */
-        private boolean hasReadVal;
-
-        /**
-         * @param op Cache operation.
-         * @param val Value.
-         * @param hasWriteVal Write value presence flag.
-         * @param hasReadVal Read value presence flag.
-         */
-        public void value(GridCacheOperation op, CacheObject val, boolean hasWriteVal, boolean
hasReadVal) {
-            if (hasReadVal && this.hasWriteVal)
-                return;
-
-            this.op = op;
-            this.val = val;
-
-            this.hasWriteVal = hasWriteVal || op == CREATE || op == UPDATE || op == DELETE;
-            this.hasReadVal = hasReadVal || op == READ;
-        }
-
-        /**
-         * @return {@code True} if has read or write value.
-         */
-        public boolean hasValue() {
-            return hasWriteVal || hasReadVal;
-        }
-
-        /**
-         * Gets stored value.
-         *
-         * @return Value.
-         */
-        public CacheObject value() {
-            return val;
-        }
-
-        /**
-         * @param val Stored value.
-         */
-        public void value(@Nullable CacheObject val) {
-            this.val = val;
-        }
-
-        /**
-         * Gets cache operation.
-         *
-         * @return Cache operation.
-         */
-        public GridCacheOperation op() {
-            return op;
-        }
-
-        /**
-         * Sets cache operation.
-         *
-         * @param op Cache operation.
-         */
-        public void op(GridCacheOperation op) {
-            this.op = op;
-        }
-
-        /**
-         * @return {@code True} if write value was set.
-         */
-        public boolean hasWriteValue() {
-            return hasWriteVal;
-        }
-
-        /**
-         * @return {@code True} if read value was set.
-         */
-        public boolean hasReadValue() {
-            return hasReadVal;
-        }
-
-        /**
-         * @param sharedCtx Shared cache context.
-         * @param ctx Cache context.
-         * @param depEnabled Deployment enabled flag.
-         * @throws IgniteCheckedException If marshaling failed.
-         */
-        public void marshal(GridCacheSharedContext<?, ?> sharedCtx, GridCacheContext<?,
?> ctx, boolean depEnabled)
-            throws IgniteCheckedException {
-            if (hasWriteVal && val != null)
-                val.prepareMarshal(ctx.cacheObjectContext());
-
-// TODO IGNITE-51.
-//            boolean valIsByteArr = val != null && val instanceof byte[];
-//
-//            // Do not send write values to remote nodes.
-//            if (hasWriteVal && val != null && !valIsByteArr &&
valBytes == null &&
-//                (depEnabled || !ctx.isUnmarshalValues()))
-//                valBytes = CU.marshal(sharedCtx, val);
-//
-//            valBytesSent = hasWriteVal && !valIsByteArr && valBytes !=
null && (depEnabled || !ctx.isUnmarshalValues());
-        }
-
-        /**
-         * @param ctx Cache context.
-         * @param ldr Class loader.
-         * @param depEnabled Deployment enabled flag.
-         * @throws IgniteCheckedException If unmarshalling failed.
-         */
-        public void unmarshal(GridCacheContext<?, ?> ctx, ClassLoader ldr, boolean
depEnabled) throws IgniteCheckedException {
-            if (val != null)
-                val.finishUnmarshal(ctx, ldr);
-
-// TODO IGNITE-51.
-//            if (valBytes != null && val == null && (ctx.isUnmarshalValues()
|| op == TRANSFORM || depEnabled))
-//                val = ctx.marshaller().unmarshal(valBytes, ldr);
-        }
-
-        /**
-         * @param out Data output.
-         * @throws IOException If failed.
-         */
-        public void writeTo(ObjectOutput out) throws IOException {
-            out.writeBoolean(hasWriteVal);
-
-            if (hasWriteVal)
-                out.writeObject(val);
-
-            out.writeInt(op.ordinal());
-// TODO IGNITE-51.
-//            out.writeBoolean(hasWriteVal);
-//            out.writeBoolean(valBytesSent);
-//
-//            if (hasWriteVal) {
-//                if (valBytesSent)
-//                    U.writeByteArray(out, valBytes);
-//                else {
-//                    if (val != null && val instanceof byte[]) {
-//                        out.writeBoolean(true);
-//
-//                        U.writeByteArray(out, (byte[]) val);
-//                    }
-//                    else {
-//                        out.writeBoolean(false);
-//
-//                        out.writeObject(val);
-//                    }
-//                }
-//            }
-//
-//            out.writeInt(op.ordinal());
-        }
-
-        /**
-         * @param in Data input.
-         * @throws IOException If failed.
-         * @throws ClassNotFoundException If failed.
-         */
-        @SuppressWarnings("unchecked")
-        public void readFrom(ObjectInput in) throws IOException, ClassNotFoundException {
-            hasWriteVal = in.readBoolean();
-
-            if (hasWriteVal)
-                val = (CacheObject)in.readObject();
-
-            op = fromOrdinal(in.readInt());
-// TODO IGNITE-51.
-//            hasWriteVal = in.readBoolean();
-//            valBytesSent = in.readBoolean();
-//
-//            if (hasWriteVal) {
-//                if (valBytesSent)
-//                    valBytes = U.readByteArray(in);
-//                else
-//                    val = in.readBoolean() ? (V) U.readByteArray(in) : (V)in.readObject();
-//            }
-//
-//            op = fromOrdinal(in.readInt());
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return "[op=" + op +", val=" + val + ']';
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
-            writer.setBuffer(buf);
-
-            if (!writer.isHeaderWritten()) {
-                if (!writer.writeHeader(directType(), fieldsCount()))
-                    return false;
-
-                writer.onHeaderWritten();
-            }
-
-            switch (writer.state()) {
-                case 0:
-                    if (!writer.writeBoolean("hasWriteVal", hasWriteVal))
-                        return false;
-
-                    writer.incrementState();
-
-                case 1:
-                    if (!writer.writeBoolean("hasReadVal", hasReadVal))
-                        return false;
-
-                    writer.incrementState();
-
-                case 2:
-                    if (!writer.writeInt("op", op.ordinal()))
-                        return false;
-
-                    writer.incrementState();
-                case 3:
-                    if (!writer.writeMessage("cacheObject", val))
-                        return false;
-
-                    writer.incrementState();
-
-
-            }
-
-            return true;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
-            reader.setBuffer(buf);
-
-            if (!reader.beforeMessageRead())
-                return false;
-
-            switch (reader.state()) {
-                case 0:
-                    hasWriteVal = reader.readBoolean("hasWriteVal");
-
-                    if (!reader.isLastRead())
-                        return false;
-
-                    reader.incrementState();
-
-                case 1:
-                    hasReadVal = reader.readBoolean("hasReadVal");
-
-                    if (!reader.isLastRead())
-                        return false;
-
-                    reader.incrementState();
-                case 2:
-                    op = GridCacheOperation.fromOrdinal(reader.readInt("op"));
-
-                    if (!reader.isLastRead())
-                        return false;
-
-                    reader.incrementState();
-
-                case 3:
-                    val = reader.readMessage("cacheObject");
-
-                    if (!reader.isLastRead())
-                        return false;
-
-                    reader.incrementState();
-
-            }
-
-            return true;
-        }
-
-        /** {@inheritDoc} */
-        @Override public byte directType() {
-            return 98;
-        }
-
-        /** {@inheritDoc} */
-        @Override public byte fieldsCount() {
-            return 4;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22df51c8/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
new file mode 100644
index 0000000..c1c759f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
@@ -0,0 +1,319 @@
+/*
+ * 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.cache.transactions;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.util.tostring.*;
+import org.apache.ignite.plugin.extensions.communication.*;
+import org.jetbrains.annotations.*;
+
+import java.io.*;
+import java.nio.*;
+
+import static org.apache.ignite.internal.processors.cache.GridCacheOperation.*;
+
+/**
+ * Auxiliary class to hold value, value-has-been-set flag, value update operation, value
bytes.
+ */
+public class TxEntryValueHolder implements Message {
+    /** */
+    @GridToStringInclude
+    private CacheObject val;
+
+    /** */
+    @GridToStringInclude
+    private GridCacheOperation op = NOOP;
+
+    /** Flag indicating that value has been set for write. */
+    private boolean hasWriteVal;
+
+    /** Flag indicating that value has been set for read. */
+    private boolean hasReadVal;
+
+    /**
+     * @param op Cache operation.
+     * @param val Value.
+     * @param hasWriteVal Write value presence flag.
+     * @param hasReadVal Read value presence flag.
+     */
+    public void value(GridCacheOperation op, CacheObject val, boolean hasWriteVal, boolean
hasReadVal) {
+        if (hasReadVal && this.hasWriteVal)
+            return;
+
+        this.op = op;
+        this.val = val;
+
+        this.hasWriteVal = hasWriteVal || op == CREATE || op == UPDATE || op == DELETE;
+        this.hasReadVal = hasReadVal || op == READ;
+    }
+
+    /**
+     * @return {@code True} if has read or write value.
+     */
+    public boolean hasValue() {
+        return hasWriteVal || hasReadVal;
+    }
+
+    /**
+     * Gets stored value.
+     *
+     * @return Value.
+     */
+    public CacheObject value() {
+        return val;
+    }
+
+    /**
+     * @param val Stored value.
+     */
+    public void value(@Nullable CacheObject val) {
+        this.val = val;
+    }
+
+    /**
+     * Gets cache operation.
+     *
+     * @return Cache operation.
+     */
+    public GridCacheOperation op() {
+        return op;
+    }
+
+    /**
+     * Sets cache operation.
+     *
+     * @param op Cache operation.
+     */
+    public void op(GridCacheOperation op) {
+        this.op = op;
+    }
+
+    /**
+     * @return {@code True} if write value was set.
+     */
+    public boolean hasWriteValue() {
+        return hasWriteVal;
+    }
+
+    /**
+     * @return {@code True} if read value was set.
+     */
+    public boolean hasReadValue() {
+        return hasReadVal;
+    }
+
+    /**
+     * @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)
+        throws IgniteCheckedException {
+        if (hasWriteVal && val != null)
+            val.prepareMarshal(ctx.cacheObjectContext());
+
+// TODO IGNITE-51.
+//            boolean valIsByteArr = val != null && val instanceof byte[];
+//
+//            // Do not send write values to remote nodes.
+//            if (hasWriteVal && val != null && !valIsByteArr &&
valBytes == null &&
+//                (depEnabled || !ctx.isUnmarshalValues()))
+//                valBytes = CU.marshal(sharedCtx, val);
+//
+//            valBytesSent = hasWriteVal && !valIsByteArr && valBytes !=
null && (depEnabled || !ctx.isUnmarshalValues());
+    }
+
+    /**
+     * @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 {
+        if (val != null)
+            val.finishUnmarshal(ctx, ldr);
+
+// TODO IGNITE-51.
+//            if (valBytes != null && val == null && (ctx.isUnmarshalValues()
|| op == TRANSFORM || depEnabled))
+//                val = ctx.marshaller().unmarshal(valBytes, ldr);
+    }
+
+    /**
+     * @param out Data output.
+     * @throws java.io.IOException If failed.
+     */
+    public void writeTo(ObjectOutput out) throws IOException {
+        out.writeBoolean(hasWriteVal);
+
+        if (hasWriteVal)
+            out.writeObject(val);
+
+        out.writeInt(op.ordinal());
+// TODO IGNITE-51.
+//            out.writeBoolean(hasWriteVal);
+//            out.writeBoolean(valBytesSent);
+//
+//            if (hasWriteVal) {
+//                if (valBytesSent)
+//                    U.writeByteArray(out, valBytes);
+//                else {
+//                    if (val != null && val instanceof byte[]) {
+//                        out.writeBoolean(true);
+//
+//                        U.writeByteArray(out, (byte[]) val);
+//                    }
+//                    else {
+//                        out.writeBoolean(false);
+//
+//                        out.writeObject(val);
+//                    }
+//                }
+//            }
+//
+//            out.writeInt(op.ordinal());
+    }
+
+    /**
+     * @param in Data input.
+     * @throws java.io.IOException If failed.
+     * @throws ClassNotFoundException If failed.
+     */
+    @SuppressWarnings("unchecked")
+    public void readFrom(ObjectInput in) throws IOException, ClassNotFoundException {
+        hasWriteVal = in.readBoolean();
+
+        if (hasWriteVal)
+            val = (CacheObject)in.readObject();
+
+        op = fromOrdinal(in.readInt());
+// TODO IGNITE-51.
+//            hasWriteVal = in.readBoolean();
+//            valBytesSent = in.readBoolean();
+//
+//            if (hasWriteVal) {
+//                if (valBytesSent)
+//                    valBytes = U.readByteArray(in);
+//                else
+//                    val = in.readBoolean() ? (V) U.readByteArray(in) : (V)in.readObject();
+//            }
+//
+//            op = fromOrdinal(in.readInt());
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return "[op=" + op +", val=" + val + ']';
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
+        writer.setBuffer(buf);
+
+        if (!writer.isHeaderWritten()) {
+            if (!writer.writeHeader(directType(), fieldsCount()))
+                return false;
+
+            writer.onHeaderWritten();
+        }
+
+        switch (writer.state()) {
+            case 0:
+                if (!writer.writeBoolean("hasWriteVal", hasWriteVal))
+                    return false;
+
+                writer.incrementState();
+
+            case 1:
+                if (!writer.writeBoolean("hasReadVal", hasReadVal))
+                    return false;
+
+                writer.incrementState();
+
+            case 2:
+                if (!writer.writeInt("op", op.ordinal()))
+                    return false;
+
+                writer.incrementState();
+            case 3:
+                if (!writer.writeMessage("cacheObject", val))
+                    return false;
+
+                writer.incrementState();
+
+
+        }
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
+        reader.setBuffer(buf);
+
+        if (!reader.beforeMessageRead())
+            return false;
+
+        switch (reader.state()) {
+            case 0:
+                hasWriteVal = reader.readBoolean("hasWriteVal");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 1:
+                hasReadVal = reader.readBoolean("hasReadVal");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+            case 2:
+                op = GridCacheOperation.fromOrdinal(reader.readInt("op"));
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 3:
+                val = reader.readMessage("cacheObject");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+        }
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte directType() {
+        return 98;
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte fieldsCount() {
+        return 4;
+    }
+}


Mime
View raw message