# Renaming
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/1515c5aa Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/1515c5aa Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/1515c5aa Branch: refs/heads/master Commit: 1515c5aadbe7f8503386d53b2bd56fed7987299c Parents: a228c7d Author: sboikov <sboi...@gridgain.com> Authored: Fri Dec 5 11:05:40 2014 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Fri Dec 5 11:05:40 2014 +0300 ---------------------------------------------------------------------- .../client/GridClientPortableArgumentTask.java | 2 +- .../gridgain/client/GridClientTestPortable.java | 8 +- .../GridClientTestPortableAffinityKeyTask.java | 2 +- .../clients/src/test/resources/spring-cache.xml | 2 +- .../src/test/resources/spring-server-node.xml | 8 +- .../test/resources/spring-server-ssl-node.xml | 2 +- .../java/org/apache/ignite/IgnitePortables.java | 24 +- .../ignite/portables/GridPortableMetadata.java | 53 ---- .../ignite/portables/GridPortableObject.java | 166 ------------ .../ignite/portables/GridPortableRawReader.java | 214 --------------- .../ignite/portables/GridPortableRawWriter.java | 197 -------------- .../ignite/portables/GridPortableReader.java | 263 ------------------- .../portables/GridPortableSerializer.java | 39 --- .../GridPortableTypeConfiguration.java | 187 ------------- .../ignite/portables/GridPortableWriter.java | 242 ----------------- .../ignite/portables/PortableBuilder.java | 8 +- .../ignite/portables/PortableConfiguration.java | 24 +- .../ignite/portables/PortableIdMapper.java | 2 +- .../PortableInvalidClassException.java | 2 +- .../ignite/portables/PortableMarshalAware.java | 4 +- .../ignite/portables/PortableMetadata.java | 53 ++++ .../apache/ignite/portables/PortableObject.java | 166 ++++++++++++ .../ignite/portables/PortableRawReader.java | 214 +++++++++++++++ .../ignite/portables/PortableRawWriter.java | 197 ++++++++++++++ .../apache/ignite/portables/PortableReader.java | 263 +++++++++++++++++++ .../ignite/portables/PortableSerializer.java | 39 +++ .../portables/PortableTypeConfiguration.java | 187 +++++++++++++ .../apache/ignite/portables/PortableWriter.java | 242 +++++++++++++++++ .../gridgain/client/GridClientCacheFlag.java | 2 +- .../grid/cache/GridCacheConfiguration.java | 2 +- .../grid/cache/GridCacheProjection.java | 2 +- .../grid/cache/store/GridCacheStore.java | 4 +- .../grid/dotnet/GridDotNetConfiguration.java | 8 +- .../dotnet/GridDotNetPortableConfiguration.java | 8 +- .../GridDotNetPortableTypeConfiguration.java | 8 +- .../gridgain/grid/kernal/GridPortablesImpl.java | 10 +- .../managers/indexing/GridIndexingManager.java | 16 +- .../processors/cache/GridCacheAdapter.java | 18 +- .../processors/cache/GridCacheContext.java | 14 +- .../GridCacheDefaultAffinityKeyMapper.java | 6 +- .../cache/GridCacheProjectionImpl.java | 4 +- .../cache/GridCacheTxLocalAdapter.java | 16 +- .../dht/GridPartitionedGetFuture.java | 8 +- .../dht/atomic/GridDhtAtomicCache.java | 4 +- .../dht/colocated/GridDhtColocatedCache.java | 4 +- .../distributed/near/GridNearGetFuture.java | 8 +- .../portable/GridPortableProcessor.java | 10 +- .../portable/os/GridOsPortableProcessor.java | 10 +- .../message/GridClientAbstractMessage.java | 8 +- .../GridClientAuthenticationRequest.java | 8 +- .../message/GridClientCacheQueryRequest.java | 8 +- .../client/message/GridClientCacheRequest.java | 8 +- .../message/GridClientGetMetaDataRequest.java | 8 +- .../client/message/GridClientLogRequest.java | 8 +- .../message/GridClientMetaDataResponse.java | 12 +- .../rest/client/message/GridClientNodeBean.java | 8 +- .../message/GridClientNodeMetricsBean.java | 8 +- .../message/GridClientPortableMetaData.java | 8 +- .../message/GridClientPutMetaDataRequest.java | 8 +- .../rest/client/message/GridClientResponse.java | 8 +- .../client/message/GridClientTaskRequest.java | 8 +- .../message/GridClientTaskResultBean.java | 8 +- .../message/GridClientTopologyRequest.java | 8 +- .../cache/GridCacheClientQueryResult.java | 8 +- .../metadata/GridPortableMetadataHandler.java | 2 +- .../VisorPortableMetadataCollectorTask.java | 2 +- .../grid/security/GridSecurityCredentials.java | 4 +- .../java/org/gridgain/grid/util/GridUtils.java | 2 +- .../util/portable/GridPortableRawReaderEx.java | 24 -- .../util/portable/GridPortableRawWriterEx.java | 35 --- .../grid/util/portable/PortableRawReaderEx.java | 24 ++ .../grid/util/portable/PortableRawWriterEx.java | 35 +++ ...heOffHeapTieredEvictionAbstractSelfTest.java | 4 +- .../GridCacheSwapScanQueryAbstractSelfTest.java | 4 +- .../dataload/GridDataLoaderImplSelfTest.java | 6 +- 75 files changed, 1623 insertions(+), 1623 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/clients/src/test/java/org/gridgain/client/GridClientPortableArgumentTask.java ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/java/org/gridgain/client/GridClientPortableArgumentTask.java b/modules/clients/src/test/java/org/gridgain/client/GridClientPortableArgumentTask.java index 051c52b..37875f8 100644 --- a/modules/clients/src/test/java/org/gridgain/client/GridClientPortableArgumentTask.java +++ b/modules/clients/src/test/java/org/gridgain/client/GridClientPortableArgumentTask.java @@ -31,7 +31,7 @@ public class GridClientPortableArgumentTask extends GridTaskSingleJobSplitAdapte GridClientTestPortable p; if (expPortable) { - GridPortableObject obj = (GridPortableObject)it.next(); + PortableObject obj = (PortableObject)it.next(); p = obj.deserialize(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/clients/src/test/java/org/gridgain/client/GridClientTestPortable.java ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/java/org/gridgain/client/GridClientTestPortable.java b/modules/clients/src/test/java/org/gridgain/client/GridClientTestPortable.java index 9836e05..113cb11 100644 --- a/modules/clients/src/test/java/org/gridgain/client/GridClientTestPortable.java +++ b/modules/clients/src/test/java/org/gridgain/client/GridClientTestPortable.java @@ -303,7 +303,7 @@ public class GridClientTestPortable implements PortableMarshalAware, Serializabl } /** {@inheritDoc} */ - @Override public void writePortable(GridPortableWriter writer) throws PortableException { + @Override public void writePortable(PortableWriter writer) throws PortableException { writer.writeByte("_b", b); writer.writeShort("_s", s); writer.writeInt("_i", i); @@ -334,7 +334,7 @@ public class GridClientTestPortable implements PortableMarshalAware, Serializabl writer.writeObject("_portable1", portable1); writer.writeObject("_portable2", portable2); - GridPortableRawWriter raw = writer.rawWriter(); + PortableRawWriter raw = writer.rawWriter(); raw.writeByte(bRaw); raw.writeShort(sRaw); @@ -368,7 +368,7 @@ public class GridClientTestPortable implements PortableMarshalAware, Serializabl } /** {@inheritDoc} */ - @Override public void readPortable(GridPortableReader reader) throws PortableException { + @Override public void readPortable(PortableReader reader) throws PortableException { b = reader.readByte("_b"); s = reader.readShort("_s"); i = reader.readInt("_i"); @@ -399,7 +399,7 @@ public class GridClientTestPortable implements PortableMarshalAware, Serializabl portable1 = (GridClientTestPortable)reader.readObject("_portable1"); portable2 = (GridClientTestPortable)reader.readObject("_portable2"); - GridPortableRawReader raw = reader.rawReader(); + PortableRawReader raw = reader.rawReader(); bRaw = raw.readByte(); sRaw = raw.readShort(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/clients/src/test/java/org/gridgain/client/GridClientTestPortableAffinityKeyTask.java ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/java/org/gridgain/client/GridClientTestPortableAffinityKeyTask.java b/modules/clients/src/test/java/org/gridgain/client/GridClientTestPortableAffinityKeyTask.java index f94481d..883b370 100644 --- a/modules/clients/src/test/java/org/gridgain/client/GridClientTestPortableAffinityKeyTask.java +++ b/modules/clients/src/test/java/org/gridgain/client/GridClientTestPortableAffinityKeyTask.java @@ -59,7 +59,7 @@ public class GridClientTestPortableAffinityKeyTask extends ComputeTaskAdapter<Ob assert args.size() == 3 : args.size(); - GridPortableObject obj = (GridPortableObject)it.next(); + PortableObject obj = (PortableObject)it.next(); String cacheName = (String)it.next(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/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 bb4a4cd..fa4c2fa 100644 --- a/modules/clients/src/test/resources/spring-cache.xml +++ b/modules/clients/src/test/resources/spring-cache.xml @@ -239,7 +239,7 @@ <bean class="org.apache.ignite.portables.PortableConfiguration"> <property name="typeConfigurations"> <list> - <bean class="org.apache.ignite.portables.GridPortableTypeConfiguration"> + <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> <property name="className" value="org.gridgain.client.GridClientTestPortable"/> </bean> </list> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/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 d5d8530..de7db25 100644 --- a/modules/clients/src/test/resources/spring-server-node.xml +++ b/modules/clients/src/test/resources/spring-server-node.xml @@ -73,16 +73,16 @@ <bean class="org.apache.ignite.portables.PortableConfiguration"> <property name="typeConfigurations"> <list> - <bean class="org.apache.ignite.portables.GridPortableTypeConfiguration"> + <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> <property name="className" value="org.gridgain.client.GridClientTestPortable"/> </bean> - <bean class="org.apache.ignite.portables.GridPortableTypeConfiguration"> + <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> <property name="className" value="org.gridgain.client.model.GridPortablePerson"/> </bean> - <bean class="org.apache.ignite.portables.GridPortableTypeConfiguration"> + <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> <property name="className" value="org.gridgain.client.model.GridImplicitPortablePerson"/> </bean> - <bean class="org.apache.ignite.portables.GridPortableTypeConfiguration"> + <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> <property name="className" value="GridNoDefPortablePerson"/> </bean> </list> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/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 0a363d5..3d50ace 100644 --- a/modules/clients/src/test/resources/spring-server-ssl-node.xml +++ b/modules/clients/src/test/resources/spring-server-ssl-node.xml @@ -321,7 +321,7 @@ <bean class="org.apache.ignite.portables.PortableConfiguration"> <property name="typeConfigurations"> <list> - <bean class="org.apache.ignite.portables.GridPortableTypeConfiguration"> + <bean class="org.apache.ignite.portables.PortableTypeConfiguration"> <property name="className" value="org.gridgain.client.GridClientTestPortable"/> </bean> </list> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/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 index 88d0e4d..7f7dbd4 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java +++ b/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java @@ -28,7 +28,7 @@ import java.util.Date; * <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.GridPortableObject} format). + * (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> @@ -74,7 +74,7 @@ import java.util.Date; * GridCacheProjection<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.GridPortableObject} format. Following + * 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> @@ -174,7 +174,7 @@ import java.util.Date; * * gridCfg.setPortableConfiguration(portCfg); * </pre> - * You can also specify class name for a portable object via {@link org.apache.ignite.portables.GridPortableTypeConfiguration}. + * 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> @@ -223,8 +223,8 @@ import java.util.Date; * } * </pre> * Alternatively, if you cannot change class definitions, you can provide custom serialization - * logic in {@link org.apache.ignite.portables.GridPortableSerializer} either globally in {@link org.apache.ignite.portables.PortableConfiguration} or - * for a specific type via {@link org.apache.ignite.portables.GridPortableTypeConfiguration} instance. + * 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> @@ -244,7 +244,7 @@ import java.util.Date; * 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.GridPortableTypeConfiguration} instance. + * 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 GridCacheQueryTypeMetadata} inside of specific {@link GridCacheConfiguration} instance, @@ -287,7 +287,7 @@ public interface IgnitePortables { public int typeId(String typeName); /** - * Converts provided object to instance of {@link org.apache.ignite.portables.GridPortableObject}. + * 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}. * @@ -319,7 +319,7 @@ public interface IgnitePortables { * @param portableObj Portable object to initialize builder. * @return Portable builder. */ - public PortableBuilder builder(GridPortableObject portableObj); + public PortableBuilder builder(PortableObject portableObj); /** * Gets metadata for provided class. @@ -328,7 +328,7 @@ public interface IgnitePortables { * @return Metadata. * @throws org.apache.ignite.portables.PortableException In case of error. */ - @Nullable public GridPortableMetadata metadata(Class<?> cls) throws PortableException; + @Nullable public PortableMetadata metadata(Class<?> cls) throws PortableException; /** * Gets metadata for provided class name. @@ -337,7 +337,7 @@ public interface IgnitePortables { * @return Metadata. * @throws org.apache.ignite.portables.PortableException In case of error. */ - @Nullable public GridPortableMetadata metadata(String typeName) throws PortableException; + @Nullable public PortableMetadata metadata(String typeName) throws PortableException; /** * Gets metadata for provided type ID. @@ -346,7 +346,7 @@ public interface IgnitePortables { * @return Metadata. * @throws org.apache.ignite.portables.PortableException In case of error. */ - @Nullable public GridPortableMetadata metadata(int typeId) throws PortableException; + @Nullable public PortableMetadata metadata(int typeId) throws PortableException; /** * Gets metadata for all known types. @@ -354,5 +354,5 @@ public interface IgnitePortables { * @return Metadata. * @throws org.apache.ignite.portables.PortableException In case of error. */ - public Collection<GridPortableMetadata> metadata() throws PortableException; + public Collection<PortableMetadata> metadata() throws PortableException; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/GridPortableMetadata.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableMetadata.java b/modules/core/src/main/java/org/apache/ignite/portables/GridPortableMetadata.java deleted file mode 100644 index 5ec0dea..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableMetadata.java +++ /dev/null @@ -1,53 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -import java.util.*; - -/** - * Portable type meta data. Metadata for portable types can be accessed from any of the - * {@link org.apache.ignite.IgnitePortables#metadata(String) 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. - */ -public interface GridPortableMetadata { - /** - * Gets portable type name. - * - * @return Portable type name. - */ - public String typeName(); - - /** - * Gets collection of all field names for this portable type. - * - * @return Collection of all field names for this portable type. - */ - public Collection<String> fields(); - - /** - * Gets name of the field type for a given field. - * - * @param fieldName Field name. - * @return Field type name. - */ - @Nullable public String fieldTypeName(String fieldName); - - /** - * Portable objects can optionally specify custom key-affinity mapping in the - * configuration. This method returns the name of the field which should be - * used for the key-affinity mapping. - * - * @return Affinity key field name. - */ - @Nullable public String affinityKeyFieldName(); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/GridPortableObject.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableObject.java b/modules/core/src/main/java/org/apache/ignite/portables/GridPortableObject.java deleted file mode 100644 index eb1f593..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableObject.java +++ /dev/null @@ -1,166 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -import java.io.*; -import java.util.*; - -/** - * Wrapper for portable object in portable binary format. Once an object is defined as portable, - * GridGain 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> - * <b>NOTE:</b> user does not need to (and should not) implement this interface directly. - * <p> - * To work with the portable format directly, user should create a cache projection - * over {@code GridPortableObject} class and then retrieve individual fields as needed: - * <pre name=code class=java> - * GridCacheProjection<GridPortableObject.class, GridPortableObject.class> prj = - * cache.projection(GridPortableObject.class, GridPortableObject.class); - * - * // 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, we could also choose a hybrid approach, where, for example, - * the keys are concrete deserialized objects and the values are returned in portable - * format, like so: - * <pre name=code class=java> - * GridCacheProjection<MyKey.class, GridPortableObject.class> prj = - * cache.projection(MyKey.class, GridPortableObject.class); - * - * GridPortableObject val = prj.get(new MyKey()); - * - * String field = val.field("myFieldName"); - * </pre> - * We could also have the values as concrete deserialized objects and the keys in portable format, - * but such use case is a lot less common because cache keys are usually a lot smaller than values, and - * it may be very cheap to deserialize the keys, but not the values. - * <p> - * And finally, 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, - * GridGain 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> - * GridCacheProjection<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> - * <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, GridGain 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">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">Building Portable Objects</h1> - * GridGain comes with {@link PortableBuilder} which allows to build portable objects dynamically: - * <pre name=code class=java> - * GridPortableBuilder builder = GridGain.grid().portables().builder("org.project.MyObject"); - * - * builder.setField("fieldA", "A"); - * builder.setField("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 = GridGain.grid().portables().toPortable(obj); - * </pre> - * <h1 class="header">Portable Metadata</h1> - * Even though GridGain portable protocol only works with hash codes for type and field names - * to achieve better performance, GridGain provides metadata for all portable types which - * can be queried ar runtime via any of the {@link org.apache.ignite.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. - */ -public interface GridPortableObject extends Serializable, Cloneable { - /** - * Gets portable object type ID. - * - * @return Type ID. - */ - public int typeId(); - - /** - * Gets meta data for this portable object. - * - * @return Meta data. - * @throws PortableException In case of error. - */ - @Nullable public GridPortableMetadata metaData() throws PortableException; - - /** - * Gets field value. - * - * @param fieldName Field name. - * @return Field value. - * @throws PortableException In case of any other error. - */ - @Nullable public <F> F field(String fieldName) throws PortableException; - - /** - * Gets fully deserialized instance of portable object. - * - * @return Fully deserialized instance of portable object. - * @throws PortableInvalidClassException If class doesn't exist. - * @throws PortableException In case of any other error. - */ - @Nullable public <T> T deserialize() throws PortableException; - - /** - * Creates a copy of this portable object and optionally changes field values - * if they are provided in map. If map is empty or {@code null}, clean copy - * is created. - * - * @param fields Fields to modify in copy. - * @return Copy of this portable object. - * @throws PortableException In case of error. - * @deprecated Use {@link PortableBuilder} instead. - * @see PortableBuilder - */ - @Deprecated - public GridPortableObject copy(@Nullable Map<String, Object> fields) throws PortableException; - - /** - * Copies this portable object. - * - * @return Copy of this portable object. - */ - public GridPortableObject clone() throws CloneNotSupportedException; -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/GridPortableRawReader.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableRawReader.java b/modules/core/src/main/java/org/apache/ignite/portables/GridPortableRawReader.java deleted file mode 100644 index 49f86bd..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableRawReader.java +++ /dev/null @@ -1,214 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -import java.sql.*; -import java.util.*; -import java.util.Date; - -/** - * Raw reader for portable objects. Raw reader does not use field name hash codes, therefore, - * making the format even more compact. However, if the raw reader is used, - * dynamic structure changes to the portable objects are not supported. - */ -public interface GridPortableRawReader { - /** - * @return Byte value. - * @throws PortableException In case of error. - */ - public byte readByte() throws PortableException; - - /** - * @return Short value. - * @throws PortableException In case of error. - */ - public short readShort() throws PortableException; - - /** - * @return Integer value. - * @throws PortableException In case of error. - */ - public int readInt() throws PortableException; - - /** - * @return Long value. - * @throws PortableException In case of error. - */ - public long readLong() throws PortableException; - - /** - * @return Float value. - * @throws PortableException In case of error. - */ - public float readFloat() throws PortableException; - - /** - * @return Double value. - * @throws PortableException In case of error. - */ - public double readDouble() throws PortableException; - - /** - * @return Char value. - * @throws PortableException In case of error. - */ - public char readChar() throws PortableException; - - /** - * @return Boolean value. - * @throws PortableException In case of error. - */ - public boolean readBoolean() throws PortableException; - - /** - * @return String value. - * @throws PortableException In case of error. - */ - @Nullable public String readString() throws PortableException; - - /** - * @return UUID. - * @throws PortableException In case of error. - */ - @Nullable public UUID readUuid() throws PortableException; - - /** - * @return Date. - * @throws PortableException In case of error. - */ - @Nullable public Date readDate() throws PortableException; - - /** - * @return Timestamp. - * @throws PortableException In case of error. - */ - @Nullable public Timestamp readTimestamp() throws PortableException; - - /** - * @return Object. - * @throws PortableException In case of error. - */ - @Nullable public Object readObject() throws PortableException; - - /** - * @return Byte array. - * @throws PortableException In case of error. - */ - @Nullable public byte[] readByteArray() throws PortableException; - - /** - * @return Short array. - * @throws PortableException In case of error. - */ - @Nullable public short[] readShortArray() throws PortableException; - - /** - * @return Integer array. - * @throws PortableException In case of error. - */ - @Nullable public int[] readIntArray() throws PortableException; - - /** - * @return Long array. - * @throws PortableException In case of error. - */ - @Nullable public long[] readLongArray() throws PortableException; - - /** - * @return Float array. - * @throws PortableException In case of error. - */ - @Nullable public float[] readFloatArray() throws PortableException; - - /** - * @return Byte array. - * @throws PortableException In case of error. - */ - @Nullable public double[] readDoubleArray() throws PortableException; - - /** - * @return Char array. - * @throws PortableException In case of error. - */ - @Nullable public char[] readCharArray() throws PortableException; - - /** - * @return Boolean array. - * @throws PortableException In case of error. - */ - @Nullable public boolean[] readBooleanArray() throws PortableException; - - /** - * @return String array. - * @throws PortableException In case of error. - */ - @Nullable public String[] readStringArray() throws PortableException; - - /** - * @return UUID array. - * @throws PortableException In case of error. - */ - @Nullable public UUID[] readUuidArray() throws PortableException; - - /** - * @return Date array. - * @throws PortableException In case of error. - */ - @Nullable public Date[] readDateArray() throws PortableException; - - /** - * @return Object array. - * @throws PortableException In case of error. - */ - @Nullable public Object[] readObjectArray() throws PortableException; - - /** - * @return Collection. - * @throws PortableException In case of error. - */ - @Nullable public <T> Collection<T> readCollection() throws PortableException; - - /** - * @param colCls Collection class. - * @return Collection. - * @throws PortableException In case of error. - */ - @Nullable public <T> Collection<T> readCollection(Class<? extends Collection<T>> colCls) - throws PortableException; - - /** - * @return Map. - * @throws PortableException In case of error. - */ - @Nullable public <K, V> Map<K, V> readMap() throws PortableException; - - /** - * @param mapCls Map class. - * @return Map. - * @throws PortableException In case of error. - */ - @Nullable public <K, V> Map<K, V> readMap(Class<? extends Map<K, V>> mapCls) throws PortableException; - - /** - * @param enumCls Enum class. - * @return Value. - * @throws PortableException In case of error. - */ - @Nullable public <T extends Enum<?>> T readEnum(Class<T> enumCls) throws PortableException; - - /** - * @param enumCls Enum class. - * @return Value. - * @throws PortableException In case of error. - */ - @Nullable public <T extends Enum<?>> T[] readEnumArray(Class<T> enumCls) throws PortableException; -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/GridPortableRawWriter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableRawWriter.java b/modules/core/src/main/java/org/apache/ignite/portables/GridPortableRawWriter.java deleted file mode 100644 index 6cb0931..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableRawWriter.java +++ /dev/null @@ -1,197 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -import java.sql.*; -import java.util.*; -import java.util.Date; - -/** - * Raw writer for portable object. Raw writer does not write field name hash codes, therefore, - * making the format even more compact. However, if the raw writer is used, - * dynamic structure changes to the portable objects are not supported. - */ -public interface GridPortableRawWriter { - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeByte(byte val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeShort(short val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeInt(int val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeLong(long val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeFloat(float val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDouble(double val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeChar(char val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeBoolean(boolean val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeString(@Nullable String val) throws PortableException; - - /** - * @param val UUID to write. - * @throws PortableException In case of error. - */ - public void writeUuid(@Nullable UUID val) throws PortableException; - - /** - * @param val Date to write. - * @throws PortableException In case of error. - */ - public void writeDate(@Nullable Date val) throws PortableException; - - /** - * @param val Timestamp to write. - * @throws PortableException In case of error. - */ - public void writeTimestamp(@Nullable Timestamp val) throws PortableException; - - /** - * @param obj Value to write. - * @throws PortableException In case of error. - */ - public void writeObject(@Nullable Object obj) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeByteArray(@Nullable byte[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeShortArray(@Nullable short[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeIntArray(@Nullable int[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeLongArray(@Nullable long[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeFloatArray(@Nullable float[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDoubleArray(@Nullable double[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeCharArray(@Nullable char[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeBooleanArray(@Nullable boolean[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeStringArray(@Nullable String[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeUuidArray(@Nullable UUID[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDateArray(@Nullable Date[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeObjectArray(@Nullable Object[] val) throws PortableException; - - /** - * @param col Collection to write. - * @throws PortableException In case of error. - */ - public <T> void writeCollection(@Nullable Collection<T> col) throws PortableException; - - /** - * @param map Map to write. - * @throws PortableException In case of error. - */ - public <K, V> void writeMap(@Nullable Map<K, V> map) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public <T extends Enum<?>> void writeEnum(T val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public <T extends Enum<?>> void writeEnumArray(T[] val) throws PortableException; -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/GridPortableReader.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableReader.java b/modules/core/src/main/java/org/apache/ignite/portables/GridPortableReader.java deleted file mode 100644 index e244ee7..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableReader.java +++ /dev/null @@ -1,263 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -import java.sql.*; -import java.util.*; -import java.util.Date; - -/** - * Reader for portable objects used in {@link PortableMarshalAware} implementations. - * Useful for the cases when user wants a fine-grained control over serialization. - * <p> - * Note that GridGain never writes full strings for field or type names. Instead, - * for performance reasons, GridGain writes integer hash codes for type and field names. - * It has been tested that hash code conflicts for the type names or the field names - * within the same type are virtually non-existent and, to gain performance, it is safe - * to work with hash codes. For the cases when hash codes for different types or fields - * actually do collide, GridGain provides {@link PortableIdMapper} which - * allows to override the automatically generated hash code IDs for the type and field names. - */ -public interface GridPortableReader { - /** - * @param fieldName Field name. - * @return Byte value. - * @throws PortableException In case of error. - */ - public byte readByte(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Short value. - * @throws PortableException In case of error. - */ - public short readShort(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Integer value. - * @throws PortableException In case of error. - */ - public int readInt(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Long value. - * @throws PortableException In case of error. - */ - public long readLong(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @throws PortableException In case of error. - * @return Float value. - */ - public float readFloat(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Double value. - * @throws PortableException In case of error. - */ - public double readDouble(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Char value. - * @throws PortableException In case of error. - */ - public char readChar(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Boolean value. - * @throws PortableException In case of error. - */ - public boolean readBoolean(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return String value. - * @throws PortableException In case of error. - */ - @Nullable public String readString(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return UUID. - * @throws PortableException In case of error. - */ - @Nullable public UUID readUuid(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Date. - * @throws PortableException In case of error. - */ - @Nullable public Date readDate(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Timestamp. - * @throws PortableException In case of error. - */ - @Nullable public Timestamp readTimestamp(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Object. - * @throws PortableException In case of error. - */ - @Nullable public <T> T readObject(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Byte array. - * @throws PortableException In case of error. - */ - @Nullable public byte[] readByteArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Short array. - * @throws PortableException In case of error. - */ - @Nullable public short[] readShortArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Integer array. - * @throws PortableException In case of error. - */ - @Nullable public int[] readIntArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Long array. - * @throws PortableException In case of error. - */ - @Nullable public long[] readLongArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Float array. - * @throws PortableException In case of error. - */ - @Nullable public float[] readFloatArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Byte array. - * @throws PortableException In case of error. - */ - @Nullable public double[] readDoubleArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Char array. - * @throws PortableException In case of error. - */ - @Nullable public char[] readCharArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Boolean array. - * @throws PortableException In case of error. - */ - @Nullable public boolean[] readBooleanArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return String array. - * @throws PortableException In case of error. - */ - @Nullable public String[] readStringArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return UUID array. - * @throws PortableException In case of error. - */ - @Nullable public UUID[] readUuidArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Date array. - * @throws PortableException In case of error. - */ - @Nullable public Date[] readDateArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Object array. - * @throws PortableException In case of error. - */ - @Nullable public Object[] readObjectArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Collection. - * @throws PortableException In case of error. - */ - @Nullable public <T> Collection<T> readCollection(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @param colCls Collection class. - * @return Collection. - * @throws PortableException In case of error. - */ - @Nullable public <T> Collection<T> readCollection(String fieldName, Class<? extends Collection<T>> colCls) - throws PortableException; - - /** - * @param fieldName Field name. - * @return Map. - * @throws PortableException In case of error. - */ - @Nullable public <K, V> Map<K, V> readMap(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @param mapCls Map class. - * @return Map. - * @throws PortableException In case of error. - */ - @Nullable public <K, V> Map<K, V> readMap(String fieldName, Class<? extends Map<K, V>> mapCls) - throws PortableException; - - /** - * @param fieldName Field name. - * @param enumCls Enum class. - * @return Value. - * @throws PortableException In case of error. - */ - @Nullable public <T extends Enum<?>> T readEnum(String fieldName, Class<T> enumCls) throws PortableException; - - /** - * @param fieldName Field name. - * @param enumCls Enum class. - * @return Value. - * @throws PortableException In case of error. - */ - @Nullable public <T extends Enum<?>> T[] readEnumArray(String fieldName, Class<T> enumCls) - throws PortableException; - - /** - * Gets raw reader. Raw reader does not use field name hash codes, therefore, - * making the format even more compact. However, if the raw reader is used, - * dynamic structure changes to the portable objects are not supported. - * - * @return Raw reader. - */ - public GridPortableRawReader rawReader(); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/GridPortableSerializer.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableSerializer.java b/modules/core/src/main/java/org/apache/ignite/portables/GridPortableSerializer.java deleted file mode 100644 index 30932f4..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableSerializer.java +++ /dev/null @@ -1,39 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.apache.ignite.portables; - -/** - * Interface that allows to implement custom serialization logic for portable objects. - * Can be used instead of {@link PortableMarshalAware} in case if the class - * cannot be changed directly. - * <p> - * Portable serializer can be configured for all portable objects via - * {@link PortableConfiguration#getSerializer()} method, or for a specific - * portable type via {@link GridPortableTypeConfiguration#getSerializer()} method. - */ -public interface GridPortableSerializer { - /** - * Writes fields to provided writer. - * - * @param obj Empty object. - * @param writer Portable object writer. - * @throws PortableException In case of error. - */ - public void writePortable(Object obj, GridPortableWriter writer) throws PortableException; - - /** - * Reads fields from provided reader. - * - * @param obj Empty object - * @param reader Portable object reader. - * @throws PortableException In case of error. - */ - public void readPortable(Object obj, GridPortableReader reader) throws PortableException; -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/GridPortableTypeConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/portables/GridPortableTypeConfiguration.java deleted file mode 100644 index 8278544..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableTypeConfiguration.java +++ /dev/null @@ -1,187 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.apache.ignite.portables; - -import org.gridgain.grid.util.typedef.internal.*; - -import java.sql.*; - -/** - * Defines configuration properties for a specific portable type. Providing per-type - * configuration is optional, as it is generally enough to provide global - * portable configuration in {@link PortableConfiguration} instance. However, - * this class allows you to change configuration properties for a specific - * portable type without affecting configuration for other portable types. - * <p> - * Per-type portable configuration can be specified in - * {@link PortableConfiguration#getTypeConfigurations()} method. - */ -public class GridPortableTypeConfiguration { - /** Class name. */ - private String clsName; - - /** ID mapper. */ - private PortableIdMapper idMapper; - - /** Serializer. */ - private GridPortableSerializer serializer; - - /** Use timestamp flag. */ - private Boolean useTs; - - /** Meta data enabled flag. */ - private Boolean metaDataEnabled; - - /** Keep deserialized flag. */ - private Boolean keepDeserialized; - - /** Affinity key field name. */ - private String affKeyFieldName; - - /** - */ - public GridPortableTypeConfiguration() { - // No-op. - } - - /** - * @param clsName Class name. - */ - public GridPortableTypeConfiguration(String clsName) { - this.clsName = clsName; - } - - /** - * Gets type name. - * - * @return Type name. - */ - public String getClassName() { - return clsName; - } - - /** - * Sets type name. - * - * @param clsName Type name. - */ - public void setClassName(String clsName) { - this.clsName = clsName; - } - - /** - * Gets ID mapper. - * - * @return ID mapper. - */ - public PortableIdMapper getIdMapper() { - return idMapper; - } - - /** - * Sets ID mapper. - * - * @param idMapper ID mapper. - */ - public void setIdMapper(PortableIdMapper idMapper) { - this.idMapper = idMapper; - } - - /** - * Gets serializer. - * - * @return Serializer. - */ - public GridPortableSerializer getSerializer() { - return serializer; - } - - /** - * Sets serializer. - * - * @param serializer Serializer. - */ - public void setSerializer(GridPortableSerializer serializer) { - this.serializer = serializer; - } - - /** - * If {@code true} then date values converted to {@link Timestamp} during unmarshalling. - * - * @return Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. - */ - public Boolean isUseTimestamp() { - return useTs; - } - - /** - * @param useTs Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. - */ - public void setUseTimestamp(Boolean useTs) { - this.useTs = useTs; - } - - /** - * Defines whether meta data is collected for this type. If provided, this value will override - * {@link PortableConfiguration#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 GridPortableObject} should cache deserialized instance. If provided, - * this value will override {@link PortableConfiguration#isKeepDeserialized()} property. - * - * @return Whether deserialized value is kept. - */ - public Boolean isKeepDeserialized() { - return keepDeserialized; - } - - /** - * @param keepDeserialized Whether deserialized value is kept. - */ - public void setKeepDeserialized(Boolean keepDeserialized) { - this.keepDeserialized = keepDeserialized; - } - - /** - * Gets affinity key field name. - * - * @return Affinity key field name. - */ - public String getAffinityKeyFieldName() { - return affKeyFieldName; - } - - /** - * Sets affinity key field name. - * - * @param affKeyFieldName Affinity key field name. - */ - public void setAffinityKeyFieldName(String affKeyFieldName) { - this.affKeyFieldName = affKeyFieldName; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridPortableTypeConfiguration.class, this, super.toString()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/GridPortableWriter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableWriter.java b/modules/core/src/main/java/org/apache/ignite/portables/GridPortableWriter.java deleted file mode 100644 index 769faa0..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/GridPortableWriter.java +++ /dev/null @@ -1,242 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -import java.sql.*; -import java.util.*; -import java.util.Date; - -/** - * Writer for portable object used in {@link PortableMarshalAware} implementations. - * Useful for the cases when user wants a fine-grained control over serialization. - * <p> - * Note that GridGain never writes full strings for field or type names. Instead, - * for performance reasons, GridGain writes integer hash codes for type and field names. - * It has been tested that hash code conflicts for the type names or the field names - * within the same type are virtually non-existent and, to gain performance, it is safe - * to work with hash codes. For the cases when hash codes for different types or fields - * actually do collide, GridGain provides {@link PortableIdMapper} which - * allows to override the automatically generated hash code IDs for the type and field names. - */ -public interface GridPortableWriter { - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeByte(String fieldName, byte val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeShort(String fieldName, short val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeInt(String fieldName, int val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeLong(String fieldName, long val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeFloat(String fieldName, float val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDouble(String fieldName, double val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeChar(String fieldName, char val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeBoolean(String fieldName, boolean val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeString(String fieldName, @Nullable String val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val UUID to write. - * @throws PortableException In case of error. - */ - public void writeUuid(String fieldName, @Nullable UUID val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Date to write. - * @throws PortableException In case of error. - */ - public void writeDate(String fieldName, @Nullable Date val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Timestamp to write. - * @throws PortableException In case of error. - */ - public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws PortableException; - - /** - * @param fieldName Field name. - * @param obj Value to write. - * @throws PortableException In case of error. - */ - public void writeObject(String fieldName, @Nullable Object obj) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeByteArray(String fieldName, @Nullable byte[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeShortArray(String fieldName, @Nullable short[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeIntArray(String fieldName, @Nullable int[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeLongArray(String fieldName, @Nullable long[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeFloatArray(String fieldName, @Nullable float[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDoubleArray(String fieldName, @Nullable double[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeCharArray(String fieldName, @Nullable char[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeStringArray(String fieldName, @Nullable String[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDateArray(String fieldName, @Nullable Date[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeObjectArray(String fieldName, @Nullable Object[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param col Collection to write. - * @throws PortableException In case of error. - */ - public <T> void writeCollection(String fieldName, @Nullable Collection<T> col) throws PortableException; - - /** - * @param fieldName Field name. - * @param map Map to write. - * @throws PortableException In case of error. - */ - public <K, V> void writeMap(String fieldName, @Nullable Map<K, V> map) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public <T extends Enum<?>> void writeEnum(String fieldName, T val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public <T extends Enum<?>> void writeEnumArray(String fieldName, T[] val) throws PortableException; - - /** - * Gets raw writer. Raw writer does not write field name hash codes, therefore, - * making the format even more compact. However, if the raw writer is used, - * dynamic structure changes to the portable objects are not supported. - * - * @return Raw writer. - */ - public GridPortableRawWriter rawWriter(); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/PortableBuilder.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableBuilder.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableBuilder.java index e353d7b..969cff7 100644 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableBuilder.java +++ b/modules/core/src/main/java/org/apache/ignite/portables/PortableBuilder.java @@ -55,7 +55,7 @@ import org.jetbrains.annotations.*; * * @see org.apache.ignite.IgnitePortables#builder(int) * @see org.apache.ignite.IgnitePortables#builder(String) - * @see org.apache.ignite.IgnitePortables#builder(GridPortableObject) + * @see org.apache.ignite.IgnitePortables#builder(PortableObject) */ public interface PortableBuilder { /** @@ -75,7 +75,7 @@ public interface PortableBuilder { * * @param name Field name. * @param val Field value (cannot be {@code null}). - * @see GridPortableObject#metaData() + * @see PortableObject#metaData() */ public PortableBuilder setField(String name, Object val); @@ -87,7 +87,7 @@ public interface PortableBuilder { * @param name Field name. * @param val Field value. * @param type Field type. - * @see GridPortableObject#metaData() + * @see PortableObject#metaData() */ public <T> PortableBuilder setField(String name, @Nullable T val, Class<? super T> type); @@ -125,5 +125,5 @@ public interface PortableBuilder { * @return Portable object. * @throws PortableException In case of error. */ - public GridPortableObject build() throws PortableException; + public PortableObject build() throws PortableException; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/PortableConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableConfiguration.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableConfiguration.java index 573836e..986d49c 100644 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/portables/PortableConfiguration.java @@ -17,7 +17,7 @@ import java.util.*; /** * Defines configuration for GridGain portable functionality. All configuration * properties defined here can be overridden on per-type level in - * {@link GridPortableTypeConfiguration}. Type configurations are provided via + * {@link PortableTypeConfiguration}. Type configurations are provided via * {@link #getTypeConfigurations()} method. */ public class PortableConfiguration { @@ -28,10 +28,10 @@ public class PortableConfiguration { private PortableIdMapper idMapper; /** Serializer. */ - private GridPortableSerializer serializer; + private PortableSerializer serializer; /** Types. */ - private Collection<GridPortableTypeConfiguration> typeCfgs; + private Collection<PortableTypeConfiguration> typeCfgs; /** Use timestamp flag. */ private boolean useTs = true; @@ -83,7 +83,7 @@ public class PortableConfiguration { * * @return Serializer. */ - public GridPortableSerializer getSerializer() { + public PortableSerializer getSerializer() { return serializer; } @@ -92,7 +92,7 @@ public class PortableConfiguration { * * @param serializer Serializer. */ - public void setSerializer(GridPortableSerializer serializer) { + public void setSerializer(PortableSerializer serializer) { this.serializer = serializer; } @@ -101,7 +101,7 @@ public class PortableConfiguration { * * @return Types configuration. */ - public Collection<GridPortableTypeConfiguration> getTypeConfigurations() { + public Collection<PortableTypeConfiguration> getTypeConfigurations() { return typeCfgs; } @@ -110,7 +110,7 @@ public class PortableConfiguration { * * @param typeCfgs Type configurations. */ - public void setTypeConfigurations(Collection<GridPortableTypeConfiguration> typeCfgs) { + public void setTypeConfigurations(Collection<PortableTypeConfiguration> typeCfgs) { this.typeCfgs = typeCfgs; } @@ -134,7 +134,7 @@ public class PortableConfiguration { /** * If {@code true}, meta data will be collected or all types. If you need to override this behaviour for - * some specific type, use {@link GridPortableTypeConfiguration#setMetaDataEnabled(Boolean)} method. + * some specific type, use {@link PortableTypeConfiguration#setMetaDataEnabled(Boolean)} method. * <p> * Default value if {@code true}. * @@ -152,11 +152,11 @@ public class PortableConfiguration { } /** - * If {@code true}, {@link GridPortableObject} will cache deserialized instance after - * {@link GridPortableObject#deserialize()} is called. All consequent calls of this - * method on the same instance of {@link GridPortableObject} will return that cached + * If {@code true}, {@link PortableObject} will cache deserialized instance after + * {@link PortableObject#deserialize()} is called. All consequent calls of this + * method on the same instance of {@link PortableObject} will return that cached * value without actually deserializing portable object. If you need to override this - * behaviour for some specific type, use {@link GridPortableTypeConfiguration#setKeepDeserialized(Boolean)} + * behaviour for some specific type, use {@link PortableTypeConfiguration#setKeepDeserialized(Boolean)} * method. * <p> * Default value if {@code true}. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/PortableIdMapper.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableIdMapper.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableIdMapper.java index dafaca9..b2e69e5 100644 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableIdMapper.java +++ b/modules/core/src/main/java/org/apache/ignite/portables/PortableIdMapper.java @@ -21,7 +21,7 @@ package org.apache.ignite.portables; * <p> * Portable ID mapper can be configured for all portable objects via * {@link PortableConfiguration#getIdMapper()} method, or for a specific - * portable type via {@link GridPortableTypeConfiguration#getIdMapper()} method. + * portable type via {@link PortableTypeConfiguration#getIdMapper()} method. */ public interface PortableIdMapper { /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/PortableInvalidClassException.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableInvalidClassException.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableInvalidClassException.java index 5322fa9..fc3f040 100644 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableInvalidClassException.java +++ b/modules/core/src/main/java/org/apache/ignite/portables/PortableInvalidClassException.java @@ -14,7 +14,7 @@ import org.jetbrains.annotations.*; /** * Exception indicating that class needed for deserialization of portable object does not exist. * <p> - * Thrown from {@link GridPortableObject#deserialize()} method. + * Thrown from {@link PortableObject#deserialize()} method. */ public class PortableInvalidClassException extends PortableException { /** */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/PortableMarshalAware.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableMarshalAware.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableMarshalAware.java index d0b5bcb..78dd0e5 100644 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableMarshalAware.java +++ b/modules/core/src/main/java/org/apache/ignite/portables/PortableMarshalAware.java @@ -28,7 +28,7 @@ public interface PortableMarshalAware { * @param writer Portable object writer. * @throws PortableException In case of error. */ - public void writePortable(GridPortableWriter writer) throws PortableException; + public void writePortable(PortableWriter writer) throws PortableException; /** * Reads fields from provided reader. @@ -36,5 +36,5 @@ public interface PortableMarshalAware { * @param reader Portable object reader. * @throws PortableException In case of error. */ - public void readPortable(GridPortableReader reader) throws PortableException; + public void readPortable(PortableReader reader) throws PortableException; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/PortableMetadata.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableMetadata.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableMetadata.java new file mode 100644 index 0000000..15f4abd --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/portables/PortableMetadata.java @@ -0,0 +1,53 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.apache.ignite.portables; + +import org.jetbrains.annotations.*; + +import java.util.*; + +/** + * Portable type meta data. Metadata for portable types can be accessed from any of the + * {@link org.apache.ignite.IgnitePortables#metadata(String) 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. + */ +public interface PortableMetadata { + /** + * Gets portable type name. + * + * @return Portable type name. + */ + public String typeName(); + + /** + * Gets collection of all field names for this portable type. + * + * @return Collection of all field names for this portable type. + */ + public Collection<String> fields(); + + /** + * Gets name of the field type for a given field. + * + * @param fieldName Field name. + * @return Field type name. + */ + @Nullable public String fieldTypeName(String fieldName); + + /** + * Portable objects can optionally specify custom key-affinity mapping in the + * configuration. This method returns the name of the field which should be + * used for the key-affinity mapping. + * + * @return Affinity key field name. + */ + @Nullable public String affinityKeyFieldName(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1515c5aa/modules/core/src/main/java/org/apache/ignite/portables/PortableObject.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableObject.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableObject.java new file mode 100644 index 0000000..59b9141 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/portables/PortableObject.java @@ -0,0 +1,166 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.apache.ignite.portables; + +import org.jetbrains.annotations.*; + +import java.io.*; +import java.util.*; + +/** + * Wrapper for portable object in portable binary format. Once an object is defined as portable, + * GridGain 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> + * <b>NOTE:</b> user does not need to (and should not) implement this interface directly. + * <p> + * To work with the portable format directly, user should create a cache projection + * over {@code GridPortableObject} class and then retrieve individual fields as needed: + * <pre name=code class=java> + * GridCacheProjection<GridPortableObject.class, GridPortableObject.class> prj = + * cache.projection(GridPortableObject.class, GridPortableObject.class); + * + * // 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, we could also choose a hybrid approach, where, for example, + * the keys are concrete deserialized objects and the values are returned in portable + * format, like so: + * <pre name=code class=java> + * GridCacheProjection<MyKey.class, GridPortableObject.class> prj = + * cache.projection(MyKey.class, GridPortableObject.class); + * + * GridPortableObject val = prj.get(new MyKey()); + * + * String field = val.field("myFieldName"); + * </pre> + * We could also have the values as concrete deserialized objects and the keys in portable format, + * but such use case is a lot less common because cache keys are usually a lot smaller than values, and + * it may be very cheap to deserialize the keys, but not the values. + * <p> + * And finally, 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, + * GridGain 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> + * GridCacheProjection<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> + * <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, GridGain 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">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">Building Portable Objects</h1> + * GridGain comes with {@link PortableBuilder} which allows to build portable objects dynamically: + * <pre name=code class=java> + * GridPortableBuilder builder = GridGain.grid().portables().builder("org.project.MyObject"); + * + * builder.setField("fieldA", "A"); + * builder.setField("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 = GridGain.grid().portables().toPortable(obj); + * </pre> + * <h1 class="header">Portable Metadata</h1> + * Even though GridGain portable protocol only works with hash codes for type and field names + * to achieve better performance, GridGain provides metadata for all portable types which + * can be queried ar runtime via any of the {@link org.apache.ignite.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. + */ +public interface PortableObject extends Serializable, Cloneable { + /** + * Gets portable object type ID. + * + * @return Type ID. + */ + public int typeId(); + + /** + * Gets meta data for this portable object. + * + * @return Meta data. + * @throws PortableException In case of error. + */ + @Nullable public PortableMetadata metaData() throws PortableException; + + /** + * Gets field value. + * + * @param fieldName Field name. + * @return Field value. + * @throws PortableException In case of any other error. + */ + @Nullable public <F> F field(String fieldName) throws PortableException; + + /** + * Gets fully deserialized instance of portable object. + * + * @return Fully deserialized instance of portable object. + * @throws PortableInvalidClassException If class doesn't exist. + * @throws PortableException In case of any other error. + */ + @Nullable public <T> T deserialize() throws PortableException; + + /** + * Creates a copy of this portable object and optionally changes field values + * if they are provided in map. If map is empty or {@code null}, clean copy + * is created. + * + * @param fields Fields to modify in copy. + * @return Copy of this portable object. + * @throws PortableException In case of error. + * @deprecated Use {@link PortableBuilder} instead. + * @see PortableBuilder + */ + @Deprecated + public PortableObject copy(@Nullable Map<String, Object> fields) throws PortableException; + + /** + * Copies this portable object. + * + * @return Copy of this portable object. + */ + public PortableObject clone() throws CloneNotSupportedException; +}