ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [2/2] ignite git commit: IGNITE-2100: WIP.
Date Wed, 16 Dec 2015 08:40:10 GMT
IGNITE-2100: WIP.


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

Branch: refs/heads/ignite-2100
Commit: 43a3de5ad28f38189be4c4354591431b6636a08b
Parents: 855b154
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Wed Dec 16 10:51:54 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Wed Dec 16 10:51:54 2015 +0300

----------------------------------------------------------------------
 .../ignite/binary/BinaryTypeConfiguration.java  | 43 +++++++++++---------
 .../ignite/internal/binary/BinaryContext.java   | 28 ++++++-------
 2 files changed, 38 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/43a3de5a/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
index 9d00eee..c9bdac1 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
@@ -33,8 +33,8 @@ import java.io.Externalizable;
  * binary type without affecting configuration for other binary types.
  */
 public class BinaryTypeConfiguration {
-    /** Default value of "use default serialization" flag. */
-    public static final boolean DFLT_USE_DFLT_SER = true;
+    /** Default value of "ignore Java serialization" flag. */
+    public static final boolean DFLT_IGNORE_JAVA_SER = false;
 
     /** Class name. */
     private String typeName;
@@ -48,8 +48,8 @@ public class BinaryTypeConfiguration {
     /** Enum flag. */
     private boolean isEnum;
 
-    /** Use default serialization flag. */
-    private boolean useDfltSer = DFLT_USE_DFLT_SER;
+    /** Ignore Java serialization flag. */
+    private boolean ignoreJavaSer = DFLT_IGNORE_JAVA_SER;
 
     /**
      * Constructor.
@@ -70,7 +70,7 @@ public class BinaryTypeConfiguration {
         idMapper = other.idMapper;
         serializer = other.serializer;
         isEnum = other.isEnum;
-        useDfltSer = other.useDfltSer;
+        ignoreJavaSer = other.ignoreJavaSer;
     }
 
     /**
@@ -153,31 +153,36 @@ public class BinaryTypeConfiguration {
     }
 
     /**
-     * Gets whether to use default serialization.
+     * Gets whether to ignore Java serialization mechanisms.
      * <p>
      * {@link BinaryMarshaller} allows for objects to be used without deserialization. To
achieve this fields metadata
-     * is written along with their values. When default Java serialization mechanisms, such
as {@link Externalizable}
-     * or {@code writeObject()} method, are used, there is no way to get this metadata. For
this reason by default
-     * {@code BinaryMarshaller} ignores these mechanisms and writes all non-transient fields
directly.
+     * must be written along with their values. When custom Java serialization mechanics
is present (such as
+     * {@link Externalizable} or {@code writeObject()} method), Ignite has to respect it.
But fields metadata cannot
+     * be written in this case and so objects will be deserialized on the server.
      * <p>
-     * Sometimes you might want to disable this behavior and fallback to default serialization.
Set value of this flag
-     * to {@code true} to achieve this.
+     * To avoid deserialization on the server you can set this property to {@code true}.
In this case Ignite will
+     * ignore custom Java serialization and will write all objects fields (except of transient
ones) directly.
      * <p>
-     * Defaults to {@link #DFLT_USE_DFLT_SER}.
+     * Note that there are other ways to achieve the same things:
+     * <ul>
+     *     <li>Implement {@link Binarylizable} interface;</li>
+     *     <li>Define custom {@link BinaryIdMapper} using {@link #setIdMapper(BinaryIdMapper)}.</li>
+     * </ul>
+     * Defaults to {@link #DFLT_IGNORE_JAVA_SER}.
      *
-     * @return {@code True} if default serialization should be used.
+     * @return {@code True} if Java serialization should be ignored.
      */
-    public boolean isUseDefaultSerialization() {
-        return useDfltSer;
+    public boolean isIgnoreJavaSerialization() {
+        return ignoreJavaSer;
     }
 
     /**
-     * Sets whether to use default serialization. See {@link #isUseDefaultSerialization()}
for details.
+     * Sets whether to ignore Java serialization mechanisms. See {@link #isIgnoreJavaSerialization()}
for details.
      *
-     * @param useDfltSer {@code True} if default serialization should be used.
+     * @param ignoreJavaSer {@code True} if Java serialization should be ignored.
      */
-    public void setUseDefaultSerialization(boolean useDfltSer) {
-        this.useDfltSer = useDfltSer;
+    public void setIgnoreJavaSerialization(boolean ignoreJavaSer) {
+        this.ignoreJavaSer = ignoreJavaSer;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/43a3de5a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 3c6f722..2f32629 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -334,17 +334,17 @@ public class BinaryContext implements Externalizable {
 
                     for (String clsName0 : classesInPackage(pkgName))
                         descs.add(clsName0, idMapper, serializer, affFields.get(clsName0),
-                            typeCfg.isEnum(), typeCfg.isUseDefaultSerialization(), true);
+                            typeCfg.isEnum(), !typeCfg.isIgnoreJavaSerialization(), true);
                 }
                 else
                     descs.add(clsName, idMapper, serializer, affFields.get(clsName),
-                        typeCfg.isEnum(), typeCfg.isUseDefaultSerialization(), false);
+                        typeCfg.isEnum(), !typeCfg.isIgnoreJavaSerialization(), false);
             }
         }
 
         for (TypeDescriptor desc : descs.descriptors())
             registerUserType(desc.clsName, desc.idMapper, desc.serializer, desc.affKeyFieldName,
desc.isEnum,
-                desc.useDfltSerialization);
+                desc.useJavaSerialization);
 
         BinaryInternalIdMapper dfltMapper = BinaryInternalIdMapper.create(globalIdMapper);
 
@@ -781,7 +781,7 @@ public class BinaryContext implements Externalizable {
      * @param serializer Serializer.
      * @param affKeyFieldName Affinity key field name.
      * @param isEnum If enum.
-     * @param useDfltSerialization Use default serialization flag.
+     * @param useJavaSerialization Use default serialization flag.
      * @throws BinaryObjectException In case of error.
      */
     @SuppressWarnings("ErrorNotRethrown")
@@ -790,7 +790,7 @@ public class BinaryContext implements Externalizable {
         @Nullable BinarySerializer serializer,
         @Nullable String affKeyFieldName,
         boolean isEnum,
-        boolean useDfltSerialization)
+        boolean useJavaSerialization)
         throws BinaryObjectException {
         assert idMapper != null;
 
@@ -821,7 +821,7 @@ public class BinaryContext implements Externalizable {
 
         typeMappers.put(typeName, idMapper);
 
-        if (!useDfltSerialization)
+        if (!useJavaSerialization)
             nonDfltSerializationFlags.add(id);
 
         Map<String, Integer> fieldsMeta = null;
@@ -840,7 +840,7 @@ public class BinaryContext implements Externalizable {
                 true,
                 true, /* registered */
                 false, /* predefined */
-                useDfltSerialization
+                useJavaSerialization
             );
 
             fieldsMeta = desc.fieldsMeta();
@@ -1028,7 +1028,7 @@ public class BinaryContext implements Externalizable {
          * @param serializer Serializer.
          * @param affKeyFieldName Affinity key field name.
          * @param isEnum Enum flag.
-         * @param useDfltSerialziation Use default serialization flag.
+         * @param useJavaSer Whether to use Java serialization.
          * @param canOverride Whether this descriptor can be override.
          * @throws BinaryObjectException If failed.
          */
@@ -1037,7 +1037,7 @@ public class BinaryContext implements Externalizable {
             BinarySerializer serializer,
             String affKeyFieldName,
             boolean isEnum,
-            boolean useDfltSerialziation,
+            boolean useJavaSer,
             boolean canOverride)
             throws BinaryObjectException {
             TypeDescriptor desc = new TypeDescriptor(clsName,
@@ -1045,7 +1045,7 @@ public class BinaryContext implements Externalizable {
                 serializer,
                 affKeyFieldName,
                 isEnum,
-                useDfltSerialziation,
+                useJavaSer,
                 canOverride);
 
             TypeDescriptor oldDesc = descs.get(clsName);
@@ -1086,7 +1086,7 @@ public class BinaryContext implements Externalizable {
         private boolean isEnum;
 
         /** Use default serialization flag. */
-        private boolean useDfltSerialization;
+        private boolean useJavaSerialization;
 
         /** Whether this descriptor can be override. */
         private boolean canOverride;
@@ -1099,17 +1099,17 @@ public class BinaryContext implements Externalizable {
          * @param serializer Serializer.
          * @param affKeyFieldName Affinity key field name.
          * @param isEnum Enum type.
-         * @param useDfltSerialization Use default serialization flag.
+         * @param useJavaSerialization Use default serialization flag.
          * @param canOverride Whether this descriptor can be override.
          */
         private TypeDescriptor(String clsName, BinaryIdMapper idMapper, BinarySerializer
serializer,
-            String affKeyFieldName, boolean isEnum, boolean useDfltSerialization, boolean
canOverride) {
+            String affKeyFieldName, boolean isEnum, boolean useJavaSerialization, boolean
canOverride) {
             this.clsName = clsName;
             this.idMapper = idMapper;
             this.serializer = serializer;
             this.affKeyFieldName = affKeyFieldName;
             this.isEnum = isEnum;
-            this.useDfltSerialization = useDfltSerialization;
+            this.useJavaSerialization = useJavaSerialization;
             this.canOverride = canOverride;
         }
 


Mime
View raw message