Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 470801831B for ; Wed, 21 Oct 2015 14:49:55 +0000 (UTC) Received: (qmail 97398 invoked by uid 500); 21 Oct 2015 14:49:55 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 97354 invoked by uid 500); 21 Oct 2015 14:49:55 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 97307 invoked by uid 99); 21 Oct 2015 14:49:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Oct 2015 14:49:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1079EE0451; Wed, 21 Oct 2015 14:49:55 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Wed, 21 Oct 2015 14:50:02 -0000 Message-Id: <4a266b081e3f46b3a5891472b7b7a04c@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [10/20] ignite git commit: Revert "ignite-1462: hid portable API in 1.4 release" This reverts commit 71379a8061f50f336adc31fa20cd593b659b050f. http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/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 new file mode 100644 index 0000000..ee0a4ec --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java @@ -0,0 +1,370 @@ +/* + * 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 java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.TreeMap; +import java.util.UUID; +import org.apache.ignite.marshaller.portable.PortableMarshaller; +import org.apache.ignite.portable.PortableBuilder; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableIdMapper; +import org.apache.ignite.portable.PortableMarshalAware; +import org.apache.ignite.portable.PortableMetadata; +import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.portable.PortableSerializer; +import org.apache.ignite.portable.PortableTypeConfiguration; +import org.jetbrains.annotations.Nullable; + +/** + * Defines portable objects functionality. With portable objects you are able to: + *
    + *
  • Seamlessly interoperate between Java, .NET, and C++.
  • + *
  • Make any object portable with zero code change to your existing code.
  • + *
  • Nest portable objects within each other.
  • + *
  • Automatically handle {@code circular} or {@code null} references.
  • + *
  • Automatically convert collections and maps between Java, .NET, and C++.
  • + *
  • + * Optionally avoid deserialization of objects on the server side + * (objects are stored in {@link PortableObject} format). + *
  • + *
  • Avoid need to have concrete class definitions on the server side.
  • + *
  • Dynamically change structure of the classes without having to restart the cluster.
  • + *
  • Index into portable objects for querying purposes.
  • + *
+ *

Working With Portables Directly

+ * 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). + *

+ * To work with the portable format directly, user should create a special cache projection + * using {@link IgniteCache#withKeepPortable()} method and then retrieve individual fields as needed: + *

+ * IgniteCache<PortableObject, PortableObject> prj = cache.withKeepPortable();
+ *
+ * // Convert instance of MyKey to portable format.
+ * // We could also use PortableBuilder to create the key in portable format directly.
+ * PortableObject key = grid.portables().toPortable(new MyKey());
+ *
+ * PortableObject val = prj.get(key);
+ *
+ * String field = val.field("myFieldName");
+ * 
+ * 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, if + * {@link PortableMarshaller#isKeepDeserialized()} is {@code true} then Ignite will only deserialize on the first access + * and will cache the deserialized object, so it does not have to be deserialized again: + *
+ * IgniteCache<MyKey.class, MyValue.class> cache = grid.cache(null);
+ *
+ * MyValue val = cache.get(new MyKey());
+ *
+ * // Normal java getter.
+ * String fieldVal = val.getMyFieldName();
+ * 
+ * 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: + *
+ * IgniteCache<Integer.class, PortableObject> prj = cache.withKeepPortable();
+ * 
+ *

Automatic Portable Types

+ * Note that only portable classes are converted to {@link 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): + *
    + *
  • All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)
  • + *
  • Arrays of primitives (byte[], int[], ...)
  • + *
  • {@link String} and array of {@link String}s
  • + *
  • {@link UUID} and array of {@link UUID}s
  • + *
  • {@link Date} and array of {@link Date}s
  • + *
  • {@link Timestamp} and array of {@link Timestamp}s
  • + *
  • Enums and array of enums
  • + *
  • + * Maps, collections and array of objects (but objects inside + * them will still be converted if they are portable) + *
  • + *
+ *

Working With Maps and Collections

+ * 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. + *

Building Portable Objects

+ * Ignite comes with {@link PortableBuilder} which allows to build portable objects dynamically: + *
+ * PortableBuilder builder = Ignition.ignite().portables().builder();
+ *
+ * builder.typeId("MyObject");
+ *
+ * builder.stringField("fieldA", "A");
+ * build.intField("fieldB", "B");
+ *
+ * PortableObject portableObj = builder.build();
+ * 
+ * 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: + *
+ * MyObject obj = new MyObject();
+ *
+ * obj.setFieldA("A");
+ * obj.setFieldB(123);
+ *
+ * PortableObject portableObj = Ignition.ignite().portables().toPortable(obj);
+ * 
+ * NOTE: you don't need to convert typed objects to portable format before storing + * them in cache, Ignite will do that automatically. + *

Portable Metadata

+ * 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)} + * methods. Having metadata also allows for proper formatting of {@code PortableObject#toString()} method, + * even when portable objects are kept in binary format only, which may be necessary for audit reasons. + *

Dynamic Structure Changes

+ * 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. + *

Configuration

+ * By default all your objects are considered as portables and no specific configuration is needed. + * However, in some cases, like when an object is used by both Java and .Net, you may need to specify portable objects + * explicitly by calling {@link PortableMarshaller#setClassNames(Collection)}. + * 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. + *

+ * Here is an example of portable configuration (note that star (*) notation is supported): + *

+ * ...
+ * <!-- Explicit portable objects configuration. -->
+ * <property name="marshaller">
+ *     <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
+ *         <property name="classNames">
+ *             <list>
+ *                 <value>my.package.for.portable.objects.*</value>
+ *                 <value>org.apache.ignite.examples.client.portable.Employee</value>
+ *             </list>
+ *         </property>
+ *     </bean>
+ * </property>
+ * ...
+ * 
+ * or from code: + *
+ * IgniteConfiguration cfg = new IgniteConfiguration();
+ *
+ * PortableMarshaller marsh = new PortableMarshaller();
+ *
+ * marsh.setClassNames(Arrays.asList(
+ *     Employee.class.getName(),
+ *     Address.class.getName())
+ * );
+ *
+ * cfg.setMarshaller(marsh);
+ * 
+ * You can also specify class name for a portable object via {@link PortableTypeConfiguration}. + * Do it in case if you need to override other configuration properties on per-type level, like + * ID-mapper, or serializer. + *

Custom Affinity Keys

+ * 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: + *
+ * <property name="marshaller">
+ *     <bean class="org.gridgain.grid.marshaller.portable.PortableMarshaller">
+ *         ...
+ *         <property name="typeConfigurations">
+ *             <list>
+ *                 <bean class="org.apache.ignite.portable.PortableTypeConfiguration">
+ *                     <property name="className" value="org.apache.ignite.examples.client.portable.EmployeeKey"/>
+ *                     <property name="affinityKeyFieldName" value="organizationId"/>
+ *                 </bean>
+ *             </list>
+ *         </property>
+ *         ...
+ *     </bean>
+ * </property>
+ * 
+ *

Serialization

+ * Serialization and deserialization works out-of-the-box in Ignite. However, you can provide your own custom + * serialization logic by optionally implementing {@link PortableMarshalAware} interface, like so: + *
+ * public class Address implements PortableMarshalAware {
+ *     private String street;
+ *     private int zip;
+ *
+ *     // Empty constructor required for portable deserialization.
+ *     public Address() {}
+ *
+ *     @Override public void writePortable(PortableWriter writer) throws PortableException {
+ *         writer.writeString("street", street);
+ *         writer.writeInt("zip", zip);
+ *     }
+ *
+ *     @Override public void readPortable(PortableReader reader) throws PortableException {
+ *         street = reader.readString("street");
+ *         zip = reader.readInt("zip");
+ *     }
+ * }
+ * 
+ * Alternatively, if you cannot change class definitions, you can provide custom serialization + * logic in {@link PortableSerializer} either globally in {@link PortableMarshaller} or + * for a specific type via {@link PortableTypeConfiguration} instance. + *

+ * Similar to java serialization you can use {@code writeReplace()} and {@code readResolve()} methods. + *

    + *
  • + * {@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. + *
  • + *
  • + * {@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. + *
  • + *
+ * + *

Custom ID Mappers

+ * 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 PortableIdMapper} implementation. + *

+ * ID-mapper may be provided either globally in {@link PortableMarshaller}, + * or for a specific type via {@link PortableTypeConfiguration} instance. + *

Query Indexing

+ * 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: + *
+ * ...
+ * <bean class="org.apache.ignite.cache.CacheConfiguration">
+ *     ...
+ *     <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>
+ * 
+ */ +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 PortableObject}. + * + * @param obj Object to convert. + * @return Converted object. + * @throws PortableException In case of error. + */ + public 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 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 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 PortableException In case of error. + */ + @Nullable public PortableMetadata metadata(int typeId) throws PortableException; + + /** + * Gets metadata for all known types. + * + * @return Metadata. + * @throws PortableException In case of error. + */ + public Collection metadata() throws PortableException; +} http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/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 7d1e14d..9fb56bc 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 @@ -17,24 +17,10 @@ package org.apache.ignite.configuration; -import java.io.Serializable; -import java.util.Collection; -import javax.cache.Cache; -import javax.cache.configuration.CompleteConfiguration; -import javax.cache.configuration.Factory; -import javax.cache.configuration.MutableConfiguration; -import javax.cache.expiry.ExpiryPolicy; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheAtomicWriteOrderMode; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheEntryProcessor; -import org.apache.ignite.cache.CacheInterceptor; -import org.apache.ignite.cache.CacheMemoryMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CacheRebalanceMode; -import org.apache.ignite.cache.CacheTypeMetadata; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.IgniteException; +import org.apache.ignite.cache.*; import org.apache.ignite.cache.affinity.AffinityFunction; import org.apache.ignite.cache.affinity.AffinityKeyMapper; import org.apache.ignite.cache.eviction.EvictionFilter; @@ -50,6 +36,15 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.plugin.CachePluginConfiguration; import org.jetbrains.annotations.Nullable; +import javax.cache.Cache; +import javax.cache.CacheException; +import javax.cache.configuration.CompleteConfiguration; +import javax.cache.configuration.Factory; +import javax.cache.configuration.MutableConfiguration; +import javax.cache.expiry.ExpiryPolicy; +import java.io.Serializable; +import java.util.Collection; + /** * This class defines grid cache configuration. This configuration is passed to * grid via {@link IgniteConfiguration#getCacheConfiguration()} method. It defines all configuration @@ -168,6 +163,10 @@ public class CacheConfiguration extends MutableConfiguration { /** Default size for onheap SQL row cache size. */ public static final int DFLT_SQL_ONHEAP_ROW_CACHE_SIZE = 10 * 1024; + /** Default value for keep portable in store behavior .*/ + @SuppressWarnings({"UnnecessaryBoxing", "BooleanConstructorCall"}) + public static final Boolean DFLT_KEEP_PORTABLE_IN_STORE = new Boolean(true); + /** Cache name. */ private String name; @@ -220,6 +219,9 @@ public class CacheConfiguration extends MutableConfiguration { private Factory storeFactory; /** */ + private Boolean keepPortableInStore = DFLT_KEEP_PORTABLE_IN_STORE; + + /** */ private boolean loadPrevVal = DFLT_LOAD_PREV_VAL; /** Node group resolver. */ @@ -381,6 +383,8 @@ public class CacheConfiguration extends MutableConfiguration { invalidate = cc.isInvalidate(); isReadThrough = cc.isReadThrough(); isWriteThrough = cc.isWriteThrough(); + keepPortableInStore = cc.isKeepPortableInStore() != null ? cc.isKeepPortableInStore() : + DFLT_KEEP_PORTABLE_IN_STORE; listenerConfigurations = cc.listenerConfigurations; loadPrevVal = cc.isLoadPreviousValue(); longQryWarnTimeout = cc.getLongQueryWarningTimeout(); @@ -821,6 +825,38 @@ public class CacheConfiguration extends MutableConfiguration { } /** + * Flag indicating that {@link CacheStore} implementation + * is working with portable objects instead of Java objects. + * Default value of this flag is {@link #DFLT_KEEP_PORTABLE_IN_STORE}, + * because this is recommended behavior from performance standpoint. + *

+ * If set to {@code false}, Ignite will deserialize keys and + * values stored in portable format before they are passed + * to cache store. + *

+ * 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. + * + * @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 key topology resolver to provide mapping from keys to nodes. * * @return Key topology resolver to provide mapping from keys to nodes. @@ -1824,4 +1860,4 @@ public class CacheConfiguration extends MutableConfiguration { return obj.getClass().equals(this.getClass()); } } -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java index 9443f21..e3859c5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java @@ -20,7 +20,6 @@ package org.apache.ignite.internal; import java.util.Collection; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteFileSystem; -import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.cluster.IgniteClusterEx; import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey; @@ -141,12 +140,4 @@ public interface IgniteEx extends Ignite { * @return Kernal context. */ public GridKernalContext context(); - - - /** - * Gets an instance of {@link IgnitePortables} interface. - * - * @return Instance of {@link IgnitePortables} interface. - */ - public IgnitePortables portables(); } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/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 daf7d23..9baf2f1 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 @@ -64,7 +64,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteFileSystem; import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteMessaging; -import org.apache.ignite.internal.portable.api.IgnitePortables; +import org.apache.ignite.IgnitePortables; import org.apache.ignite.IgniteQueue; import org.apache.ignite.IgniteScheduler; import org.apache.ignite.IgniteServices; @@ -157,7 +157,7 @@ import org.apache.ignite.lifecycle.LifecycleBean; import org.apache.ignite.lifecycle.LifecycleEventType; import org.apache.ignite.marshaller.MarshallerExclusions; import org.apache.ignite.marshaller.optimized.OptimizedMarshaller; -import org.apache.ignite.internal.portable.api.PortableMarshaller; +import org.apache.ignite.marshaller.portable.PortableMarshaller; import org.apache.ignite.mxbean.ClusterLocalNodeMetricsMXBean; import org.apache.ignite.mxbean.IgniteMXBean; import org.apache.ignite.mxbean.ThreadPoolMXBean; @@ -203,6 +203,7 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_NODE_CONSISTENT_ID; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PHY_RAM; +import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PORTABLE_PROTO_VER; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PREFIX; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_RESTART_ENABLED; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REST_PORT_RANGE; @@ -1269,6 +1270,9 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable { add(ATTR_MARSHALLER, cfg.getMarshaller().getClass().getName()); add(ATTR_USER_NAME, System.getProperty("user.name")); add(ATTR_GRID_NAME, gridName); + add(ATTR_PORTABLE_PROTO_VER, cfg.getMarshaller() instanceof PortableMarshaller ? + ((PortableMarshaller)cfg.getMarshaller()).getProtocolVersion().toString() : + PortableMarshaller.DFLT_PORTABLE_PROTO_VER.toString()); add(ATTR_PEER_CLASSLOADING, cfg.isPeerClassLoadingEnabled()); add(ATTR_DEPLOYMENT_MODE, cfg.getDeploymentMode()); http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java index 10b8df0..7be2af3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java @@ -135,10 +135,13 @@ public final class IgniteNodeAttributes { /** Node consistent id. */ public static final String ATTR_NODE_CONSISTENT_ID = ATTR_PREFIX + ".consistent.id"; + /** Portable protocol version. */ + public static final String ATTR_PORTABLE_PROTO_VER = ATTR_PREFIX + ".portable.proto.ver"; + /** * Enforces singleton. */ private IgniteNodeAttributes() { /* No-op. */ } -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java index 3a09b2c..bc4f756 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java @@ -125,6 +125,7 @@ import static org.apache.ignite.events.EventType.EVT_NODE_SEGMENTED; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_DEPLOYMENT_MODE; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING; +import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PORTABLE_PROTO_VER; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_USER_NAME; import static org.apache.ignite.internal.IgniteVersionUtils.VER; import static org.apache.ignite.plugin.segmentation.SegmentationPolicy.NOOP; @@ -981,6 +982,8 @@ public class GridDiscoveryManager extends GridManagerAdapter { // Fetch local node attributes once. String locPreferIpV4 = locNode.attribute("java.net.preferIPv4Stack"); + String locPortableProtoVer = locNode.attribute(ATTR_PORTABLE_PROTO_VER); + Object locMode = locNode.attribute(ATTR_DEPLOYMENT_MODE); int locJvmMajVer = nodeJavaMajorVersion(locNode); @@ -1030,6 +1033,13 @@ public class GridDiscoveryManager extends GridManagerAdapter { ", rmtId8=" + U.id8(n.id()) + ", rmtPeerClassLoading=" + rmtP2pEnabled + ", rmtAddrs=" + U.addressesAsString(n) + ']'); } + + String rmtPortableProtoVer = n.attribute(ATTR_PORTABLE_PROTO_VER); + + // In order to support backward compatibility skip the check for nodes that don't have this attribute. + if (rmtPortableProtoVer != null && !F.eq(locPortableProtoVer, rmtPortableProtoVer)) + throw new IgniteCheckedException("Remote node has portable protocol version different from local " + + "[locVersion=" + locPortableProtoVer + ", rmtVersion=" + rmtPortableProtoVer + ']'); } if (log.isDebugEnabled()) http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java index 4bc8545..c7a9e6f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java @@ -19,7 +19,7 @@ package org.apache.ignite.internal.portable; import org.apache.ignite.internal.portable.streams.PortableInputStream; import org.apache.ignite.internal.portable.streams.PortableOutputStream; -import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.portable.PortableException; import org.jetbrains.annotations.Nullable; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java index e1b7324..a2b4b74 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java @@ -40,11 +40,11 @@ import org.apache.ignite.internal.processors.cache.CacheObjectImpl; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.MarshallerExclusions; import org.apache.ignite.marshaller.optimized.OptimizedMarshaller; -import org.apache.ignite.internal.portable.api.PortableMarshaller; -import org.apache.ignite.internal.portable.api.PortableException; -import org.apache.ignite.internal.portable.api.PortableIdMapper; -import org.apache.ignite.internal.portable.api.PortableMarshalAware; -import org.apache.ignite.internal.portable.api.PortableSerializer; +import org.apache.ignite.marshaller.portable.PortableMarshaller; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableIdMapper; +import org.apache.ignite.portable.PortableMarshalAware; +import org.apache.ignite.portable.PortableSerializer; import org.jetbrains.annotations.Nullable; import static java.lang.reflect.Modifier.isStatic; http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java index 2ee96b7..165ad9a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java @@ -60,16 +60,16 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.marshaller.MarshallerContext; import org.apache.ignite.marshaller.optimized.OptimizedMarshaller; -import org.apache.ignite.internal.portable.api.PortableMarshaller; +import org.apache.ignite.marshaller.portable.PortableMarshaller; import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetConfiguration; import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableConfiguration; import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableTypeConfiguration; -import org.apache.ignite.internal.portable.api.PortableException; -import org.apache.ignite.internal.portable.api.PortableIdMapper; -import org.apache.ignite.internal.portable.api.PortableInvalidClassException; -import org.apache.ignite.internal.portable.api.PortableMetadata; -import org.apache.ignite.internal.portable.api.PortableSerializer; -import org.apache.ignite.internal.portable.api.PortableTypeConfiguration; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableIdMapper; +import org.apache.ignite.portable.PortableInvalidClassException; +import org.apache.ignite.portable.PortableMetadata; +import org.apache.ignite.portable.PortableSerializer; +import org.apache.ignite.portable.PortableTypeConfiguration; import org.jetbrains.annotations.Nullable; import org.jsr166.ConcurrentHashMap8; http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java index 05e7f20..ae5fbf0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java @@ -27,9 +27,9 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.UUID; -import org.apache.ignite.internal.portable.api.PortableException; -import org.apache.ignite.internal.portable.api.PortableRawWriter; -import org.apache.ignite.internal.portable.api.PortableWriter; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableRawWriter; +import org.apache.ignite.portable.PortableWriter; import org.jetbrains.annotations.Nullable; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java index fafafad..e03d67f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java @@ -17,8 +17,8 @@ package org.apache.ignite.internal.portable; -import org.apache.ignite.internal.portable.api.PortableException; -import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableMetadata; /** * Portable meta data handler. http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataImpl.java index c0423eb..1d26007 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataImpl.java @@ -27,13 +27,13 @@ import java.util.Map; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.portable.api.PortableException; -import org.apache.ignite.internal.portable.api.PortableMarshalAware; -import org.apache.ignite.internal.portable.api.PortableMetadata; -import org.apache.ignite.internal.portable.api.PortableRawReader; -import org.apache.ignite.internal.portable.api.PortableRawWriter; -import org.apache.ignite.internal.portable.api.PortableReader; -import org.apache.ignite.internal.portable.api.PortableWriter; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableMarshalAware; +import org.apache.ignite.portable.PortableMetadata; +import org.apache.ignite.portable.PortableRawReader; +import org.apache.ignite.portable.PortableRawWriter; +import org.apache.ignite.portable.PortableReader; +import org.apache.ignite.portable.PortableWriter; import org.jetbrains.annotations.Nullable; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java index 229c90f..fe4b628 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java @@ -23,9 +23,9 @@ import java.util.IdentityHashMap; import org.apache.ignite.IgniteException; import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory; import org.apache.ignite.internal.util.typedef.internal.SB; -import org.apache.ignite.internal.portable.api.PortableException; -import org.apache.ignite.internal.portable.api.PortableMetadata; -import org.apache.ignite.internal.portable.api.PortableObject; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableMetadata; +import org.apache.ignite.portable.PortableObject; import org.jetbrains.annotations.Nullable; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java index cb81efe..47ff1ab 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java @@ -34,9 +34,9 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageWriter; -import org.apache.ignite.internal.portable.api.PortableException; -import org.apache.ignite.internal.portable.api.PortableMetadata; -import org.apache.ignite.internal.portable.api.PortableObject; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableMetadata; +import org.apache.ignite.portable.PortableObject; import org.jetbrains.annotations.Nullable; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java index e788422..ba8ee83 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java @@ -30,9 +30,9 @@ import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageWriter; -import org.apache.ignite.internal.portable.api.PortableException; -import org.apache.ignite.internal.portable.api.PortableMetadata; -import org.apache.ignite.internal.portable.api.PortableObject; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableMetadata; +import org.apache.ignite.portable.PortableObject; import org.jetbrains.annotations.Nullable; import sun.misc.Unsafe; http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawReaderEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawReaderEx.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawReaderEx.java index e401142..e703f2f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawReaderEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawReaderEx.java @@ -17,8 +17,8 @@ package org.apache.ignite.internal.portable; -import org.apache.ignite.internal.portable.api.PortableException; -import org.apache.ignite.internal.portable.api.PortableRawReader; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableRawReader; import org.jetbrains.annotations.Nullable; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawWriterEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawWriterEx.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawWriterEx.java index 43b7650..a59f157 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawWriterEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawWriterEx.java @@ -18,8 +18,8 @@ package org.apache.ignite.internal.portable; import org.apache.ignite.internal.portable.streams.PortableOutputStream; -import org.apache.ignite.internal.portable.api.PortableException; -import org.apache.ignite.internal.portable.api.PortableRawWriter; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableRawWriter; import org.jetbrains.annotations.Nullable; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java index 2537926..2d4a1c3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java @@ -20,7 +20,7 @@ package org.apache.ignite.internal.portable; import java.util.HashMap; import java.util.Map; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.portable.api.PortableObject; +import org.apache.ignite.portable.PortableObject; import org.jetbrains.annotations.Nullable; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java index a101db5..4ad125a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java @@ -45,11 +45,11 @@ import org.apache.ignite.internal.util.GridEnumCache; import org.apache.ignite.internal.util.lang.GridMapEntry; import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.portable.api.PortableException; -import org.apache.ignite.internal.portable.api.PortableInvalidClassException; -import org.apache.ignite.internal.portable.api.PortableObject; -import org.apache.ignite.internal.portable.api.PortableRawReader; -import org.apache.ignite.internal.portable.api.PortableReader; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableInvalidClassException; +import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.portable.PortableRawReader; +import org.apache.ignite.portable.PortableReader; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java index ccc1a5b..7259cc9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java @@ -35,7 +35,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentSkipListSet; import org.apache.ignite.internal.portable.builder.PortableLazyValue; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.portable.api.PortableObject; +import org.apache.ignite.portable.PortableObject; import org.jetbrains.annotations.Nullable; import org.jsr166.ConcurrentHashMap8; http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java index 1d5ca60..3152c4b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java @@ -18,8 +18,12 @@ package org.apache.ignite.internal.portable; import java.io.IOException; +import java.io.ObjectInputStream; import java.io.ObjectOutput; +import java.io.ObjectOutputStream; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.math.BigDecimal; import java.math.BigInteger; import java.sql.Timestamp; @@ -28,13 +32,14 @@ import java.util.Date; import java.util.IdentityHashMap; import java.util.Map; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.portable.streams.PortableHeapOutputStream; import org.apache.ignite.internal.portable.streams.PortableOutputStream; import org.apache.ignite.internal.util.typedef.internal.A; -import org.apache.ignite.internal.portable.api.PortableException; -import org.apache.ignite.internal.portable.api.PortableRawWriter; -import org.apache.ignite.internal.portable.api.PortableWriter; +import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableRawWriter; +import org.apache.ignite.portable.PortableWriter; import org.jetbrains.annotations.Nullable; import static java.nio.charset.StandardCharsets.UTF_8; http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/api/IgnitePortables.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/IgnitePortables.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/IgnitePortables.java deleted file mode 100644 index 56f3768..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/IgnitePortables.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.portable.api; - -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.TreeMap; -import java.util.UUID; -import org.apache.ignite.IgniteCache; -import org.jetbrains.annotations.Nullable; - -/** - * Defines portable objects functionality. With portable objects you are able to: - *

    - *
  • Seamlessly interoperate between Java, .NET, and C++.
  • - *
  • Make any object portable with zero code change to your existing code.
  • - *
  • Nest portable objects within each other.
  • - *
  • Automatically handle {@code circular} or {@code null} references.
  • - *
  • Automatically convert collections and maps between Java, .NET, and C++.
  • - *
  • - * Optionally avoid deserialization of objects on the server side - * (objects are stored in {@link PortableObject} format). - *
  • - *
  • Avoid need to have concrete class definitions on the server side.
  • - *
  • Dynamically change structure of the classes without having to restart the cluster.
  • - *
  • Index into portable objects for querying purposes.
  • - *
- *

Working With Portables Directly

- * 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). - *

- * To work with the portable format directly, user should create a special cache projection - * using {@link IgniteCache#withKeepPortable()} method and then retrieve individual fields as needed: - *

- * IgniteCache<PortableObject, PortableObject> prj = cache.withKeepPortable();
- *
- * // Convert instance of MyKey to portable format.
- * // We could also use PortableBuilder to create the key in portable format directly.
- * PortableObject key = grid.portables().toPortable(new MyKey());
- *
- * PortableObject val = prj.get(key);
- *
- * String field = val.field("myFieldName");
- * 
- * 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, if - * {@link PortableMarshaller#isKeepDeserialized()} is {@code true} then Ignite will only deserialize on the first access - * and will cache the deserialized object, so it does not have to be deserialized again: - *
- * IgniteCache<MyKey.class, MyValue.class> cache = grid.cache(null);
- *
- * MyValue val = cache.get(new MyKey());
- *
- * // Normal java getter.
- * String fieldVal = val.getMyFieldName();
- * 
- * 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: - *
- * IgniteCache<Integer.class, PortableObject> prj = cache.withKeepPortable();
- * 
- *

Automatic Portable Types

- * Note that only portable classes are converted to {@link 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): - *
    - *
  • All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)
  • - *
  • Arrays of primitives (byte[], int[], ...)
  • - *
  • {@link String} and array of {@link String}s
  • - *
  • {@link UUID} and array of {@link UUID}s
  • - *
  • {@link Date} and array of {@link Date}s
  • - *
  • {@link Timestamp} and array of {@link Timestamp}s
  • - *
  • Enums and array of enums
  • - *
  • - * Maps, collections and array of objects (but objects inside - * them will still be converted if they are portable) - *
  • - *
- *

Working With Maps and Collections

- * 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. - *

Building Portable Objects

- * Ignite comes with {@link PortableBuilder} which allows to build portable objects dynamically: - *
- * PortableBuilder builder = Ignition.ignite().portables().builder();
- *
- * builder.typeId("MyObject");
- *
- * builder.stringField("fieldA", "A");
- * build.intField("fieldB", "B");
- *
- * PortableObject portableObj = builder.build();
- * 
- * 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: - *
- * MyObject obj = new MyObject();
- *
- * obj.setFieldA("A");
- * obj.setFieldB(123);
- *
- * PortableObject portableObj = Ignition.ignite().portables().toPortable(obj);
- * 
- * NOTE: you don't need to convert typed objects to portable format before storing - * them in cache, Ignite will do that automatically. - *

Portable Metadata

- * 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)} - * methods. Having metadata also allows for proper formatting of {@code PortableObject#toString()} method, - * even when portable objects are kept in binary format only, which may be necessary for audit reasons. - *

Dynamic Structure Changes

- * 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. - *

Configuration

- * By default all your objects are considered as portables and no specific configuration is needed. - * However, in some cases, like when an object is used by both Java and .Net, you may need to specify portable objects - * explicitly by calling {@link PortableMarshaller#setClassNames(Collection)}. - * 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. - *

- * Here is an example of portable configuration (note that star (*) notation is supported): - *

- * ...
- * <!-- Explicit portable objects configuration. -->
- * <property name="marshaller">
- *     <bean class="org.apache.ignite.internal.portable.api.PortableMarshaller">
- *         <property name="classNames">
- *             <list>
- *                 <value>my.package.for.portable.objects.*</value>
- *                 <value>org.apache.ignite.examples.client.portable.Employee</value>
- *             </list>
- *         </property>
- *     </bean>
- * </property>
- * ...
- * 
- * or from code: - *
- * IgniteConfiguration cfg = new IgniteConfiguration();
- *
- * PortableMarshaller marsh = new PortableMarshaller();
- *
- * marsh.setClassNames(Arrays.asList(
- *     Employee.class.getName(),
- *     Address.class.getName())
- * );
- *
- * cfg.setMarshaller(marsh);
- * 
- * You can also specify class name for a portable object via {@link PortableTypeConfiguration}. - * Do it in case if you need to override other configuration properties on per-type level, like - * ID-mapper, or serializer. - *

Custom Affinity Keys

- * 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: - *
- * <property name="marshaller">
- *     <bean class="org.gridgain.grid.marshaller.portable.PortableMarshaller">
- *         ...
- *         <property name="typeConfigurations">
- *             <list>
- *                 <bean class="org.apache.ignite.internal.portable.api.PortableTypeConfiguration">
- *                     <property name="className" value="org.apache.ignite.examples.client.portable.EmployeeKey"/>
- *                     <property name="affinityKeyFieldName" value="organizationId"/>
- *                 </bean>
- *             </list>
- *         </property>
- *         ...
- *     </bean>
- * </property>
- * 
- *

Serialization

- * Serialization and deserialization works out-of-the-box in Ignite. However, you can provide your own custom - * serialization logic by optionally implementing {@link PortableMarshalAware} interface, like so: - *
- * public class Address implements PortableMarshalAware {
- *     private String street;
- *     private int zip;
- *
- *     // Empty constructor required for portable deserialization.
- *     public Address() {}
- *
- *     @Override public void writePortable(PortableWriter writer) throws PortableException {
- *         writer.writeString("street", street);
- *         writer.writeInt("zip", zip);
- *     }
- *
- *     @Override public void readPortable(PortableReader reader) throws PortableException {
- *         street = reader.readString("street");
- *         zip = reader.readInt("zip");
- *     }
- * }
- * 
- * Alternatively, if you cannot change class definitions, you can provide custom serialization - * logic in {@link PortableSerializer} either globally in {@link PortableMarshaller} or - * for a specific type via {@link PortableTypeConfiguration} instance. - *

- * Similar to java serialization you can use {@code writeReplace()} and {@code readResolve()} methods. - *

    - *
  • - * {@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. - *
  • - *
  • - * {@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. - *
  • - *
- * - *

Custom ID Mappers

- * 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 PortableIdMapper} implementation. - *

- * ID-mapper may be provided either globally in {@link PortableMarshaller}, - * or for a specific type via {@link PortableTypeConfiguration} instance. - *

Query Indexing

- * 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: - *
- * ...
- * <bean class="org.apache.ignite.cache.CacheConfiguration">
- *     ...
- *     <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>
- * 
- */ -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 PortableObject}. - * - * @param obj Object to convert. - * @return Converted object. - * @throws PortableException In case of error. - */ - public 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 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 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 PortableException In case of error. - */ - @Nullable public PortableMetadata metadata(int typeId) throws PortableException; - - /** - * Gets metadata for all known types. - * - * @return Metadata. - * @throws PortableException In case of error. - */ - public Collection metadata() throws PortableException; -} http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableBuilder.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableBuilder.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableBuilder.java deleted file mode 100644 index c819f46..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableBuilder.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.portable.api; - -import org.jetbrains.annotations.Nullable; - -/** - * Portable object builder. Provides ability to build portable objects dynamically without having class definitions. - *

- * Here is an example of how a portable object can be built dynamically: - *

- * PortableBuilder builder = Ignition.ignite().portables().builder("org.project.MyObject");
- *
- * builder.setField("fieldA", "A");
- * builder.setField("fieldB", "B");
- *
- * PortableObject portableObj = builder.build();
- * 
- * - *

- * Also builder can be initialized by existing portable object. This allows changing some fields without affecting - * other fields. - *

- * PortableBuilder builder = Ignition.ignite().portables().builder(person);
- *
- * builder.setField("name", "John");
- *
- * person = builder.build();
- * 
- *

- * - * If you need to modify nested portable object you can get builder for nested object using - * {@link #getField(String)}, changes made on nested builder will affect parent object, - * for example: - * - *
- * PortableBuilder personBuilder = grid.portables().createBuilder(personPortableObj);
- * PortableBuilder addressBuilder = personBuilder.setField("address");
- *
- * addressBuilder.setField("city", "New York");
- *
- * personPortableObj = personBuilder.build();
- *
- * // Should be "New York".
- * String city = personPortableObj.getField("address").getField("city");
- * 
- * - * @see IgnitePortables#builder(int) - * @see IgnitePortables#builder(String) - * @see IgnitePortables#builder(PortableObject) - */ -public interface PortableBuilder { - /** - * Returns value assigned to the specified field. - * If the value is a portable object instance of {@code GridPortableBuilder} will be returned, - * which can be modified. - *

- * Collections and maps returned from this method are modifiable. - * - * @param name Field name. - * @return Filed value. - */ - public T getField(String name); - - /** - * Sets field value. - * - * @param name Field name. - * @param val Field value (cannot be {@code null}). - * @see PortableObject#metaData() - */ - public PortableBuilder setField(String name, Object val); - - /** - * Sets field value with value type specification. - *

- * Field type is needed for proper metadata update. - * - * @param name Field name. - * @param val Field value. - * @param type Field type. - * @see PortableObject#metaData() - */ - public PortableBuilder setField(String name, @Nullable T val, Class type); - - /** - * Sets field value. - *

- * This method should be used if field is portable object. - * - * @param name Field name. - * @param builder Builder for object field. - */ - public PortableBuilder setField(String name, @Nullable PortableBuilder builder); - - /** - * Removes field from this builder. - * - * @param fieldName Field name. - * @return {@code this} instance for chaining. - */ - public PortableBuilder removeField(String fieldName); - - /** - * Sets hash code for resulting portable object returned by {@link #build()} method. - *

- * If not set {@code 0} is used. - * - * @param hashCode Hash code. - * @return {@code this} instance for chaining. - */ - public PortableBuilder hashCode(int hashCode); - - /** - * Builds portable object. - * - * @return Portable object. - * @throws PortableException In case of error. - */ - public PortableObject build() throws PortableException; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableException.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableException.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableException.java deleted file mode 100644 index f230182..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.portable.api; - -import org.apache.ignite.IgniteException; -import org.jetbrains.annotations.Nullable; - -/** - * Exception indicating portable object serialization error. - */ -public class PortableException extends IgniteException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Creates portable exception with error message. - * - * @param msg Error message. - */ - public PortableException(String msg) { - super(msg); - } - - /** - * Creates portable exception with {@link Throwable} as a cause. - * - * @param cause Cause. - */ - public PortableException(Throwable cause) { - super(cause); - } - - /** - * Creates portable exception with error message and {@link Throwable} as a cause. - * - * @param msg Error message. - * @param cause Cause. - */ - public PortableException(String msg, @Nullable Throwable cause) { - super(msg, cause); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableIdMapper.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableIdMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableIdMapper.java deleted file mode 100644 index 1e20f8e..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableIdMapper.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.portable.api; - -/** - * Type and field ID mapper for portable objects. Ignite never writes full - * strings for field or type names. Instead, for performance reasons, Ignite - * 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 {@code PortableIdMapper} allows to override the automatically - * generated hash code IDs for the type and field names. - *

- * Portable ID mapper can be configured for all portable objects via {@link PortableMarshaller#getIdMapper()} method, - * or for a specific portable type via {@link PortableTypeConfiguration#getIdMapper()} method. - */ -public interface PortableIdMapper { - /** - * Gets type ID for provided class name. - *

- * If {@code 0} is returned, hash code of class simple name will be used. - * - * @param clsName Class name. - * @return Type ID. - */ - public int typeId(String clsName); - - /** - * Gets ID for provided field. - *

- * If {@code 0} is returned, hash code of field name will be used. - * - * @param typeId Type ID. - * @param fieldName Field name. - * @return Field ID. - */ - public int fieldId(int typeId, String fieldName); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableInvalidClassException.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableInvalidClassException.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableInvalidClassException.java deleted file mode 100644 index 82e6697..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableInvalidClassException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.portable.api; - -import org.jetbrains.annotations.Nullable; - -/** - * Exception indicating that class needed for deserialization of portable object does not exist. - *

- * Thrown from {@link PortableObject#deserialize()} method. - */ -public class PortableInvalidClassException extends PortableException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Creates invalid class exception with error message. - * - * @param msg Error message. - */ - public PortableInvalidClassException(String msg) { - super(msg); - } - - /** - * Creates invalid class exception with {@link Throwable} as a cause. - * - * @param cause Cause. - */ - public PortableInvalidClassException(Throwable cause) { - super(cause); - } - - /** - * Creates invalid class exception with error message and {@link Throwable} as a cause. - * - * @param msg Error message. - * @param cause Cause. - */ - public PortableInvalidClassException(String msg, @Nullable Throwable cause) { - super(msg, cause); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/e7eb2b37/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshalAware.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshalAware.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshalAware.java deleted file mode 100644 index f304afb..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshalAware.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.portable.api; - -/** - * Interface that allows to implement custom serialization - * logic for portable objects. Portable objects are not required - * to implement this interface, in which case Ignite will automatically - * serialize portable objects using reflection. - *

- * This interface, in a way, is analogous to {@link java.io.Externalizable} - * interface, which allows users to override default serialization logic, - * usually for performance reasons. The only difference here is that portable - * serialization is already very fast and implementing custom serialization - * logic for portables does not provide significant performance gains. - */ -public interface PortableMarshalAware { - /** - * Writes fields to provided writer. - * - * @param writer Portable object writer. - * @throws PortableException In case of error. - */ - public void writePortable(PortableWriter writer) throws PortableException; - - /** - * Reads fields from provided reader. - * - * @param reader Portable object reader. - * @throws PortableException In case of error. - */ - public void readPortable(PortableReader reader) throws PortableException; -} \ No newline at end of file