org.apache.ignite.internal.processors.cache

## Class GridCacheMessage

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheMessage

All Implemented Interfaces:
  Serializable, Message

Direct Known Subclasses:
  CacheContinuousQueryBatchAck, GridCacheEvictionRequest, GridCacheEvictionResponse, GridCacheQueryRequest, GridCacheQueryResponse, GridCacheTtlUpdateRequest, GridDhtAffinityAssignmentRequest, GridDhtAffinityAssignmentResponse, GridDhtAtomicDeferredUpdateResponse, GridDhtAtomicUpdateRequest, GridDhtAtomicUpdateResponse, GridDhtForceKeysRequest, GridDhtForceKeysResponse, GridDhtPartitionDemandMessage, GridDhtPartitionsFullMessage, GridDhtPartitionsSingleMessage, GridDhtPartitionsSingleRequest, GridDhtPartitionSupplyMessage, GridDhtPartitionSupplyMessageV2, GridDistributedBaseMessage, GridDistributedTxFinishResponse, GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse, GridNearGetRequest, GridNearGetResponse, GridNearSingleGetRequest, GridNearSingleGetResponse

    public abstract class GridCacheMessage
    extends Object
    implements Message

Parent of all cache messages.

See Also:
  Serialized Form

### Field Summary

Fields
`protected boolean` `addDepInfo`
`static String` `CACHE_MSG_INDEX_FIELD_NAME` Cache message index field name.
`protected int` `cacheId` Cache ID.
`protected boolean` `forceAddDepInfo` Force addition of deployment info regardless of `addDepInfo` flag value.
`static int` `MAX_CACHE_MSG_LOOKUP_INDEX` Maximum number of cache lookup indexes.

### Constructor Summary

Constructors
Constructor and Description
`GridCacheMessage()`

### Method Summary

Methods
`abstract boolean` `addDeploymentInfo()` Deployment enabled flag indicates whether deployment info has to be added to this message.
`int` `cacheId()`
`void` `cacheId(int cacheId)`
`IgniteCheckedException` `classError()`
`GridDeploymentInfo` `deployInfo()`
`Throwable` `error()`
`void` `finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr)` This method is called after the message is deserialized and is responsible for unmarshalling state marshalled in `prepareMarshal(GridCacheSharedContext)` method.
`protected void` `finishUnmarshalCacheObjects(Collection<? extends CacheObject> col, GridCacheContext ctx, ClassLoader ldr)`
`protected void` `finishUnmarshalCacheObjects(List<? extends CacheObject> col, GridCacheContext ctx, ClassLoader ldr)`
`boolean` `ignoreClassErrors()`
`int` `lookupIndex()` Gets message lookup index.
`protected List<byte[]>` `marshalCollection(Collection<?> col, GridCacheContext ctx)`
`protected void` `marshalInfo(GridCacheEntryInfo info, GridCacheContext ctx)`
`protected void` `marshalInfos(Iterable<? extends GridCacheEntryInfo> infos, GridCacheContext ctx)`
`protected byte[][]` `marshalInvokeArguments(Object[] args, GridCacheContext ctx)`
`protected void` `marshalTx(Iterable<IgniteTxEntry> txEntries, GridCacheSharedContext ctx)`
`long` `messageId()`
`static int` `nextIndexId()` Gets next ID for indexed message ID.
`void` `onClassError(IgniteCheckedException err)` If class loading error occurred during unmarshalling and `ignoreClassErrors()` is set to `true`, then the error will be passed into this method.
`boolean` `partitionExchangeMessage()`
`void` `prepare(GridDeploymentInfo depInfo)`
`void` `prepareMarshal(GridCacheSharedContext ctx)` This method is called before the whole message is serialized and is responsible for pre-marshalling state.
`protected void` `prepareMarshalCacheObject(CacheObject obj, GridCacheContext ctx)`
`protected void` `prepareMarshalCacheObjects(Collection<? extends CacheObject> col, GridCacheContext ctx)`
`protected void` `prepareMarshalCacheObjects(List<? extends CacheObject> col, GridCacheContext ctx)`
`protected void` `prepareObject(Object o, GridCacheContext ctx)`
`boolean` `readFrom(ByteBuffer buf, MessageReader reader)` Reads this message from provided byte buffer.
`AffinityTopologyVersion` `topologyVersion()` Gets topology version or -1 in case of topology version is not required for this message.
`String` `toString()`
`protected boolean` `transferExpiryPolicy()`
`protected <T> List<T>` `unmarshalCollection(Collection<byte[]> byteCol, GridCacheSharedContext ctx, ClassLoader ldr)`
`protected void` `unmarshalInfo(GridCacheEntryInfo info, GridCacheContext ctx, ClassLoader ldr)`
`protected void` `unmarshalInfos(Iterable<? extends GridCacheEntryInfo> infos, GridCacheContext ctx, ClassLoader ldr)`
`protected Object[]` `unmarshalInvokeArguments(byte[][] byteCol, GridCacheSharedContext ctx, ClassLoader ldr)`
`protected void` `unmarshalTx(Iterable<IgniteTxEntry> txEntries, boolean near, GridCacheSharedContext ctx, ClassLoader ldr)`
`boolean` `writeTo(ByteBuffer buf, MessageWriter writer)` Writes this message to provided byte buffer.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.apache.ignite.plugin.extensions.communication.Message

`directType, fieldsCount`

### Field Detail

#### MAX_CACHE_MSG_LOOKUP_INDEX

    public static final int MAX_CACHE_MSG_LOOKUP_INDEX

Maximum number of cache lookup indexes.

See Also:
  Constant Field Values

#### CACHE_MSG_INDEX_FIELD_NAME

    public static final String CACHE_MSG_INDEX_FIELD_NAME

Cache message index field name.

See Also:
  Constant Field Values

#### addDepInfo

    protected boolean addDepInfo

#### forceAddDepInfo

    protected boolean forceAddDepInfo

Force addition of deployment info regardless of `addDepInfo` flag value.

#### cacheId

    @GridToStringInclude
    protected int cacheId

Cache ID.

### Constructor Detail

#### GridCacheMessage

    public GridCacheMessage()

### Method Detail

#### error

    @Nullable
    public Throwable error()

Returns:
  Error, if any.

#### nextIndexId

    public static int nextIndexId()

Gets next ID for indexed message ID.

Returns:
  Message ID.

#### partitionExchangeMessage

    public boolean partitionExchangeMessage()

Returns:
  `True` if this message is partition exchange message.

#### ignoreClassErrors

    public boolean ignoreClassErrors()

Returns:
  `True` if class loading errors should be ignored, false otherwise.

#### lookupIndex

    public int lookupIndex()

Gets message lookup index. All messages that does not return -1 in this method must return a unique number in range from 0 to `MAX_CACHE_MSG_LOOKUP_INDEX`.

Returns:
  Message lookup index.

#### onClassError

    public void onClassError(IgniteCheckedException err)

If class loading error occurred during unmarshalling and `ignoreClassErrors()` is set to `true`, then the error will be passed into this method.

Parameters:
  `err` - Error.

#### classError

    public IgniteCheckedException classError()

Returns:
  Error set via `onClassError(IgniteCheckedException)` method.

#### messageId

    public long messageId()

Returns:
  Message ID.

#### cacheId

    public int cacheId()

Returns:
  Cache ID.

#### cacheId

    public void cacheId(int cacheId)

Parameters:
  `cacheId` - Cache ID.

#### topologyVersion

    public AffinityTopologyVersion topologyVersion()

Gets topology version or -1 in case of topology version is not required for this message.

Returns:
  Topology version.

#### addDeploymentInfo

    public abstract boolean addDeploymentInfo()

Deployment enabled flag indicates whether deployment info has to be added to this message.

Returns:
  `true` or if deployment info must be added to the the message, `false` otherwise.

#### prepareObject

    protected final void prepareObject(@Nullable
                     Object o,
                     GridCacheContext ctx)
                                throws IgniteCheckedException

Parameters:
  `o` - Object to prepare for marshalling.
  `ctx` - Context.
Throws:
  `IgniteCheckedException` - If failed.

#### prepare

    public final void prepare(GridDeploymentInfo depInfo)

Parameters:
  `depInfo` - Deployment to set.
See Also:
  `GridCacheDeployable.prepare(GridDeploymentInfo)`

#### deployInfo

    public GridDeploymentInfo deployInfo()

Returns:
  Preset deployment info.
See Also:
  `GridCacheDeployable.deployInfo()`

#### prepareMarshal

    public void prepareMarshal(GridCacheSharedContext ctx)
                        throws IgniteCheckedException

This method is called before the whole message is serialized and is responsible for pre-marshalling state.

Parameters:
  `ctx` - Cache context.
Throws:
  `IgniteCheckedException` - If failed.

#### finishUnmarshal

    public void finishUnmarshal(GridCacheSharedContext ctx,
                       ClassLoader ldr)
                         throws IgniteCheckedException

This method is called after the message is deserialized and is responsible for unmarshalling state marshalled in `prepareMarshal(GridCacheSharedContext)` method.

Parameters:
  `ctx` - Context.
  `ldr` - Class loader.
Throws:
  `IgniteCheckedException` - If failed.

#### marshalInfo

    protected final void marshalInfo(GridCacheEntryInfo info,
                   GridCacheContext ctx)
                              throws IgniteCheckedException

Parameters:
  `info` - Entry to marshal.
  `ctx` - Context.
Throws:
  `IgniteCheckedException` - If failed.

#### unmarshalInfo

    protected final void unmarshalInfo(GridCacheEntryInfo info,
                     GridCacheContext ctx,
                     ClassLoader ldr)
                                throws IgniteCheckedException

Parameters:
  `info` - Entry to unmarshal.
  `ctx` - Context.
  `ldr` - Loader.
Throws:
  `IgniteCheckedException` - If failed.

#### marshalInfos

    protected final void marshalInfos(Iterable<? extends GridCacheEntryInfo> infos,
                    GridCacheContext ctx)
                               throws IgniteCheckedException

Parameters:
  `infos` - Entries to marshal.
  `ctx` - Context.
Throws:
  `IgniteCheckedException` - If failed.

#### unmarshalInfos

    protected final void unmarshalInfos(Iterable<? extends GridCacheEntryInfo> infos,
                      GridCacheContext ctx,
                      ClassLoader ldr)
                                 throws IgniteCheckedException

Parameters:
  `infos` - Entries to unmarshal.
  `ctx` - Context.
  `ldr` - Loader.
Throws:
  `IgniteCheckedException` - If failed.

#### marshalTx

    protected final void marshalTx(Iterable<IgniteTxEntry> txEntries,
                 GridCacheSharedContext ctx)
                            throws IgniteCheckedException

Parameters:
  `txEntries` - Entries to marshal.
  `ctx` - Context.
Throws:
  `IgniteCheckedException` - If failed.

#### transferExpiryPolicy

    protected boolean transferExpiryPolicy()

Returns:
  `True` if entries expire policy should be marshalled.

#### unmarshalTx

    protected final void unmarshalTx(Iterable<IgniteTxEntry> txEntries,
                   boolean near,
                   GridCacheSharedContext ctx,
                   ClassLoader ldr)
                              throws IgniteCheckedException

Parameters:
  `txEntries` - Entries to unmarshal.
  `ctx` - Context.
  `ldr` - Loader.
Throws:
  `IgniteCheckedException` - If failed.

#### marshalInvokeArguments

    @Nullable
    protected final byte[][] marshalInvokeArguments(@Nullable
                                           Object[] args,
                                           GridCacheContext ctx)
                                             throws IgniteCheckedException

Parameters:
  `args` - Arguments to marshal.
  `ctx` - Context.
Returns:
  Marshalled collection.
Throws:
  `IgniteCheckedException` - If failed.

#### unmarshalInvokeArguments

    @Nullable
    protected final Object[] unmarshalInvokeArguments(@Nullable
                                             byte[][] byteCol,
                                             GridCacheSharedContext ctx,
                                             ClassLoader ldr)
                                               throws IgniteCheckedException

Parameters:
  `byteCol` - Collection to unmarshal.
  `ctx` - Context.
  `ldr` - Loader.
Returns:
  Unmarshalled collection.
Throws:
  `IgniteCheckedException` - If failed.

#### marshalCollection

    @Nullable
    protected List<byte[]> marshalCollection(@Nullable
                                          Collection<?> col,
                                          GridCacheContext ctx)
                                      throws IgniteCheckedException

Parameters:
  `col` - Collection to marshal.
  `ctx` - Context.
Returns:
  Marshalled collection.
Throws:
  `IgniteCheckedException` - If failed.

#### prepareMarshalCacheObjects

    protected final void prepareMarshalCacheObjects(@Nullable
                                  List<? extends CacheObject> col,
                                  GridCacheContext ctx)
                                             throws IgniteCheckedException

Parameters:
  `col` - Collection.
  `ctx` - Cache context.
Throws:
  `IgniteCheckedException` - If failed.

#### prepareMarshalCacheObject

    protected final void prepareMarshalCacheObject(CacheObject obj,
                                 GridCacheContext ctx)
                                            throws IgniteCheckedException

Parameters:
  `obj` - Object.
  `ctx` - Context.
Throws:
  `IgniteCheckedException` - If failed.

#### prepareMarshalCacheObjects

    protected final void prepareMarshalCacheObjects(@Nullable
                                  Collection<? extends CacheObject> col,
                                  GridCacheContext ctx)
                                             throws IgniteCheckedException

Parameters:
  `col` - Collection.
  `ctx` - Cache context.
Throws:
  `IgniteCheckedException` - If failed.

#### finishUnmarshalCacheObjects

    protected final void finishUnmarshalCacheObjects(@Nullable
                                   List<? extends CacheObject> col,
                                   GridCacheContext ctx,
                                   ClassLoader ldr)
                                              throws IgniteCheckedException

Parameters:
  `col` - Collection.
  `ctx` - Context.
  `ldr` - Class loader.
Throws:
  `IgniteCheckedException` - If failed.

#### finishUnmarshalCacheObjects

    protected final void finishUnmarshalCacheObjects(@Nullable
                                   Collection<? extends CacheObject> col,
                                   GridCacheContext ctx,
                                   ClassLoader ldr)
                                              throws IgniteCheckedException

Parameters:
  `col` - Collection.
  `ctx` - Context.
  `ldr` - Class loader.
Throws:
  `IgniteCheckedException` - If failed.

#### unmarshalCollection

    @Nullable
    protected <T> List<T> unmarshalCollection(@Nullable
                                           Collection<byte[]> byteCol,
                                           GridCacheSharedContext ctx,
                                           ClassLoader ldr)
                                   throws IgniteCheckedException

Parameters:
  `byteCol` - Collection to unmarshal.
  `ctx` - Context.
  `ldr` - Loader.
Returns:
  Unmarshalled collection.
Throws:
  `IgniteCheckedException` - If failed.

#### writeTo

    public boolean writeTo(ByteBuffer buf,
                  MessageWriter writer)

Writes this message to provided byte buffer.

Specified by:
  `writeTo` in interface `Message`
Parameters:
  `buf` - Byte buffer.
  `writer` - Writer.
Returns:
  Whether message was fully written.

#### readFrom

    public boolean readFrom(ByteBuffer buf,
                   MessageReader reader)

Reads this message from provided byte buffer.

Specified by:
  `readFrom` in interface `Message`
Parameters:
  `buf` - Byte buffer.
  `reader` - Reader.
Returns:
  Whether message was fully read.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.5.0-b1
Release Date | : December 1 2015