Vladsz83 commented on code in PR #13095:
URL: https://github.com/apache/ignite/pull/13095#discussion_r3569929661
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java:
##########
@@ -200,27 +201,28 @@ public void
lastAffinityChangedTopologyVersion(AffinityTopologyVersion topVer) {
public abstract boolean addDeploymentInfo();
/**
- * @param o Object to prepare for marshalling.
+ * @param o Object to deploy.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void prepareObject(@Nullable Object o, GridCacheContext
ctx) throws IgniteCheckedException {
- prepareObject(o, ctx.shared());
+ public final void deployObject(@Nullable Object o, @Nullable
GridCacheContext ctx) throws IgniteCheckedException {
Review Comment:
Minor codestyle suggestion: `@Nullable GridCacheContext ctx` -> `@Nullable
GridCacheContext<?, ?> ctx`
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java:
##########
@@ -200,27 +201,28 @@ public void
lastAffinityChangedTopologyVersion(AffinityTopologyVersion topVer) {
public abstract boolean addDeploymentInfo();
/**
- * @param o Object to prepare for marshalling.
+ * @param o Object to deploy.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void prepareObject(@Nullable Object o, GridCacheContext
ctx) throws IgniteCheckedException {
- prepareObject(o, ctx.shared());
+ public final void deployObject(@Nullable Object o, @Nullable
GridCacheContext ctx) throws IgniteCheckedException {
+ if (ctx != null)
+ deployObject(o, ctx.shared());
}
/**
- * @param o Object to prepare for marshalling.
+ * @param o Object to deploy.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void prepareObject(@Nullable Object o,
GridCacheSharedContext ctx) throws IgniteCheckedException {
+ final void deployObject(@Nullable Object o, GridCacheSharedContext ctx)
throws IgniteCheckedException {
Review Comment:
Minor codestyle suggestion: `GridCacheSharedContext` ->
`GridCacheSharedContext<?, ?>`.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java:
##########
@@ -262,370 +270,234 @@ public GridDeploymentInfoBean deployInfo() {
return depInfo;
}
- /**
- * This method is called before the whole message is serialized
- * and is responsible for pre-marshalling state.
- *
- * @param ctx Cache context.
- * @throws IgniteCheckedException If failed.
- */
- public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws
IgniteCheckedException {
- // No-op.
- }
-
- /**
- * This method is called after the message is deserialized and is
responsible for
- * unmarshalling state marshalled in {@link
#prepareMarshal(GridCacheSharedContext)} method.
- *
- * @param ctx Context.
- * @param ldr Class loader.
- * @throws IgniteCheckedException If failed.
- */
- public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader
ldr) throws IgniteCheckedException {
- // No-op.
- }
-
/**
* @param info Entry to marshal.
* @param ctx Context.
* @param cacheObjCtx Cache object context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfo(GridCacheEntryInfo info,
+ public final void deployInfo(GridCacheEntryInfo info,
GridCacheSharedContext ctx,
Review Comment:
Minor code style suggestion: `GridCacheSharedContext` ->
`GridCacheSharedContext<?, ?>`.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java:
##########
@@ -262,370 +270,234 @@ public GridDeploymentInfoBean deployInfo() {
return depInfo;
}
- /**
- * This method is called before the whole message is serialized
- * and is responsible for pre-marshalling state.
- *
- * @param ctx Cache context.
- * @throws IgniteCheckedException If failed.
- */
- public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws
IgniteCheckedException {
- // No-op.
- }
-
- /**
- * This method is called after the message is deserialized and is
responsible for
- * unmarshalling state marshalled in {@link
#prepareMarshal(GridCacheSharedContext)} method.
- *
- * @param ctx Context.
- * @param ldr Class loader.
- * @throws IgniteCheckedException If failed.
- */
- public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader
ldr) throws IgniteCheckedException {
- // No-op.
- }
-
/**
* @param info Entry to marshal.
* @param ctx Context.
* @param cacheObjCtx Cache object context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfo(GridCacheEntryInfo info,
+ public final void deployInfo(GridCacheEntryInfo info,
GridCacheSharedContext ctx,
CacheObjectContext cacheObjCtx
) throws IgniteCheckedException {
assert ctx != null;
if (info != null) {
- info.marshal(cacheObjCtx);
-
if (addDepInfo) {
if (info.key() != null)
- prepareObject(info.key().value(cacheObjCtx, false), ctx);
+ deployObject(info.key().value(cacheObjCtx, false), ctx);
CacheObject val = info.value();
if (val != null) {
- val.finishUnmarshal(cacheObjCtx,
ctx.deploy().globalLoader());
+ val.unmarshal(cacheObjCtx, ctx.deploy().globalLoader());
- prepareObject(val.value(cacheObjCtx, false), ctx);
+ deployObject(val.value(cacheObjCtx, false), ctx);
}
}
}
}
- /**
- * @param info Entry to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfo(GridCacheEntryInfo info,
GridCacheContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (info != null)
- info.unmarshal(ctx.cacheObjectContext(), ldr);
+ /** Deploys all {@code infos}, resolving shared and cache-object contexts
from {@code cctx}; no-op when {@code cctx} is absent. */
+ public final void deployInfos(@Nullable Iterable<? extends
GridCacheEntryInfo> infos, @Nullable GridCacheContext cctx)
Review Comment:
Minor codes tyle suggestion: `@Nullable GridCacheContext ctx` -> `@Nullable
GridCacheContext<?, ?> ctx`. And in the other similar places.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java:
##########
@@ -262,370 +270,234 @@ public GridDeploymentInfoBean deployInfo() {
return depInfo;
}
- /**
- * This method is called before the whole message is serialized
- * and is responsible for pre-marshalling state.
- *
- * @param ctx Cache context.
- * @throws IgniteCheckedException If failed.
- */
- public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws
IgniteCheckedException {
- // No-op.
- }
-
- /**
- * This method is called after the message is deserialized and is
responsible for
- * unmarshalling state marshalled in {@link
#prepareMarshal(GridCacheSharedContext)} method.
- *
- * @param ctx Context.
- * @param ldr Class loader.
- * @throws IgniteCheckedException If failed.
- */
- public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader
ldr) throws IgniteCheckedException {
- // No-op.
- }
-
/**
* @param info Entry to marshal.
* @param ctx Context.
* @param cacheObjCtx Cache object context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfo(GridCacheEntryInfo info,
+ public final void deployInfo(GridCacheEntryInfo info,
GridCacheSharedContext ctx,
CacheObjectContext cacheObjCtx
) throws IgniteCheckedException {
assert ctx != null;
if (info != null) {
- info.marshal(cacheObjCtx);
-
if (addDepInfo) {
if (info.key() != null)
- prepareObject(info.key().value(cacheObjCtx, false), ctx);
+ deployObject(info.key().value(cacheObjCtx, false), ctx);
CacheObject val = info.value();
if (val != null) {
- val.finishUnmarshal(cacheObjCtx,
ctx.deploy().globalLoader());
+ val.unmarshal(cacheObjCtx, ctx.deploy().globalLoader());
- prepareObject(val.value(cacheObjCtx, false), ctx);
+ deployObject(val.value(cacheObjCtx, false), ctx);
}
}
}
}
- /**
- * @param info Entry to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfo(GridCacheEntryInfo info,
GridCacheContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (info != null)
- info.unmarshal(ctx.cacheObjectContext(), ldr);
+ /** Deploys all {@code infos}, resolving shared and cache-object contexts
from {@code cctx}; no-op when {@code cctx} is absent. */
+ public final void deployInfos(@Nullable Iterable<? extends
GridCacheEntryInfo> infos, @Nullable GridCacheContext cctx)
+ throws IgniteCheckedException {
+ if (cctx != null)
+ deployInfos(infos, cctx.shared(), cctx.cacheObjectContext());
}
/**
* @param infos Entries to marshal.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfos(
- Iterable<? extends GridCacheEntryInfo> infos,
- GridCacheSharedContext ctx,
- CacheObjectContext cacheObjCtx
- ) throws IgniteCheckedException {
+ final void deployInfos(Iterable<? extends GridCacheEntryInfo> infos,
GridCacheSharedContext ctx,
+ CacheObjectContext cacheObjCtx) throws IgniteCheckedException {
assert ctx != null;
if (infos != null)
Review Comment:
Codestyle: missing brackets below.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java:
##########
@@ -262,370 +270,234 @@ public GridDeploymentInfoBean deployInfo() {
return depInfo;
}
- /**
- * This method is called before the whole message is serialized
- * and is responsible for pre-marshalling state.
- *
- * @param ctx Cache context.
- * @throws IgniteCheckedException If failed.
- */
- public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws
IgniteCheckedException {
- // No-op.
- }
-
- /**
- * This method is called after the message is deserialized and is
responsible for
- * unmarshalling state marshalled in {@link
#prepareMarshal(GridCacheSharedContext)} method.
- *
- * @param ctx Context.
- * @param ldr Class loader.
- * @throws IgniteCheckedException If failed.
- */
- public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader
ldr) throws IgniteCheckedException {
- // No-op.
- }
-
/**
* @param info Entry to marshal.
* @param ctx Context.
* @param cacheObjCtx Cache object context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfo(GridCacheEntryInfo info,
+ public final void deployInfo(GridCacheEntryInfo info,
GridCacheSharedContext ctx,
CacheObjectContext cacheObjCtx
) throws IgniteCheckedException {
assert ctx != null;
if (info != null) {
- info.marshal(cacheObjCtx);
-
if (addDepInfo) {
if (info.key() != null)
- prepareObject(info.key().value(cacheObjCtx, false), ctx);
+ deployObject(info.key().value(cacheObjCtx, false), ctx);
CacheObject val = info.value();
if (val != null) {
- val.finishUnmarshal(cacheObjCtx,
ctx.deploy().globalLoader());
+ val.unmarshal(cacheObjCtx, ctx.deploy().globalLoader());
- prepareObject(val.value(cacheObjCtx, false), ctx);
+ deployObject(val.value(cacheObjCtx, false), ctx);
}
}
}
}
- /**
- * @param info Entry to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfo(GridCacheEntryInfo info,
GridCacheContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (info != null)
- info.unmarshal(ctx.cacheObjectContext(), ldr);
+ /** Deploys all {@code infos}, resolving shared and cache-object contexts
from {@code cctx}; no-op when {@code cctx} is absent. */
+ public final void deployInfos(@Nullable Iterable<? extends
GridCacheEntryInfo> infos, @Nullable GridCacheContext cctx)
+ throws IgniteCheckedException {
+ if (cctx != null)
+ deployInfos(infos, cctx.shared(), cctx.cacheObjectContext());
}
/**
* @param infos Entries to marshal.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfos(
- Iterable<? extends GridCacheEntryInfo> infos,
- GridCacheSharedContext ctx,
- CacheObjectContext cacheObjCtx
- ) throws IgniteCheckedException {
+ final void deployInfos(Iterable<? extends GridCacheEntryInfo> infos,
GridCacheSharedContext ctx,
+ CacheObjectContext cacheObjCtx) throws IgniteCheckedException {
assert ctx != null;
if (infos != null)
for (GridCacheEntryInfo e : infos)
- marshalInfo(e, ctx, cacheObjCtx);
- }
-
- /**
- * @param infos Entries to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfos(Iterable<? extends GridCacheEntryInfo>
infos,
- GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (infos != null)
- for (GridCacheEntryInfo e : infos)
- unmarshalInfo(e, ctx, ldr);
+ deployInfo(e, ctx, cacheObjCtx);
}
/**
* @param txEntries Entries to marshal.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalTx(Iterable<IgniteTxEntry> txEntries,
GridCacheSharedContext ctx)
+ public final void deployTx(Iterable<IgniteTxEntry> txEntries,
GridCacheSharedContext ctx)
throws IgniteCheckedException {
assert ctx != null;
if (txEntries != null) {
- boolean transferExpiry = transferExpiryPolicy();
boolean p2pEnabled = ctx.deploymentEnabled();
for (IgniteTxEntry e : txEntries) {
- e.marshal(ctx, transferExpiry);
-
GridCacheContext cctx = e.context();
if (addDepInfo) {
if (e.key() != null)
- prepareObject(e.key().value(cctx.cacheObjectContext(),
false), ctx);
+ deployObject(e.key().value(cctx.cacheObjectContext(),
false), ctx);
if (e.value() != null)
-
prepareObject(e.value().value(cctx.cacheObjectContext(), false), ctx);
+
deployObject(e.value().value(cctx.cacheObjectContext(), false), ctx);
if (e.entryProcessors() != null) {
for (T2<EntryProcessor<Object, Object, Object>,
Object[]> entProc : e.entryProcessors())
- prepareObject(entProc.get1(), ctx);
+ deployObject(entProc.get1(), ctx);
}
}
else if (p2pEnabled && e.entryProcessors() != null) {
if (!forceAddDepInfo)
forceAddDepInfo = true;
for (T2<EntryProcessor<Object, Object, Object>, Object[]>
entProc : e.entryProcessors())
- prepareObject(entProc.get1(), ctx);
+ deployObject(entProc.get1(), ctx);
}
}
}
}
/**
- * @return {@code True} if entries expire policy should be marshalled.
- */
- protected boolean transferExpiryPolicy() {
- return false;
- }
-
- /**
- * @param txEntries Entries to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
+ * @param args Arguments to marshal.
+ * @param marsh Marshaller.
+ * @return Marshalled collection.
* @throws IgniteCheckedException If failed.
*/
- protected final void unmarshalTx(Iterable<IgniteTxEntry> txEntries,
- GridCacheSharedContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
+ @Nullable protected final List<byte[]> marshallInvokeArguments(@Nullable
Object[] args, Marshaller marsh)
+ throws IgniteCheckedException {
- if (txEntries != null) {
- for (IgniteTxEntry e : txEntries) {
- e.prepareUnmarshal(ctx, topologyVersion(), false);
+ if (args == null || args.length == 0)
Review Comment:
`F.isEmpty(args)` ?
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java:
##########
@@ -262,370 +270,234 @@ public GridDeploymentInfoBean deployInfo() {
return depInfo;
}
- /**
- * This method is called before the whole message is serialized
- * and is responsible for pre-marshalling state.
- *
- * @param ctx Cache context.
- * @throws IgniteCheckedException If failed.
- */
- public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws
IgniteCheckedException {
- // No-op.
- }
-
- /**
- * This method is called after the message is deserialized and is
responsible for
- * unmarshalling state marshalled in {@link
#prepareMarshal(GridCacheSharedContext)} method.
- *
- * @param ctx Context.
- * @param ldr Class loader.
- * @throws IgniteCheckedException If failed.
- */
- public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader
ldr) throws IgniteCheckedException {
- // No-op.
- }
-
/**
* @param info Entry to marshal.
* @param ctx Context.
* @param cacheObjCtx Cache object context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfo(GridCacheEntryInfo info,
+ public final void deployInfo(GridCacheEntryInfo info,
GridCacheSharedContext ctx,
CacheObjectContext cacheObjCtx
) throws IgniteCheckedException {
assert ctx != null;
if (info != null) {
- info.marshal(cacheObjCtx);
-
if (addDepInfo) {
if (info.key() != null)
- prepareObject(info.key().value(cacheObjCtx, false), ctx);
+ deployObject(info.key().value(cacheObjCtx, false), ctx);
CacheObject val = info.value();
if (val != null) {
- val.finishUnmarshal(cacheObjCtx,
ctx.deploy().globalLoader());
+ val.unmarshal(cacheObjCtx, ctx.deploy().globalLoader());
- prepareObject(val.value(cacheObjCtx, false), ctx);
+ deployObject(val.value(cacheObjCtx, false), ctx);
}
}
}
}
- /**
- * @param info Entry to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfo(GridCacheEntryInfo info,
GridCacheContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (info != null)
- info.unmarshal(ctx.cacheObjectContext(), ldr);
+ /** Deploys all {@code infos}, resolving shared and cache-object contexts
from {@code cctx}; no-op when {@code cctx} is absent. */
+ public final void deployInfos(@Nullable Iterable<? extends
GridCacheEntryInfo> infos, @Nullable GridCacheContext cctx)
+ throws IgniteCheckedException {
+ if (cctx != null)
+ deployInfos(infos, cctx.shared(), cctx.cacheObjectContext());
}
/**
* @param infos Entries to marshal.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfos(
- Iterable<? extends GridCacheEntryInfo> infos,
- GridCacheSharedContext ctx,
- CacheObjectContext cacheObjCtx
- ) throws IgniteCheckedException {
+ final void deployInfos(Iterable<? extends GridCacheEntryInfo> infos,
GridCacheSharedContext ctx,
+ CacheObjectContext cacheObjCtx) throws IgniteCheckedException {
assert ctx != null;
if (infos != null)
for (GridCacheEntryInfo e : infos)
- marshalInfo(e, ctx, cacheObjCtx);
- }
-
- /**
- * @param infos Entries to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfos(Iterable<? extends GridCacheEntryInfo>
infos,
- GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (infos != null)
- for (GridCacheEntryInfo e : infos)
- unmarshalInfo(e, ctx, ldr);
+ deployInfo(e, ctx, cacheObjCtx);
}
/**
* @param txEntries Entries to marshal.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalTx(Iterable<IgniteTxEntry> txEntries,
GridCacheSharedContext ctx)
+ public final void deployTx(Iterable<IgniteTxEntry> txEntries,
GridCacheSharedContext ctx)
throws IgniteCheckedException {
assert ctx != null;
if (txEntries != null) {
- boolean transferExpiry = transferExpiryPolicy();
boolean p2pEnabled = ctx.deploymentEnabled();
for (IgniteTxEntry e : txEntries) {
- e.marshal(ctx, transferExpiry);
-
GridCacheContext cctx = e.context();
if (addDepInfo) {
if (e.key() != null)
- prepareObject(e.key().value(cctx.cacheObjectContext(),
false), ctx);
+ deployObject(e.key().value(cctx.cacheObjectContext(),
false), ctx);
if (e.value() != null)
-
prepareObject(e.value().value(cctx.cacheObjectContext(), false), ctx);
+
deployObject(e.value().value(cctx.cacheObjectContext(), false), ctx);
if (e.entryProcessors() != null) {
for (T2<EntryProcessor<Object, Object, Object>,
Object[]> entProc : e.entryProcessors())
- prepareObject(entProc.get1(), ctx);
+ deployObject(entProc.get1(), ctx);
}
}
else if (p2pEnabled && e.entryProcessors() != null) {
if (!forceAddDepInfo)
forceAddDepInfo = true;
for (T2<EntryProcessor<Object, Object, Object>, Object[]>
entProc : e.entryProcessors())
- prepareObject(entProc.get1(), ctx);
+ deployObject(entProc.get1(), ctx);
}
}
}
}
/**
- * @return {@code True} if entries expire policy should be marshalled.
- */
- protected boolean transferExpiryPolicy() {
- return false;
- }
-
- /**
- * @param txEntries Entries to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
+ * @param args Arguments to marshal.
+ * @param marsh Marshaller.
+ * @return Marshalled collection.
* @throws IgniteCheckedException If failed.
*/
- protected final void unmarshalTx(Iterable<IgniteTxEntry> txEntries,
- GridCacheSharedContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
+ @Nullable protected final List<byte[]> marshallInvokeArguments(@Nullable
Object[] args, Marshaller marsh)
Review Comment:
`@Nullable List<byte[]>` seems to be a normal practice. In the other places
too.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java:
##########
@@ -262,370 +270,234 @@ public GridDeploymentInfoBean deployInfo() {
return depInfo;
}
- /**
- * This method is called before the whole message is serialized
- * and is responsible for pre-marshalling state.
- *
- * @param ctx Cache context.
- * @throws IgniteCheckedException If failed.
- */
- public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws
IgniteCheckedException {
- // No-op.
- }
-
- /**
- * This method is called after the message is deserialized and is
responsible for
- * unmarshalling state marshalled in {@link
#prepareMarshal(GridCacheSharedContext)} method.
- *
- * @param ctx Context.
- * @param ldr Class loader.
- * @throws IgniteCheckedException If failed.
- */
- public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader
ldr) throws IgniteCheckedException {
- // No-op.
- }
-
/**
* @param info Entry to marshal.
* @param ctx Context.
* @param cacheObjCtx Cache object context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfo(GridCacheEntryInfo info,
+ public final void deployInfo(GridCacheEntryInfo info,
GridCacheSharedContext ctx,
CacheObjectContext cacheObjCtx
) throws IgniteCheckedException {
assert ctx != null;
if (info != null) {
- info.marshal(cacheObjCtx);
-
if (addDepInfo) {
if (info.key() != null)
- prepareObject(info.key().value(cacheObjCtx, false), ctx);
+ deployObject(info.key().value(cacheObjCtx, false), ctx);
CacheObject val = info.value();
if (val != null) {
- val.finishUnmarshal(cacheObjCtx,
ctx.deploy().globalLoader());
+ val.unmarshal(cacheObjCtx, ctx.deploy().globalLoader());
- prepareObject(val.value(cacheObjCtx, false), ctx);
+ deployObject(val.value(cacheObjCtx, false), ctx);
}
}
}
}
- /**
- * @param info Entry to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfo(GridCacheEntryInfo info,
GridCacheContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (info != null)
- info.unmarshal(ctx.cacheObjectContext(), ldr);
+ /** Deploys all {@code infos}, resolving shared and cache-object contexts
from {@code cctx}; no-op when {@code cctx} is absent. */
+ public final void deployInfos(@Nullable Iterable<? extends
GridCacheEntryInfo> infos, @Nullable GridCacheContext cctx)
+ throws IgniteCheckedException {
+ if (cctx != null)
+ deployInfos(infos, cctx.shared(), cctx.cacheObjectContext());
}
/**
* @param infos Entries to marshal.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfos(
- Iterable<? extends GridCacheEntryInfo> infos,
- GridCacheSharedContext ctx,
- CacheObjectContext cacheObjCtx
- ) throws IgniteCheckedException {
+ final void deployInfos(Iterable<? extends GridCacheEntryInfo> infos,
GridCacheSharedContext ctx,
+ CacheObjectContext cacheObjCtx) throws IgniteCheckedException {
assert ctx != null;
if (infos != null)
Review Comment:
If `infos` can be null, let's mark them `@Nullable`.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java:
##########
@@ -262,370 +270,234 @@ public GridDeploymentInfoBean deployInfo() {
return depInfo;
}
- /**
- * This method is called before the whole message is serialized
- * and is responsible for pre-marshalling state.
- *
- * @param ctx Cache context.
- * @throws IgniteCheckedException If failed.
- */
- public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws
IgniteCheckedException {
- // No-op.
- }
-
- /**
- * This method is called after the message is deserialized and is
responsible for
- * unmarshalling state marshalled in {@link
#prepareMarshal(GridCacheSharedContext)} method.
- *
- * @param ctx Context.
- * @param ldr Class loader.
- * @throws IgniteCheckedException If failed.
- */
- public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader
ldr) throws IgniteCheckedException {
- // No-op.
- }
-
/**
* @param info Entry to marshal.
* @param ctx Context.
* @param cacheObjCtx Cache object context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfo(GridCacheEntryInfo info,
+ public final void deployInfo(GridCacheEntryInfo info,
GridCacheSharedContext ctx,
CacheObjectContext cacheObjCtx
) throws IgniteCheckedException {
assert ctx != null;
if (info != null) {
- info.marshal(cacheObjCtx);
-
if (addDepInfo) {
if (info.key() != null)
- prepareObject(info.key().value(cacheObjCtx, false), ctx);
+ deployObject(info.key().value(cacheObjCtx, false), ctx);
CacheObject val = info.value();
if (val != null) {
- val.finishUnmarshal(cacheObjCtx,
ctx.deploy().globalLoader());
+ val.unmarshal(cacheObjCtx, ctx.deploy().globalLoader());
- prepareObject(val.value(cacheObjCtx, false), ctx);
+ deployObject(val.value(cacheObjCtx, false), ctx);
}
}
}
}
- /**
- * @param info Entry to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfo(GridCacheEntryInfo info,
GridCacheContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (info != null)
- info.unmarshal(ctx.cacheObjectContext(), ldr);
+ /** Deploys all {@code infos}, resolving shared and cache-object contexts
from {@code cctx}; no-op when {@code cctx} is absent. */
+ public final void deployInfos(@Nullable Iterable<? extends
GridCacheEntryInfo> infos, @Nullable GridCacheContext cctx)
+ throws IgniteCheckedException {
+ if (cctx != null)
+ deployInfos(infos, cctx.shared(), cctx.cacheObjectContext());
}
/**
* @param infos Entries to marshal.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfos(
- Iterable<? extends GridCacheEntryInfo> infos,
- GridCacheSharedContext ctx,
- CacheObjectContext cacheObjCtx
- ) throws IgniteCheckedException {
+ final void deployInfos(Iterable<? extends GridCacheEntryInfo> infos,
GridCacheSharedContext ctx,
+ CacheObjectContext cacheObjCtx) throws IgniteCheckedException {
assert ctx != null;
if (infos != null)
for (GridCacheEntryInfo e : infos)
- marshalInfo(e, ctx, cacheObjCtx);
- }
-
- /**
- * @param infos Entries to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfos(Iterable<? extends GridCacheEntryInfo>
infos,
- GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (infos != null)
- for (GridCacheEntryInfo e : infos)
- unmarshalInfo(e, ctx, ldr);
+ deployInfo(e, ctx, cacheObjCtx);
}
/**
* @param txEntries Entries to marshal.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalTx(Iterable<IgniteTxEntry> txEntries,
GridCacheSharedContext ctx)
+ public final void deployTx(Iterable<IgniteTxEntry> txEntries,
GridCacheSharedContext ctx)
throws IgniteCheckedException {
assert ctx != null;
if (txEntries != null) {
- boolean transferExpiry = transferExpiryPolicy();
boolean p2pEnabled = ctx.deploymentEnabled();
for (IgniteTxEntry e : txEntries) {
- e.marshal(ctx, transferExpiry);
-
GridCacheContext cctx = e.context();
if (addDepInfo) {
if (e.key() != null)
- prepareObject(e.key().value(cctx.cacheObjectContext(),
false), ctx);
+ deployObject(e.key().value(cctx.cacheObjectContext(),
false), ctx);
if (e.value() != null)
-
prepareObject(e.value().value(cctx.cacheObjectContext(), false), ctx);
+
deployObject(e.value().value(cctx.cacheObjectContext(), false), ctx);
if (e.entryProcessors() != null) {
for (T2<EntryProcessor<Object, Object, Object>,
Object[]> entProc : e.entryProcessors())
- prepareObject(entProc.get1(), ctx);
+ deployObject(entProc.get1(), ctx);
}
}
else if (p2pEnabled && e.entryProcessors() != null) {
if (!forceAddDepInfo)
forceAddDepInfo = true;
for (T2<EntryProcessor<Object, Object, Object>, Object[]>
entProc : e.entryProcessors())
- prepareObject(entProc.get1(), ctx);
+ deployObject(entProc.get1(), ctx);
}
}
}
}
/**
- * @return {@code True} if entries expire policy should be marshalled.
- */
- protected boolean transferExpiryPolicy() {
- return false;
- }
-
- /**
- * @param txEntries Entries to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
+ * @param args Arguments to marshal.
+ * @param marsh Marshaller.
+ * @return Marshalled collection.
* @throws IgniteCheckedException If failed.
*/
- protected final void unmarshalTx(Iterable<IgniteTxEntry> txEntries,
- GridCacheSharedContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
+ @Nullable protected final List<byte[]> marshallInvokeArguments(@Nullable
Object[] args, Marshaller marsh)
+ throws IgniteCheckedException {
- if (txEntries != null) {
- for (IgniteTxEntry e : txEntries) {
- e.prepareUnmarshal(ctx, topologyVersion(), false);
+ if (args == null || args.length == 0)
+ return null;
- e.unmarshal(ctx, false, ldr);
- }
- }
+ List<byte[]> argsBytes = new ArrayList<>(args.length);
+
+ for (Object arg : args)
+ argsBytes.add(arg == null ? null : U.marshal(marsh, arg));
+
+ return argsBytes;
}
/**
* @param args Arguments to marshal.
* @param ctx Context.
- * @return Marshalled collection.
* @throws IgniteCheckedException If failed.
*/
- @Nullable protected final byte[][] marshalInvokeArguments(@Nullable
Object[] args, GridCacheContext ctx)
+ public final void deployInvokeArguments(@Nullable Object[] args, @Nullable
GridCacheContext ctx)
throws IgniteCheckedException {
- assert ctx != null;
-
- if (args == null || args.length == 0)
- return null;
-
- byte[][] argsBytes = new byte[args.length][];
+ if (ctx == null || args == null)
+ return;
for (int i = 0; i < args.length; i++) {
Object arg = args[i];
if (addDepInfo)
- prepareObject(arg, ctx.shared());
-
- argsBytes[i] = arg == null ? null : CU.marshal(ctx, arg);
+ deployObject(arg, ctx.shared());
}
-
- return argsBytes;
}
-
/**
* @param byteCol Collection to unmarshal.
- * @param ctx Context.
+ * @param marsh Marshaller.
* @param ldr Loader.
* @return Unmarshalled collection.
* @throws IgniteCheckedException If failed.
*/
- @Nullable protected final Object[] unmarshalInvokeArguments(@Nullable
byte[][] byteCol,
- GridCacheSharedContext ctx,
+ @Nullable protected final Object[] unmarshalInvokeArguments(@Nullable
List<byte[]> byteCol,
+ Marshaller marsh,
ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
if (byteCol == null)
return null;
- Object[] args = new Object[byteCol.length];
+ Object[] args = new Object[byteCol.size()];
- Marshaller marsh = ctx.marshaller();
+ int i = 0;
- for (int i = 0; i < byteCol.length; i++)
- args[i] = byteCol[i] == null ? null : U.unmarshal(marsh,
byteCol[i], U.resolveClassLoader(ldr, ctx.gridConfig()));
+ for (byte[] bytes : byteCol)
+ args[i++] = bytes == null ? null : U.unmarshal(marsh, bytes, ldr);
return args;
}
/**
* @param col Collection to marshal.
- * @param ctx Context.
+ * @param marsh Marshaller.
* @return Marshalled collection.
* @throws IgniteCheckedException If failed.
*/
- @Nullable protected List<byte[]> marshalCollection(@Nullable Collection<?>
col,
- GridCacheContext ctx) throws IgniteCheckedException {
- assert ctx != null;
-
+ @Nullable protected List<byte[]> marshallCollection(@Nullable
Collection<?> col, Marshaller marsh) throws IgniteCheckedException {
if (col == null)
return null;
List<byte[]> byteCol = new ArrayList<>(col.size());
- for (Object o : col) {
- if (addDepInfo)
- prepareObject(o, ctx.shared());
-
- byteCol.add(o == null ? null : CU.marshal(ctx, o));
- }
+ for (Object o : col)
+ byteCol.add(o == null ? null : U.marshal(marsh, o));
return byteCol;
}
/**
- * @param col Collection.
- * @param ctx Cache context.
+ * Deploys each element of {@code col} via {@link #deployObject} on each
item.
+ *
+ * @param col Collection to marshal.
+ * @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- @SuppressWarnings("ForLoopReplaceableByForEach")
- public final void prepareMarshalCacheObjects(@Nullable List<? extends
CacheObject> col,
- GridCacheContext ctx) throws IgniteCheckedException {
- if (col == null)
+ public final void deployCollection(@Nullable Collection<?> col,
+ @Nullable GridCacheContext ctx) throws IgniteCheckedException {
+ if (ctx == null || col == null)
Review Comment:
```suggestion
if (ctx == null || col == null || !addDepInfo)
return;
for (Object o : col)
deployObject(o, ctx.shared());
```
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java:
##########
@@ -262,370 +270,234 @@ public GridDeploymentInfoBean deployInfo() {
return depInfo;
}
- /**
- * This method is called before the whole message is serialized
- * and is responsible for pre-marshalling state.
- *
- * @param ctx Cache context.
- * @throws IgniteCheckedException If failed.
- */
- public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws
IgniteCheckedException {
- // No-op.
- }
-
- /**
- * This method is called after the message is deserialized and is
responsible for
- * unmarshalling state marshalled in {@link
#prepareMarshal(GridCacheSharedContext)} method.
- *
- * @param ctx Context.
- * @param ldr Class loader.
- * @throws IgniteCheckedException If failed.
- */
- public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader
ldr) throws IgniteCheckedException {
- // No-op.
- }
-
/**
* @param info Entry to marshal.
* @param ctx Context.
* @param cacheObjCtx Cache object context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfo(GridCacheEntryInfo info,
+ public final void deployInfo(GridCacheEntryInfo info,
GridCacheSharedContext ctx,
CacheObjectContext cacheObjCtx
) throws IgniteCheckedException {
assert ctx != null;
if (info != null) {
- info.marshal(cacheObjCtx);
-
if (addDepInfo) {
if (info.key() != null)
- prepareObject(info.key().value(cacheObjCtx, false), ctx);
+ deployObject(info.key().value(cacheObjCtx, false), ctx);
CacheObject val = info.value();
if (val != null) {
- val.finishUnmarshal(cacheObjCtx,
ctx.deploy().globalLoader());
+ val.unmarshal(cacheObjCtx, ctx.deploy().globalLoader());
- prepareObject(val.value(cacheObjCtx, false), ctx);
+ deployObject(val.value(cacheObjCtx, false), ctx);
}
}
}
}
- /**
- * @param info Entry to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfo(GridCacheEntryInfo info,
GridCacheContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (info != null)
- info.unmarshal(ctx.cacheObjectContext(), ldr);
+ /** Deploys all {@code infos}, resolving shared and cache-object contexts
from {@code cctx}; no-op when {@code cctx} is absent. */
+ public final void deployInfos(@Nullable Iterable<? extends
GridCacheEntryInfo> infos, @Nullable GridCacheContext cctx)
+ throws IgniteCheckedException {
+ if (cctx != null)
+ deployInfos(infos, cctx.shared(), cctx.cacheObjectContext());
}
/**
* @param infos Entries to marshal.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfos(
- Iterable<? extends GridCacheEntryInfo> infos,
- GridCacheSharedContext ctx,
- CacheObjectContext cacheObjCtx
- ) throws IgniteCheckedException {
+ final void deployInfos(Iterable<? extends GridCacheEntryInfo> infos,
GridCacheSharedContext ctx,
+ CacheObjectContext cacheObjCtx) throws IgniteCheckedException {
assert ctx != null;
if (infos != null)
for (GridCacheEntryInfo e : infos)
- marshalInfo(e, ctx, cacheObjCtx);
- }
-
- /**
- * @param infos Entries to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfos(Iterable<? extends GridCacheEntryInfo>
infos,
- GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (infos != null)
- for (GridCacheEntryInfo e : infos)
- unmarshalInfo(e, ctx, ldr);
+ deployInfo(e, ctx, cacheObjCtx);
}
/**
* @param txEntries Entries to marshal.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalTx(Iterable<IgniteTxEntry> txEntries,
GridCacheSharedContext ctx)
+ public final void deployTx(Iterable<IgniteTxEntry> txEntries,
GridCacheSharedContext ctx)
throws IgniteCheckedException {
assert ctx != null;
if (txEntries != null) {
- boolean transferExpiry = transferExpiryPolicy();
boolean p2pEnabled = ctx.deploymentEnabled();
for (IgniteTxEntry e : txEntries) {
- e.marshal(ctx, transferExpiry);
-
GridCacheContext cctx = e.context();
if (addDepInfo) {
if (e.key() != null)
- prepareObject(e.key().value(cctx.cacheObjectContext(),
false), ctx);
+ deployObject(e.key().value(cctx.cacheObjectContext(),
false), ctx);
if (e.value() != null)
-
prepareObject(e.value().value(cctx.cacheObjectContext(), false), ctx);
+
deployObject(e.value().value(cctx.cacheObjectContext(), false), ctx);
if (e.entryProcessors() != null) {
for (T2<EntryProcessor<Object, Object, Object>,
Object[]> entProc : e.entryProcessors())
- prepareObject(entProc.get1(), ctx);
+ deployObject(entProc.get1(), ctx);
}
}
else if (p2pEnabled && e.entryProcessors() != null) {
if (!forceAddDepInfo)
forceAddDepInfo = true;
for (T2<EntryProcessor<Object, Object, Object>, Object[]>
entProc : e.entryProcessors())
- prepareObject(entProc.get1(), ctx);
+ deployObject(entProc.get1(), ctx);
}
}
}
}
/**
- * @return {@code True} if entries expire policy should be marshalled.
- */
- protected boolean transferExpiryPolicy() {
- return false;
- }
-
- /**
- * @param txEntries Entries to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
+ * @param args Arguments to marshal.
+ * @param marsh Marshaller.
+ * @return Marshalled collection.
* @throws IgniteCheckedException If failed.
*/
- protected final void unmarshalTx(Iterable<IgniteTxEntry> txEntries,
- GridCacheSharedContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
+ @Nullable protected final List<byte[]> marshallInvokeArguments(@Nullable
Object[] args, Marshaller marsh)
+ throws IgniteCheckedException {
- if (txEntries != null) {
- for (IgniteTxEntry e : txEntries) {
- e.prepareUnmarshal(ctx, topologyVersion(), false);
+ if (args == null || args.length == 0)
+ return null;
- e.unmarshal(ctx, false, ldr);
- }
- }
+ List<byte[]> argsBytes = new ArrayList<>(args.length);
+
+ for (Object arg : args)
+ argsBytes.add(arg == null ? null : U.marshal(marsh, arg));
+
+ return argsBytes;
}
/**
* @param args Arguments to marshal.
* @param ctx Context.
- * @return Marshalled collection.
* @throws IgniteCheckedException If failed.
*/
- @Nullable protected final byte[][] marshalInvokeArguments(@Nullable
Object[] args, GridCacheContext ctx)
+ public final void deployInvokeArguments(@Nullable Object[] args, @Nullable
GridCacheContext ctx)
throws IgniteCheckedException {
- assert ctx != null;
-
- if (args == null || args.length == 0)
- return null;
-
- byte[][] argsBytes = new byte[args.length][];
+ if (ctx == null || args == null)
+ return;
for (int i = 0; i < args.length; i++) {
Object arg = args[i];
if (addDepInfo)
- prepareObject(arg, ctx.shared());
-
- argsBytes[i] = arg == null ? null : CU.marshal(ctx, arg);
+ deployObject(arg, ctx.shared());
}
-
- return argsBytes;
}
-
/**
* @param byteCol Collection to unmarshal.
- * @param ctx Context.
+ * @param marsh Marshaller.
* @param ldr Loader.
* @return Unmarshalled collection.
* @throws IgniteCheckedException If failed.
*/
- @Nullable protected final Object[] unmarshalInvokeArguments(@Nullable
byte[][] byteCol,
- GridCacheSharedContext ctx,
+ @Nullable protected final Object[] unmarshalInvokeArguments(@Nullable
List<byte[]> byteCol,
+ Marshaller marsh,
ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
if (byteCol == null)
return null;
- Object[] args = new Object[byteCol.length];
+ Object[] args = new Object[byteCol.size()];
- Marshaller marsh = ctx.marshaller();
+ int i = 0;
- for (int i = 0; i < byteCol.length; i++)
- args[i] = byteCol[i] == null ? null : U.unmarshal(marsh,
byteCol[i], U.resolveClassLoader(ldr, ctx.gridConfig()));
+ for (byte[] bytes : byteCol)
+ args[i++] = bytes == null ? null : U.unmarshal(marsh, bytes, ldr);
return args;
}
/**
* @param col Collection to marshal.
- * @param ctx Context.
+ * @param marsh Marshaller.
* @return Marshalled collection.
* @throws IgniteCheckedException If failed.
*/
- @Nullable protected List<byte[]> marshalCollection(@Nullable Collection<?>
col,
- GridCacheContext ctx) throws IgniteCheckedException {
- assert ctx != null;
-
+ @Nullable protected List<byte[]> marshallCollection(@Nullable
Collection<?> col, Marshaller marsh) throws IgniteCheckedException {
if (col == null)
return null;
List<byte[]> byteCol = new ArrayList<>(col.size());
- for (Object o : col) {
- if (addDepInfo)
- prepareObject(o, ctx.shared());
-
- byteCol.add(o == null ? null : CU.marshal(ctx, o));
- }
+ for (Object o : col)
+ byteCol.add(o == null ? null : U.marshal(marsh, o));
return byteCol;
}
/**
- * @param col Collection.
- * @param ctx Cache context.
+ * Deploys each element of {@code col} via {@link #deployObject} on each
item.
+ *
+ * @param col Collection to marshal.
+ * @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- @SuppressWarnings("ForLoopReplaceableByForEach")
- public final void prepareMarshalCacheObjects(@Nullable List<? extends
CacheObject> col,
- GridCacheContext ctx) throws IgniteCheckedException {
- if (col == null)
+ public final void deployCollection(@Nullable Collection<?> col,
Review Comment:
```suggestion
public final void deployCollection(@Nullable Collection<?> col,
@Nullable GridCacheContext<?, ?> ctx)
throws IgniteCheckedException {
```
##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java:
##########
@@ -241,8 +239,8 @@ public long responseReceivedTsMillis() {
}
/**
- * This method is called to initialize tracing variables.
- * TODO: introduce direct message lifecycle API?
+ * Captures the receive timestamp. Invoked by {@code GridIoManager} right
after the message is received,
Review Comment:
`received timestamp.`?
##########
modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.plugin.extensions.communication;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that
requires custom serialization.
Review Comment:
`{@code marshal}/{@code unmarshal}` -> `{@code marshall}/{@code unmarshall}`
?
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java:
##########
@@ -262,370 +270,234 @@ public GridDeploymentInfoBean deployInfo() {
return depInfo;
}
- /**
- * This method is called before the whole message is serialized
- * and is responsible for pre-marshalling state.
- *
- * @param ctx Cache context.
- * @throws IgniteCheckedException If failed.
- */
- public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws
IgniteCheckedException {
- // No-op.
- }
-
- /**
- * This method is called after the message is deserialized and is
responsible for
- * unmarshalling state marshalled in {@link
#prepareMarshal(GridCacheSharedContext)} method.
- *
- * @param ctx Context.
- * @param ldr Class loader.
- * @throws IgniteCheckedException If failed.
- */
- public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader
ldr) throws IgniteCheckedException {
- // No-op.
- }
-
/**
* @param info Entry to marshal.
* @param ctx Context.
* @param cacheObjCtx Cache object context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfo(GridCacheEntryInfo info,
+ public final void deployInfo(GridCacheEntryInfo info,
GridCacheSharedContext ctx,
CacheObjectContext cacheObjCtx
) throws IgniteCheckedException {
assert ctx != null;
if (info != null) {
- info.marshal(cacheObjCtx);
-
if (addDepInfo) {
if (info.key() != null)
- prepareObject(info.key().value(cacheObjCtx, false), ctx);
+ deployObject(info.key().value(cacheObjCtx, false), ctx);
CacheObject val = info.value();
if (val != null) {
- val.finishUnmarshal(cacheObjCtx,
ctx.deploy().globalLoader());
+ val.unmarshal(cacheObjCtx, ctx.deploy().globalLoader());
- prepareObject(val.value(cacheObjCtx, false), ctx);
+ deployObject(val.value(cacheObjCtx, false), ctx);
}
}
}
}
- /**
- * @param info Entry to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfo(GridCacheEntryInfo info,
GridCacheContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (info != null)
- info.unmarshal(ctx.cacheObjectContext(), ldr);
+ /** Deploys all {@code infos}, resolving shared and cache-object contexts
from {@code cctx}; no-op when {@code cctx} is absent. */
+ public final void deployInfos(@Nullable Iterable<? extends
GridCacheEntryInfo> infos, @Nullable GridCacheContext cctx)
+ throws IgniteCheckedException {
+ if (cctx != null)
+ deployInfos(infos, cctx.shared(), cctx.cacheObjectContext());
}
/**
* @param infos Entries to marshal.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalInfos(
- Iterable<? extends GridCacheEntryInfo> infos,
- GridCacheSharedContext ctx,
- CacheObjectContext cacheObjCtx
- ) throws IgniteCheckedException {
+ final void deployInfos(Iterable<? extends GridCacheEntryInfo> infos,
GridCacheSharedContext ctx,
+ CacheObjectContext cacheObjCtx) throws IgniteCheckedException {
assert ctx != null;
if (infos != null)
for (GridCacheEntryInfo e : infos)
- marshalInfo(e, ctx, cacheObjCtx);
- }
-
- /**
- * @param infos Entries to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
- * @throws IgniteCheckedException If failed.
- */
- protected final void unmarshalInfos(Iterable<? extends GridCacheEntryInfo>
infos,
- GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
- if (infos != null)
- for (GridCacheEntryInfo e : infos)
- unmarshalInfo(e, ctx, ldr);
+ deployInfo(e, ctx, cacheObjCtx);
}
/**
* @param txEntries Entries to marshal.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void marshalTx(Iterable<IgniteTxEntry> txEntries,
GridCacheSharedContext ctx)
+ public final void deployTx(Iterable<IgniteTxEntry> txEntries,
GridCacheSharedContext ctx)
throws IgniteCheckedException {
assert ctx != null;
if (txEntries != null) {
- boolean transferExpiry = transferExpiryPolicy();
boolean p2pEnabled = ctx.deploymentEnabled();
for (IgniteTxEntry e : txEntries) {
- e.marshal(ctx, transferExpiry);
-
GridCacheContext cctx = e.context();
if (addDepInfo) {
if (e.key() != null)
- prepareObject(e.key().value(cctx.cacheObjectContext(),
false), ctx);
+ deployObject(e.key().value(cctx.cacheObjectContext(),
false), ctx);
if (e.value() != null)
-
prepareObject(e.value().value(cctx.cacheObjectContext(), false), ctx);
+
deployObject(e.value().value(cctx.cacheObjectContext(), false), ctx);
if (e.entryProcessors() != null) {
for (T2<EntryProcessor<Object, Object, Object>,
Object[]> entProc : e.entryProcessors())
- prepareObject(entProc.get1(), ctx);
+ deployObject(entProc.get1(), ctx);
}
}
else if (p2pEnabled && e.entryProcessors() != null) {
if (!forceAddDepInfo)
forceAddDepInfo = true;
for (T2<EntryProcessor<Object, Object, Object>, Object[]>
entProc : e.entryProcessors())
- prepareObject(entProc.get1(), ctx);
+ deployObject(entProc.get1(), ctx);
}
}
}
}
/**
- * @return {@code True} if entries expire policy should be marshalled.
- */
- protected boolean transferExpiryPolicy() {
- return false;
- }
-
- /**
- * @param txEntries Entries to unmarshal.
- * @param ctx Context.
- * @param ldr Loader.
+ * @param args Arguments to marshal.
+ * @param marsh Marshaller.
+ * @return Marshalled collection.
* @throws IgniteCheckedException If failed.
*/
- protected final void unmarshalTx(Iterable<IgniteTxEntry> txEntries,
- GridCacheSharedContext ctx,
- ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
+ @Nullable protected final List<byte[]> marshallInvokeArguments(@Nullable
Object[] args, Marshaller marsh)
+ throws IgniteCheckedException {
- if (txEntries != null) {
- for (IgniteTxEntry e : txEntries) {
- e.prepareUnmarshal(ctx, topologyVersion(), false);
+ if (args == null || args.length == 0)
+ return null;
- e.unmarshal(ctx, false, ldr);
- }
- }
+ List<byte[]> argsBytes = new ArrayList<>(args.length);
+
+ for (Object arg : args)
+ argsBytes.add(arg == null ? null : U.marshal(marsh, arg));
+
+ return argsBytes;
}
/**
* @param args Arguments to marshal.
* @param ctx Context.
- * @return Marshalled collection.
* @throws IgniteCheckedException If failed.
*/
- @Nullable protected final byte[][] marshalInvokeArguments(@Nullable
Object[] args, GridCacheContext ctx)
+ public final void deployInvokeArguments(@Nullable Object[] args, @Nullable
GridCacheContext ctx)
throws IgniteCheckedException {
- assert ctx != null;
-
- if (args == null || args.length == 0)
- return null;
-
- byte[][] argsBytes = new byte[args.length][];
+ if (ctx == null || args == null)
+ return;
for (int i = 0; i < args.length; i++) {
Object arg = args[i];
if (addDepInfo)
- prepareObject(arg, ctx.shared());
-
- argsBytes[i] = arg == null ? null : CU.marshal(ctx, arg);
+ deployObject(arg, ctx.shared());
}
-
- return argsBytes;
}
-
/**
* @param byteCol Collection to unmarshal.
- * @param ctx Context.
+ * @param marsh Marshaller.
* @param ldr Loader.
* @return Unmarshalled collection.
* @throws IgniteCheckedException If failed.
*/
- @Nullable protected final Object[] unmarshalInvokeArguments(@Nullable
byte[][] byteCol,
- GridCacheSharedContext ctx,
+ @Nullable protected final Object[] unmarshalInvokeArguments(@Nullable
List<byte[]> byteCol,
+ Marshaller marsh,
ClassLoader ldr) throws IgniteCheckedException {
- assert ldr != null;
- assert ctx != null;
-
if (byteCol == null)
return null;
- Object[] args = new Object[byteCol.length];
+ Object[] args = new Object[byteCol.size()];
- Marshaller marsh = ctx.marshaller();
+ int i = 0;
- for (int i = 0; i < byteCol.length; i++)
- args[i] = byteCol[i] == null ? null : U.unmarshal(marsh,
byteCol[i], U.resolveClassLoader(ldr, ctx.gridConfig()));
+ for (byte[] bytes : byteCol)
+ args[i++] = bytes == null ? null : U.unmarshal(marsh, bytes, ldr);
return args;
}
/**
* @param col Collection to marshal.
- * @param ctx Context.
+ * @param marsh Marshaller.
* @return Marshalled collection.
* @throws IgniteCheckedException If failed.
*/
- @Nullable protected List<byte[]> marshalCollection(@Nullable Collection<?>
col,
- GridCacheContext ctx) throws IgniteCheckedException {
- assert ctx != null;
-
+ @Nullable protected List<byte[]> marshallCollection(@Nullable
Collection<?> col, Marshaller marsh) throws IgniteCheckedException {
if (col == null)
return null;
List<byte[]> byteCol = new ArrayList<>(col.size());
- for (Object o : col) {
- if (addDepInfo)
- prepareObject(o, ctx.shared());
-
- byteCol.add(o == null ? null : CU.marshal(ctx, o));
- }
+ for (Object o : col)
+ byteCol.add(o == null ? null : U.marshal(marsh, o));
return byteCol;
}
/**
- * @param col Collection.
- * @param ctx Cache context.
+ * Deploys each element of {@code col} via {@link #deployObject} on each
item.
+ *
+ * @param col Collection to marshal.
+ * @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- @SuppressWarnings("ForLoopReplaceableByForEach")
- public final void prepareMarshalCacheObjects(@Nullable List<? extends
CacheObject> col,
- GridCacheContext ctx) throws IgniteCheckedException {
- if (col == null)
+ public final void deployCollection(@Nullable Collection<?> col,
+ @Nullable GridCacheContext ctx) throws IgniteCheckedException {
+ if (ctx == null || col == null)
return;
- int size = col.size();
-
- for (int i = 0; i < size; i++)
- prepareMarshalCacheObject(col.get(i), ctx);
+ for (Object o : col) {
+ if (addDepInfo)
+ deployObject(o, ctx.shared());
+ }
}
/**
* @param obj Object.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
- protected final void prepareMarshalCacheObject(CacheObject obj,
GridCacheContext ctx) throws IgniteCheckedException {
- if (obj != null) {
- obj.prepareMarshal(ctx.cacheObjectContext());
-
- if (addDepInfo)
- prepareObject(obj.value(ctx.cacheObjectContext(), false),
ctx.shared());
- }
+ public final void deployCacheObject(@Nullable CacheObject obj, @Nullable
GridCacheContext ctx) throws IgniteCheckedException {
+ if (ctx != null && obj != null && addDepInfo)
+ deployObject(obj.value(ctx.cacheObjectContext(), false),
ctx.shared());
}
/**
* @param col Collection.
* @param ctx Cache context.
* @throws IgniteCheckedException If failed.
*/
- protected final void prepareMarshalCacheObjects(@Nullable Collection<?
extends CacheObject> col,
- GridCacheContext ctx) throws IgniteCheckedException {
- if (col == null)
+ public final void deployCacheObjects(@Nullable Collection<? extends
CacheObject> col,
+ @Nullable GridCacheContext ctx) throws IgniteCheckedException {
+ if (col == null || ctx == null)
Review Comment:
```suggestion
if (col == null || ctx == null || !addDepInfo)
return;
for (CacheObject obj : col) {
if (obj != null)
deployObject(obj.value(ctx.cacheObjectContext(), false),
ctx.shared());
}
```
##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java:
##########
@@ -241,8 +239,8 @@ public long responseReceivedTsMillis() {
}
/**
- * This method is called to initialize tracing variables.
- * TODO: introduce direct message lifecycle API?
+ * Captures the receive timestamp. Invoked by {@code GridIoManager} right
after the message is received,
Review Comment:
Suggestion: let's remove the part `Invoked by {@code GridIoManager} right
after the message is received...`. The method is public. Anyone can call it.
##########
modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.plugin.extensions.communication;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that
requires custom serialization.
Review Comment:
`for a {@link Message} type` -> `for a {@link Message}` ?
##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java:
##########
@@ -259,8 +257,8 @@ public void onAfterRead() {
}
/**
- * This method is called to initialize tracing variables.
- * TODO: introduce direct message lifecycle API?
+ * Captures the send timestamp. Invoked by {@code GridIoManager} right
before the message is sent,
Review Comment:
Suggestion: let's remove the part `Invoked by {@code GridIoManager} ...`.
The method is public. Anyone can call it.
##########
modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.plugin.extensions.communication;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that
requires custom serialization.
+ *
+ * @param <M> Message type.
+ */
+public interface MessageMarshaller<M extends Message> {
+ /**
+ * Marshals the message on the user thread before sending.
+ *
+ * @param msg Message to marshal.
Review Comment:
`marshal` -> `marshall` ? In the other places too. Same for `unmarshal`.
Lets search th code for these exact notations.
##########
modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.plugin.extensions.communication;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that
requires custom serialization.
+ *
+ * @param <M> Message type.
+ */
+public interface MessageMarshaller<M extends Message> {
+ /**
+ * Marshals the message on the user thread before sending.
+ *
+ * @param msg Message to marshal.
+ * @param kctx Kernal context.
+ * @param nested Cache object context, or {@code null} if not applicable.
+ */
+ public void marshal(M msg, GridKernalContext kctx, @Nullable
CacheObjectContext nested)
+ throws IgniteCheckedException;
+
+ /**
+ * Unmarshals the message with full cache context and class loader.
Review Comment:
`Unmarshals` -> `Unmarshalls` ? In other places too.
##########
modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.plugin.extensions.communication;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that
requires custom serialization.
+ *
+ * @param <M> Message type.
+ */
+public interface MessageMarshaller<M extends Message> {
+ /**
+ * Marshals the message on the user thread before sending.
+ *
+ * @param msg Message to marshal.
+ * @param kctx Kernal context.
+ * @param nested Cache object context, or {@code null} if not applicable.
+ */
+ public void marshal(M msg, GridKernalContext kctx, @Nullable
CacheObjectContext nested)
Review Comment:
`marshal(...)` -> `marshall(...)` ? In the other places too. Same for
`unmarshal(...)`. Lets search th code for these exact notations.
##########
modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.plugin.extensions.communication;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that
requires custom serialization.
+ *
+ * @param <M> Message type.
+ */
+public interface MessageMarshaller<M extends Message> {
+ /**
+ * Marshals the message on the user thread before sending.
+ *
+ * @param msg Message to marshal.
+ * @param kctx Kernal context.
+ * @param nested Cache object context, or {@code null} if not applicable.
+ */
+ public void marshal(M msg, GridKernalContext kctx, @Nullable
CacheObjectContext nested)
Review Comment:
Suggestion: `nested` -> to smth. like `coCtx` or `cacheCtx` or `cacheObjCtx`.
##########
modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.plugin.extensions.communication;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that
requires custom serialization.
+ *
+ * @param <M> Message type.
+ */
+public interface MessageMarshaller<M extends Message> {
+ /**
+ * Marshals the message on the user thread before sending.
+ *
+ * @param msg Message to marshal.
+ * @param kctx Kernal context.
+ * @param nested Cache object context, or {@code null} if not applicable.
+ */
+ public void marshal(M msg, GridKernalContext kctx, @Nullable
CacheObjectContext nested)
+ throws IgniteCheckedException;
+
+ /**
+ * Unmarshals the message with full cache context and class loader.
+ *
+ * @param msg Message to unmarshal.
+ * @param kctx Kernal context.
+ * @param nested Cache object context, or {@code null} if not applicable.
+ * @param clsLdr Class loader for unmarshalling.
+ */
+ public void unmarshal(M msg, GridKernalContext kctx, @Nullable
CacheObjectContext nested, ClassLoader clsLdr)
+ throws IgniteCheckedException;
+
+ /**
+ * Unmarshals the message without a cache context, using the configuration
class loader — the cache-free receive
+ * path (e.g. the generic {@code GridIoManager} pass). Delegates to the
cache-aware overload with a {@code null}
+ * context, so per-message marshallers need only implement the cache-aware
method.
+ *
+ * @param msg Message to unmarshal.
+ * @param kctx Kernal context.
+ */
+ default void unmarshal(M msg, GridKernalContext kctx) throws
IgniteCheckedException {
+ unmarshal(msg, kctx, null, U.resolveClassLoader(kctx.config()));
+ }
+
+ /**
+ * Unmarshals only {@code @NioField}-annotated fields in the NIO/IO
thread. No-op by default.
+ *
+ * @param msg Message to unmarshal.
+ * @param kctx Kernal context.
+ */
+ default void unmarshalNio(M msg, GridKernalContext kctx) throws
IgniteCheckedException {
+ }
+
+ /**
+ * Null-safe {@code unmarshalNio} — skips when no marshaller is registered.
+ *
+ * @param <M> Message type.
+ * @param factory Message factory.
+ * @param msg Message to unmarshal.
+ * @param kctx Kernal context.
+ */
+ static <M extends Message> void unmarshalNio(MessageFactory factory, M
msg, GridKernalContext kctx)
Review Comment:
`factory` is always `kctx.messageFactory()`.
##########
modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.plugin.extensions.communication;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that
requires custom serialization.
+ *
+ * @param <M> Message type.
Review Comment:
Suggestion: `Message type` -> `A {@link Message}` or A message.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]