Class GridCacheMessage
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.GridCacheMessage
-
- All Implemented Interfaces:
Serializable,Message
- Direct Known Subclasses:
GridCacheGroupIdMessage,GridCacheIdMessage,GridChangeGlobalStateMessageResponse,GridDhtPartitionsAbstractMessage,GridDhtTxOnePhaseCommitAckRequest,GridDistributedTxFinishResponse,IncrementalSnapshotAwareMessage,TxLocksRequest,TxLocksResponse
public abstract class GridCacheMessage extends Object implements Message
Parent of all cache messages.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanaddDepInfostatic StringCACHE_MSG_INDEX_FIELD_NAMECache message index field name.protected booleanforceAddDepInfoForce addition of deployment info regardless ofaddDepInfoflag value.static intMAX_CACHE_MSG_LOOKUP_INDEXMaximum number of cache lookup indexes.-
Fields inherited from interface org.apache.ignite.plugin.extensions.communication.Message
DIRECT_TYPE_SIZE
-
-
Constructor Summary
Constructors Constructor Description GridCacheMessage()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleanaddDeploymentInfo()Deployment enabled flag indicates whether deployment info has to be added to this message.protected voidappendFlag(StringBuilder str, String name)abstract booleancacheGroupMessage()IgniteCheckedExceptionclassError()GridDeploymentInfodeployInfo()@Nullable Throwableerror()bytefieldsCount()Gets fields count.voidfinishUnmarshal(GridCacheSharedContext<?,?> ctx, ClassLoader ldr)This method is called after the message is deserialized and is responsible for unmarshalling state marshalled inprepareMarshal(GridCacheSharedContext)method.protected voidfinishUnmarshalCacheObjects(@Nullable Collection<? extends CacheObject> col, GridCacheContext ctx, ClassLoader ldr)voidfinishUnmarshalCacheObjects(@Nullable List<? extends CacheObject> col, GridCacheContext ctx, ClassLoader ldr)abstract inthandlerId()booleanignoreClassErrors()AffinityTopologyVersionlastAffinityChangedTopologyVersion()Returns the earliest affinity topology version for which this message is valid.voidlastAffinityChangedTopologyVersion(AffinityTopologyVersion topVer)Sets the earliest affinity topology version for which this message is valid.intlookupIndex()Gets message lookup index.protected @Nullable List<byte[]>marshalCollection(@Nullable Collection<?> col, GridCacheContext ctx)protected voidmarshalInfo(GridCacheEntryInfo info, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx)protected voidmarshalInfos(Iterable<? extends GridCacheEntryInfo> infos, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx)protected @org.jetbrains.annotations.Nullable byte[][]marshalInvokeArguments(@Nullable Object[] args, GridCacheContext ctx)protected voidmarshalTx(Iterable<IgniteTxEntry> txEntries, GridCacheSharedContext ctx)longmessageId()IgniteLoggermessageLogger(GridCacheSharedContext<?,?> ctx)static intnextIndexId()Gets next ID for indexed message ID.voidonAckReceived()Method called when ack message received.voidonClassError(IgniteCheckedException err)If class loading error occurred during unmarshalling andignoreClassErrors()is set totrue, then the error will be passed into this method.intpartition()booleanpartitionExchangeMessage()voidprepare(GridDeploymentInfo depInfo)voidprepareMarshal(GridCacheSharedContext<?,?> ctx)This method is called before the whole message is serialized and is responsible for pre-marshalling state.protected voidprepareMarshalCacheObject(CacheObject obj, GridCacheContext ctx)protected voidprepareMarshalCacheObjects(@Nullable Collection<? extends CacheObject> col, GridCacheContext ctx)voidprepareMarshalCacheObjects(@Nullable List<? extends CacheObject> col, GridCacheContext ctx)protected voidprepareObject(@Nullable Object o, GridCacheContext ctx)protected voidprepareObject(@Nullable Object o, GridCacheSharedContext ctx)booleanreadFrom(ByteBuffer buf, MessageReader reader)Reads this message from provided byte buffer.AffinityTopologyVersiontopologyVersion()Gets topology version or -1 in case of topology version is not required for this message.StringtoString()protected booleantransferExpiryPolicy()protected <T> @Nullable List<T>unmarshalCollection(@Nullable Collection<byte[]> byteCol, GridCacheSharedContext ctx, ClassLoader ldr)protected voidunmarshalInfo(GridCacheEntryInfo info, GridCacheContext ctx, ClassLoader ldr)protected voidunmarshalInfos(Iterable<? extends GridCacheEntryInfo> infos, GridCacheContext ctx, ClassLoader ldr)protected @Nullable Object[]unmarshalInvokeArguments(@org.jetbrains.annotations.Nullable byte[][] byteCol, GridCacheSharedContext ctx, ClassLoader ldr)protected voidunmarshalTx(Iterable<IgniteTxEntry> txEntries, GridCacheSharedContext ctx, ClassLoader ldr)booleanwriteTo(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
-
-
-
-
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 ofaddDepInfoflag value.
-
-
Method Detail
-
handlerId
public abstract int handlerId()
- Returns:
- ID to distinguish message handlers for the same messages but for different caches/cache groups.
-
cacheGroupMessage
public abstract boolean cacheGroupMessage()
- Returns:
Trueif cache group message.
-
error
@Nullable public @Nullable 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:
Trueif this message is partition exchange message.
-
ignoreClassErrors
public boolean ignoreClassErrors()
- Returns:
Trueif 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 toMAX_CACHE_MSG_LOOKUP_INDEX.- Returns:
- Message lookup index.
-
partition
public int partition()
- Returns:
- Partition ID this message is targeted to or
-1if it cannot be determined.
-
onClassError
public void onClassError(IgniteCheckedException err)
If class loading error occurred during unmarshalling andignoreClassErrors()is set totrue, 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.
-
topologyVersion
public AffinityTopologyVersion topologyVersion()
Gets topology version or -1 in case of topology version is not required for this message.- Returns:
- Topology version.
-
lastAffinityChangedTopologyVersion
public AffinityTopologyVersion lastAffinityChangedTopologyVersion()
Returns the earliest affinity topology version for which this message is valid.- Returns:
- Last affinity topology version when affinity was modified.
-
lastAffinityChangedTopologyVersion
public void lastAffinityChangedTopologyVersion(AffinityTopologyVersion topVer)
Sets the earliest affinity topology version for which this message is valid.- Parameters:
topVer- Last affinity topology version when affinity was modified.
-
addDeploymentInfo
public abstract boolean addDeploymentInfo()
Deployment enabled flag indicates whether deployment info has to be added to this message.- Returns:
trueor if deployment info must be added to the the message,falseotherwise.
-
prepareObject
protected final void prepareObject(@Nullable @Nullable Object o, GridCacheContext ctx) throws IgniteCheckedException- Parameters:
o- Object to prepare for marshalling.ctx- Context.- Throws:
IgniteCheckedException- If failed.
-
prepareObject
protected final void prepareObject(@Nullable @Nullable Object o, GridCacheSharedContext 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 inprepareMarshal(GridCacheSharedContext)method.- Parameters:
ctx- Context.ldr- Class loader.- Throws:
IgniteCheckedException- If failed.
-
marshalInfo
protected final void marshalInfo(GridCacheEntryInfo info, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx) throws IgniteCheckedException
- Parameters:
info- Entry to marshal.ctx- Context.cacheObjCtx- Cache object 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, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx) 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:
Trueif entries expire policy should be marshalled.
-
unmarshalTx
protected final void unmarshalTx(Iterable<IgniteTxEntry> txEntries, GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException
- Parameters:
txEntries- Entries to unmarshal.ctx- Context.ldr- Loader.- Throws:
IgniteCheckedException- If failed.
-
marshalInvokeArguments
@Nullable protected final @org.jetbrains.annotations.Nullable byte[][] marshalInvokeArguments(@Nullable @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 @Nullable Object[] unmarshalInvokeArguments(@Nullable @org.jetbrains.annotations.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 @Nullable List<byte[]> marshalCollection(@Nullable @Nullable Collection<?> col, GridCacheContext ctx) throws IgniteCheckedException
- Parameters:
col- Collection to marshal.ctx- Context.- Returns:
- Marshalled collection.
- Throws:
IgniteCheckedException- If failed.
-
prepareMarshalCacheObjects
public final void prepareMarshalCacheObjects(@Nullable @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 @Nullable Collection<? extends CacheObject> col, GridCacheContext ctx) throws IgniteCheckedException- Parameters:
col- Collection.ctx- Cache context.- Throws:
IgniteCheckedException- If failed.
-
finishUnmarshalCacheObjects
public final void finishUnmarshalCacheObjects(@Nullable @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 @Nullable Collection<? extends CacheObject> col, GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException- Parameters:
col- Collection.ctx- Context.ldr- Class loader.- Throws:
IgniteCheckedException- If failed.
-
onAckReceived
public void onAckReceived()
Method called when ack message received.- Specified by:
onAckReceivedin interfaceMessage
-
unmarshalCollection
@Nullable protected <T> @Nullable List<T> unmarshalCollection(@Nullable @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.
-
messageLogger
public IgniteLogger messageLogger(GridCacheSharedContext<?,?> ctx)
- Parameters:
ctx- Context.- Returns:
- Logger.
-
fieldsCount
public byte fieldsCount()
Gets fields count.- Specified by:
fieldsCountin interfaceMessage- Returns:
- Fields count.
-
writeTo
public boolean writeTo(ByteBuffer buf, MessageWriter writer)
Writes this message to provided byte buffer.
-
readFrom
public boolean readFrom(ByteBuffer buf, MessageReader reader)
Reads this message from provided byte buffer.
-
appendFlag
protected final void appendFlag(StringBuilder str, String name)
- Parameters:
str- Bulder.name- Flag name.
-
-