IGNITE-51 - Got rid of portables in code, tests need to be fixed.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/dff026be Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/dff026be Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/dff026be Branch: refs/heads/ignite-211 Commit: dff026be8dc1d511003fb14e89b8f2b18b2f862f Parents: 2cfcca0 Author: Alexey Goncharuk <agoncha...@gridgain.com> Authored: Sat Feb 7 13:55:52 2015 -0800 Committer: Alexey Goncharuk <agoncha...@gridgain.com> Committed: Sat Feb 7 13:55:53 2015 -0800 ---------------------------------------------------------------------- .../client/ClientPortableArgumentTask.java | 52 -- .../ignite/client/ClientTestPortable.java | 490 ------------------- .../ClientTestPortableAffinityKeyTask.java | 2 +- .../clients/src/test/resources/spring-cache.xml | 6 +- .../src/test/resources/spring-server-node.xml | 12 +- .../test/resources/spring-server-ssl-node.xml | 6 +- .../src/main/java/org/apache/ignite/Ignite.java | 7 - .../java/org/apache/ignite/IgniteCache.java | 2 +- .../java/org/apache/ignite/IgnitePortables.java | 364 -------------- .../apache/ignite/cache/CacheProjection.java | 2 +- .../apache/ignite/cache/store/CacheStore.java | 10 +- .../ignite/client/GridClientCacheFlag.java | 2 +- .../ignite/client/GridClientConfiguration.java | 23 - .../configuration/CacheConfiguration.java | 64 --- .../configuration/IgniteConfiguration.java | 19 - .../ignite/internal/GridPortablesImpl.java | 174 ------- .../apache/ignite/internal/IgniteKernal.java | 13 - .../org/apache/ignite/internal/IgnitionEx.java | 3 - .../affinity/GridAffinityAssignmentCache.java | 3 +- .../affinity/GridAffinityProcessor.java | 2 +- .../processors/cache/GridCacheAdapter.java | 21 +- .../processors/cache/GridCacheAttributes.java | 11 - .../processors/cache/GridCacheContext.java | 123 +---- .../GridCacheDefaultAffinityKeyMapper.java | 34 +- .../processors/cache/GridCacheProcessor.java | 7 - .../cache/GridCacheProjectionImpl.java | 10 - .../processors/cache/GridCacheStoreManager.java | 4 +- .../IgniteCacheOsSerializationManager.java | 48 ++ .../cache/affinity/GridCacheAffinityImpl.java | 3 +- .../IgniteCacheSerializationManager.java | 51 ++ .../transactions/IgniteTxLocalAdapter.java | 7 +- .../dataload/IgniteDataLoaderImpl.java | 6 +- .../plugin/IgnitePluginProcessor.java | 4 +- .../portable/GridPortableProcessor.java | 88 ++-- .../portable/os/GridOsPortableProcessor.java | 48 +- .../processors/query/GridQueryProcessor.java | 33 +- .../processors/rest/GridRestProcessor.java | 10 +- .../message/GridClientAbstractMessage.java | 17 +- .../GridClientAuthenticationRequest.java | 19 - .../message/GridClientCacheQueryRequest.java | 45 -- .../client/message/GridClientCacheRequest.java | 48 -- .../message/GridClientGetMetaDataRequest.java | 64 --- .../client/message/GridClientLogRequest.java | 23 - .../message/GridClientMetaDataResponse.java | 57 --- .../rest/client/message/GridClientNodeBean.java | 40 +- .../message/GridClientNodeMetricsBean.java | 120 +---- .../message/GridClientPortableMetaData.java | 23 +- .../message/GridClientPutMetaDataRequest.java | 64 --- .../rest/client/message/GridClientResponse.java | 23 - .../client/message/GridClientTaskRequest.java | 28 -- .../message/GridClientTaskResultBean.java | 28 +- .../message/GridClientTopologyRequest.java | 25 - .../cache/GridCacheClientQueryResult.java | 24 +- .../metadata/GridPortableMetadataHandler.java | 103 ---- .../handlers/task/GridTaskCommandHandler.java | 3 +- .../protocols/tcp/GridTcpRestNioListener.java | 14 - .../GridRestPortableGetMetaDataRequest.java | 44 -- .../GridRestPortablePutMetaDataRequest.java | 44 -- .../ignite/internal/util/IgniteUtils.java | 72 --- .../util/portable/PortableRawReaderEx.java | 32 -- .../util/portable/PortableRawWriterEx.java | 43 -- .../visor/portable/VisorPortableMetadata.java | 72 --- .../VisorPortableMetadataCollectorTask.java | 94 ---- .../portable/VisorPortableMetadataField.java | 71 --- .../apache/ignite/plugin/PluginProvider.java | 2 +- .../security/GridSecurityCredentials.java | 20 +- .../ignite/portables/PortableBuilder.java | 137 ------ .../ignite/portables/PortableConfiguration.java | 189 ------- .../ignite/portables/PortableException.java | 57 --- .../ignite/portables/PortableIdMapper.java | 55 --- .../PortableInvalidClassException.java | 58 --- .../ignite/portables/PortableMarshalAware.java | 48 -- .../ignite/portables/PortableMetadata.java | 61 --- .../apache/ignite/portables/PortableObject.java | 160 ------ .../ignite/portables/PortableRawReader.java | 235 --------- .../ignite/portables/PortableRawWriter.java | 218 --------- .../apache/ignite/portables/PortableReader.java | 286 ----------- .../ignite/portables/PortableSerializer.java | 47 -- .../portables/PortableTypeConfiguration.java | 195 -------- .../apache/ignite/portables/PortableWriter.java | 265 ---------- .../org/apache/ignite/portables/package.html | 24 - .../cache/GridCacheAbstractSelfTest.java | 8 - .../cache/GridCacheMemoryModeSelfTest.java | 8 - ...HeapMultiThreadedUpdateAbstractSelfTest.java | 1 - .../GridCacheOffHeapTieredAbstractSelfTest.java | 2 +- ...heOffHeapTieredEvictionAbstractSelfTest.java | 2 +- .../cache/IgniteCacheAbstractTest.java | 8 - ...tractDistributedByteArrayValuesSelfTest.java | 10 - ...tractPartitionedByteArrayValuesSelfTest.java | 3 - .../GridCacheSwapScanQueryAbstractSelfTest.java | 66 +-- .../query/GridCacheSwapScanQuerySelfTest.java | 4 - .../ignite/testframework/junits/IgniteMock.java | 5 - 92 files changed, 269 insertions(+), 4909 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/clients/src/test/java/org/apache/ignite/client/ClientPortableArgumentTask.java ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/java/org/apache/ignite/client/ClientPortableArgumentTask.java b/modules/clients/src/test/java/org/apache/ignite/client/ClientPortableArgumentTask.java deleted file mode 100644 index 82cafda..0000000 --- a/modules/clients/src/test/java/org/apache/ignite/client/ClientPortableArgumentTask.java +++ /dev/null @@ -1,52 +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.client; - -import org.apache.ignite.portables.*; - -import java.util.*; - -/** - * Task where argument and result are {@link ClientTestPortable}. - */ -public class ClientPortableArgumentTask extends TaskSingleJobSplitAdapter { - /** {@inheritDoc} */ - @Override protected Object executeJob(int gridSize, Object arg) { - Collection args = (Collection)arg; - - Iterator<Object> it = args.iterator(); - - assert args.size() == 2 : args.size(); - - boolean expPortable = (Boolean)it.next(); - - ClientTestPortable p; - - if (expPortable) { - PortableObject obj = (PortableObject)it.next(); - - p = obj.deserialize(); - } - else - p = (ClientTestPortable)it.next(); - - assert p != null; - - return new ClientTestPortable(p.i + 1, true); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortable.java ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortable.java b/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortable.java deleted file mode 100644 index 07d6177..0000000 --- a/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortable.java +++ /dev/null @@ -1,490 +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.client; - -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; - -import java.io.*; -import java.util.*; - -/** - * Test portable object. - */ -@SuppressWarnings("PublicField") -public class ClientTestPortable implements PortableMarshalAware, Serializable { - /** */ - public byte b; - - /** */ - public byte bRaw; - - /** */ - public short s; - - /** */ - public short sRaw; - - /** */ - public int i; - - /** */ - public int iRaw; - - /** */ - public long l; - - /** */ - public long lRaw; - - /** */ - public float f; - - /** */ - public float fRaw; - - /** */ - public double d; - - /** */ - public double dRaw; - - /** */ - public char c; - - /** */ - public char cRaw; - - /** */ - public boolean bool; - - /** */ - public boolean boolRaw; - - /** */ - public String str; - - /** */ - public String strRaw; - - /** */ - public UUID uuid; - - /** */ - public UUID uuidRaw; - - /** */ - public Date date; - - /** */ - public Date dateRaw; - - /** */ - public TestEnum e; - - /** */ - public TestEnum eRaw; - - /** */ - public byte[] bArr; - - /** */ - public byte[] bArrRaw; - - /** */ - public short[] sArr; - - /** */ - public short[] sArrRaw; - - /** */ - public int[] iArr; - - /** */ - public int[] iArrRaw; - - /** */ - public long[] lArr; - - /** */ - public long[] lArrRaw; - - /** */ - public float[] fArr; - - /** */ - public float[] fArrRaw; - - /** */ - public double[] dArr; - - /** */ - public double[] dArrRaw; - - /** */ - public char[] cArr; - - /** */ - public char[] cArrRaw; - - /** */ - public boolean[] boolArr; - - /** */ - public boolean[] boolArrRaw; - - /** */ - public String[] strArr; - - /** */ - public String[] strArrRaw; - - /** */ - public UUID[] uuidArr; - - /** */ - public UUID[] uuidArrRaw; - - /** */ - public Date[] dateArr; - - /** */ - public Date[] dateArrRaw; - - /** */ - public TestEnum[] eArr; - - /** */ - public TestEnum[] eArrRaw; - - /** */ - public Object[] objArr; - - /** */ - public Object[] objArrRaw; - - /** */ - public Collection<String> col; - - /** */ - public Collection<String> colRaw; - - /** */ - public Map<Integer, String> map; - - /** */ - public Map<Integer, String> mapRaw; - - /** */ - public ClientTestPortable portable1; - - /** */ - public ClientTestPortable portable2; - - /** */ - public ClientTestPortable portableRaw1; - - /** */ - public ClientTestPortable portableRaw2; - - /** - */ - public ClientTestPortable() { - // No-op. - } - - /** - * @param val Value. - * @param createInner If {@code true} creates nested object. - */ - public ClientTestPortable(int val, boolean createInner) { - b = (byte)val; - bRaw = (byte)(val + 1); - - s = (short)val; - sRaw = (short)(val + 1); - - i = val; - iRaw = i + 1; - - l = val; - lRaw = i + 1; - - f = val + 0.5f; - fRaw = f + 1; - - d = val + 0.5f; - dRaw = d + 1; - - c = (char)val; - cRaw = (char)(val + 1); - - bool = true; - boolRaw = false; - - str = String.valueOf(i); - strRaw = String.valueOf(iRaw); - - uuid = new UUID(i, i); - uuidRaw = new UUID(iRaw, iRaw); - - date = new Date(i); - dateRaw = new Date(iRaw); - - e = enumValue(i); - eRaw = enumValue(iRaw); - - bArr = new byte[]{b, (byte)(b + 1)}; - bArrRaw = new byte[]{bRaw, (byte)(bRaw + 1)}; - - sArr = new short[]{s, (short)(s + 1)}; - sArrRaw = new short[]{sRaw, (short)(sRaw + 1)}; - - iArr = new int[]{i, i + 1}; - iArrRaw = new int[]{iRaw, iRaw + 1}; - - lArr = new long[]{l, l + 1}; - lArrRaw = new long[]{lRaw, lRaw + 1}; - - fArr = new float[]{f, f + 1}; - fArrRaw = new float[]{fRaw, fRaw + 1}; - - dArr = new double[]{d, d + 1}; - dArrRaw = new double[]{dRaw, dRaw + 1}; - - cArr = new char[]{c, (char)(c + 1)}; - cArrRaw = new char[]{cRaw, (char)(cRaw + 1)}; - - boolArr = new boolean[]{true, true}; - boolArrRaw = new boolean[]{true, true}; - - strArr = new String[]{str, str + "1"}; - strArrRaw = new String[]{strRaw, strRaw + "1"}; - - uuidArr = new UUID[]{uuid, new UUID(uuid.getMostSignificantBits() + 1, uuid.getLeastSignificantBits() + 1)}; - uuidArrRaw = new UUID[]{uuidRaw, - new UUID(uuidRaw.getMostSignificantBits() + 1, uuidRaw.getLeastSignificantBits() + 1)}; - - dateArr = new Date[]{date, new Date(date.getTime() + 1)}; - dateArrRaw = new Date[]{dateRaw, new Date(dateRaw.getTime() + 1)}; - - eArr = new TestEnum[]{enumValue(i), enumValue(i + 1)}; - eArrRaw = new TestEnum[]{enumValue(iRaw), enumValue(iRaw + 1)}; - - objArr = new Object[]{uuid, new UUID(uuid.getMostSignificantBits() + 1, uuid.getLeastSignificantBits() + 1)}; - objArrRaw = new Object[]{uuidRaw, - new UUID(uuidRaw.getMostSignificantBits() + 1, uuidRaw.getLeastSignificantBits() + 1)}; - - col = Arrays.asList(str, str + "1"); - colRaw = Arrays.asList(strRaw, strRaw + "1"); - - map = new HashMap<>(); - map.put(1, str); - map.put(2, str + "1"); - - mapRaw = new HashMap<>(); - mapRaw.put(1, strRaw); - mapRaw.put(2, strRaw + "1"); - - if (createInner) { - portable1 = new ClientTestPortable(val + 1, false); - portable2 = portable1; - - portableRaw1 = new ClientTestPortable(val + 2, false); - portableRaw2 = portableRaw1; - } - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.writeByte("_b", b); - writer.writeShort("_s", s); - writer.writeInt("_i", i); - writer.writeLong("_l", l); - writer.writeFloat("_f", f); - writer.writeDouble("_d", d); - writer.writeChar("_c", c); - writer.writeBoolean("_bool", bool); - writer.writeString("_str", str); - writer.writeUuid("_uuid", uuid); - writer.writeDate("_date", date); - writer.writeEnum("_enum", e); - writer.writeByteArray("_bArr", bArr); - writer.writeShortArray("_sArr", sArr); - writer.writeIntArray("_iArr", iArr); - writer.writeLongArray("_lArr", lArr); - writer.writeFloatArray("_fArr", fArr); - writer.writeDoubleArray("_dArr", dArr); - writer.writeCharArray("_cArr", cArr); - writer.writeBooleanArray("_boolArr", boolArr); - writer.writeStringArray("_strArr", strArr); - writer.writeUuidArray("_uuidArr", uuidArr); - writer.writeDateArray("_dateArr", dateArr); - writer.writeEnumArray("_eArr", eArr); - writer.writeObjectArray("_objArr", objArr); - writer.writeCollection("_col", col); - writer.writeMap("_map", map); - writer.writeObject("_portable1", portable1); - writer.writeObject("_portable2", portable2); - - PortableRawWriter raw = writer.rawWriter(); - - raw.writeByte(bRaw); - raw.writeShort(sRaw); - raw.writeInt(iRaw); - raw.writeLong(lRaw); - raw.writeFloat(fRaw); - raw.writeDouble(dRaw); - raw.writeChar(cRaw); - raw.writeBoolean(boolRaw); - raw.writeString(strRaw); - raw.writeUuid(uuidRaw); - raw.writeDate(dateRaw); - raw.writeEnum(eRaw); - raw.writeByteArray(bArrRaw); - raw.writeShortArray(sArrRaw); - raw.writeIntArray(iArrRaw); - raw.writeLongArray(lArrRaw); - raw.writeFloatArray(fArrRaw); - raw.writeDoubleArray(dArrRaw); - raw.writeCharArray(cArrRaw); - raw.writeBooleanArray(boolArrRaw); - raw.writeStringArray(strArrRaw); - raw.writeUuidArray(uuidArrRaw); - raw.writeDateArray(dateArrRaw); - raw.writeEnumArray(eArrRaw); - raw.writeObjectArray(objArrRaw); - raw.writeCollection(colRaw); - raw.writeMap(mapRaw); - raw.writeObject(portableRaw1); - raw.writeObject(portableRaw2); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - b = reader.readByte("_b"); - s = reader.readShort("_s"); - i = reader.readInt("_i"); - l = reader.readLong("_l"); - f = reader.readFloat("_f"); - d = reader.readDouble("_d"); - c = reader.readChar("_c"); - bool = reader.readBoolean("_bool"); - str = reader.readString("_str"); - uuid = reader.readUuid("_uuid"); - date = reader.readDate("_date"); - e = reader.readEnum("_enum", TestEnum.class); - bArr = reader.readByteArray("_bArr"); - sArr = reader.readShortArray("_sArr"); - iArr = reader.readIntArray("_iArr"); - lArr = reader.readLongArray("_lArr"); - fArr = reader.readFloatArray("_fArr"); - dArr = reader.readDoubleArray("_dArr"); - cArr = reader.readCharArray("_cArr"); - boolArr = reader.readBooleanArray("_boolArr"); - strArr = reader.readStringArray("_strArr"); - uuidArr = reader.readUuidArray("_uuidArr"); - dateArr = reader.readDateArray("_dateArr"); - eArr = reader.readEnumArray("_eArr", TestEnum.class); - objArr = reader.readObjectArray("_objArr"); - col = reader.readCollection("_col"); - map = reader.readMap("_map"); - portable1 = (ClientTestPortable)reader.readObject("_portable1"); - portable2 = (ClientTestPortable)reader.readObject("_portable2"); - - PortableRawReader raw = reader.rawReader(); - - bRaw = raw.readByte(); - sRaw = raw.readShort(); - iRaw = raw.readInt(); - lRaw = raw.readLong(); - fRaw = raw.readFloat(); - dRaw = raw.readDouble(); - cRaw = raw.readChar(); - boolRaw = raw.readBoolean(); - strRaw = raw.readString(); - uuidRaw = raw.readUuid(); - dateRaw = raw.readDate(); - eRaw = raw.readEnum(TestEnum.class); - bArrRaw = raw.readByteArray(); - sArrRaw = raw.readShortArray(); - iArrRaw = raw.readIntArray(); - lArrRaw = raw.readLongArray(); - fArrRaw = raw.readFloatArray(); - dArrRaw = raw.readDoubleArray(); - cArrRaw = raw.readCharArray(); - boolArrRaw = raw.readBooleanArray(); - strArrRaw = raw.readStringArray(); - uuidArrRaw = raw.readUuidArray(); - dateArrRaw = raw.readDateArray(); - eArrRaw = raw.readEnumArray(TestEnum.class); - objArrRaw = raw.readObjectArray(); - colRaw = raw.readCollection(); - mapRaw = raw.readMap(); - portableRaw1 = (ClientTestPortable)raw.readObject(); - portableRaw2 = (ClientTestPortable)raw.readObject(); - } - - /** - * @param idx Value index. - * @return Enum value. - */ - static TestEnum enumValue(int idx) { - return TestEnum.values()[idx % TestEnum.values().length]; - } - - /** - * Test enum. - */ - private enum TestEnum { - /** */ - VAL1, - - /** */ - VAL2, - - /** */ - VAl3, - - /** */ - VAL4, - - /** */ - VAL5, - - /** */ - VAL6, - - /** */ - VAL7, - - /** */ - VAL8, - - /** */ - VAL9, - - /** */ - VAL10 - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(ClientTestPortable.class, this); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java b/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java index cde3a0d..0c459f5 100644 --- a/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java +++ b/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java @@ -20,7 +20,7 @@ package org.apache.ignite.client; import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.compute.*; -import org.apache.ignite.portables.*; +import org.gridgain.grid.portables.*; import org.apache.ignite.resources.*; import org.jetbrains.annotations.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/clients/src/test/resources/spring-cache.xml ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/resources/spring-cache.xml b/modules/clients/src/test/resources/spring-cache.xml index 4f980be..4df7806 100644 --- a/modules/clients/src/test/resources/spring-cache.xml +++ b/modules/clients/src/test/resources/spring-cache.xml @@ -229,11 +229,11 @@ </property> <property name="portableConfiguration"> - <bean class="org.apache.ignite.portables.PortableConfiguration"> + <bean class="org.gridgain.grid.portables.PortableConfiguration"> <property name="typeConfigurations"> <list> - <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> - <property name="className" value="org.apache.ignite.client.ClientTestPortable"/> + <bean class="org.gridgain.grid.portables.PortableTypeConfiguration"> + <property name="className" value="org.gridgain.client.ClientTestPortable"/> </bean> </list> </property> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/clients/src/test/resources/spring-server-node.xml ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/resources/spring-server-node.xml b/modules/clients/src/test/resources/spring-server-node.xml index 3b7fb06..9ef4dc8 100644 --- a/modules/clients/src/test/resources/spring-server-node.xml +++ b/modules/clients/src/test/resources/spring-server-node.xml @@ -76,19 +76,19 @@ </property> <property name="portableConfiguration"> - <bean class="org.apache.ignite.portables.PortableConfiguration"> + <bean class="org.gridgain.grid.portables.PortableConfiguration"> <property name="typeConfigurations"> <list> - <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> - <property name="className" value="org.apache.ignite.client.ClientTestPortable"/> + <bean class="org.gridgain.grid.portables.PortableTypeConfiguration"> + <property name="className" value="org.gridgain.client.ClientTestPortable"/> </bean> - <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> + <bean class="org.gridgain.grid.portables.PortableTypeConfiguration"> <property name="className" value="org.apache.ignite.client.model.GridPortablePerson"/> </bean> - <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> + <bean class="org.gridgain.grid.portables.PortableTypeConfiguration"> <property name="className" value="org.apache.ignite.client.model.GridImplicitPortablePerson"/> </bean> - <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> + <bean class="org.gridgain.grid.portables.PortableTypeConfiguration"> <property name="className" value="GridNoDefPortablePerson"/> </bean> </list> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/clients/src/test/resources/spring-server-ssl-node.xml ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/resources/spring-server-ssl-node.xml b/modules/clients/src/test/resources/spring-server-ssl-node.xml index f0da77c..f05a625 100644 --- a/modules/clients/src/test/resources/spring-server-ssl-node.xml +++ b/modules/clients/src/test/resources/spring-server-ssl-node.xml @@ -324,11 +324,11 @@ <property name="systemExecutorServiceShutdown" value="true"/> <property name="portableConfiguration"> - <bean class="org.apache.ignite.portables.PortableConfiguration"> + <bean class="org.gridgain.grid.portables.PortableConfiguration"> <property name="typeConfigurations"> <list> - <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> - <property name="className" value="org.apache.ignite.client.ClientTestPortable"/> + <bean class="org.gridgain.grid.portables.PortableTypeConfiguration"> + <property name="className" value="org.gridgain.client.ClientTestPortable"/> </bean> </list> </property> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/Ignite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/Ignite.java b/modules/core/src/main/java/org/apache/ignite/Ignite.java index df75d04..26bb08e 100644 --- a/modules/core/src/main/java/org/apache/ignite/Ignite.java +++ b/modules/core/src/main/java/org/apache/ignite/Ignite.java @@ -197,13 +197,6 @@ public interface Ignite extends AutoCloseable { public GridSecurity security(); /** - * Gets an instance of {@code GridPortables} interface. Available in enterprise edition only. - * - * @return Instance of {@code GridPortables} interface. - */ - public IgnitePortables portables(); - - /** * Gets the cache instance for the given name, if one does not * exist {@link IllegalArgumentException} will be thrown. * Note that in case named cache instance is used as GGFS data or meta cache, {@link IllegalStateException} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/IgniteCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java index d6a54fc..ab44fd1 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java @@ -294,7 +294,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * so keys and values will be returned from cache API methods without changes. Therefore, * signature of the projection can contain only following types: * <ul> - * <li>{@link org.apache.ignite.portables.PortableObject} for portable classes</li> + * <li>{@link org.gridgain.grid.portables.PortableObject} for portable classes</li> * <li>All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)</li> * <li>Arrays of primitives (byte[], int[], ...)</li> * <li>{@link String} and array of {@link String}s</li> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java b/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java deleted file mode 100644 index 6857961..0000000 --- a/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java +++ /dev/null @@ -1,364 +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; - -import org.apache.ignite.portables.*; -import org.jetbrains.annotations.*; - -import java.sql.*; -import java.util.*; -import java.util.Date; - -/** - * Defines portable objects functionality. With portable objects you are able to: - * <ul> - * <li>Seamlessly interoperate between Java, .NET, and C++.</li> - * <li>Make any object portable with zero code change to your existing code.</li> - * <li>Nest portable objects within each other.</li> - * <li>Automatically handle {@code circular} or {@code null} references.</li> - * <li>Automatically convert collections and maps between Java, .NET, and C++.</li> - * <li> - * Optionally avoid deserialization of objects on the server side - * (objects are stored in {@link org.apache.ignite.portables.PortableObject} format). - * </li> - * <li>Avoid need to have concrete class definitions on the server side.</li> - * <li>Dynamically change structure of the classes without having to restart the cluster.</li> - * <li>Index into portable objects for querying purposes.</li> - * </ul> - * <h1 class="header">Working With Portables Directly</h1> - * Once an object is defined as portable, - * Ignite will always store it in memory in the portable (i.e. binary) format. - * User can choose to work either with the portable format or with the deserialized form - * (assuming that class definitions are present in the classpath). - * <p> - * To work with the portable format directly, user should create a special cache projection - * using {@link org.apache.ignite.cache.CacheProjection#keepPortable()} method and then retrieve individual fields as needed: - * <pre name=code class=java> - * CacheProjection<GridPortableObject.class, GridPortableObject.class> prj = cache.keepPortable(); - * - * // Convert instance of MyKey to portable format. - * // We could also use GridPortableBuilder to create - * // the key in portable format directly. - * GridPortableObject key = grid.portables().toPortable(new MyKey()); - * - * GridPortableObject val = prj.get(key); - * - * String field = val.field("myFieldName"); - * </pre> - * Alternatively, if we have class definitions in the classpath, we may choose to work with deserialized - * typed objects at all times. In this case we do incur the deserialization cost, however, - * Ignite will only deserialize on the first access and will cache the deserialized object, - * so it does not have to be deserialized again: - * <pre name=code class=java> - * CacheProjection<MyKey.class, MyValue.class> prj = - * cache.projection(MyKey.class, MyValue.class); - * - * MyValue val = prj.get(new MyKey()); - * - * // Normal java getter. - * String fieldVal = val.getMyFieldName(); - * </pre> - * If we used, for example, one of the automatically handled portable types for a key, like integer, - * and still wanted to work with binary portable format for values, then we would declare cache projection - * as follows: - * <pre name=code class=java> - * CacheProjection<Integer.class, GridPortableObject.class> prj = cache.keepPortable(); - * </pre> - * <h1 class="header">Automatic Portable Types</h1> - * Note that only portable classes are converted to {@link org.apache.ignite.portables.PortableObject} format. Following - * classes are never converted (e.g., {@link #toPortable(Object)} method will return original - * object, and instances of these classes will be stored in cache without changes): - * <ul> - * <li>All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)</li> - * <li>Arrays of primitives (byte[], int[], ...)</li> - * <li>{@link String} and array of {@link String}s</li> - * <li>{@link UUID} and array of {@link UUID}s</li> - * <li>{@link Date} and array of {@link Date}s</li> - * <li>{@link Timestamp} and array of {@link Timestamp}s</li> - * <li>Enums and array of enums</li> - * <li> - * Maps, collections and array of objects (but objects inside - * them will still be converted if they are portable) - * </li> - * </ul> - * <h1 class="header">Working With Maps and Collections</h1> - * All maps and collections in the portable objects are serialized automatically. When working - * with different platforms, e.g. C++ or .NET, Ignite will automatically pick the most - * adequate collection or map in either language. For example, {@link ArrayList} in Java will become - * {@code List} in C#, {@link LinkedList} in Java is {@link LinkedList} in C#, {@link HashMap} - * in Java is {@code Dictionary} in C#, and {@link TreeMap} in Java becomes {@code SortedDictionary} - * in C#, etc. - * <h1 class="header">Building Portable Objects</h1> - * Ignite comes with {@link org.apache.ignite.portables.PortableBuilder} which allows to build portable objects dynamically: - * <pre name=code class=java> - * GridPortableBuilder builder = Ignition.ignite().portables().builder(); - * - * builder.typeId("MyObject"); - * - * builder.stringField("fieldA", "A"); - * build.intField("fieldB", "B"); - * - * GridPortableObject portableObj = builder.build(); - * </pre> - * For the cases when class definition is present - * in the class path, it is also possible to populate a standard POJO and then - * convert it to portable format, like so: - * <pre name=code class=java> - * MyObject obj = new MyObject(); - * - * obj.setFieldA("A"); - * obj.setFieldB(123); - * - * GridPortableObject portableObj = Ignition.ignite().portables().toPortable(obj); - * </pre> - * NOTE: you don't need to convert typed objects to portable format before storing - * them in cache, Ignite will do that automatically. - * <h1 class="header">Portable Metadata</h1> - * Even though Ignite portable protocol only works with hash codes for type and field names - * to achieve better performance, Ignite provides metadata for all portable types which - * can be queried ar runtime via any of the {@link IgnitePortables#metadata(Class) GridPortables.metadata(...)} - * methods. Having metadata also allows for proper formatting of {@code GridPortableObject.toString()} method, - * even when portable objects are kept in binary format only, which may be necessary for audit reasons. - * <h1 class="header">Dynamic Structure Changes</h1> - * Since objects are always cached in the portable binary format, server does not need to - * be aware of the class definitions. Moreover, if class definitions are not present or not - * used on the server, then clients can continuously change the structure of the portable - * objects without having to restart the cluster. For example, if one client stores a - * certain class with fields A and B, and another client stores the same class with - * fields B and C, then the server-side portable object will have the fields A, B, and C. - * As the structure of a portable object changes, the new fields become available for SQL queries - * automatically. - * <h1 class="header">Configuration</h1> - * To make any object portable, you have to specify it in {@link org.apache.ignite.portables.PortableConfiguration} - * at startup. The only requirement Ignite imposes is that your object has an empty - * constructor. Note, that since server side does not have to know the class definition, - * you only need to list portable objects in configuration on the client side. However, if you - * list them on the server side as well, then you get the ability to deserialize portable objects - * into concrete types on the server as well as on the client. - * <p> - * Here is an example of portable configuration (note that star (*) notation is supported): - * <pre name=code class=xml> - * ... - * <!-- Portable objects configuration. --> - * <property name="portableConfiguration"> - * <bean class="org.apache.ignite.portables.PortableConfiguration"> - * <property name="classNames"> - * <list> - * <value>my.package.for.portable.objects.*</value> - * <value>org.apache.ignite.examples.client.portable.Employee</value> - * </list> - * </property> - * </bean> - * </property> - * ... - * </pre> - * or from code: - * <pre name=code class=java> - * GridConfiguration gridCfg = new GridConfiguration(); - * - * GridPortableConfiguration portCfg = new GridPortableConfiguration(); - * - * portCfg.setClassNames(Arrays.asList( - * Employee.class.getName(), - * Address.class.getName()) - * ); - * - * gridCfg.setPortableConfiguration(portCfg); - * </pre> - * You can also specify class name for a portable object via {@link org.apache.ignite.portables.PortableTypeConfiguration}. - * Do it in case if you need to override other configuration properties on per-type level, like - * ID-mapper, or serializer. - * <h1 class="header">Custom Affinity Keys</h1> - * Often you need to specify an alternate key (not the cache key) for affinity routing whenever - * storing objects in cache. For example, if you are caching {@code Employee} object with - * {@code Organization}, and want to colocate employees with organization they work for, - * so you can process them together, you need to specify an alternate affinity key. - * With portable objects you would have to do it as following: - * <pre name=code class=xml> - * <property name="portableConfiguration"> - * <bean class="org.apache.ignite.portables.PortableConfiguration"> - * ... - * <property name="typeConfigurations"> - * <list> - * <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> - * <property name="className" value="org.apache.ignite.examples.client.portable.EmployeeKey"/> - * <property name="affinityKeyFieldName" value="organizationId"/> - * </bean> - * </list> - * </property> - * ... - * </bean> - * </property> - * </pre> - * <h1 class="header">Serialization</h1> - * Once portable object is specified in {@link org.apache.ignite.portables.PortableConfiguration}, Ignite will - * be able to serialize and deserialize it. However, you can provide your own custom - * serialization logic by optionally implementing {@link org.apache.ignite.portables.PortableMarshalAware} interface, like so: - * <pre name=code class=java> - * public class Address implements GridPortableMarshalAware { - * private String street; - * private int zip; - * - * // Empty constructor required for portable deserialization. - * public Address() {} - * - * @Override public void writePortable(GridPortableWriter writer) throws GridPortableException { - * writer.writeString("street", street); - * writer.writeInt("zip", zip); - * } - * - * @Override public void readPortable(GridPortableReader reader) throws GridPortableException { - * street = reader.readString("street"); - * zip = reader.readInt("zip"); - * } - * } - * </pre> - * Alternatively, if you cannot change class definitions, you can provide custom serialization - * logic in {@link org.apache.ignite.portables.PortableSerializer} either globally in {@link org.apache.ignite.portables.PortableConfiguration} or - * for a specific type via {@link org.apache.ignite.portables.PortableTypeConfiguration} instance. - * <p> - * Similar to java serialization you can use {@code writeReplace()} and {@code readResolve()} methods. - * <ul> - * <li> - * {@code readResolve} is defined as follows: {@code ANY-ACCESS-MODIFIER Object readResolve()}. - * It may be used to replace the de-serialized object by another one of your choice. - * </li> - * <li> - * {@code writeReplace} is defined as follows: {@code ANY-ACCESS-MODIFIER Object writeReplace()}. This method allows the - * developer to provide a replacement object that will be serialized instead of the original one. - * </li> - * </ul> - * - * <h1 class="header">Custom ID Mappers</h1> - * Ignite implementation uses name hash codes to generate IDs for class names or field names - * internally. However, in cases when you want to provide your own ID mapping schema, - * you can provide your own {@link org.apache.ignite.portables.PortableIdMapper} implementation. - * <p> - * ID-mapper may be provided either globally in {@link org.apache.ignite.portables.PortableConfiguration}, - * or for a specific type via {@link org.apache.ignite.portables.PortableTypeConfiguration} instance. - * <h1 class="header">Query Indexing</h1> - * Portable objects can be indexed for querying by specifying index fields in - * {@link org.apache.ignite.cache.CacheTypeMetadata} inside of specific {@link org.apache.ignite.configuration.CacheConfiguration} instance, - * like so: - * <pre name=code class=xml> - * ... - * <bean class="org.apache.ignite.cache.CacheConfiguration"> - * ... - * <property name="queryConfiguration"> - * <bean class="CacheQueryConfiguration"> - * <property name="typeMetadata"> - * <list> - * <bean class="CacheTypeMetadata"> - * <property name="type" value="Employee"/> - * - * <!-- Fields to index in ascending order. --> - * <property name="ascendingFields"> - * <map> - * <entry key="name" value="java.lang.String"/> - * - * <!-- Nested portable objects can also be indexed. --> - * <entry key="address.zip" value="java.lang.Integer"/> - * </map> - * </property> - * </bean> - * </list> - * </property> - * </bean> - * </property> - * </bean> - * </pre> - */ -public interface IgnitePortables { - /** - * Gets type ID for given type name. - * - * @param typeName Type name. - * @return Type ID. - */ - public int typeId(String typeName); - - /** - * Converts provided object to instance of {@link org.apache.ignite.portables.PortableObject}. - * <p> - * Note that object's type needs to be configured in {@link org.apache.ignite.portables.PortableConfiguration}. - * - * @param obj Object to convert. - * @return Converted object. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - public <T> T toPortable(@Nullable Object obj) throws PortableException; - - /** - * Creates new portable builder. - * - * @param typeId ID of the type. - * @return Newly portable builder. - */ - public PortableBuilder builder(int typeId); - - /** - * Creates new portable builder. - * - * @param typeName Type name. - * @return Newly portable builder. - */ - public PortableBuilder builder(String typeName); - - /** - * Creates portable builder initialized by existing portable object. - * - * @param portableObj Portable object to initialize builder. - * @return Portable builder. - */ - public PortableBuilder builder(PortableObject portableObj); - - /** - * Gets metadata for provided class. - * - * @param cls Class. - * @return Metadata. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - @Nullable public PortableMetadata metadata(Class<?> cls) throws PortableException; - - /** - * Gets metadata for provided class name. - * - * @param typeName Type name. - * @return Metadata. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - @Nullable public PortableMetadata metadata(String typeName) throws PortableException; - - /** - * Gets metadata for provided type ID. - * - * @param typeId Type ID. - * @return Metadata. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - @Nullable public PortableMetadata metadata(int typeId) throws PortableException; - - /** - * Gets metadata for all known types. - * - * @return Metadata. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - public Collection<PortableMetadata> metadata() throws PortableException; -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java index 014c508..1ca705a 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java @@ -289,7 +289,7 @@ public interface CacheProjection<K, V> extends Iterable<CacheEntry<K, V>> { * so keys and values will be returned from cache API methods without changes. Therefore, * signature of the projection can contain only following types: * <ul> - * <li>{@link org.apache.ignite.portables.PortableObject} for portable classes</li> + * <li>{@link org.gridgain.grid.portables.PortableObject} for portable classes</li> * <li>All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)</li> * <li>Arrays of primitives (byte[], int[], ...)</li> * <li>{@link String} and array of {@link String}s</li> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java index 367773f..114b56e 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java @@ -20,7 +20,6 @@ package org.apache.ignite.cache.store; import org.apache.ignite.*; import org.apache.ignite.cache.store.jdbc.*; import org.apache.ignite.lang.*; -import org.apache.ignite.portables.*; import org.apache.ignite.resources.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; @@ -69,8 +68,8 @@ import static javax.cache.Cache.*; * } * </pre> * <h1 class="header">Working With Portable Objects</h1> - * When portables are enabled for cache by setting {@link org.apache.ignite.configuration.CacheConfiguration#isPortableEnabled()} to - * {@code true}), all portable keys and values are converted to instances of {@link PortableObject}. + * When portables are enabled for cache by setting {@code org.apache.ignite.configuration.CacheConfiguration#isPortableEnabled()} to + * {@code true}), all portable keys and values are converted to instances of {@code PortableObject}. * Therefore, all cache store methods will take parameters in portable format. To avoid class * cast exceptions, store must have signature compatible with portables. E.g., if you use {@link Integer} * as a key and {@code Value} class as a value (which will be converted to portable format), cache store @@ -84,7 +83,7 @@ import static javax.cache.Cache.*; * ... * } * </pre> - * This behavior can be overridden by setting {@link org.apache.ignite.configuration.CacheConfiguration#setKeepPortableInStore(boolean)} + * This behavior can be overridden by setting {@code org.apache.ignite.configuration.CacheConfiguration#setKeepPortableInStore(boolean)} * flag value to {@code false}. In this case, Ignite will deserialize keys and values stored in portable * format before they are passed to cache store, so that you can use the following cache store signature instead: * <pre name="code" class="java"> @@ -100,7 +99,7 @@ import static javax.cache.Cache.*; * due to additional serializations and deserializations of portable objects. You will also need to have key * and value classes on all nodes since portables will be deserialized when store is invoked. * <p> - * Note that only portable classes are converted to {@link PortableObject} format. Following + * Note that only portable classes are converted to {@code PortableObject} format. Following * types are stored in cache without changes and therefore should not affect cache store signature: * <ul> * <li>All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)</li> @@ -116,7 +115,6 @@ import static javax.cache.Cache.*; * </li> * </ul> * - * @see IgnitePortables * @see CacheStoreSession */ public abstract class CacheStore<K, V> implements CacheLoader<K, V>, CacheWriter<K, V> { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/client/GridClientCacheFlag.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/client/GridClientCacheFlag.java b/modules/core/src/main/java/org/apache/ignite/client/GridClientCacheFlag.java index 9cf307e..eeba658 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/GridClientCacheFlag.java +++ b/modules/core/src/main/java/org/apache/ignite/client/GridClientCacheFlag.java @@ -43,7 +43,7 @@ public enum GridClientCacheFlag { * Disable deserialization of portable objects on get operations. * If set and portable marshaller is used, {@link GridClientData#get(Object)} * and {@link GridClientData#getAll(Collection)} methods will return - * instances of {@link org.apache.ignite.portables.PortableObject} class instead of user objects. + * instances of {@link org.gridgain.grid.portables.PortableObject} class instead of user objects. * Use this flag if you don't have corresponding class on your client of * if you want to get access to some individual fields, but do not want to * fully deserialize the object. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/client/GridClientConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/client/GridClientConfiguration.java b/modules/core/src/main/java/org/apache/ignite/client/GridClientConfiguration.java index d571f47..bf3a013 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/GridClientConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/client/GridClientConfiguration.java @@ -25,7 +25,6 @@ import org.apache.ignite.client.ssl.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.plugin.security.*; -import org.apache.ignite.portables.*; import org.jetbrains.annotations.*; import java.net.*; @@ -117,9 +116,6 @@ public class GridClientConfiguration { /** Daemon flag. */ private boolean daemon; - /** Portable configuration. */ - private PortableConfiguration portableCfg; - /** * Creates default configuration. */ @@ -154,7 +150,6 @@ public class GridClientConfiguration { topRefreshFreq = cfg.getTopologyRefreshFrequency(); daemon = cfg.isDaemon(); marshaller = cfg.getMarshaller(); - portableCfg = cfg.getPortableConfiguration(); setDataConfigurations(cfg.getDataConfigurations()); } @@ -632,24 +627,6 @@ public class GridClientConfiguration { } /** - * Gets portable configuration. - * - * @return Portable configuration. - */ - public PortableConfiguration getPortableConfiguration() { - return portableCfg; - } - - /** - * Sets portable configuration. - * - * @param portableCfg Portable configuration. - */ - public void setPortableConfiguration(@Nullable PortableConfiguration portableCfg) { - this.portableCfg = portableCfg; - } - - /** * Load client configuration from the properties map. * * @param prefix Prefix for the client properties. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java index 4358fa4..b57b435 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java @@ -25,7 +25,6 @@ import org.apache.ignite.cache.eviction.*; import org.apache.ignite.cache.query.*; import org.apache.ignite.cache.store.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import org.apache.ignite.spi.indexing.*; import org.jetbrains.annotations.*; @@ -312,12 +311,6 @@ public class CacheConfiguration extends MutableConfiguration { /** */ private CacheInterceptor<?, ?> interceptor; - /** */ - private boolean portableEnabled; - - /** */ - private boolean keepPortableInStore = true; - /** Query configuration. */ private CacheQueryConfiguration qryCfg; @@ -379,7 +372,6 @@ public class CacheConfiguration extends MutableConfiguration { invalidate = cc.isInvalidate(); isReadThrough = cc.isReadThrough(); isWriteThrough = cc.isWriteThrough(); - keepPortableInStore = cc.isKeepPortableInStore(); listenerConfigurations = cc.listenerConfigurations; loadPrevVal = cc.isLoadPreviousValue(); offHeapMaxMem = cc.getOffHeapMaxMemory(); @@ -389,7 +381,6 @@ public class CacheConfiguration extends MutableConfiguration { name = cc.getName(); nearStartSize = cc.getNearStartSize(); nearEvictPlc = cc.getNearEvictionPolicy(); - portableEnabled = cc.isPortableEnabled(); preloadMode = cc.getPreloadMode(); preloadBatchSize = cc.getPreloadBatchSize(); preloadDelay = cc.getPreloadPartitionedDelay(); @@ -1604,61 +1595,6 @@ public class CacheConfiguration extends MutableConfiguration { } /** - * Flag indicating whether Ignite should store portable keys and values - * as instances of {@link PortableObject}. - * - * @return Portable enabled flag. - */ - public boolean isPortableEnabled() { - return portableEnabled; - } - - /** - * Gets portable enabled flag value. - * - * @param portableEnabled Portable enabled flag value. - */ - public void setPortableEnabled(boolean portableEnabled) { - this.portableEnabled = portableEnabled; - } - - /** - * Flag indicating that {@link CacheStore} implementation - * is working with portable objects instead of Java objects - * if portable mode for this cache is enabled ({@link #isPortableEnabled()} - * flag is {@code true}). Default value of this flag is {@code true}, - * because this is recommended behavior from performance standpoint. - * <p> - * If set to {@code false}, Ignite will deserialize keys and - * values stored in portable format before they are passed - * to cache store. - * <p> - * Note that setting this flag to {@code false} can simplify - * store implementation in some cases, but it can cause performance - * degradation due to additional serializations and deserializations - * of portable objects. You will also need to have key and value - * classes on all nodes since portables will be deserialized when - * store is called. - * <p> - * This flag is ignored if portable mode is disabled for this - * cache ({@link #isPortableEnabled()} flag is {@code false}). - * - * @return Keep portables in store flag. - */ - public boolean isKeepPortableInStore() { - return keepPortableInStore; - } - - /** - * Sets keep portables in store flag. - * - * @param keepPortableInStore Keep portables in store flag. - */ - public void setKeepPortableInStore(boolean keepPortableInStore) { - this.keepPortableInStore = keepPortableInStore; - } - - /** * Gets collection of type metadata objects. * * @return Collection of type metadata. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java index 5ec0924..014daba 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java @@ -28,7 +28,6 @@ import org.apache.ignite.lifecycle.*; import org.apache.ignite.services.*; import org.apache.ignite.marshaller.*; import org.apache.ignite.plugin.*; -import org.apache.ignite.portables.*; import org.apache.ignite.spi.authentication.*; import org.apache.ignite.spi.indexing.*; import org.apache.ignite.streamer.*; @@ -512,9 +511,6 @@ public class IgniteConfiguration { /** Client access configuration. */ private ClientConnectionConfiguration clientCfg; - /** Portable configuration. */ - private PortableConfiguration portableCfg; - /** Warmup closure. Will be invoked before actual grid start. */ private IgniteInClosure<IgniteConfiguration> warmupClos; @@ -606,7 +602,6 @@ public class IgniteConfiguration { p2pSvc = cfg.getPeerClassLoadingExecutorService(); p2pSvcShutdown = cfg.getPeerClassLoadingExecutorServiceShutdown(); pluginCfgs = cfg.getPluginConfigurations(); - portableCfg = cfg.getPortableConfiguration(); qryCfg = cfg.getQueryConfiguration(); restAccessibleFolders = cfg.getRestAccessibleFolders(); restEnabled = cfg.isRestEnabled(); @@ -3040,20 +3035,6 @@ public class IgniteConfiguration { } /** - * @return Portable configuration. - */ - public PortableConfiguration getPortableConfiguration() { - return portableCfg; - } - - /** - * @param portableCfg Portable configuration. - */ - public void setPortableConfiguration(PortableConfiguration portableCfg) { - this.portableCfg = portableCfg; - } - - /** * Gets configurations for services to be deployed on the grid. * * @return Configurations for services to be deployed on the grid. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/internal/GridPortablesImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridPortablesImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridPortablesImpl.java deleted file mode 100644 index 8dedc4d..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridPortablesImpl.java +++ /dev/null @@ -1,174 +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; - -import org.apache.ignite.*; -import org.apache.ignite.internal.processors.portable.*; -import org.apache.ignite.portables.*; -import org.jetbrains.annotations.*; - -import java.util.*; - -/** - * {@link org.apache.ignite.IgnitePortables} implementation. - */ -public class GridPortablesImpl implements IgnitePortables { - /** */ - private GridKernalContext ctx; - - /** */ - private GridPortableProcessor proc; - - /** - * @param ctx Context. - */ - public GridPortablesImpl(GridKernalContext ctx) { - this.ctx = ctx; - - proc = ctx.portable(); - } - - /** {@inheritDoc} */ - @Override public int typeId(String typeName) { - guard(); - - try { - return proc.typeId(typeName); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Override public <T> T toPortable(@Nullable Object obj) throws PortableException { - guard(); - - try { - return (T)proc.marshalToPortable(obj); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Override public PortableBuilder builder(int typeId) { - guard(); - - try { - return proc.builder(typeId); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Override public PortableBuilder builder(String typeName) { - guard(); - - try { - return proc.builder(typeName); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Override public PortableBuilder builder(PortableObject portableObj) { - guard(); - - try { - return proc.builder(portableObj); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Nullable @Override public PortableMetadata metadata(Class<?> cls) throws PortableException { - guard(); - - try { - return proc.metadata(proc.typeId(cls.getName())); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Nullable @Override public PortableMetadata metadata(String typeName) throws PortableException { - guard(); - - try { - return proc.metadata(proc.typeId(typeName)); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Nullable @Override public PortableMetadata metadata(int typeId) throws PortableException { - guard(); - - try { - return proc.metadata(typeId); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Override public Collection<PortableMetadata> metadata() throws PortableException { - guard(); - - try { - return proc.metadata(); - } - finally { - unguard(); - } - } - - /** - * @return Portable processor. - */ - public GridPortableProcessor processor() { - return proc; - } - - /** - * <tt>ctx.gateway().readLock()</tt> - */ - private void guard() { - ctx.gateway().readLock(); - } - - /** - * <tt>ctx.gateway().readUnlock()</tt> - */ - private void unguard() { - ctx.gateway().readUnlock(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index 7425813..c24235b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -212,10 +212,6 @@ public class IgniteKernal extends ClusterGroupAdapter implements IgniteEx, Ignit @GridToStringExclude private GridSecurity security; - /** Portables instance. */ - @GridToStringExclude - private IgnitePortables portables; - /** Kernal gateway. */ @GridToStringExclude private final AtomicReference<GridKernalGateway> gw = new AtomicReference<>(); @@ -772,7 +768,6 @@ public class IgniteKernal extends ClusterGroupAdapter implements IgniteEx, Ignit if (ctx.isEnterprise()) { security = new GridSecurityImpl(ctx); - portables = new GridPortablesImpl(ctx); } gw.writeLock(); @@ -3246,14 +3241,6 @@ public class IgniteKernal extends ClusterGroupAdapter implements IgniteEx, Ignit } /** {@inheritDoc} */ - @Override public IgnitePortables portables() { - if (!ctx.isEnterprise()) - throw new UnsupportedOperationException("Portables interface available in Enterprise edition only."); - - return portables; - } - - /** {@inheritDoc} */ @Override public Collection<String> compatibleVersions() { return compatibleVers; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java index c2bab47..6ef5973 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java @@ -1795,9 +1795,6 @@ public class IgnitionEx { // REST configuration. myCfg.setClientConnectionConfiguration(clientCfg); - // Portable configuration. - myCfg.setPortableConfiguration(cfg.getPortableConfiguration()); - // Hadoop configuration. myCfg.setHadoopConfiguration(cfg.getHadoopConfiguration()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java index ff44528..a5261e0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java @@ -27,7 +27,6 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.util.future.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; @@ -277,7 +276,7 @@ public class GridAffinityAssignmentCache { try { key = ctx.marshalToPortable(key); } - catch (PortableException e) { + catch (IgniteException e) { U.error(log, "Failed to marshal key to portable: " + key, e); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java index 5ee9826..cf268fd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java @@ -397,7 +397,7 @@ public class GridAffinityProcessor extends GridProcessorAdapter { f.reset(); m.reset(); - Boolean portableEnabled = U.portableEnabled(n, cacheName); + Boolean portableEnabled = ctx.portable().portableEnabled(n, cacheName); return new AffinityInfo(f, m, t.get3(), portableEnabled != null && portableEnabled); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 342220a..1071d8f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -45,7 +45,6 @@ import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.mxbean.*; import org.apache.ignite.plugin.security.*; -import org.apache.ignite.portables.*; import org.apache.ignite.resources.*; import org.apache.ignite.transactions.*; import org.jdk8.backport.*; @@ -458,10 +457,6 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, Class<? super K1> keyType, Class<? super V1> valType ) { - if (PortableObject.class.isAssignableFrom(keyType) || PortableObject.class.isAssignableFrom(valType)) - throw new IllegalStateException("Failed to create cache projection for portable objects. " + - "Use keepPortable() method instead."); - if (ctx.deploymentEnabled()) { try { ctx.deploy().registerClasses(keyType, valType); @@ -1564,7 +1559,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, try { key = (K)ctx.marshalToPortable(key); } - catch (PortableException e) { + catch (IgniteException e) { throw new IgniteException(e); } } @@ -3575,7 +3570,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, try { key0 = (K)ctx.marshalToPortable(key); } - catch (PortableException e) { + catch (IgniteException e) { return new GridFinishedFuture<>(ctx.kernalContext(), e); } } @@ -3843,7 +3838,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, ctx.store().loadCache(new CIX3<K, V, GridCacheVersion>() { @Override public void applyx(K key, V val, @Nullable GridCacheVersion ver) - throws PortableException { + throws IgniteException { assert ver == null; loadEntry(key, val, ver0, p, topVer, replicate, ttl); @@ -4774,14 +4769,8 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, if (keyCheck) validateCacheKey(key); - if (ctx.portableEnabled()) { - try { - key = (K)ctx.marshalToPortable(key); - } - catch (PortableException e) { - throw new IgniteException(e); - } - } + if (ctx.portableEnabled()) + key = (K)ctx.marshalToPortable(key); GridCacheEntryEx<K, V> e = peekEx(key); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java index 999ad66..b0cfb6b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java @@ -157,9 +157,6 @@ public class GridCacheAttributes implements Externalizable { /** Store load previous value flag. */ private boolean loadPrevVal; - /** Portable enabled flag. */ - private boolean portableEnabled; - /** * @param cfg Cache configuration. * @param store Cache store. @@ -176,7 +173,6 @@ public class GridCacheAttributes implements Externalizable { loadPrevVal = cfg.isLoadPreviousValue(); name = cfg.getName(); partDistro = GridCacheUtils.distributionMode(cfg); - portableEnabled = cfg.isPortableEnabled(); preloadBatchSize = cfg.getPreloadBatchSize(); preloadMode = cfg.getPreloadMode(); qryIdxEnabled = cfg.isQueryIndexEnabled(); @@ -521,13 +517,6 @@ public class GridCacheAttributes implements Externalizable { return indexingSpiName; } - /** - * @return Portable enabled flag. - */ - public boolean portableEnabled() { - return portableEnabled; - } - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { U.writeEnum(out, atomicityMode); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java index 6b3b084..5370a30 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java @@ -37,6 +37,7 @@ import org.apache.ignite.internal.processors.cache.jta.*; import org.apache.ignite.internal.processors.cache.local.*; import org.apache.ignite.internal.processors.cache.query.*; import org.apache.ignite.internal.processors.cache.query.continuous.*; +import org.apache.ignite.internal.processors.cache.serialization.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.processors.closure.*; @@ -52,7 +53,6 @@ import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.*; import org.apache.ignite.plugin.security.*; -import org.apache.ignite.portables.*; import org.jetbrains.annotations.*; import javax.cache.configuration.*; @@ -130,6 +130,9 @@ public class GridCacheContext<K, V> implements Externalizable { /** Replication manager. */ private GridCacheDrManager<K, V> drMgr; + /** Serialization manager. */ + private IgniteCacheSerializationManager<K, V> serMgr; + /** JTA manager. */ private CacheJtaManagerAdapter<K, V> jtaMgr; @@ -1609,7 +1612,7 @@ public class GridCacheContext<K, V> implements Externalizable { } /** - * @param interceptorRes Result of {@link org.apache.ignite.cache.CacheInterceptor#onBeforeRemove} callback. + * @param interceptorRes Result of {@link CacheInterceptor#onBeforeRemove} callback. * @return {@code True} if interceptor cancels remove. */ public boolean cancelRemove(@Nullable IgniteBiTuple<Boolean, ?> interceptorRes) { @@ -1641,7 +1644,14 @@ public class GridCacheContext<K, V> implements Externalizable { * @return Portable enabled flag. */ public boolean portableEnabled() { - return cacheCfg.isPortableEnabled(); + return serMgr.portableEnabled(); + } + + /** + * @return Keep portable in store flag. + */ + public boolean keepPortableInStore() { + return serMgr.keepPortableInStore(); } /** @@ -1687,15 +1697,15 @@ public class GridCacheContext<K, V> implements Externalizable { /** * @param obj Object. * @return Portable object. - * @throws PortableException In case of error. + * @throws IgniteException In case of error. */ - @Nullable public Object marshalToPortable(@Nullable Object obj) throws PortableException { + @Nullable public Object marshalToPortable(@Nullable Object obj) throws IgniteException { assert portableEnabled(); if (obj == null) return null; - if (obj instanceof PortableObject || obj instanceof GridCacheInternal) + if (ctx.portable().isPortableObject(obj) || obj instanceof GridCacheInternal) return obj; GridPortableProcessor proc = kernalContext().portable(); @@ -1713,58 +1723,7 @@ public class GridCacheContext<K, V> implements Externalizable { * @return Unwrapped collection. */ public Collection<Object> unwrapPortablesIfNeeded(Collection<Object> col, boolean keepPortable) { - if (keepPortable || !config().isPortableEnabled()) - return col; - - if (col instanceof ArrayList) - return unwrapPortables((ArrayList<Object>)col); - - Collection<Object> col0 = new ArrayList<>(col.size()); - - for (Object obj : col) - col0.add(unwrapPortable(obj)); - - return col0; - } - - /** - * Unwraps map. - * - * @param map Map to unwrap. - * @param keepPortable Keep portable flag. - * @return Unwrapped collection. - */ - public Map<Object, Object> unwrapPortablesIfNeeded(Map<Object, Object> map, boolean keepPortable) { - if (keepPortable || !config().isPortableEnabled()) - return map; - - Map<Object, Object> map0 = U.newHashMap(map.size()); - - for (Map.Entry<Object, Object> e : map.entrySet()) - map0.put(unwrapPortable(e.getKey()), unwrapPortable(e.getValue())); - - return map0; - } - - /** - * Unwraps array list. - * - * @param col List to unwrap. - * @return Unwrapped list. - */ - private Collection<Object> unwrapPortables(ArrayList<Object> col) { - int size = col.size(); - - for (int i = 0; i < size; i++) { - Object o = col.get(i); - - Object unwrapped = unwrapPortable(o); - - if (o != unwrapped) - col.set(i, unwrapped); - } - - return col; + return serMgr.unwrapPortablesIfNeeded(col, keepPortable); } /** @@ -1776,53 +1735,7 @@ public class GridCacheContext<K, V> implements Externalizable { */ @SuppressWarnings("IfMayBeConditional") public Object unwrapPortableIfNeeded(Object o, boolean keepPortable) { - assert !portableEnabled() || o == null || U.isPortableOrCollectionType(o.getClass()); - - if (o == null) - return null; - - if (keepPortable || !portableEnabled()) - return o; - - return unwrapPortable(o); - } - - /** - * @param o Object to unwrap. - * @return Unwrapped object. - */ - private Object unwrapPortable(Object o) { - if (o instanceof Map.Entry) { - Map.Entry entry = (Map.Entry)o; - - Object key = entry.getKey(); - - boolean unwrapped = false; - - if (key instanceof PortableObject) { - key = ((PortableObject)key).deserialize(); - - unwrapped = true; - } - - Object val = entry.getValue(); - - if (val instanceof PortableObject) { - val = ((PortableObject)val).deserialize(); - - unwrapped = true; - } - - return unwrapped ? F.t(key, val) : o; - } - else if (o instanceof Collection) - return unwrapPortablesIfNeeded((Collection<Object>)o, false); - else if (o instanceof Map) - return unwrapPortablesIfNeeded((Map<Object, Object>)o, false); - else if (o instanceof PortableObject) - return ((PortableObject)o).deserialize(); - - return o; + return serMgr.unwrapPortableIfNeeded(o, keepPortable); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dff026be/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDefaultAffinityKeyMapper.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDefaultAffinityKeyMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDefaultAffinityKeyMapper.java index d89c9fc..2b6bfc9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDefaultAffinityKeyMapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDefaultAffinityKeyMapper.java @@ -19,30 +19,35 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; import org.apache.ignite.cache.affinity.*; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import org.apache.ignite.resources.*; import java.lang.annotation.*; import java.lang.reflect.*; /** - * Default key affinity mapper. If key class has annotation {@link org.apache.ignite.cache.affinity.CacheAffinityKeyMapped}, + * Default key affinity mapper. If key class has annotation {@link CacheAffinityKeyMapped}, * then the value of annotated method or field will be used to get affinity value instead * of the key itself. If there is no annotation, then the key is used as is. * <p> - * Convenience affinity key adapter, {@link org.apache.ignite.cache.affinity.CacheAffinityKey} can be used in + * Convenience affinity key adapter, {@link CacheAffinityKey} can be used in * conjunction with this mapper to automatically provide custom affinity keys for cache keys. * <p> * If non-default affinity mapper is used, is should be provided via - * {@link org.apache.ignite.configuration.CacheConfiguration#getAffinityMapper()} configuration property. + * {@link CacheConfiguration#getAffinityMapper()} configuration property. */ public class GridCacheDefaultAffinityKeyMapper implements CacheAffinityKeyMapper { /** */ private static final long serialVersionUID = 0L; + /** Injected ignite instance. */ + @IgniteInstanceResource + private Ignite ignite; + /** Reflection cache. */ private GridReflectionCache reflectCache = new GridReflectionCache( new P1<Field>() { @@ -74,7 +79,7 @@ public class GridCacheDefaultAffinityKeyMapper implements CacheAffinityKeyMapper private transient IgniteLogger log; /** - * If key class has annotation {@link org.apache.ignite.cache.affinity.CacheAffinityKeyMapped}, + * If key class has annotation {@link CacheAffinityKeyMapped}, * then the value of annotated method or field will be used to get affinity value instead * of the key itself. If there is no annotation, then the key is returned as is. * @@ -84,23 +89,10 @@ public class GridCacheDefaultAffinityKeyMapper implements CacheAffinityKeyMapper @Override public Object affinityKey(Object key) { GridArgumentCheck.notNull(key, "key"); - if (key instanceof PortableObject) { - PortableObject po = (PortableObject)key; - - try { - PortableMetadata meta = po.metaData(); - - if (meta != null) { - String affKeyFieldName = meta.affinityKeyFieldName(); + IgniteKernal kernal = (IgniteKernal)ignite; - if (affKeyFieldName != null) - return po.field(affKeyFieldName); - } - } - catch (PortableException e) { - U.error(log, "Failed to get affinity field from portable object: " + key, e); - } - } + if (kernal.context().portable().isPortableObject(key)) + return kernal.context().portable().affinityKey(key); else { try { Object o = reflectCache.firstFieldValue(key);