IGNITE-1819: Removed "metadataEnabled" flag.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1a01ad84 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1a01ad84 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1a01ad84 Branch: refs/heads/ignite-1753-1282 Commit: 1a01ad848f898ad4f0c15627d080acba9b84f9ac Parents: b783d2b Author: vozerov-gridgain <voze...@gridgain.com> Authored: Thu Nov 5 17:24:36 2015 +0300 Committer: vozerov-gridgain <voze...@gridgain.com> Committed: Thu Nov 5 17:24:36 2015 +0300 ---------------------------------------------------------------------- .../ignite/binary/BinaryTypeConfiguration.java | 21 -- .../internal/portable/BinaryWriterExImpl.java | 3 +- .../portable/PortableClassDescriptor.java | 7 + .../internal/portable/PortableContext.java | 66 ++--- .../builder/BinaryObjectBuilderImpl.java | 61 +++-- .../marshaller/portable/PortableMarshaller.java | 23 +- .../PlatformDotNetPortableConfiguration.java | 26 -- .../GridPortableMetaDataDisabledSelfTest.java | 238 ------------------- ...CacheClientNodeBinaryObjectMetadataTest.java | 71 ------ .../IgnitePortableObjectsTestSuite.java | 2 - 10 files changed, 50 insertions(+), 468 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/1a01ad84/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 3b73edb..ab68efa 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 @@ -40,10 +40,6 @@ public class BinaryTypeConfiguration { /** Serializer. */ private BinarySerializer serializer; - /** Meta data enabled flag. */ - // TODO ignite-1282. - private Boolean metaDataEnabled; - /** Keep deserialized flag. */ private Boolean keepDeserialized; @@ -115,23 +111,6 @@ public class BinaryTypeConfiguration { } /** - * Defines whether meta data is collected for this type. If provided, this value will override - * {@link PortableMarshaller#isMetaDataEnabled()} property. - * - * @return Whether meta data is collected. - */ - public Boolean isMetaDataEnabled() { - return metaDataEnabled; - } - - /** - * @param metaDataEnabled Whether meta data is collected. - */ - public void setMetaDataEnabled(Boolean metaDataEnabled) { - this.metaDataEnabled = metaDataEnabled; - } - - /** * Defines whether {@link BinaryObject} should cache deserialized instance. If provided, * this value will override {@link PortableMarshaller#isKeepDeserialized()} * property. http://git-wip-us.apache.org/repos/asf/ignite/blob/1a01ad84/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java index c1d9e6e..ef3ef2f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java @@ -272,8 +272,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje } typeId = desc.typeId(); - - metaEnabled = ctx.isMetaDataEnabled(typeId); + metaEnabled = desc.userType(); desc.write(obj, this); } http://git-wip-us.apache.org/repos/asf/ignite/blob/1a01ad84/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java index b95dc3d..dd04828 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java @@ -274,6 +274,13 @@ public class PortableClassDescriptor { } /** + * @return User type flag. + */ + public boolean userType() { + return userType; + } + + /** * @return Fields meta data. */ Map<String, String> fieldsMeta() { http://git-wip-us.apache.org/repos/asf/ignite/blob/1a01ad84/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java index 8fcbc86..8c42624 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java @@ -134,9 +134,6 @@ public class PortableContext implements Externalizable { private final Map<String, BinaryTypeIdMapper> typeMappers = new ConcurrentHashMap8<>(0); /** */ - private Map<Integer, Boolean> metaEnabled = new HashMap<>(0); - - /** */ private PortableMetaDataHandler metaHnd; /** */ @@ -155,9 +152,6 @@ public class PortableContext implements Externalizable { private boolean convertStrings; /** */ - private boolean metaDataEnabled; - - /** */ private boolean keepDeserialized; /** Object schemas. */ @@ -260,7 +254,6 @@ public class PortableContext implements Externalizable { return; convertStrings = marsh.isConvertStringToBytes(); - metaDataEnabled = marsh.isMetaDataEnabled(); keepDeserialized = marsh.isKeepDeserialized(); marshCtx = marsh.getContext(); @@ -272,7 +265,6 @@ public class PortableContext implements Externalizable { configure( marsh.getIdMapper(), marsh.getSerializer(), - marsh.isMetaDataEnabled(), marsh.isKeepDeserialized(), marsh.getClassNames(), marsh.getTypeConfigurations() @@ -282,7 +274,6 @@ public class PortableContext implements Externalizable { /** * @param globalIdMapper ID mapper. * @param globalSerializer Serializer. - * @param globalMetaDataEnabled Metadata enabled flag. * @param globalKeepDeserialized Keep deserialized flag. * @param clsNames Class names. * @param typeCfgs Type configurations. @@ -291,7 +282,6 @@ public class PortableContext implements Externalizable { private void configure( BinaryTypeIdMapper globalIdMapper, BinarySerializer globalSerializer, - boolean globalMetaDataEnabled, boolean globalKeepDeserialized, Collection<String> clsNames, Collection<BinaryTypeConfiguration> typeCfgs @@ -306,12 +296,10 @@ public class PortableContext implements Externalizable { String pkgName = clsName.substring(0, clsName.length() - 2); for (String clsName0 : classesInPackage(pkgName)) - descs.add(clsName0, idMapper, null, null, globalMetaDataEnabled, - globalKeepDeserialized, true); + descs.add(clsName0, idMapper, null, null, globalKeepDeserialized, true); } else // Regular single class - descs.add(clsName, idMapper, null, null, globalMetaDataEnabled, - globalKeepDeserialized, true); + descs.add(clsName, idMapper, null, null, globalKeepDeserialized, true); } } @@ -341,8 +329,6 @@ public class PortableContext implements Externalizable { if (typeCfg.getSerializer() != null) serializer = typeCfg.getSerializer(); - boolean metaDataEnabled = typeCfg.isMetaDataEnabled() != null ? typeCfg.isMetaDataEnabled() : - globalMetaDataEnabled; boolean keepDeserialized = typeCfg.isKeepDeserialized() != null ? typeCfg.isKeepDeserialized() : globalKeepDeserialized; @@ -351,17 +337,17 @@ public class PortableContext implements Externalizable { for (String clsName0 : classesInPackage(pkgName)) descs.add(clsName0, idMapper, serializer, affFields.get(clsName0), - metaDataEnabled, keepDeserialized, true); + keepDeserialized, true); } else descs.add(clsName, idMapper, serializer, affFields.get(clsName), - metaDataEnabled, keepDeserialized, false); + keepDeserialized, false); } } for (TypeDescriptor desc : descs.descriptors()) { registerUserType(desc.clsName, desc.idMapper, desc.serializer, desc.affKeyFieldName, - desc.metadataEnabled, desc.keepDeserialized); + desc.keepDeserialized); } } @@ -445,7 +431,7 @@ public class PortableContext implements Externalizable { PortableClassDescriptor desc = descByCls.get(cls); if (desc == null || !desc.registered()) - desc = registerClassDescriptor(cls, true); + desc = registerClassDescriptor(cls); return desc; } @@ -500,7 +486,7 @@ public class PortableContext implements Externalizable { } if (desc == null) { - desc = registerClassDescriptor(cls, false); + desc = registerClassDescriptor(cls); assert desc.typeId() == typeId; } @@ -514,7 +500,7 @@ public class PortableContext implements Externalizable { * @param cls Class. * @return Class descriptor. */ - private PortableClassDescriptor registerClassDescriptor(Class<?> cls, boolean registerMetadata) { + private PortableClassDescriptor registerClassDescriptor(Class<?> cls) { PortableClassDescriptor desc; String clsName = cls.getName(); @@ -527,7 +513,7 @@ public class PortableContext implements Externalizable { clsName, BASIC_CLS_ID_MAPPER, null, - metaDataEnabled, + false, keepDeserialized, true, /* registered */ false /* predefined */ @@ -539,7 +525,7 @@ public class PortableContext implements Externalizable { desc = old; } else - desc = registerUserClassDescriptor(cls, registerMetadata); + desc = registerUserClassDescriptor(cls); return desc; } @@ -550,7 +536,7 @@ public class PortableContext implements Externalizable { * @param cls Class. * @return Class descriptor. */ - private PortableClassDescriptor registerUserClassDescriptor(Class<?> cls, boolean registerMetadata) { + private PortableClassDescriptor registerUserClassDescriptor(Class<?> cls) { boolean registered; String typeName = typeName(cls.getName()); @@ -573,7 +559,7 @@ public class PortableContext implements Externalizable { typeName, idMapper, null, - metaDataEnabled, + true, keepDeserialized, registered, false /* predefined */ @@ -738,7 +724,6 @@ public class PortableContext implements Externalizable { * @param idMapper ID mapper. * @param serializer Serializer. * @param affKeyFieldName Affinity key field name. - * @param metaDataEnabled Metadata enabled flag. * @param keepDeserialized Keep deserialized flag. * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ @@ -747,7 +732,6 @@ public class PortableContext implements Externalizable { BinaryTypeIdMapper idMapper, @Nullable BinarySerializer serializer, @Nullable String affKeyFieldName, - boolean metaDataEnabled, boolean keepDeserialized) throws BinaryObjectException { assert idMapper != null; @@ -774,8 +758,6 @@ public class PortableContext implements Externalizable { typeMappers.put(typeName, idMapper); - metaEnabled.put(id, metaDataEnabled); - Map<String, String> fieldsMeta = null; if (cls != null) { @@ -787,7 +769,7 @@ public class PortableContext implements Externalizable { typeName, idMapper, serializer, - metaDataEnabled, + true, keepDeserialized, true, /* registered */ false /* predefined */ @@ -815,16 +797,6 @@ public class PortableContext implements Externalizable { /** * @param typeId Type ID. - * @return Whether meta data is enabled. - */ - public boolean isMetaDataEnabled(int typeId) { - Boolean enabled = metaEnabled.get(typeId); - - return enabled != null ? enabled : metaDataEnabled; - } - - /** - * @param typeId Type ID. * @param metaHashSum Meta data hash sum. * @return Whether meta is changed. */ @@ -1058,7 +1030,6 @@ public class PortableContext implements Externalizable { * @param idMapper ID mapper. * @param serializer Serializer. * @param affKeyFieldName Affinity key field name. - * @param metadataEnabled Metadata enabled flag. * @param keepDeserialized Keep deserialized flag. * @param canOverride Whether this descriptor can be override. * @throws org.apache.ignite.binary.BinaryObjectException If failed. @@ -1067,7 +1038,6 @@ public class PortableContext implements Externalizable { BinaryTypeIdMapper idMapper, BinarySerializer serializer, String affKeyFieldName, - boolean metadataEnabled, boolean keepDeserialized, boolean canOverride) throws BinaryObjectException { @@ -1075,7 +1045,6 @@ public class PortableContext implements Externalizable { idMapper, serializer, affKeyFieldName, - metadataEnabled, keepDeserialized, canOverride); @@ -1113,9 +1082,6 @@ public class PortableContext implements Externalizable { /** Affinity key field name. */ private String affKeyFieldName; - /** Metadata enabled flag. */ - private boolean metadataEnabled; - /** Keep deserialized flag. */ private boolean keepDeserialized; @@ -1129,18 +1095,15 @@ public class PortableContext implements Externalizable { * @param idMapper ID mapper. * @param serializer Serializer. * @param affKeyFieldName Affinity key field name. - * @param metadataEnabled Metadata enabled flag. * @param keepDeserialized Keep deserialized flag. * @param canOverride Whether this descriptor can be override. */ private TypeDescriptor(String clsName, BinaryTypeIdMapper idMapper, BinarySerializer serializer, - String affKeyFieldName, boolean metadataEnabled, boolean keepDeserialized, - boolean canOverride) { + String affKeyFieldName, boolean keepDeserialized, boolean canOverride) { this.clsName = clsName; this.idMapper = idMapper; this.serializer = serializer; this.affKeyFieldName = affKeyFieldName; - this.metadataEnabled = metadataEnabled; this.keepDeserialized = keepDeserialized; this.canOverride = canOverride; } @@ -1158,7 +1121,6 @@ public class PortableContext implements Externalizable { idMapper = other.idMapper; serializer = other.serializer; affKeyFieldName = other.affKeyFieldName; - metadataEnabled = other.metadataEnabled; keepDeserialized = other.keepDeserialized; canOverride = other.canOverride; } http://git-wip-us.apache.org/repos/asf/ignite/blob/1a01ad84/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java index 8844660..eb4f02c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java @@ -290,12 +290,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder { } if (assignedVals != null && (remainsFlds == null || !remainsFlds.isEmpty())) { - boolean metadataEnabled = ctx.isMetaDataEnabled(typeId); - - BinaryType metadata = null; - - if (metadataEnabled) - metadata = ctx.metaData(typeId); + BinaryType metadata = ctx.metaData(typeId); Map<String, String> newFldsMetadata = null; @@ -316,40 +311,38 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder { serializer.writeValue(writer, val); - if (metadataEnabled) { - String oldFldTypeName = metadata == null ? null : metadata.fieldTypeName(name); + String oldFldTypeName = metadata == null ? null : metadata.fieldTypeName(name); - String newFldTypeName; + String newFldTypeName; - if (val instanceof PortableValueWithType) - newFldTypeName = ((PortableValueWithType) val).typeName(); - else { - byte type = PortableUtils.typeByClass(val.getClass()); + if (val instanceof PortableValueWithType) + newFldTypeName = ((PortableValueWithType) val).typeName(); + else { + byte type = PortableUtils.typeByClass(val.getClass()); - newFldTypeName = CacheObjectBinaryProcessorImpl.fieldTypeName(type); - } + newFldTypeName = CacheObjectBinaryProcessorImpl.fieldTypeName(type); + } - if (oldFldTypeName == null) { - // It's a new field, we have to add it to metadata. + if (oldFldTypeName == null) { + // It's a new field, we have to add it to metadata. - if (newFldsMetadata == null) - newFldsMetadata = new HashMap<>(); + if (newFldsMetadata == null) + newFldsMetadata = new HashMap<>(); - newFldsMetadata.put(name, newFldTypeName); - } - else { - String objTypeName = - CacheObjectBinaryProcessorImpl.FIELD_TYPE_NAMES[GridPortableMarshaller.OBJ]; - - if (!objTypeName.equals(oldFldTypeName) && !oldFldTypeName.equals(newFldTypeName)) { - throw new BinaryObjectException( - "Wrong value has been set [" + - "typeName=" + (typeName == null ? metadata.typeName() : typeName) + - ", fieldName=" + name + - ", fieldType=" + oldFldTypeName + - ", assignedValueType=" + newFldTypeName + ']' - ); - } + newFldsMetadata.put(name, newFldTypeName); + } + else { + String objTypeName = + CacheObjectBinaryProcessorImpl.FIELD_TYPE_NAMES[GridPortableMarshaller.OBJ]; + + if (!objTypeName.equals(oldFldTypeName) && !oldFldTypeName.equals(newFldTypeName)) { + throw new BinaryObjectException( + "Wrong value has been set [" + + "typeName=" + (typeName == null ? metadata.typeName() : typeName) + + ", fieldName=" + name + + ", fieldType=" + oldFldTypeName + + ", assignedValueType=" + newFldTypeName + ']' + ); } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/1a01ad84/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java index d3e7437..4a1b0ad 100644 --- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java @@ -90,9 +90,6 @@ public class PortableMarshaller extends AbstractMarshaller { /** Whether to convert string to bytes using UTF-8 encoding. */ private boolean convertString = true; - /** Meta data enabled flag. */ - private boolean metaDataEnabled = true; - /** Keep deserialized flag. */ private boolean keepDeserialized = true; @@ -197,25 +194,6 @@ public class PortableMarshaller extends AbstractMarshaller { } /** - * If {@code true}, meta data will be collected or all types. If you need to override this behaviour for - * some specific type, use {@link org.apache.ignite.binary.BinaryTypeConfiguration#setMetaDataEnabled(Boolean)} method. - * <p> - * Default value if {@code true}. - * - * @return Whether meta data is collected. - */ - public boolean isMetaDataEnabled() { - return metaDataEnabled; - } - - /** - * @param metaDataEnabled Whether meta data is collected. - */ - public void setMetaDataEnabled(boolean metaDataEnabled) { - this.metaDataEnabled = metaDataEnabled; - } - - /** * If {@code true}, {@link org.apache.ignite.binary.BinaryObject} will cache deserialized instance after * {@link org.apache.ignite.binary.BinaryObject#deserialize()} is called. All consequent calls of this * method on the same instance of {@link org.apache.ignite.binary.BinaryObject} will return that cached @@ -252,6 +230,7 @@ public class PortableMarshaller extends AbstractMarshaller { * <p/> * @param ctx Portable context. */ + @SuppressWarnings("UnusedDeclaration") private void setPortableContext(PortableContext ctx) { ctx.configure(this); http://git-wip-us.apache.org/repos/asf/ignite/blob/1a01ad84/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java index dd7b988..ed25a0f 100644 --- a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java @@ -41,9 +41,6 @@ public class PlatformDotNetPortableConfiguration { /** Default serializer. */ private String dfltSerializer; - /** Default metadata enabled. */ - private boolean dfltMetadataEnabled = true; - /** Whether to cache deserialized value in IGridPortableObject */ private boolean dfltKeepDeserialized = true; @@ -72,7 +69,6 @@ public class PlatformDotNetPortableConfiguration { dfltNameMapper = cfg.getDefaultNameMapper(); dfltIdMapper = cfg.getDefaultIdMapper(); dfltSerializer = cfg.getDefaultSerializer(); - dfltMetadataEnabled = cfg.isDefaultMetadataEnabled(); dfltKeepDeserialized = cfg.isDefaultKeepDeserialized(); } @@ -147,28 +143,6 @@ public class PlatformDotNetPortableConfiguration { } /** - * Gets default metadata enabled flag. See {@link #setDefaultMetadataEnabled(boolean)} for more information. - * - * @return Default metadata enabled flag. - */ - public boolean isDefaultMetadataEnabled() { - return dfltMetadataEnabled; - } - - /** - * Sets default metadata enabled flag. When set to {@code true} all portable types will save it's metadata to - * cluster. - * <p /> - * Can be overridden for particular type using - * {@link PlatformDotNetPortableTypeConfiguration#setMetadataEnabled(Boolean)}. - * - * @param dfltMetadataEnabled Default metadata enabled flag. - */ - public void setDefaultMetadataEnabled(boolean dfltMetadataEnabled) { - this.dfltMetadataEnabled = dfltMetadataEnabled; - } - - /** * Gets default keep deserialized flag. See {@link #setDefaultKeepDeserialized(boolean)} for more information. * * @return Flag indicates whether to cache deserialized value in IGridPortableObject. http://git-wip-us.apache.org/repos/asf/ignite/blob/1a01ad84/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java deleted file mode 100644 index fbdb562..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java +++ /dev/null @@ -1,238 +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.portable; - -import java.util.Arrays; -import org.apache.ignite.IgniteBinary; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.binary.BinaryObjectBuilder; -import org.apache.ignite.binary.BinaryObjectException; -import org.apache.ignite.binary.Binarylizable; -import org.apache.ignite.binary.BinaryReader; -import org.apache.ignite.binary.BinaryTypeConfiguration; -import org.apache.ignite.binary.BinaryWriter; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -/** - * Test for disabled meta data. - */ -public class GridPortableMetaDataDisabledSelfTest extends GridCommonAbstractTest { - /** */ - private PortableMarshaller marsh; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setMarshaller(marsh); - - return cfg; - } - - /** - * @return Portables. - */ - private IgniteBinary portables() { - return grid().binary(); - } - - /** - * @throws Exception If failed. - */ - public void testDisableGlobal() throws Exception { - marsh = new PortableMarshaller(); - - marsh.setClassNames(Arrays.asList( - TestObject1.class.getName(), - TestObject2.class.getName() - )); - - marsh.setMetaDataEnabled(false); - - try { - startGrid(); - - portables().toBinary(new TestObject1()); - portables().toBinary(new TestObject2()); - portables().toBinary(new TestObject3()); - - assertEquals(0, portables().metadata(TestObject1.class).fields().size()); - assertEquals(0, portables().metadata(TestObject2.class).fields().size()); - - BinaryObjectBuilder bldr = portables().builder("FakeType"); - - bldr.setField("field1", 0).setField("field2", "value").build(); - - assertNull(portables().metadata("FakeType")); - assertNull(portables().metadata(TestObject3.class)); - } - finally { - stopGrid(); - } - } - - /** - * @throws Exception If failed. - */ - public void testDisableGlobalSimpleClass() throws Exception { - marsh = new PortableMarshaller(); - - BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(TestObject2.class.getName()); - - typeCfg.setMetaDataEnabled(true); - - marsh.setTypeConfigurations(Arrays.asList( - new BinaryTypeConfiguration(TestObject1.class.getName()), - typeCfg - )); - - marsh.setMetaDataEnabled(false); - - try { - startGrid(); - - portables().toBinary(new TestObject1()); - portables().toBinary(new TestObject2()); - - assertEquals(0, portables().metadata(TestObject1.class).fields().size()); - assertEquals(1, portables().metadata(TestObject2.class).fields().size()); - } - finally { - stopGrid(); - } - } - - /** - * @throws Exception If failed. - */ - public void testDisableGlobalMarshalAwareClass() throws Exception { - marsh = new PortableMarshaller(); - - BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(TestObject1.class.getName()); - - typeCfg.setMetaDataEnabled(true); - - marsh.setTypeConfigurations(Arrays.asList( - new BinaryTypeConfiguration(TestObject2.class.getName()), - typeCfg - )); - - marsh.setMetaDataEnabled(false); - - try { - startGrid(); - - portables().toBinary(new TestObject1()); - portables().toBinary(new TestObject2()); - - assertEquals(1, portables().metadata(TestObject1.class).fields().size()); - assertEquals(0, portables().metadata(TestObject2.class).fields().size()); - } - finally { - stopGrid(); - } - } - - /** - * @throws Exception If failed. - */ - public void testDisableSimpleClass() throws Exception { - marsh = new PortableMarshaller(); - - BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(TestObject1.class.getName()); - - typeCfg.setMetaDataEnabled(false); - - marsh.setTypeConfigurations(Arrays.asList( - new BinaryTypeConfiguration(TestObject2.class.getName()), - typeCfg - )); - - try { - startGrid(); - - portables().toBinary(new TestObject1()); - portables().toBinary(new TestObject2()); - - assertEquals(0, portables().metadata(TestObject1.class).fields().size()); - assertEquals(1, portables().metadata(TestObject2.class).fields().size()); - } - finally { - stopGrid(); - } - } - - /** - * @throws Exception If failed. - */ - public void testDisableMarshalAwareClass() throws Exception { - marsh = new PortableMarshaller(); - - BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(TestObject2.class.getName()); - - typeCfg.setMetaDataEnabled(false); - - marsh.setTypeConfigurations(Arrays.asList( - new BinaryTypeConfiguration(TestObject1.class.getName()), - typeCfg - )); - - try { - startGrid(); - - portables().toBinary(new TestObject1()); - portables().toBinary(new TestObject2()); - - assertEquals(1, portables().metadata(TestObject1.class).fields().size()); - assertEquals(0, portables().metadata(TestObject2.class).fields().size()); - } - finally { - stopGrid(); - } - } - - /** - */ - @SuppressWarnings("UnusedDeclaration") - private static class TestObject1 { - /** */ - private int field; - } - - /** - */ - private static class TestObject2 implements Binarylizable { - /** {@inheritDoc} */ - @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { - writer.writeInt("field", 1); - } - - /** {@inheritDoc} */ - @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { - // No-op. - } - } - - /** - */ - @SuppressWarnings("UnusedDeclaration") - private static class TestObject3 { - /** */ - private int field; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/1a01ad84/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java index c2d0197..b20adb8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java @@ -116,77 +116,6 @@ public class GridCacheClientNodeBinaryObjectMetadataTest extends GridCacheAbstra aff0.mapKeyToPrimaryAndBackups(obj2)); } - { - BinaryObjectBuilder builder = ignite0.binary().builder("TestObject3"); - - builder.setField("f1", 1); - - ignite0.cache(null).put(0, builder.build()); - - IgniteCache<Integer, BinaryObject> cache = ignite0.cache(null).withKeepBinary(); - - BinaryObject obj = cache.get(0); - - BinaryType meta = obj.type(); - - assertNotNull(meta); - assertEquals(1, meta.fields().size()); - - meta = ignite0.binary().metadata(TestObject1.class); - - assertNotNull(meta); - assertEquals("val2", meta.affinityKeyFieldName()); - - meta = ignite0.binary().metadata(TestObject2.class); - - assertNotNull(meta); - assertNull(meta.affinityKeyFieldName()); - } - - { - BinaryObjectBuilder builder = ignite1.binary().builder("TestObject3"); - - builder.setField("f2", 2); - - ignite1.cache(null).put(1, builder.build()); - - IgniteCache<Integer, BinaryObject> cache = ignite1.cache(null).withKeepBinary(); - - BinaryObject obj = cache.get(0); - - BinaryType meta = obj.type(); - - assertNotNull(meta); - assertEquals(2, meta.fields().size()); - - meta = ignite1.binary().metadata(TestObject1.class); - - assertNotNull(meta); - assertEquals("val2", meta.affinityKeyFieldName()); - - meta = ignite1.binary().metadata(TestObject2.class); - - assertNotNull(meta); - assertNull(meta.affinityKeyFieldName()); - } - - BinaryType meta = ignite0.binary().metadata("TestObject3"); - - assertNotNull(meta); - assertEquals(2, meta.fields().size()); - - IgniteCache<Integer, BinaryObject> cache = ignite0.cache(null).withKeepBinary(); - - BinaryObject obj = cache.get(1); - - assertEquals(Integer.valueOf(2), obj.field("f2")); - assertNull(obj.field("f1")); - - meta = obj.type(); - - assertNotNull(meta); - assertEquals(2, meta.fields().size()); - Collection<BinaryType> meta1 = ignite1.binary().metadata(); Collection<BinaryType> meta2 = ignite1.binary().metadata(); http://git-wip-us.apache.org/repos/asf/ignite/blob/1a01ad84/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java index c6b1fbc..1231ef9 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java @@ -25,7 +25,6 @@ import org.apache.ignite.internal.portable.GridBinaryObjectBuilderStringAsCharsA import org.apache.ignite.internal.portable.GridBinaryObjectBuilderStringAsCharsSelfTest; import org.apache.ignite.internal.portable.GridPortableMarshallerCtxDisabledSelfTest; import org.apache.ignite.internal.portable.GridPortableMarshallerSelfTest; -import org.apache.ignite.internal.portable.GridPortableMetaDataDisabledSelfTest; import org.apache.ignite.internal.portable.GridPortableMetaDataSelfTest; import org.apache.ignite.internal.portable.GridPortableWildcardsSelfTest; import org.apache.ignite.internal.portable.PortableCompactOffsetsHeapSelfTest; @@ -71,7 +70,6 @@ public class IgnitePortableObjectsTestSuite extends TestSuite { suite.addTestSuite(PortableCompactOffsetsHeapSelfTest.class); suite.addTestSuite(PortableCompactOffsetsOffheapSelfTest.class); suite.addTestSuite(GridPortableMetaDataSelfTest.class); - suite.addTestSuite(GridPortableMetaDataDisabledSelfTest.class); suite.addTestSuite(GridPortableAffinityKeySelfTest.class); suite.addTestSuite(GridPortableWildcardsSelfTest.class);