From 8e8bb8f793f507220f18137898fbf454d99af5a9 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 30 Apr 2026 14:10:14 +0300 Subject: [PATCH 001/215] WIP --- .../internal/MessageSerializerGenerator.java | 527 +++++++++++++++++- .../processors/cache/GridCacheIoManager.java | 20 + .../GridCacheTtlUpdateRequest.java | 11 - .../GridDistributedLockRequest.java | 10 - .../GridDistributedLockResponse.java | 8 - .../distributed/GridNearUnlockRequest.java | 8 - .../distributed/dht/GridDhtUnlockRequest.java | 7 - .../dht/atomic/GridDhtAtomicNearResponse.java | 8 - .../atomic/GridDhtAtomicUpdateRequest.java | 10 - .../atomic/GridDhtAtomicUpdateResponse.java | 15 - .../GridNearAtomicFullUpdateRequest.java | 2 - .../GridNearAtomicSingleUpdateRequest.java | 12 - .../atomic/GridNearAtomicUpdateResponse.java | 6 - .../distributed/dht/atomic/UpdateErrors.java | 5 - .../preloader/GridDhtForceKeysRequest.java | 9 - .../preloader/GridDhtForceKeysResponse.java | 3 - .../distributed/near/GridNearGetRequest.java | 16 - .../communication/MessageSerializer.java | 24 +- .../codegen/MessageProcessorTest.java | 30 + .../codegen/KeyCacheObjectEntryMsg.java | 35 ++ .../KeyCacheObjectEntryMsgSerializer.java | 95 ++++ .../TestCollectionsMessageSerializer.java | 67 ++- .../TestKeyCacheObjectCollectionMessage.java | 34 ++ ...acheObjectCollectionMessageSerializer.java | 112 ++++ .../codegen/TestMapKeyCacheObjectMessage.java | 33 ++ ...estMapKeyCacheObjectMessageSerializer.java | 94 ++++ .../codegen/TestMapMessageSerializer.java | 67 ++- .../codegen/TestMessageSerializer.java | 31 +- 28 files changed, 1110 insertions(+), 189 deletions(-) create mode 100644 modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsg.java create mode 100644 modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsgSerializer.java create mode 100644 modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessage.java create mode 100644 modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessageSerializer.java create mode 100644 modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessage.java create mode 100644 modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessageSerializer.java diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 7874b5dcd8c42..0b869c96e6e51 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -38,6 +38,7 @@ import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; +import javax.lang.model.element.Modifier; import javax.lang.model.element.QualifiedNameable; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; @@ -74,7 +75,7 @@ public class MessageSerializerGenerator { public static final String NL = System.lineSeparator(); /** */ - private static final String CLS_JAVADOC = "/** " + NL + + private static final String CLS_JAVADOC = "/**" + NL + " * This class is generated automatically." + NL + " *" + NL + " * @see org.apache.ignite.internal.MessageProcessor" + NL + @@ -114,6 +115,12 @@ public class MessageSerializerGenerator { /** The marshallable message type. */ private final TypeMirror marshallableMsgType; + /** */ + private final List prepareCacheObjects = new ArrayList<>(); + + /** Map of {@code } for recursion into nested messages. */ + private final LinkedHashMap nestedSerializerFields = new LinkedHashMap<>(); + /** */ private int indent; @@ -189,9 +196,14 @@ private String generateSerializerCode(String serClsName) throws IOException { writer.write(TAB + "}" + NL); - writer.write("}"); + if (!prepareCacheObjects.isEmpty()) { + writer.write(NL); - writer.write(NL); + for (String p: prepareCacheObjects) + writer.write(p + NL); + } + + writer.write("}"); return writer.toString(); } @@ -242,6 +254,515 @@ private void generateMethods(List fields) throws Exception { finish(write, false, false); finish(read, true, marshallableMessage()); + + generateCacheObjectMethods(fields); + } + + /** */ + private void generateCacheObjectMethods(List orderedFields) throws Exception { + List traversable = new ArrayList<>(); + + for (VariableElement field: orderedFields) { + if (classify(field.asType()) != FieldKind.SKIP) + traversable.add(field); + } + + if (traversable.isEmpty()) + return; + + imports.add("org.apache.ignite.IgniteCheckedException"); + imports.add("org.apache.ignite.internal.processors.cache.CacheObjectValueContext"); + imports.add("org.apache.ignite.internal.processors.cache.GridCacheSharedContext"); + + startCacheObjectMethod(prepareCacheObjects); + + indent++; + + boolean first = true; + + for (VariableElement field: traversable) { + if (!first) + prepareCacheObjects.add(EMPTY); + + emitCacheObjectCall(prepareCacheObjects, field); + + first = false; + } + + indent--; + + prepareCacheObjects.add(identedLine("}")); + + for (Map.Entry e : nestedSerializerFields.entrySet()) { + imports.add(e.getValue()); + + String serSimple = e.getValue().substring(e.getValue().lastIndexOf('.') + 1); + + fields.add("private final static " + serSimple + " " + e.getKey() + " = new " + serSimple + "();"); + } + } + + /** Traversal kinds for {@link #generateCacheObjectMethods}. */ + private enum FieldKind { + /** {@code CacheObject} / {@code KeyCacheObject} scalar. */ + CO, + /** {@code Collection} / {@code Collection}. */ + CO_COLL, + /** {@code CacheObject[]} / {@code KeyCacheObject[]}. */ + CO_ARR, + /** Nested concrete {@code Message}. */ + MSG, + /** {@code Collection} with concrete element type. */ + MSG_COLL, + /** {@code Message[]} with concrete component type. */ + MSG_ARR, + /** {@code Map} with at least one CO/Message side. */ + MAP, + /** Skipped — abstract Message, cross-cache nested Message, Map with no traversable side, unsupported. */ + SKIP + } + + /** */ + private FieldKind classify(TypeMirror t) { + if (t.getKind() == TypeKind.ARRAY) { + TypeMirror comp = ((ArrayType)t).getComponentType(); + + if (comp.getKind() != TypeKind.DECLARED) + return FieldKind.SKIP; + + if (isCacheObjectType(comp)) + return FieldKind.CO_ARR; + + return isRecursableMessage(comp) ? FieldKind.MSG_ARR : FieldKind.SKIP; + } + + if (t.getKind() != TypeKind.DECLARED) + return FieldKind.SKIP; + + if (isCacheObjectType(t)) + return FieldKind.CO; + + if (assignableFrom(erasedType(t), type(Map.class.getName()))) { + List args = ((DeclaredType)t).getTypeArguments(); + + if (args.size() != 2) + return FieldKind.SKIP; + + FieldKind kSide = classifyMapSide(args.get(0)); + FieldKind vSide = classifyMapSide(args.get(1)); + + if (kSide == FieldKind.SKIP && vSide == FieldKind.SKIP) + return FieldKind.SKIP; + + return FieldKind.MAP; + } + + if (assignableFrom(erasedType(t), type(Collection.class.getName()))) { + List args = ((DeclaredType)t).getTypeArguments(); + + if (args.size() != 1) + return FieldKind.SKIP; + + TypeMirror arg = args.get(0); + + if (arg.getKind() != TypeKind.DECLARED) + return FieldKind.SKIP; + + if (isCacheObjectType(arg)) + return FieldKind.CO_COLL; + + return isRecursableMessage(arg) ? FieldKind.MSG_COLL : FieldKind.SKIP; + } + + return isRecursableMessage(t) ? FieldKind.MSG : FieldKind.SKIP; + } + + /** Classifies one side (key or value) of a {@code Map} field: {@link FieldKind#CO}, {@link FieldKind#MSG}, or + * {@link FieldKind#SKIP}. */ + private FieldKind classifyMapSide(TypeMirror t) { + if (t.getKind() != TypeKind.DECLARED) + return FieldKind.SKIP; + + if (isCacheObjectType(t)) + return FieldKind.CO; + + return isRecursableMessage(t) ? FieldKind.MSG : FieldKind.SKIP; + } + + /** */ + private boolean isCacheObjectType(TypeMirror type) { + return assignableFrom(type, type("org.apache.ignite.internal.processors.cache.CacheObject")); + } + + /** True if {@code t} is a concrete non-abstract {@code Message} safe to recurse into (no self-ref). */ + private boolean isRecursableMessage(TypeMirror t) { + TypeMirror msgIface = type(MESSAGE_INTERFACE); + + if (msgIface == null || !assignableFrom(t, msgIface)) + return false; + + if (assignableFrom(t, marshallableMsgType)) + return false; + + Element el = env.getTypeUtils().asElement(t); + + if (!(el instanceof TypeElement)) + return false; + + TypeElement te = (TypeElement)el; + + if (te.getKind() != ElementKind.CLASS) + return false; + + if (te.getModifiers().contains(Modifier.ABSTRACT)) + return false; + + return !te.equals(type); + } + + /** True if {@code te} extends {@code GridCacheIdMessage} and therefore carries its own per-cache {@code cacheId()}. */ + private boolean isCacheIdMessage(TypeElement te) { + return assignableFrom(te.asType(), type("org.apache.ignite.internal.processors.cache.GridCacheIdMessage")); + } + + /** */ + private void startCacheObjectMethod(List code) { + indent = 1; + + code.add(identedLine(METHOD_JAVADOC)); + + code.add(identedLine( + "@Override public void prepareMarshalCacheObjects(" + type.getSimpleName() + + " msg, CacheObjectValueContext ctx, GridCacheSharedContext sharedCtx) throws IgniteCheckedException {")); + } + + /** */ + private void emitCacheObjectCall(List code, VariableElement field) { + String accessor = fieldAccessor(field); + TypeMirror t = field.asType(); + FieldKind kind = classify(t); + + switch (kind) { + case CO: + emitCoDirect(code, accessor); + break; + + case CO_COLL: + case CO_ARR: + emitCoIterable(code, accessor, t, kind == FieldKind.CO_ARR); + break; + + case MSG: + emitMsgDirect(code, accessor, (DeclaredType)t); + break; + + case MSG_COLL: + emitMsgIterable(code, accessor, (DeclaredType)((DeclaredType)t).getTypeArguments().get(0)); + break; + + case MSG_ARR: + emitMsgIterable(code, accessor, (DeclaredType)((ArrayType)t).getComponentType()); + break; + + case MAP: + emitMapTraversal(code, accessor, (DeclaredType)t); + break; + + default: + throw new IllegalStateException("Unexpected kind: " + kind); + } + } + + /** */ + private void emitMapTraversal(List code, String accessor, DeclaredType mapType) { + List args = mapType.getTypeArguments(); + + TypeMirror keyT = args.get(0); + TypeMirror valT = args.get(1); + + FieldKind kSide = classifyMapSide(keyT); + FieldKind vSide = classifyMapSide(valT); + + code.add(identedLine("if (%s != null) {", accessor)); + + indent++; + + if (kSide != FieldKind.SKIP) + emitMapSideIteration(code, accessor, keyT, kSide, true); + + if (kSide != FieldKind.SKIP && vSide != FieldKind.SKIP) + code.add(EMPTY); + + if (vSide != FieldKind.SKIP) + emitMapSideIteration(code, accessor, valT, vSide, false); + + indent--; + + code.add(identedLine("}")); + } + + /** */ + private void emitMapSideIteration( + List code, + String accessor, + TypeMirror sideType, + FieldKind sideKind, + boolean isKey + ) { + String side = accessor + (isKey ? ".keySet()" : ".values()"); + + String var = isKey ? "k" : "v"; + + if (sideKind == FieldKind.CO) { + String elementType = "org.apache.ignite.internal.processors.cache.KeyCacheObject"; + + if (!assignableFrom(sideType, type(elementType))) + elementType = "org.apache.ignite.internal.processors.cache.CacheObject"; + + imports.add(elementType); + + String simple = elementType.substring(elementType.lastIndexOf('.') + 1); + + code.add(identedLine("for (%s %s : %s) {", simple, var, side)); + + indent++; + + code.add(identedLine("if (%s != null)", var)); + + indent++; + + code.add(identedLine("%s.prepareMarshal(ctx);", var)); + + indent -= 2; + + code.add(identedLine("}")); + } + else { + assert sideKind == FieldKind.MSG : sideKind; + + DeclaredType msgType = (DeclaredType)sideType; + String serRef = nestedSerializerRef(msgType); + boolean cacheIdAware = isCacheIdMessage((TypeElement)msgType.asElement()); + String elemSimple = msgType.asElement().getSimpleName().toString(); + + imports.add(((TypeElement)msgType.asElement()).getQualifiedName().toString()); + + code.add(identedLine("for (%s %s : %s) {", elemSimple, var, side)); + + indent++; + + if (cacheIdAware) { + // Resolve per-element cacheId-aware ctx via sharedCtx. Skip if cache is not registered. + code.add(identedLine("if (%s != null) {", var)); + + indent++; + + code.add(identedLine("var nestedCtx = sharedCtx.cacheObjectContext(%s.cacheId());", var)); + + code.add(identedLine("if (nestedCtx != null)")); + + indent++; + + code.add(identedLine("%s.prepareMarshalCacheObjects(%s, nestedCtx, sharedCtx);", serRef, var)); + + indent -= 2; + + code.add(identedLine("}")); + } + else { + code.add(identedLine("if (%s != null)", var)); + + indent++; + + code.add(identedLine("%s.prepareMarshalCacheObjects(%s, ctx, sharedCtx);", serRef, var)); + + indent--; + } + + indent--; + + code.add(identedLine("}")); + } + } + + /** */ + private void emitCoDirect(List code, String accessor) { + code.add(identedLine("if (%s != null)", accessor)); + + indent++; + + code.add(identedLine("%s.prepareMarshal(ctx);", accessor)); + + indent--; + } + + /** */ + private void emitCoIterable(List code, String accessor, TypeMirror t, boolean isArr) { + String elementType = "org.apache.ignite.internal.processors.cache.KeyCacheObject"; + + TypeMirror elem = isArr ? ((ArrayType)t).getComponentType() : ((DeclaredType)t).getTypeArguments().get(0); + + if (!assignableFrom(elem, type(elementType))) + elementType = "org.apache.ignite.internal.processors.cache.CacheObject"; + + imports.add(elementType); + + String simple = elementType.substring(elementType.lastIndexOf('.') + 1); + + code.add(identedLine("if (%s != null) {", accessor)); + + indent++; + + code.add(identedLine("for (%s obj : %s) {", simple, accessor)); + + indent++; + + code.add(identedLine("if (obj != null)")); + + indent++; + + code.add(identedLine("obj.prepareMarshal(ctx);")); + + indent -= 2; + + code.add(identedLine("}")); + + indent--; + + code.add(identedLine("}")); + } + + /** */ + private void emitMsgDirect(List code, String accessor, DeclaredType msgType) { + String serRef = nestedSerializerRef(msgType); + boolean cacheIdAware = isCacheIdMessage((TypeElement)msgType.asElement()); + + if (cacheIdAware) { + // Resolve nested cacheId-aware ctx via sharedCtx. Skip if cache is not registered for the cacheId. + code.add(identedLine("if (%s != null) {", accessor)); + + indent++; + + code.add(identedLine("var nestedCtx = sharedCtx.cacheObjectContext(%s.cacheId());", accessor)); + + code.add(identedLine("if (nestedCtx != null)")); + + indent++; + + code.add(identedLine("%s.prepareMarshalCacheObjects(%s, nestedCtx, sharedCtx);", serRef, accessor)); + + indent -= 2; + + code.add(identedLine("}")); + } + else { + code.add(identedLine("if (%s != null)", accessor)); + + indent++; + + code.add(identedLine("%s.prepareMarshalCacheObjects(%s, ctx, sharedCtx);", serRef, accessor)); + + indent--; + } + } + + /** */ + private void emitMsgIterable(List code, String accessor, DeclaredType elemType) { + String serRef = nestedSerializerRef(elemType); + boolean cacheIdAware = isCacheIdMessage((TypeElement)elemType.asElement()); + + String elemSimple = elemType.asElement().getSimpleName().toString(); + + imports.add(((TypeElement)elemType.asElement()).getQualifiedName().toString()); + + code.add(identedLine("if (%s != null) {", accessor)); + + indent++; + + code.add(identedLine("for (%s e : %s) {", elemSimple, accessor)); + + indent++; + + if (cacheIdAware) { + // Resolve per-element cacheId-aware ctx via sharedCtx. Skip if cache is not registered. + code.add(identedLine("if (e != null) {")); + + indent++; + + code.add(identedLine("var nestedCtx = sharedCtx.cacheObjectContext(e.cacheId());")); + + code.add(identedLine("if (nestedCtx != null)")); + + indent++; + + code.add(identedLine("%s.prepareMarshalCacheObjects(e, nestedCtx, sharedCtx);", serRef)); + + indent -= 2; + + code.add(identedLine("}")); + } + else { + code.add(identedLine("if (e != null)")); + + indent++; + + code.add(identedLine("%s.prepareMarshalCacheObjects(e, ctx, sharedCtx);", serRef)); + + indent--; + } + + indent--; + + code.add(identedLine("}")); + + indent--; + + code.add(identedLine("}")); + } + + /** + * Returns the expression for a static instance of the nested message's generated serializer (e.g. + * {@code CacheInvokeDirectResultSerializer.INSTANCE}), registering the class to be emitted as a {@code private + * static final} field on the enclosing serializer. + */ + private String nestedSerializerRef(DeclaredType msgType) { + TypeElement el = (TypeElement)msgType.asElement(); + + String pkg = env.getElementUtils().getPackageOf(el).getQualifiedName().toString(); + String serSimple = el.getSimpleName() + "Serializer"; + String serFqn = pkg + "." + serSimple; + + String varName = camelToConstant(el.getSimpleName().toString()) + "_SER"; + + nestedSerializerFields.put(varName, serFqn); + + return varName; + } + + /** Converts {@code CacheInvokeDirectResult} to {@code CACHE_INVOKE_DIRECT_RESULT}. */ + private static String camelToConstant(String simple) { + StringBuilder sb = new StringBuilder(simple.length() + 8); + + for (int i = 0; i < simple.length(); i++) { + char c = simple.charAt(i); + + if (i > 0 && Character.isUpperCase(c) && !Character.isUpperCase(simple.charAt(i - 1))) + sb.append('_'); + + sb.append(Character.toUpperCase(c)); + } + + return sb.toString(); + } + + /** */ + private String fieldAccessor(VariableElement field) { + String name = field.getSimpleName().toString(); + + if (type.equals(field.getEnclosingElement())) + return "msg." + name; + + return "((" + field.getEnclosingElement().getSimpleName() + ")msg)." + name; } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index 5c639d08b2596..fa7710cf7e4a5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -91,6 +91,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; @@ -1150,6 +1151,8 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I if (destNodeId == null || !cctx.localNodeId().equals(destNodeId)) { msg.prepareMarshal(cctx); + prepareMarshalGeneratedCacheObjects(msg); + if (msg instanceof GridCacheDeployable && msg.addDeploymentInfo()) cctx.deploy().prepare((GridCacheDeployable)msg); } @@ -1157,6 +1160,23 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I return true; } + /** */ + @SuppressWarnings({"unchecked", "rawtypes"}) + private void prepareMarshalGeneratedCacheObjects(GridCacheMessage msg) throws IgniteCheckedException { + if (!(msg instanceof GridCacheIdMessage)) + return; + + CacheObjectContext cacheObjCtx = cctx.cacheObjectContext(((GridCacheIdMessage)msg).cacheId()); + + if (cacheObjCtx == null) + return; + + MessageSerializer ser = cctx.gridIO().messageFactory().serializer(msg.directType()); + + if (ser != null) + ser.prepareMarshalCacheObjects(msg, cacheObjCtx, cctx); + } + /** * @param nodeId Node ID. * @param sndErr Send error. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java index c83e732f6181a..3edaef8256731 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java @@ -155,17 +155,6 @@ public List nearVersions() { return nearVers; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareMarshalCacheObjects(keys, cctx); - - prepareMarshalCacheObjects(nearKeys, cctx); - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index b02d75024fec5..ad67d52fff18f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -346,16 +346,6 @@ public long timeout() { return ctx.txLockMessageLogger(); } - /** {@inheritDoc} - * @param ctx*/ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareMarshalCacheObjects(keys, cctx); - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java index cbf10745a7a19..03000227d06c2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java @@ -159,14 +159,6 @@ protected int valuesSize() { return ctx.txLockMessageLogger(); } - /** {@inheritDoc} - * @param ctx*/ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - prepareMarshalCacheObjects(vals, ctx.cacheContext(cacheId)); - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java index 7f46f96774850..2fb7c3daf9226 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java @@ -93,14 +93,6 @@ public void addKey(KeyCacheObject key) { return keys != null && !keys.isEmpty() ? keys.get(0).partition() : -1; } - /** {@inheritDoc} - * @param ctx*/ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - prepareMarshalCacheObjects(keys, ctx.cacheContext(cacheId)); - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index 8c5fc051a69e7..dbc831076f5de 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -70,13 +70,6 @@ public void addNearKey(KeyCacheObject key) nearKeys.add(key); } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - prepareMarshalCacheObjects(nearKeys, ctx.cacheContext(cacheId)); - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java index f71e035bdac94..bdb7717e85bf8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java @@ -171,14 +171,6 @@ public long futureId() { return false; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - if (errs != null) - errs.prepareMarshal(this, ctx.cacheContext(cacheId)); - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 4d06d1705daaf..ede157f28af63 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -467,16 +467,6 @@ else if (conflictVers != null) GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareMarshalCacheObjects(keys, cctx); - - prepareMarshalCacheObjects(vals, cctx); - - prepareMarshalCacheObjects(nearKeys, cctx); - - prepareMarshalCacheObjects(nearVals, cctx); - - prepareMarshalCacheObjects(prevVals, cctx); - if (forceTransformBackups) { // force addition of deployment info for entry processors if P2P is enabled globally. if (!addDepInfo && ctx.deploymentEnabled()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index a63354bc634fa..c763930c2d154 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -118,21 +118,6 @@ public void nearEvicted(List nearEvicted) { return partId; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - // Can be null if client near cache was removed, in this case assume do not need prepareMarshal. - if (cctx != null) { - prepareMarshalCacheObjects(nearEvicted, cctx); - - if (errs != null) - errs.prepareMarshal(this, cctx); - } - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index 62fcf3966d916..c06365250a965 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -336,8 +336,6 @@ else if (conflictVers != null) if (expiryPlc != null && expiryPlcBytes == null) expiryPlcBytes = CU.marshal(cctx, new IgniteExternalizableExpiryPolicy(expiryPlc)); - prepareMarshalCacheObjects(keys, cctx); - if (filter != null) { boolean hasFilter = false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java index 25b31b062c7c3..394f003c14da6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java @@ -216,18 +216,6 @@ public GridNearAtomicSingleUpdateRequest() { return CU.EXPIRE_TIME_CALCULATE; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareMarshalCacheObject(key, cctx); - - if (val != null) - prepareMarshalCacheObject(val, cctx); - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index a1103fb308d55..38efb2c32037d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -344,14 +344,8 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { GridCacheContext cctx = ctx.cacheContext(cacheId); - if (errs != null) - errs.prepareMarshal(this, cctx); - if (nearUpdates != null) prepareMarshalCacheObjects(nearUpdates.nearValues(), cctx); - - if (ret != null) - ret.prepareMarshal(cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java index 0e42f82082251..d1e0d942c38f5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java @@ -115,11 +115,6 @@ void addFailedKeys(Collection keys, Throwable e) { errMsg.error().addSuppressed(e); } - /** */ - void prepareMarshal(GridCacheMessage msg, GridCacheContext cctx) throws IgniteCheckedException { - msg.prepareMarshalCacheObjects(failedKeys, cctx); - } - /** */ void finishUnmarshal(GridCacheMessage msg, GridCacheContext cctx, ClassLoader ldr) throws IgniteCheckedException { msg.finishUnmarshalCacheObjects(failedKeys, cctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 898ad4478f086..4628adfdabd3b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -113,15 +113,6 @@ public Collection keys() { return topVer; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareMarshalCacheObjects(keys, cctx); - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index cafcb5fa3e364..65e848ada854a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -137,9 +137,6 @@ public void addInfo(GridCacheEntryInfo info) { GridCacheContext cctx = ctx.cacheContext(cacheId); - if (missedKeys != null) - prepareMarshalCacheObjects(missedKeys, cctx); - if (infos != null) { for (GridCacheEntryInfo info : infos) info.marshal(cctx.cacheObjectContext()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index 74ad48394405d..da185e7aa3902 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -280,22 +280,6 @@ public long accessTtl() { return txLbl; } - /** - * @param ctx Cache context. - * @throws IgniteCheckedException If failed. - */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - assert ctx != null; - assert !F.isEmpty(keys); - assert readersFlags == null || keys.size() == readersFlags.size(); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareMarshalCacheObjects(keys, cctx); - } - /** * @param ctx Context. * @param ldr Loader. diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index 90df0601693c3..0dfa54286768a 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -17,9 +17,11 @@ package org.apache.ignite.plugin.extensions.communication; -/** - * Interface for message serialization logic. - */ +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; + +/** Message serialization logic. */ public interface MessageSerializer { /** * Writes this message to provided byte buffer. @@ -38,4 +40,20 @@ public interface MessageSerializer { * @return Whether message was fully read. */ public boolean readFrom(M msg, MessageReader reader); + + /** + * Runs {@code CacheObject.prepareMarshal} for {@code @Order} cache-object fields on the user thread, so the NIO + * worker never does it. Default is a no-op. The caller is responsible for guaranteeing that {@code ctx} is + * non-null when invoking this method; resolution-with-null-skip happens at call sites. + * + * @param msg Message instance. + * @param ctx Cache object value context for {@code msg}'s direct {@code CacheObject} fields and non-cacheId-aware + * nested messages. Always non-null. + * @param sharedCtx Shared cache context for resolving per-cache contexts of nested cacheId-aware messages. + * @throws IgniteCheckedException If marshalling fails. + */ + public default void prepareMarshalCacheObjects(M msg, CacheObjectValueContext ctx, GridCacheSharedContext sharedCtx) + throws IgniteCheckedException { + // No-op by default. + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java index e1e2e38dbbf5c..89fd3aae12c15 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java @@ -340,6 +340,36 @@ public void testCompressedMessageExplicitUsageFails() { assertThat(compilation).hadErrorContaining(errMsg); } + /** Collection-of-entries encoding of a {@code Map}: generator recurses into each entry's KCO. */ + @Test + public void testKeyCacheObjectInCollectionOfEntries() { + Compilation compilation = compile("KeyCacheObjectEntryMsg.java", "TestKeyCacheObjectCollectionMessage.java"); + + assertThat(compilation).succeeded(); + + assertEquals(2, compilation.generatedSourceFiles().size()); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.KeyCacheObjectEntryMsgSerializer") + .hasSourceEquivalentTo(javaFile("KeyCacheObjectEntryMsgSerializer.java")); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestKeyCacheObjectCollectionMessageSerializer") + .hasSourceEquivalentTo(javaFile("TestKeyCacheObjectCollectionMessageSerializer.java")); + } + +/** {@code @Order Map}: generator walks keys/values via {@code keySet()/values()}. */ + @Test + public void testMapWithKeyCacheObjectAndMessageValue() { + Compilation compilation = compile("TestMapKeyCacheObjectMessage.java"); + + assertThat(compilation).succeeded(); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMapKeyCacheObjectMessageSerializer") + .hasSourceEquivalentTo(javaFile("TestMapKeyCacheObjectMessageSerializer.java")); + } + /** * Negative test that verifies the compilation failed if the Compress annotation is used for unsupported types. */ diff --git a/modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsg.java b/modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsg.java new file mode 100644 index 0000000000000..80d23d2e6ad09 --- /dev/null +++ b/modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsg.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.plugin.extensions.communication.Message; + +/** APT fixture: entry Message for {@link TestKeyCacheObjectCollectionMessage}. */ +public class KeyCacheObjectEntryMsg implements Message { + @Order(0) + KeyCacheObject key; + + @Order(1) + GridCacheVersion val; + + public short directType() { + return 0; + } +} diff --git a/modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsgSerializer.java b/modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsgSerializer.java new file mode 100644 index 0000000000000..59e90a33c9ade --- /dev/null +++ b/modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsgSerializer.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.KeyCacheObjectEntryMsg; +import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersionSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageWriter; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class KeyCacheObjectEntryMsgSerializer implements MessageSerializer { + /** */ + private final static GridCacheVersionSerializer GRID_CACHE_VERSION_SER = new GridCacheVersionSerializer(); + + /** */ + @Override public boolean writeTo(KeyCacheObjectEntryMsg msg, MessageWriter writer) { + if (!writer.isHeaderWritten()) { + if (!writer.writeHeader(msg.directType())) + return false; + + writer.onHeaderWritten(); + } + + switch (writer.state()) { + case 0: + if (!writer.writeKeyCacheObject(msg.key)) + return false; + + writer.incrementState(); + + case 1: + if (!writer.writeMessage(msg.val)) + return false; + + writer.incrementState(); + } + + return true; + } + + /** */ + @Override public boolean readFrom(KeyCacheObjectEntryMsg msg, MessageReader reader) { + switch (reader.state()) { + case 0: + msg.key = reader.readKeyCacheObject(); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + + case 1: + msg.val = reader.readMessage(); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + } + + return true; + } + + /** */ + @Override public void prepareMarshalCacheObjects(KeyCacheObjectEntryMsg msg, CacheObjectValueContext ctx, GridCacheSharedContext sharedCtx) throws IgniteCheckedException { + if (msg.key != null) + msg.key.prepareMarshal(ctx); + + if (msg.val != null) + GRID_CACHE_VERSION_SER.prepareMarshalCacheObjects(msg.val, ctx, sharedCtx); + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java b/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java index 329f334337488..496d5c889d7e1 100644 --- a/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java @@ -17,7 +17,12 @@ package org.apache.ignite.internal; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.TestCollectionsMessage; +import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersionSerializer; import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; import org.apache.ignite.plugin.extensions.communication.MessageItemType; @@ -32,55 +37,57 @@ */ public class TestCollectionsMessageSerializer implements MessageSerializer { /** */ - private final static MessageCollectionType affTopVersionListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.AFFINITY_TOPOLOGY_VERSION), false); + private final static GridCacheVersionSerializer GRID_CACHE_VERSION_SER = new GridCacheVersionSerializer(); /** */ - private final static MessageCollectionType bitSetListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BIT_SET), false); + private static final MessageCollectionType affTopVersionListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.AFFINITY_TOPOLOGY_VERSION), false); /** */ - private final static MessageCollectionType bitSetSetCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BIT_SET), true); + private static final MessageCollectionType bitSetListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BIT_SET), false); /** */ - private final static MessageCollectionType booleanArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BOOLEAN_ARR), false); + private static final MessageCollectionType bitSetSetCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BIT_SET), true); /** */ - private final static MessageCollectionType boxedBooleanListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BOOLEAN), false); + private static final MessageCollectionType booleanArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BOOLEAN_ARR), false); /** */ - private final static MessageCollectionType boxedByteListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BYTE), false); + private static final MessageCollectionType boxedBooleanListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BOOLEAN), false); /** */ - private final static MessageCollectionType boxedCharListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.CHAR), false); + private static final MessageCollectionType boxedByteListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BYTE), false); /** */ - private final static MessageCollectionType boxedDoubleListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.DOUBLE), false); + private static final MessageCollectionType boxedCharListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.CHAR), false); /** */ - private final static MessageCollectionType boxedFloatListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.FLOAT), false); + private static final MessageCollectionType boxedDoubleListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.DOUBLE), false); /** */ - private final static MessageCollectionType boxedIntListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.INT), false); + private static final MessageCollectionType boxedFloatListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.FLOAT), false); /** */ - private final static MessageCollectionType boxedIntegerSetCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.INT), true); + private static final MessageCollectionType boxedIntListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.INT), false); /** */ - private final static MessageCollectionType boxedLongListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.LONG), false); + private static final MessageCollectionType boxedIntegerSetCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.INT), true); /** */ - private final static MessageCollectionType boxedShortListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.SHORT), false); + private static final MessageCollectionType boxedLongListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.LONG), false); /** */ - private final static MessageCollectionType byteArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BYTE_ARR), false); + private static final MessageCollectionType boxedShortListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.SHORT), false); /** */ - private final static MessageCollectionType charArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.CHAR_ARR), false); + private static final MessageCollectionType byteArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BYTE_ARR), false); /** */ - private final static MessageCollectionType doubleArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.DOUBLE_ARR), false); + private static final MessageCollectionType charArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.CHAR_ARR), false); /** */ - private final static MessageCollectionType floatArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.FLOAT_ARR), false); + private static final MessageCollectionType doubleArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.DOUBLE_ARR), false); /** */ - private final static MessageCollectionType gridLongListListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.GRID_LONG_LIST), false); + private static final MessageCollectionType floatArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.FLOAT_ARR), false); /** */ - private final static MessageCollectionType igniteUuidListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.IGNITE_UUID), false); + private static final MessageCollectionType gridLongListListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.GRID_LONG_LIST), false); /** */ - private final static MessageCollectionType intArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.INT_ARR), false); + private static final MessageCollectionType igniteUuidListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.IGNITE_UUID), false); /** */ - private final static MessageCollectionType longArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.LONG_ARR), false); + private static final MessageCollectionType intArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.INT_ARR), false); /** */ - private final static MessageCollectionType messageListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.MSG), false); + private static final MessageCollectionType longArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.LONG_ARR), false); /** */ - private final static MessageCollectionType shortArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.SHORT_ARR), false); + private static final MessageCollectionType messageListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.MSG), false); /** */ - private final static MessageCollectionType stringListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.STRING), false); + private static final MessageCollectionType shortArrayListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.SHORT_ARR), false); /** */ - private final static MessageCollectionType uuidListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.UUID), false); + private static final MessageCollectionType stringListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.STRING), false); + /** */ + private static final MessageCollectionType uuidListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.UUID), false); /** */ @Override public boolean writeTo(TestCollectionsMessage msg, MessageWriter writer) { @@ -452,4 +459,14 @@ public class TestCollectionsMessageSerializer implements MessageSerializer} field. */ +public class TestKeyCacheObjectCollectionMessage implements Message { + @Order(0) + Collection entries; + + @Order(1) + KeyCacheObjectEntryMsg[] entriesArr; + + public short directType() { + return 1; + } +} diff --git a/modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessageSerializer.java b/modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessageSerializer.java new file mode 100644 index 0000000000000..70510b79eee0c --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessageSerializer.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.KeyCacheObjectEntryMsg; +import org.apache.ignite.internal.KeyCacheObjectEntryMsgSerializer; +import org.apache.ignite.internal.TestKeyCacheObjectCollectionMessage; +import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.plugin.extensions.communication.MessageArrayType; +import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; +import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; +import org.apache.ignite.plugin.extensions.communication.MessageItemType; +import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageWriter; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestKeyCacheObjectCollectionMessageSerializer implements MessageSerializer { + /** */ + private final static KeyCacheObjectEntryMsgSerializer KEY_CACHE_OBJECT_ENTRY_MSG_SER = new KeyCacheObjectEntryMsgSerializer(); + /** */ + private static final MessageArrayType entriesArrCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.MSG), KeyCacheObjectEntryMsg.class); + /** */ + private static final MessageCollectionType entriesCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.MSG), false); + + /** */ + @Override public boolean writeTo(TestKeyCacheObjectCollectionMessage msg, MessageWriter writer) { + if (!writer.isHeaderWritten()) { + if (!writer.writeHeader(msg.directType())) + return false; + + writer.onHeaderWritten(); + } + + switch (writer.state()) { + case 0: + if (!writer.writeCollection(msg.entries, entriesCollDesc)) + return false; + + writer.incrementState(); + + case 1: + if (!writer.writeObjectArray(msg.entriesArr, entriesArrCollDesc)) + return false; + + writer.incrementState(); + } + + return true; + } + + /** */ + @Override public boolean readFrom(TestKeyCacheObjectCollectionMessage msg, MessageReader reader) { + switch (reader.state()) { + case 0: + msg.entries = reader.readCollection(entriesCollDesc); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + + case 1: + msg.entriesArr = reader.readObjectArray(entriesArrCollDesc); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + } + + return true; + } + + /** */ + @Override public void prepareMarshalCacheObjects(TestKeyCacheObjectCollectionMessage msg, CacheObjectValueContext ctx, GridCacheSharedContext sharedCtx) throws IgniteCheckedException { + if (msg.entries != null) { + for (KeyCacheObjectEntryMsg e : msg.entries) { + if (e != null) + KEY_CACHE_OBJECT_ENTRY_MSG_SER.prepareMarshalCacheObjects(e, ctx, sharedCtx); + } + } + + if (msg.entriesArr != null) { + for (KeyCacheObjectEntryMsg e : msg.entriesArr) { + if (e != null) + KEY_CACHE_OBJECT_ENTRY_MSG_SER.prepareMarshalCacheObjects(e, ctx, sharedCtx); + } + } + } +} diff --git a/modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessage.java b/modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessage.java new file mode 100644 index 0000000000000..1956319cef672 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessage.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.util.Map; +import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.plugin.extensions.communication.Message; + +/** APT fixture: {@code @Order Map} is safe — deferred {@code HashMap} assembly. */ +public class TestMapKeyCacheObjectMessage implements Message { + @Order(0) + Map entries; + + public short directType() { + return 0; + } +} diff --git a/modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessageSerializer.java new file mode 100644 index 0000000000000..c7217c0dba9e3 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessageSerializer.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.TestMapKeyCacheObjectMessage; +import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersionSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; +import org.apache.ignite.plugin.extensions.communication.MessageItemType; +import org.apache.ignite.plugin.extensions.communication.MessageMapType; +import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageWriter; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMapKeyCacheObjectMessageSerializer implements MessageSerializer { + /** */ + private final static GridCacheVersionSerializer GRID_CACHE_VERSION_SER = new GridCacheVersionSerializer(); + /** */ + private static final MessageMapType entriesCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.KEY_CACHE_OBJECT), new MessageItemType(MessageCollectionItemType.MSG), false); + + /** */ + @Override public boolean writeTo(TestMapKeyCacheObjectMessage msg, MessageWriter writer) { + if (!writer.isHeaderWritten()) { + if (!writer.writeHeader(msg.directType())) + return false; + + writer.onHeaderWritten(); + } + + switch (writer.state()) { + case 0: + if (!writer.writeMap(msg.entries, entriesCollDesc)) + return false; + + writer.incrementState(); + } + + return true; + } + + /** */ + @Override public boolean readFrom(TestMapKeyCacheObjectMessage msg, MessageReader reader) { + switch (reader.state()) { + case 0: + msg.entries = reader.readMap(entriesCollDesc); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + } + + return true; + } + + /** */ + @Override public void prepareMarshalCacheObjects(TestMapKeyCacheObjectMessage msg, CacheObjectValueContext ctx, GridCacheSharedContext sharedCtx) throws IgniteCheckedException { + if (msg.entries != null) { + for (KeyCacheObject k : msg.entries.keySet()) { + if (k != null) + k.prepareMarshal(ctx); + } + + for (GridCacheVersion v : msg.entries.values()) { + if (v != null) + GRID_CACHE_VERSION_SER.prepareMarshalCacheObjects(v, ctx, sharedCtx); + } + } + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java index b2e66053653df..d210abbc82ba8 100644 --- a/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java @@ -17,7 +17,12 @@ package org.apache.ignite.internal; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.TestMapMessage; +import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersionSerializer; import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; import org.apache.ignite.plugin.extensions.communication.MessageItemType; @@ -33,55 +38,57 @@ */ public class TestMapMessageSerializer implements MessageSerializer { /** */ - private final static MessageMapType affTopVersionIgniteUuidMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.AFFINITY_TOPOLOGY_VERSION), new MessageItemType(MessageCollectionItemType.IGNITE_UUID), false); + private final static GridCacheVersionSerializer GRID_CACHE_VERSION_SER = new GridCacheVersionSerializer(); /** */ - private final static MessageMapType bitSetUuidMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.BIT_SET), new MessageItemType(MessageCollectionItemType.UUID), false); + private static final MessageMapType affTopVersionIgniteUuidMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.AFFINITY_TOPOLOGY_VERSION), new MessageItemType(MessageCollectionItemType.IGNITE_UUID), false); /** */ - private final static MessageMapType booleanArrayBoxedLongMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.BOOLEAN_ARR), new MessageItemType(MessageCollectionItemType.LONG), false); + private static final MessageMapType bitSetUuidMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.BIT_SET), new MessageItemType(MessageCollectionItemType.UUID), false); /** */ - private final static MessageMapType boxedBooleanAffTopVersionMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.BOOLEAN), new MessageItemType(MessageCollectionItemType.AFFINITY_TOPOLOGY_VERSION), false); + private static final MessageMapType booleanArrayBoxedLongMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.BOOLEAN_ARR), new MessageItemType(MessageCollectionItemType.LONG), false); /** */ - private final static MessageMapType boxedByteBoxedBooleanMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.BYTE), new MessageItemType(MessageCollectionItemType.BOOLEAN), false); + private static final MessageMapType boxedBooleanAffTopVersionMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.BOOLEAN), new MessageItemType(MessageCollectionItemType.AFFINITY_TOPOLOGY_VERSION), false); /** */ - private final static MessageMapType boxedCharBoxedLongMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.CHAR), new MessageItemType(MessageCollectionItemType.LONG), false); + private static final MessageMapType boxedByteBoxedBooleanMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.BYTE), new MessageItemType(MessageCollectionItemType.BOOLEAN), false); /** */ - private final static MessageMapType boxedDoubleBoxedFloatMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.DOUBLE), new MessageItemType(MessageCollectionItemType.FLOAT), false); + private static final MessageMapType boxedCharBoxedLongMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.CHAR), new MessageItemType(MessageCollectionItemType.LONG), false); /** */ - private final static MessageMapType boxedFloatBoxedCharMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.FLOAT), new MessageItemType(MessageCollectionItemType.CHAR), false); + private static final MessageMapType boxedDoubleBoxedFloatMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.DOUBLE), new MessageItemType(MessageCollectionItemType.FLOAT), false); /** */ - private final static MessageMapType boxedIntBoxedShortMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.INT), new MessageItemType(MessageCollectionItemType.SHORT), false); + private static final MessageMapType boxedFloatBoxedCharMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.FLOAT), new MessageItemType(MessageCollectionItemType.CHAR), false); /** */ - private final static MessageMapType boxedLongBoxedIntMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.LONG), new MessageItemType(MessageCollectionItemType.INT), false); + private static final MessageMapType boxedIntBoxedShortMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.INT), new MessageItemType(MessageCollectionItemType.SHORT), false); /** */ - private final static MessageMapType boxedShortBoxedByteMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.SHORT), new MessageItemType(MessageCollectionItemType.BYTE), false); + private static final MessageMapType boxedLongBoxedIntMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.LONG), new MessageItemType(MessageCollectionItemType.INT), false); /** */ - private final static MessageMapType byteArrayBooleanArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.BYTE_ARR), new MessageItemType(MessageCollectionItemType.BOOLEAN_ARR), false); + private static final MessageMapType boxedShortBoxedByteMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.SHORT), new MessageItemType(MessageCollectionItemType.BYTE), false); /** */ - private final static MessageMapType charArrayLongArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.CHAR_ARR), new MessageItemType(MessageCollectionItemType.LONG_ARR), false); + private static final MessageMapType byteArrayBooleanArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.BYTE_ARR), new MessageItemType(MessageCollectionItemType.BOOLEAN_ARR), false); /** */ - private final static MessageMapType doubleArrayFloatArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.DOUBLE_ARR), new MessageItemType(MessageCollectionItemType.FLOAT_ARR), false); + private static final MessageMapType charArrayLongArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.CHAR_ARR), new MessageItemType(MessageCollectionItemType.LONG_ARR), false); /** */ - private final static MessageMapType floatArrayCharArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.FLOAT_ARR), new MessageItemType(MessageCollectionItemType.CHAR_ARR), false); + private static final MessageMapType doubleArrayFloatArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.DOUBLE_ARR), new MessageItemType(MessageCollectionItemType.FLOAT_ARR), false); /** */ - private final static MessageMapType gridLongListIntegerMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.GRID_LONG_LIST), new MessageItemType(MessageCollectionItemType.INT), false); + private static final MessageMapType floatArrayCharArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.FLOAT_ARR), new MessageItemType(MessageCollectionItemType.CHAR_ARR), false); /** */ - private final static MessageMapType gridlistDoubleMapUuidMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.GRID_LONG_LIST), new MessageMapType(new MessageItemType(MessageCollectionItemType.UUID), new MessageCollectionType(new MessageItemType(MessageCollectionItemType.DOUBLE), false), false), false); + private static final MessageMapType gridLongListIntegerMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.GRID_LONG_LIST), new MessageItemType(MessageCollectionItemType.INT), false); /** */ - private final static MessageMapType igniteUuidBitSetMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.IGNITE_UUID), new MessageItemType(MessageCollectionItemType.BIT_SET), false); + private static final MessageMapType gridlistDoubleMapUuidMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.GRID_LONG_LIST), new MessageMapType(new MessageItemType(MessageCollectionItemType.UUID), new MessageCollectionType(new MessageItemType(MessageCollectionItemType.DOUBLE), false), false), false); /** */ - private final static MessageMapType intArrayShortArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.INT_ARR), new MessageItemType(MessageCollectionItemType.SHORT_ARR), false); + private static final MessageMapType igniteUuidBitSetMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.IGNITE_UUID), new MessageItemType(MessageCollectionItemType.BIT_SET), false); /** */ - private final static MessageMapType integerGridLongListMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.INT), new MessageItemType(MessageCollectionItemType.GRID_LONG_LIST), false); + private static final MessageMapType intArrayShortArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.INT_ARR), new MessageItemType(MessageCollectionItemType.SHORT_ARR), false); /** */ - private final static MessageMapType longArrayIntArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.LONG_ARR), new MessageItemType(MessageCollectionItemType.INT_ARR), false); + private static final MessageMapType integerGridLongListMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.INT), new MessageItemType(MessageCollectionItemType.GRID_LONG_LIST), false); /** */ - private final static MessageMapType messageBoxedDoubleMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.MSG), new MessageItemType(MessageCollectionItemType.DOUBLE), false); + private static final MessageMapType longArrayIntArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.LONG_ARR), new MessageItemType(MessageCollectionItemType.INT_ARR), false); /** */ - private final static MessageMapType shortArrayByteArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.SHORT_ARR), new MessageItemType(MessageCollectionItemType.BYTE_ARR), false); + private static final MessageMapType messageBoxedDoubleMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.MSG), new MessageItemType(MessageCollectionItemType.DOUBLE), false); /** */ - private final static MessageMapType stringDoubleArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.STRING), new MessageItemType(MessageCollectionItemType.DOUBLE_ARR), false); + private static final MessageMapType shortArrayByteArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.SHORT_ARR), new MessageItemType(MessageCollectionItemType.BYTE_ARR), false); /** */ - private final static MessageMapType uuidStringMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.UUID), new MessageItemType(MessageCollectionItemType.STRING), false); + private static final MessageMapType stringDoubleArrayMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.STRING), new MessageItemType(MessageCollectionItemType.DOUBLE_ARR), false); + /** */ + private static final MessageMapType uuidStringMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.UUID), new MessageItemType(MessageCollectionItemType.STRING), false); /** */ @Override public boolean writeTo(TestMapMessage msg, MessageWriter writer) { @@ -453,4 +460,14 @@ public class TestMapMessageSerializer implements MessageSerializer { /** */ - private final static MessageArrayType intMatrixCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.INT_ARR), int[].class); + private final static GridCacheVersionSerializer GRID_CACHE_VERSION_SER = new GridCacheVersionSerializer(); /** */ - private final static MessageArrayType strArrCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.STRING), String.class); + private static final MessageArrayType intMatrixCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.INT_ARR), int[].class); /** */ - private final static MessageArrayType verArrCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.MSG), GridCacheVersion.class); + private static final MessageArrayType strArrCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.STRING), String.class); + /** */ + private static final MessageArrayType verArrCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.MSG), GridCacheVersion.class); /** */ @Override public boolean writeTo(TestMessage msg, MessageWriter writer) { @@ -269,4 +275,23 @@ public class TestMessageSerializer implements MessageSerializer { return true; } + + /** */ + @Override public void prepareMarshalCacheObjects(TestMessage msg, CacheObjectValueContext ctx, GridCacheSharedContext sharedCtx) throws IgniteCheckedException { + if (msg.ver != null) + GRID_CACHE_VERSION_SER.prepareMarshalCacheObjects(msg.ver, ctx, sharedCtx); + + if (msg.verArr != null) { + for (GridCacheVersion e : msg.verArr) { + if (e != null) + GRID_CACHE_VERSION_SER.prepareMarshalCacheObjects(e, ctx, sharedCtx); + } + } + + if (msg.keyCacheObject != null) + msg.keyCacheObject.prepareMarshal(ctx); + + if (msg.cacheObject != null) + msg.cacheObject.prepareMarshal(ctx); + } } \ No newline at end of file From d7c93484488dbc1f6165dddca6f32a7e73f84f18 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 4 May 2026 19:06:05 +0300 Subject: [PATCH 002/215] WIP --- .../internal/MessageSerializerGenerator.java | 139 ++++++------------ .../processors/cache/GridCacheIoManager.java | 6 +- .../processors/cache/GridCacheMessage.java | 2 +- .../communication/MessageSerializer.java | 8 +- 4 files changed, 55 insertions(+), 100 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 0b869c96e6e51..01303c344525d 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -272,7 +272,7 @@ private void generateCacheObjectMethods(List orderedFields) thr imports.add("org.apache.ignite.IgniteCheckedException"); imports.add("org.apache.ignite.internal.processors.cache.CacheObjectValueContext"); - imports.add("org.apache.ignite.internal.processors.cache.GridCacheSharedContext"); + imports.add("org.apache.ignite.internal.processors.cache.GridCacheContext"); startCacheObjectMethod(prepareCacheObjects); @@ -433,7 +433,7 @@ private void startCacheObjectMethod(List code) { code.add(identedLine( "@Override public void prepareMarshalCacheObjects(" + type.getSimpleName() + - " msg, CacheObjectValueContext ctx, GridCacheSharedContext sharedCtx) throws IgniteCheckedException {")); + " msg, GridCacheContext ctx) throws IgniteCheckedException {")); } /** */ @@ -527,13 +527,21 @@ private void emitMapSideIteration( indent++; - code.add(identedLine("if (%s != null)", var)); + boolean cacheIdAware = isCacheIdMessage(type); - indent++; + if (cacheIdAware) + code.add(identedLine("msg.prepareMarshalCacheObject(%s, ctx);", accessor)); + else { + code.add(identedLine("if (%s != null)", var)); - code.add(identedLine("%s.prepareMarshal(ctx);", var)); + indent++; - indent -= 2; + code.add(identedLine("%s.prepareMarshal(ctx.cacheObjectContext());", var)); + + indent--; + } + + indent--; code.add(identedLine("}")); } @@ -542,7 +550,6 @@ private void emitMapSideIteration( DeclaredType msgType = (DeclaredType)sideType; String serRef = nestedSerializerRef(msgType); - boolean cacheIdAware = isCacheIdMessage((TypeElement)msgType.asElement()); String elemSimple = msgType.asElement().getSimpleName().toString(); imports.add(((TypeElement)msgType.asElement()).getQualifiedName().toString()); @@ -551,34 +558,13 @@ private void emitMapSideIteration( indent++; - if (cacheIdAware) { - // Resolve per-element cacheId-aware ctx via sharedCtx. Skip if cache is not registered. - code.add(identedLine("if (%s != null) {", var)); - - indent++; - - code.add(identedLine("var nestedCtx = sharedCtx.cacheObjectContext(%s.cacheId());", var)); - - code.add(identedLine("if (nestedCtx != null)")); - - indent++; - - code.add(identedLine("%s.prepareMarshalCacheObjects(%s, nestedCtx, sharedCtx);", serRef, var)); - - indent -= 2; - - code.add(identedLine("}")); - } - else { - code.add(identedLine("if (%s != null)", var)); - - indent++; + code.add(identedLine("if (%s != null)", var)); - code.add(identedLine("%s.prepareMarshalCacheObjects(%s, ctx, sharedCtx);", serRef, var)); + indent++; - indent--; - } + code.add(identedLine("%s.prepareMarshalCacheObjects(%s, ctx);", serRef, var)); + indent--; indent--; code.add(identedLine("}")); @@ -587,13 +573,19 @@ private void emitMapSideIteration( /** */ private void emitCoDirect(List code, String accessor) { - code.add(identedLine("if (%s != null)", accessor)); + boolean cacheIdAware = isCacheIdMessage(type); - indent++; + if (cacheIdAware) + code.add(identedLine("msg.prepareMarshalCacheObject(%s, ctx);", accessor)); + else { + code.add(identedLine("if (%s != null)", accessor)); - code.add(identedLine("%s.prepareMarshal(ctx);", accessor)); + indent++; - indent--; + code.add(identedLine("%s.prepareMarshal(ctx.cacheObjectContext());", accessor)); + + indent--; + } } /** */ @@ -617,13 +609,21 @@ private void emitCoIterable(List code, String accessor, TypeMirror t, bo indent++; - code.add(identedLine("if (obj != null)")); + boolean cacheIdAware = isCacheIdMessage(type); - indent++; + if (cacheIdAware) + code.add(identedLine("msg.prepareMarshalCacheObject(obj, ctx);")); + else { + code.add(identedLine("if (obj != null)")); - code.add(identedLine("obj.prepareMarshal(ctx);")); + indent++; - indent -= 2; + code.add(identedLine("obj.prepareMarshal(ctx.cacheObjectContext());")); + + indent--; + } + + indent--; code.add(identedLine("}")); @@ -635,41 +635,19 @@ private void emitCoIterable(List code, String accessor, TypeMirror t, bo /** */ private void emitMsgDirect(List code, String accessor, DeclaredType msgType) { String serRef = nestedSerializerRef(msgType); - boolean cacheIdAware = isCacheIdMessage((TypeElement)msgType.asElement()); - - if (cacheIdAware) { - // Resolve nested cacheId-aware ctx via sharedCtx. Skip if cache is not registered for the cacheId. - code.add(identedLine("if (%s != null) {", accessor)); - - indent++; - - code.add(identedLine("var nestedCtx = sharedCtx.cacheObjectContext(%s.cacheId());", accessor)); - - code.add(identedLine("if (nestedCtx != null)")); - - indent++; - code.add(identedLine("%s.prepareMarshalCacheObjects(%s, nestedCtx, sharedCtx);", serRef, accessor)); - - indent -= 2; - - code.add(identedLine("}")); - } - else { - code.add(identedLine("if (%s != null)", accessor)); + code.add(identedLine("if (%s != null)", accessor)); - indent++; + indent++; - code.add(identedLine("%s.prepareMarshalCacheObjects(%s, ctx, sharedCtx);", serRef, accessor)); + code.add(identedLine("%s.prepareMarshalCacheObjects(%s, ctx);", serRef, accessor)); - indent--; - } + indent--; } /** */ private void emitMsgIterable(List code, String accessor, DeclaredType elemType) { String serRef = nestedSerializerRef(elemType); - boolean cacheIdAware = isCacheIdMessage((TypeElement)elemType.asElement()); String elemSimple = elemType.asElement().getSimpleName().toString(); @@ -683,34 +661,13 @@ private void emitMsgIterable(List code, String accessor, DeclaredType el indent++; - if (cacheIdAware) { - // Resolve per-element cacheId-aware ctx via sharedCtx. Skip if cache is not registered. - code.add(identedLine("if (e != null) {")); - - indent++; - - code.add(identedLine("var nestedCtx = sharedCtx.cacheObjectContext(e.cacheId());")); - - code.add(identedLine("if (nestedCtx != null)")); - - indent++; - - code.add(identedLine("%s.prepareMarshalCacheObjects(e, nestedCtx, sharedCtx);", serRef)); - - indent -= 2; + code.add(identedLine("if (e != null)")); - code.add(identedLine("}")); - } - else { - code.add(identedLine("if (e != null)")); - - indent++; + indent++; - code.add(identedLine("%s.prepareMarshalCacheObjects(e, ctx, sharedCtx);", serRef)); - - indent--; - } + code.add(identedLine("%s.prepareMarshalCacheObjects(e, ctx);", serRef)); + indent--; indent--; code.add(identedLine("}")); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index fa7710cf7e4a5..1ea1f8da8662d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -1166,15 +1166,15 @@ private void prepareMarshalGeneratedCacheObjects(GridCacheMessage msg) throws Ig if (!(msg instanceof GridCacheIdMessage)) return; - CacheObjectContext cacheObjCtx = cctx.cacheObjectContext(((GridCacheIdMessage)msg).cacheId()); + GridCacheContext ctx = cctx.cacheContext(((GridCacheIdMessage)msg).cacheId()); - if (cacheObjCtx == null) + if (ctx == null) return; MessageSerializer ser = cctx.gridIO().messageFactory().serializer(msg.directType()); if (ser != null) - ser.prepareMarshalCacheObjects(msg, cacheObjCtx, cctx); + ser.prepareMarshalCacheObjects(msg, ctx); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index ec670da2d1cbf..bda427bcebab9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -533,7 +533,7 @@ public final void prepareMarshalCacheObjects(@Nullable List { @@ -48,11 +47,10 @@ public interface MessageSerializer { * * @param msg Message instance. * @param ctx Cache object value context for {@code msg}'s direct {@code CacheObject} fields and non-cacheId-aware - * nested messages. Always non-null. - * @param sharedCtx Shared cache context for resolving per-cache contexts of nested cacheId-aware messages. + * nested messages. Always non-null. * @throws IgniteCheckedException If marshalling fails. */ - public default void prepareMarshalCacheObjects(M msg, CacheObjectValueContext ctx, GridCacheSharedContext sharedCtx) + public default void prepareMarshalCacheObjects(M msg, GridCacheContext ctx) throws IgniteCheckedException { // No-op by default. } From bac9529c82347a7e255ae806f8b48c2e632994f8 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 4 May 2026 19:08:11 +0300 Subject: [PATCH 003/215] WIP --- .../cache/distributed/near/GridNearSingleGetRequest.java | 6 ------ .../cache/distributed/near/GridNearSingleGetResponse.java | 4 +--- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java index 07ca1355fc0f0..5fcde994593bd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java @@ -252,12 +252,6 @@ public boolean recovery() { /** {@inheritDoc} */ @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { super.prepareMarshal(ctx); - - assert key != null; - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareMarshalCacheObject(key, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java index 73f72ec4c0247..cf8508d7d8c14 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java @@ -151,9 +151,7 @@ public long futureId() { if (res != null) { GridCacheContext cctx = ctx.cacheContext(cacheId); - if (res instanceof CacheObject) - prepareMarshalCacheObject((CacheObject)res, cctx); - else if (res instanceof CacheVersionedValue) + if (res instanceof CacheVersionedValue) ((CacheVersionedValue)res).prepareMarshal(cctx.cacheObjectContext()); else if (res instanceof GridCacheEntryInfo) ((GridCacheEntryInfo)res).marshal(cctx); From 2793feb7d9a4cc5d1efd43e82330fb433d727146 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 4 May 2026 19:09:17 +0300 Subject: [PATCH 004/215] WIP --- .../processors/cache/GridCacheMessage.java | 17 ----------------- .../atomic/GridNearAtomicFullUpdateRequest.java | 2 -- .../atomic/GridNearAtomicUpdateResponse.java | 5 ----- 3 files changed, 24 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index bda427bcebab9..6b04ba0aea1f9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -511,23 +511,6 @@ protected final void unmarshalTx(Iterable txEntries, return byteCol; } - /** - * @param col Collection. - * @param ctx Cache context. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings("ForLoopReplaceableByForEach") - public final void prepareMarshalCacheObjects(@Nullable List col, - GridCacheContext ctx) throws IgniteCheckedException { - if (col == null) - return; - - int size = col.size(); - - for (int i = 0; i < size; i++) - prepareMarshalCacheObject(col.get(i), ctx); - } - /** * @param obj Object. * @param ctx Context. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index c06365250a965..a7350c2756805 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -362,8 +362,6 @@ else if (conflictVers != null) if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) invokeArgsBytes = Arrays.asList(marshalInvokeArguments(invokeArgs, cctx)); } - else - prepareMarshalCacheObjects(vals, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index 38efb2c32037d..7b5913a0f705d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -341,11 +341,6 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { * @param ctx*/ @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { super.prepareMarshal(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (nearUpdates != null) - prepareMarshalCacheObjects(nearUpdates.nearValues(), cctx); } /** {@inheritDoc} */ From 6d317df096d86e63f5cd0e9f296f3a71e93a8b35 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 4 May 2026 19:15:34 +0300 Subject: [PATCH 005/215] WIP --- .../internal/processors/cache/GridCacheIoManager.java | 1 - .../dht/atomic/GridNearAtomicUpdateResponse.java | 6 ------ .../cache/distributed/near/GridNearSingleGetRequest.java | 5 ----- 3 files changed, 12 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index 1ea1f8da8662d..257761e01c9af 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -1161,7 +1161,6 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I } /** */ - @SuppressWarnings({"unchecked", "rawtypes"}) private void prepareMarshalGeneratedCacheObjects(GridCacheMessage msg) throws IgniteCheckedException { if (!(msg instanceof GridCacheIdMessage)) return; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index 7b5913a0f705d..7ec70cf19e48a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -337,12 +337,6 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { errs.addFailedKeys(keys, e); } - /** {@inheritDoc} - * @param ctx*/ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java index 5fcde994593bd..abceaf5bb9efe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java @@ -249,11 +249,6 @@ public boolean recovery() { return (flags & RECOVERY_FLAG_MASK) != 0; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); From 802f7e1a8491425b4974c41a075dda7e2d11cbd2 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 4 May 2026 19:20:31 +0300 Subject: [PATCH 006/215] WIP --- .../apache/ignite/internal/MessageSerializerGenerator.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 01303c344525d..2a11890e15115 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -716,10 +716,7 @@ private static String camelToConstant(String simple) { private String fieldAccessor(VariableElement field) { String name = field.getSimpleName().toString(); - if (type.equals(field.getEnclosingElement())) - return "msg." + name; - - return "((" + field.getEnclosingElement().getSimpleName() + ")msg)." + name; + return "msg." + name; } /** From 7c5d2e14fcd6ee804447f77537d677496ec80493 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 4 May 2026 19:56:43 +0300 Subject: [PATCH 007/215] WIP --- .../query/calcite/message/QueryTxEntry.java | 6 --- .../cache/CacheEntryPredicateAdapter.java | 2 - .../cache/CacheInvokeDirectResult.java | 13 ------ .../processors/cache/GridCacheEntryInfo.java | 7 ---- .../processors/cache/GridCacheIoManager.java | 6 +-- .../processors/cache/GridCacheMessage.java | 20 ---------- .../processors/cache/GridCacheReturn.java | 16 -------- .../GridDistributedTxPrepareRequest.java | 6 --- .../dht/GridDhtTxFinishResponse.java | 13 ------ .../dht/GridDhtTxPrepareRequest.java | 2 - .../dht/GridDhtTxPrepareResponse.java | 10 ----- .../GridDhtAtomicSingleUpdateRequest.java | 23 ----------- .../distributed/near/CacheVersionedValue.java | 12 ------ .../near/GridNearSingleGetResponse.java | 14 ------- .../near/GridNearTxPrepareResponse.java | 40 ------------------- .../cache/query/GridCacheQueryRequest.java | 5 --- .../continuous/CacheContinuousQueryEntry.java | 15 ------- .../CacheContinuousQueryHandler.java | 7 +--- .../cache/transactions/IgniteTxEntry.java | 7 ---- .../cache/transactions/IgniteTxKey.java | 8 ---- .../transactions/TxEntryValueHolder.java | 9 ----- .../cache/transactions/TxLocksRequest.java | 5 +-- .../cache/transactions/TxLocksResponse.java | 7 +--- .../datastreamer/DataStreamerImpl.java | 9 ----- .../h2/twostep/msg/GridH2CacheObject.java | 5 +-- 25 files changed, 7 insertions(+), 260 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java index 36f2d9dceee84..8f5d44a466336 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java @@ -97,12 +97,6 @@ public GridCacheVersion version() { /** {@inheritDoc} */ @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - CacheObjectContext coctx = ctx.cacheContext(cacheId).cacheObjectContext(); - - key.prepareMarshal(coctx); - - if (val != null) - val.prepareMarshal(coctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java index 0c30dc615aa66..69da0dbec23f3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java @@ -127,8 +127,6 @@ public CacheEntryPredicateType type() { /** {@inheritDoc} */ @Override public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException { - if (type == CacheEntryPredicateType.VALUE) - val.prepareMarshal(ctx.cacheObjectContext()); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java index 1276c6b63c82c..2f76570ff6ee5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java @@ -111,19 +111,6 @@ public CacheObject result() { return ErrorMessage.error(errMsg); } - /** - * @param ctx Cache context. - * @throws IgniteCheckedException If failed. - */ - public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException { - key.prepareMarshal(ctx.cacheObjectContext()); - - assert unprepareRes == null : "marshalResult() was not called for the result: " + this; - - if (res != null) - res.prepareMarshal(ctx.cacheObjectContext()); - } - /** * Converts the entry processor unprepared result to a cache object instance. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java index d8d710f62368f..52313dea6139c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java @@ -214,13 +214,6 @@ public void marshal(GridCacheContext ctx) throws IgniteCheckedException { * @throws IgniteCheckedException In case of error. */ public void marshal(CacheObjectContext ctx) throws IgniteCheckedException { - assert key != null; - - key.prepareMarshal(ctx); - - if (val != null) - val.prepareMarshal(ctx); - if (expireTime == 0) expireTime = -1; else { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index 257761e01c9af..c2d2d37abf6d9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -1149,10 +1149,10 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I msg.messageId(idGen.incrementAndGet()); if (destNodeId == null || !cctx.localNodeId().equals(destNodeId)) { + prepareMarshalCacheObjects(msg); + msg.prepareMarshal(cctx); - prepareMarshalGeneratedCacheObjects(msg); - if (msg instanceof GridCacheDeployable && msg.addDeploymentInfo()) cctx.deploy().prepare((GridCacheDeployable)msg); } @@ -1161,7 +1161,7 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I } /** */ - private void prepareMarshalGeneratedCacheObjects(GridCacheMessage msg) throws IgniteCheckedException { + private void prepareMarshalCacheObjects(GridCacheMessage msg) throws IgniteCheckedException { if (!(msg instanceof GridCacheIdMessage)) return; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index 6b04ba0aea1f9..4aa7c9f51d1d5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -525,26 +525,6 @@ public final void prepareMarshalCacheObject(CacheObject obj, GridCacheContext ct } } - /** - * @param col Collection. - * @param ctx Cache context. - * @throws IgniteCheckedException If failed. - */ - protected final void prepareMarshalCacheObjects(@Nullable Collection col, - GridCacheContext ctx) throws IgniteCheckedException { - if (col == null) - return; - - for (CacheObject obj : col) { - if (obj != null) { - obj.prepareMarshal(ctx.cacheObjectContext()); - - if (addDepInfo) - prepareObject(obj.value(ctx.cacheObjectContext(), false), ctx.shared()); - } - } - } - /** * @param col Collection. * @param ctx Context. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index 7c78a10a5cf48..5a15eaf8de95f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -328,22 +328,6 @@ public void marshalResult(GridCacheContext ctx) { } } - /** - * @param ctx Cache context. - * @throws IgniteCheckedException If failed. - */ - public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException { - assert !loc; - - if (cacheObj != null) - cacheObj.prepareMarshal(ctx.cacheObjectContext()); - - if (invokeRes && invokeResCol != null) { - for (CacheInvokeDirectResult res : invokeResCol) - res.prepareMarshal(ctx); - } - } - /** * @param ctx Cache context. * @param ldr Class loader. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index bd427bd47b56f..3bcbaa4e001c5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -382,12 +382,6 @@ public void applicationAttributes(Map appAttrs) { marshalTx(reads, ctx); if (dhtVers != null && dhtVerKeys == null) { - for (IgniteTxKey key : dhtVers.keySet()) { - GridCacheContext cctx = ctx.cacheContext(key.cacheId()); - - key.prepareMarshal(cctx); - } - dhtVerKeys = dhtVers.keySet(); dhtVerVals = dhtVers.values(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java index 352281f9b57c8..4225fffcfb22b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java @@ -118,19 +118,6 @@ public boolean checkCommitted() { return checkCommitted; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - if (retVal != null && retVal.cacheId() != 0) { - GridCacheContext cctx = ctx.cacheContext(retVal.cacheId()); - - assert cctx != null : retVal.cacheId(); - - retVal.prepareMarshal(cctx); - } - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index f8364dca6adb1..62b4e2e159434 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -331,8 +331,6 @@ public boolean skipCompletedVersion() { for (IgniteTxKey key: ownedKeys) { GridCacheContext cctx = ctx.cacheContext(key.cacheId()); - key.prepareMarshal(cctx); - if (addDepInfo) prepareObject(key, cctx); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java index 921f52790252b..7c2406ec802e1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java @@ -173,16 +173,6 @@ public void addPreloadEntry(GridCacheEntryInfo info) { @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { super.prepareMarshal(ctx); - if (nearEvicted != null) { - for (IgniteTxKey key : nearEvicted) { - GridCacheContext cctx = ctx.cacheContext(key.cacheId()); - - // Can be null if client near cache was removed, in this case assume do not need prepareMarshal. - if (cctx != null) - key.prepareMarshal(cctx); - } - } - if (preloadEntries != null) { for (GridCacheEntryInfo info : preloadEntries) { GridCacheContext cctx = ctx.cacheContext(info.cacheId()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java index 20aad2f7dec8b..907934555ade5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java @@ -311,19 +311,6 @@ private void near(boolean near) { return null; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareMarshalObject(key, cctx); - - prepareMarshalObject(val, cctx); - - prepareMarshalObject(prevVal, cctx); - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); @@ -337,16 +324,6 @@ private void near(boolean near) { finishUnmarshalObject(prevVal, cctx, ldr); } - /** - * @param obj CacheObject to marshal - * @param ctx context - * @throws IgniteCheckedException if error - */ - private void prepareMarshalObject(CacheObject obj, GridCacheContext ctx) throws IgniteCheckedException { - if (obj != null) - obj.prepareMarshal(ctx.cacheObjectContext()); - } - /** * @param obj CacheObject un to marshal * @param ctx context diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java index af5d90f84d2a2..a46c4d1ee1c4b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java @@ -69,18 +69,6 @@ public CacheObject value() { return val; } - /** - * This method is called before the whole message is sent - * and is responsible for pre-marshalling state. - * - * @param ctx Cache object context. - * @throws IgniteCheckedException If failed. - */ - public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException { - if (val != null) - val.prepareMarshal(ctx); - } - /** * This method is called after the whole message is received * and is responsible for unmarshalling state. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java index cf8508d7d8c14..397ed4a316e6d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java @@ -144,20 +144,6 @@ public long futureId() { return futId; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - if (res != null) { - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (res instanceof CacheVersionedValue) - ((CacheVersionedValue)res).prepareMarshal(cctx.cacheObjectContext()); - else if (res instanceof GridCacheEntryInfo) - ((GridCacheEntryInfo)res).marshal(cctx); - } - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index 646335209b86e..34b71de34bfb9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -235,46 +235,6 @@ public boolean hasOwnedValue(IgniteTxKey key) { return F.mapContainsKey(ownedVals, key); } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - // There are separate collections for keys and values of the 'ownedVals' map, because IgniteTxKey - // can not be inserted directly in a map as a key during invocation of MessageReader#read. - // The IgniteTxKey's hash code calculation will fail due to delegation of calculation - // to KeyCacheObjectImpl#hashCode, which in turn fails with assertion error if KeyCacheObjectImpl#val - // has not initialized yet in KeyCacheObjectImpl#finishUnmarshal. - if (ownedVals != null && ownedValKeys == null) { - ownedValKeys = ownedVals.keySet(); - - ownedValVals = ownedVals.values(); - - for (Map.Entry entry : ownedVals.entrySet()) { - GridCacheContext cacheCtx = ctx.cacheContext(entry.getKey().cacheId()); - - entry.getKey().prepareMarshal(cacheCtx); - - entry.getValue().prepareMarshal(cacheCtx.cacheObjectContext()); - } - } - - if (retVal != null && retVal.cacheId() != 0) { - GridCacheContext cctx = ctx.cacheContext(retVal.cacheId()); - - assert cctx != null : retVal.cacheId(); - - retVal.prepareMarshal(cctx); - } - - if (filterFailedKeys != null) { - for (IgniteTxKey key : filterFailedKeys) { - GridCacheContext cctx = ctx.cacheContext(key.cacheId()); - - key.prepareMarshal(cctx); - } - } - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 84813c40420c9..592cf335b2904 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -448,11 +448,6 @@ private static byte setDataPageScanEnabled(int flags, Boolean enabled) { idxQryDescBytes = CU.marshal(cctx, idxQryDesc); } - - if (!F.isEmpty(skipKeys)) { - for (KeyCacheObject k : skipKeys) - k.prepareMarshal(cctx.cacheObjectContext()); - } } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java index 130dcec622821..70caf5f5342c9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java @@ -295,21 +295,6 @@ boolean isKeepBinary() { return (flags & KEEP_BINARY) != 0; } - /** - * @param cctx Cache context. - * @throws IgniteCheckedException In case of error. - */ - void prepareMarshal(GridCacheContext cctx) throws IgniteCheckedException { - if (key != null) - key.prepareMarshal(cctx.cacheObjectContext()); - - if (newVal != null) - newVal.prepareMarshal(cctx.cacheObjectContext()); - - if (oldVal != null) - oldVal.prepareMarshal(cctx.cacheObjectContext()); - } - /** * @param cctx Cache context. * @param ldr Class loader. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java index 200a40cb796d1..902b418f64fe3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java @@ -928,13 +928,8 @@ protected CacheEntryEventFilter getEventFilter0() { */ private void prepareEntry(GridCacheContext cctx, UUID nodeId, CacheContinuousQueryEntry entry) throws IgniteCheckedException { - if (cctx.kernalContext().config().isPeerClassLoadingEnabled() && cctx.discovery().node(nodeId) != null) { - entry.prepareMarshal(cctx); - + if (cctx.kernalContext().config().isPeerClassLoadingEnabled() && cctx.discovery().node(nodeId) != null) cctx.deploy().prepare(entry); - } - else - entry.prepareMarshal(cctx); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index c4f024b2d25b0..8f213662d8287 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -1041,19 +1041,12 @@ public void marshal(GridCacheSharedContext ctx, boolean transferExpiry) th if (transferExpiry) transferExpiryPlc = expiryPlc != null && expiryPlc != this.ctx.expiry(); - key.prepareMarshal(context().cacheObjectContext()); - - val.marshal(context()); - if (transferExpiryPlc) { if (expiryPlcBytes == null) expiryPlcBytes = CU.marshal(this.ctx, new IgniteExternalizableExpiryPolicy(expiryPlc)); } else expiryPlcBytes = null; - - if (oldVal != null) - oldVal.marshal(context()); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java index b50bc340c3ba1..9b6d426a2ef76 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java @@ -69,14 +69,6 @@ public int cacheId() { return cacheId; } - /** - * @param ctx Context. - * @throws IgniteCheckedException If failed. - */ - public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException { - key.prepareMarshal(ctx.cacheObjectContext()); - } - /** * @param ctx Context. * @param ldr Class loader. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java index 98e5830cb3b46..89a6ffe0dd4c2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java @@ -119,15 +119,6 @@ public boolean hasReadValue() { return hasReadVal; } - /** - * @param ctx Cache context. - * @throws IgniteCheckedException If marshaling failed. - */ - public void marshal(GridCacheContext ctx) throws IgniteCheckedException { - if (hasWriteVal && val != null) - val.prepareMarshal(ctx.cacheObjectContext()); - } - /** * @param ctx Cache context. * @param ldr Class loader. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java index 4db908333d72b..a3221cd2173ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java @@ -96,11 +96,8 @@ public Collection txKeys() { int i = 0; - for (IgniteTxKey key : txKeys) { - key.prepareMarshal(ctx.cacheContext(key.cacheId())); - + for (IgniteTxKey key : txKeys) txKeysArr[i++] = key; - } } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index 8ebbcbddbd031..a00fa1be14032 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -151,8 +151,6 @@ public void addKey(IgniteTxKey key) { for (Map.Entry> entry : nearTxKeyLocks.entrySet()) { IgniteTxKey key = entry.getKey(); - key.prepareMarshal(ctx.cacheContext(key.cacheId())); - nearTxKeysArr[i] = key; locksArr[i] = entry.getValue(); @@ -165,11 +163,8 @@ public void addKey(IgniteTxKey key) { int i = 0; - for (IgniteTxKey key : txKeys) { - key.prepareMarshal(ctx.cacheContext(key.cacheId())); - + for (IgniteTxKey key : txKeys) txKeysArr[i++] = key; - } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java index a86b6240ed06a..f18f6d5288592 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java @@ -1933,15 +1933,6 @@ private void submit( localUpdate(entries, topVer, curFut, plc); else { try { - for (DataStreamerEntry e : entries) { - e.getKey().prepareMarshal(cacheObjCtx); - - CacheObject val = e.getValue(); - - if (val != null) - val.prepareMarshal(cacheObjCtx); - } - if (updaterBytes == null) { assert rcvr != null; diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java index 559f96bccad5c..d15b25c7b1b8f 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java @@ -42,12 +42,9 @@ public GridH2CacheObject() { /** * @param v Value. - * @throws IgniteCheckedException If failed. */ - public GridH2CacheObject(GridH2ValueCacheObject v) throws IgniteCheckedException { + public GridH2CacheObject(GridH2ValueCacheObject v) { obj = v.getCacheObject(); - - obj.prepareMarshal(v.valueContext()); } /** {@inheritDoc} */ From 05253c6d78bda7eb8f4d470a7d7afa8f775bdec7 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 5 May 2026 16:56:02 +0300 Subject: [PATCH 008/215] WIP --- .../internal/MessageSerializerGenerator.java | 35 +++++++++++-------- .../processors/cache/GridCacheIdMessage.java | 9 +++-- .../processors/cache/GridCacheIoManager.java | 10 +----- .../cache/transactions/IgniteTxEntry.java | 5 +-- .../cache/transactions/IgniteTxKey.java | 5 +-- .../communication/CacheIdAware.java | 25 +++++++++++++ .../communication/MessageSerializer.java | 3 +- 7 files changed, 59 insertions(+), 33 deletions(-) create mode 100644 modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 2a11890e15115..d54ad62a4415d 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -272,12 +272,20 @@ private void generateCacheObjectMethods(List orderedFields) thr imports.add("org.apache.ignite.IgniteCheckedException"); imports.add("org.apache.ignite.internal.processors.cache.CacheObjectValueContext"); + imports.add("org.apache.ignite.internal.processors.cache.GridCacheSharedContext"); imports.add("org.apache.ignite.internal.processors.cache.GridCacheContext"); startCacheObjectMethod(prepareCacheObjects); indent++; + if (isGridCacheIdMessage(type) || isCacheIdAwareMessage(type)) + prepareCacheObjects.add(identedLine("GridCacheContext ctx = nested == null ? sctx.cacheContext(msg.cacheId()) : nested;")); + else + prepareCacheObjects.add(identedLine("GridCacheContext ctx = nested;")); + + prepareCacheObjects.add(EMPTY); + boolean first = true; for (VariableElement field: traversable) { @@ -421,10 +429,15 @@ private boolean isRecursableMessage(TypeMirror t) { } /** True if {@code te} extends {@code GridCacheIdMessage} and therefore carries its own per-cache {@code cacheId()}. */ - private boolean isCacheIdMessage(TypeElement te) { + private boolean isGridCacheIdMessage(TypeElement te) { return assignableFrom(te.asType(), type("org.apache.ignite.internal.processors.cache.GridCacheIdMessage")); } + /** True if {@code te} extends {@code CacheIdAware} and therefore carries its own per-cache {@code cacheId()}. */ + private boolean isCacheIdAwareMessage(TypeElement te) { + return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.CacheIdAware")); + } + /** */ private void startCacheObjectMethod(List code) { indent = 1; @@ -433,7 +446,7 @@ private void startCacheObjectMethod(List code) { code.add(identedLine( "@Override public void prepareMarshalCacheObjects(" + type.getSimpleName() + - " msg, GridCacheContext ctx) throws IgniteCheckedException {")); + " msg, GridCacheSharedContext sctx, GridCacheContext nested) throws IgniteCheckedException {")); } /** */ @@ -527,9 +540,7 @@ private void emitMapSideIteration( indent++; - boolean cacheIdAware = isCacheIdMessage(type); - - if (cacheIdAware) + if (isGridCacheIdMessage(type)) code.add(identedLine("msg.prepareMarshalCacheObject(%s, ctx);", accessor)); else { code.add(identedLine("if (%s != null)", var)); @@ -562,7 +573,7 @@ private void emitMapSideIteration( indent++; - code.add(identedLine("%s.prepareMarshalCacheObjects(%s, ctx);", serRef, var)); + code.add(identedLine("%s.prepareMarshalCacheObjects(%s, sctx, ctx);", serRef, var)); indent--; indent--; @@ -573,9 +584,7 @@ private void emitMapSideIteration( /** */ private void emitCoDirect(List code, String accessor) { - boolean cacheIdAware = isCacheIdMessage(type); - - if (cacheIdAware) + if (isGridCacheIdMessage(type)) code.add(identedLine("msg.prepareMarshalCacheObject(%s, ctx);", accessor)); else { code.add(identedLine("if (%s != null)", accessor)); @@ -609,9 +618,7 @@ private void emitCoIterable(List code, String accessor, TypeMirror t, bo indent++; - boolean cacheIdAware = isCacheIdMessage(type); - - if (cacheIdAware) + if (isGridCacheIdMessage(type)) code.add(identedLine("msg.prepareMarshalCacheObject(obj, ctx);")); else { code.add(identedLine("if (obj != null)")); @@ -640,7 +647,7 @@ private void emitMsgDirect(List code, String accessor, DeclaredType msgT indent++; - code.add(identedLine("%s.prepareMarshalCacheObjects(%s, ctx);", serRef, accessor)); + code.add(identedLine("%s.prepareMarshalCacheObjects(%s, sctx, ctx);", serRef, accessor)); indent--; } @@ -665,7 +672,7 @@ private void emitMsgIterable(List code, String accessor, DeclaredType el indent++; - code.add(identedLine("%s.prepareMarshalCacheObjects(e, ctx);", serRef)); + code.add(identedLine("%s.prepareMarshalCacheObjects(e, sctx, ctx);", serRef)); indent--; indent--; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIdMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIdMessage.java index f0ebb72b7b5b1..1236d67451ac1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIdMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIdMessage.java @@ -20,20 +20,19 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.plugin.extensions.communication.CacheIdAware; /** * Message related to particular cache. */ -public abstract class GridCacheIdMessage extends GridCacheMessage { +public abstract class GridCacheIdMessage extends GridCacheMessage implements CacheIdAware { /** Cache ID. */ @GridToStringInclude @Order(0) public int cacheId; - /** - * @return Cache ID. - */ - public int cacheId() { + /** {@inheritDoc} */ + @Override public int cacheId() { return cacheId; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index c2d2d37abf6d9..19ad283dbb491 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -1162,18 +1162,10 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I /** */ private void prepareMarshalCacheObjects(GridCacheMessage msg) throws IgniteCheckedException { - if (!(msg instanceof GridCacheIdMessage)) - return; - - GridCacheContext ctx = cctx.cacheContext(((GridCacheIdMessage)msg).cacheId()); - - if (ctx == null) - return; - MessageSerializer ser = cctx.gridIO().messageFactory().serializer(msg.directType()); if (ser != null) - ser.prepareMarshalCacheObjects(msg, ctx); + ser.prepareMarshalCacheObjects(msg, cctx, null); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index 8f213662d8287..d9f1e3deac4e2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -47,6 +47,7 @@ import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.plugin.extensions.communication.CacheIdAware; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; @@ -59,7 +60,7 @@ * {@link #equals(Object)} method, as transaction entries should use referential * equality. */ -public class IgniteTxEntry implements GridPeerDeployAware, Message { +public class IgniteTxEntry implements GridPeerDeployAware, Message, CacheIdAware { /** */ private static final long serialVersionUID = 0L; @@ -588,7 +589,7 @@ public KeyCacheObject key() { /** * @return Cache ID. */ - public int cacheId() { + @Override public int cacheId() { return cacheId; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java index 9b6d426a2ef76..b90e3a4805f05 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java @@ -23,13 +23,14 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.plugin.extensions.communication.CacheIdAware; import org.apache.ignite.plugin.extensions.communication.Message; /** * Cache transaction key. This wrapper is needed because same keys may be enlisted in the same transaction * for multiple caches. */ -public class IgniteTxKey implements Message { +public class IgniteTxKey implements Message, CacheIdAware { /** Key. */ @Order(0) @GridToStringInclude(sensitive = true) @@ -65,7 +66,7 @@ public KeyCacheObject key() { /** * @return Cache ID. */ - public int cacheId() { + @Override public int cacheId() { return cacheId; } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java new file mode 100644 index 0000000000000..3233d054dd2d8 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java @@ -0,0 +1,25 @@ +/* + * 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; +/** */ +public interface CacheIdAware { + /** + * @return Cache ID. + */ + public int cacheId(); +} diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index e5dbfae75aa29..9b24885cbe183 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -19,6 +19,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; /** Message serialization logic. */ public interface MessageSerializer { @@ -50,7 +51,7 @@ public interface MessageSerializer { * nested messages. Always non-null. * @throws IgniteCheckedException If marshalling fails. */ - public default void prepareMarshalCacheObjects(M msg, GridCacheContext ctx) + public default void prepareMarshalCacheObjects(M msg, GridCacheSharedContext sctx, GridCacheContext nested) throws IgniteCheckedException { // No-op by default. } From 63110cdbc708d8be13e8da7fa8687f4501df3a95 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 7 May 2026 14:51:18 +0300 Subject: [PATCH 009/215] WIP --- .../internal/MessageSerializerGenerator.java | 89 +++++++------------ .../processors/cache/GridCacheIoManager.java | 15 ++-- .../processors/cache/GridCacheReturn.java | 9 +- .../cache/transactions/IgniteTxManager.java | 9 +- .../datastreamer/DataStreamerImpl.java | 9 ++ 5 files changed, 59 insertions(+), 72 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index d54ad62a4415d..823ba4e8c5a60 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -38,7 +38,6 @@ import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; -import javax.lang.model.element.Modifier; import javax.lang.model.element.QualifiedNameable; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; @@ -53,6 +52,7 @@ import javax.tools.JavaFileObject; import javax.tools.StandardLocation; import org.apache.ignite.internal.systemview.SystemViewRowAttributeWalkerProcessor; +import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.SB; import org.jetbrains.annotations.Nullable; @@ -118,9 +118,6 @@ public class MessageSerializerGenerator { /** */ private final List prepareCacheObjects = new ArrayList<>(); - /** Map of {@code } for recursion into nested messages. */ - private final LinkedHashMap nestedSerializerFields = new LinkedHashMap<>(); - /** */ private int indent; @@ -255,11 +252,11 @@ private void generateMethods(List fields) throws Exception { finish(write, false, false); finish(read, true, marshallableMessage()); - generateCacheObjectMethods(fields); + generateCacheObjectMarshallMethods(fields); } /** */ - private void generateCacheObjectMethods(List orderedFields) throws Exception { + private void generateCacheObjectMarshallMethods(List orderedFields) throws Exception { List traversable = new ArrayList<>(); for (VariableElement field: orderedFields) { @@ -300,17 +297,9 @@ private void generateCacheObjectMethods(List orderedFields) thr indent--; prepareCacheObjects.add(identedLine("}")); - - for (Map.Entry e : nestedSerializerFields.entrySet()) { - imports.add(e.getValue()); - - String serSimple = e.getValue().substring(e.getValue().lastIndexOf('.') + 1); - - fields.add("private final static " + serSimple + " " + e.getKey() + " = new " + serSimple + "();"); - } } - /** Traversal kinds for {@link #generateCacheObjectMethods}. */ + /** Traversal kinds for {@link #generateCacheObjectMarshallMethods}. */ private enum FieldKind { /** {@code CacheObject} / {@code KeyCacheObject} scalar. */ CO, @@ -409,9 +398,6 @@ private boolean isRecursableMessage(TypeMirror t) { if (msgIface == null || !assignableFrom(t, msgIface)) return false; - if (assignableFrom(t, marshallableMsgType)) - return false; - Element el = env.getTypeUtils().asElement(t); if (!(el instanceof TypeElement)) @@ -419,12 +405,6 @@ private boolean isRecursableMessage(TypeMirror t) { TypeElement te = (TypeElement)el; - if (te.getKind() != ElementKind.CLASS) - return false; - - if (te.getModifiers().contains(Modifier.ABSTRACT)) - return false; - return !te.equals(type); } @@ -445,7 +425,7 @@ private void startCacheObjectMethod(List code) { code.add(identedLine(METHOD_JAVADOC)); code.add(identedLine( - "@Override public void prepareMarshalCacheObjects(" + type.getSimpleName() + + "@Override public void prepareMarshalCacheObjects(" + simpleNameWithGeneric(type) + " msg, GridCacheSharedContext sctx, GridCacheContext nested) throws IgniteCheckedException {")); } @@ -466,7 +446,7 @@ private void emitCacheObjectCall(List code, VariableElement field) { break; case MSG: - emitMsgDirect(code, accessor, (DeclaredType)t); + emitMsgDirect(code, accessor); break; case MSG_COLL: @@ -560,7 +540,6 @@ private void emitMapSideIteration( assert sideKind == FieldKind.MSG : sideKind; DeclaredType msgType = (DeclaredType)sideType; - String serRef = nestedSerializerRef(msgType); String elemSimple = msgType.asElement().getSimpleName().toString(); imports.add(((TypeElement)msgType.asElement()).getQualifiedName().toString()); @@ -573,7 +552,8 @@ private void emitMapSideIteration( indent++; - code.add(identedLine("%s.prepareMarshalCacheObjects(%s, sctx, ctx);", serRef, var)); + code.add(identedLine( + "sctx.gridIO().messageFactory().serializer(%s.directType()).prepareMarshalCacheObjects(%s, sctx, ctx);", var, var)); indent--; indent--; @@ -640,22 +620,19 @@ private void emitCoIterable(List code, String accessor, TypeMirror t, bo } /** */ - private void emitMsgDirect(List code, String accessor, DeclaredType msgType) { - String serRef = nestedSerializerRef(msgType); - + private void emitMsgDirect(List code, String accessor) { code.add(identedLine("if (%s != null)", accessor)); indent++; - code.add(identedLine("%s.prepareMarshalCacheObjects(%s, sctx, ctx);", serRef, accessor)); + code.add(identedLine( + "sctx.gridIO().messageFactory().serializer(%s.directType()).prepareMarshalCacheObjects(%s, sctx, ctx);", accessor, accessor)); indent--; } /** */ private void emitMsgIterable(List code, String accessor, DeclaredType elemType) { - String serRef = nestedSerializerRef(elemType); - String elemSimple = elemType.asElement().getSimpleName().toString(); imports.add(((TypeElement)elemType.asElement()).getQualifiedName().toString()); @@ -672,7 +649,7 @@ private void emitMsgIterable(List code, String accessor, DeclaredType el indent++; - code.add(identedLine("%s.prepareMarshalCacheObjects(e, sctx, ctx);", serRef)); + code.add(identedLine("sctx.gridIO().messageFactory().serializer(e.directType()).prepareMarshalCacheObjects(e, sctx, ctx);")); indent--; indent--; @@ -684,25 +661,6 @@ private void emitMsgIterable(List code, String accessor, DeclaredType el code.add(identedLine("}")); } - /** - * Returns the expression for a static instance of the nested message's generated serializer (e.g. - * {@code CacheInvokeDirectResultSerializer.INSTANCE}), registering the class to be emitted as a {@code private - * static final} field on the enclosing serializer. - */ - private String nestedSerializerRef(DeclaredType msgType) { - TypeElement el = (TypeElement)msgType.asElement(); - - String pkg = env.getElementUtils().getPackageOf(el).getQualifiedName().toString(); - String serSimple = el.getSimpleName() + "Serializer"; - String serFqn = pkg + "." + serSimple; - - String varName = camelToConstant(el.getSimpleName().toString()) + "_SER"; - - nestedSerializerFields.put(varName, serFqn); - - return varName; - } - /** Converts {@code CacheInvokeDirectResult} to {@code CACHE_INVOKE_DIRECT_RESULT}. */ private static String camelToConstant(String simple) { StringBuilder sb = new StringBuilder(simple.length() + 8); @@ -746,7 +704,7 @@ private void start(Collection code, boolean write) { code.add(identedLine(METHOD_JAVADOC)); - code.add(identedLine("@Override public boolean %s(" + type.getSimpleName() + " msg, %s) {", + code.add(identedLine("@Override public boolean %s(" + simpleNameWithGeneric(type) + " msg, %s) {", write ? "writeTo" : "readFrom", write ? "MessageWriter writer" : "MessageReader reader")); @@ -1530,7 +1488,7 @@ private void writeClassHeader(Writer writer, String pkgName, String serClsName) writer.write(CLS_JAVADOC); writer.write(NL); - writer.write("public class " + serClsName + " implements MessageSerializer<" + type.getSimpleName() + "> {" + NL); + writer.write("public class " + serClsName + " implements MessageSerializer<" + simpleNameWithGeneric(type) + "> {" + NL); } /** */ @@ -1626,4 +1584,23 @@ private void checkTypeForCompress(TypeMirror type) { throw new IllegalArgumentException("Compress annotation is used for an unsupported type: " + type); } + + /** @return Simple class name. */ + private String simpleNameWithGeneric(TypeElement te) { + if (F.size(te.getTypeParameters()) == 0) + return te.getSimpleName().toString(); + + StringBuilder generic = new StringBuilder(te.getSimpleName() + "<"); + + for (int i = 0; i < F.size(te.getTypeParameters()); i++) { + if (i > 0) + generic.append(", "); + + generic.append("?"); + } + + generic.append(">"); + + return generic.toString(); + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index 19ad283dbb491..4df2a0a533d74 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -1149,9 +1149,12 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I msg.messageId(idGen.incrementAndGet()); if (destNodeId == null || !cctx.localNodeId().equals(destNodeId)) { - prepareMarshalCacheObjects(msg); - msg.prepareMarshal(cctx); + + MessageSerializer ser = cctx.gridIO().messageFactory().serializer(msg.directType()); + + if (ser != null) + ser.prepareMarshalCacheObjects(msg, cctx, null); if (msg instanceof GridCacheDeployable && msg.addDeploymentInfo()) cctx.deploy().prepare((GridCacheDeployable)msg); @@ -1160,14 +1163,6 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I return true; } - /** */ - private void prepareMarshalCacheObjects(GridCacheMessage msg) throws IgniteCheckedException { - MessageSerializer ser = cctx.gridIO().messageFactory().serializer(msg.directType()); - - if (ser != null) - ser.prepareMarshalCacheObjects(msg, cctx, null); - } - /** * @param nodeId Node ID. * @param sndErr Send error. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index 5a15eaf8de95f..2ca5fa2376f4e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -31,13 +31,14 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.plugin.extensions.communication.CacheIdAware; import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; /** * Return value for cases where both, value and success flag need to be returned. */ -public class GridCacheReturn implements Message { +public class GridCacheReturn implements Message, CacheIdAware { /** Value. */ @GridToStringInclude(sensitive = true) private volatile Object v; @@ -285,10 +286,8 @@ else if (err instanceof UnregisteredBinaryTypeException) } } - /** - * @return Cache ID. - */ - public int cacheId() { + /** {@inheritDoc} */ + @Override public int cacheId() { return cacheId; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 29c5283c0af13..d5e2111cf3429 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -114,6 +114,7 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteOutClosure; import org.apache.ignite.lang.IgniteReducer; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.spi.systemview.view.TransactionView; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; @@ -2430,8 +2431,14 @@ void txLocksInfo(UUID nodeId, TxDeadlockFuture fut, Set txKeys) { TxLocksRequest req = new TxLocksRequest(fut.futureId(), txKeys); try { - if (!cctx.localNodeId().equals(nodeId)) + if (!cctx.localNodeId().equals(nodeId)) { req.prepareMarshal(cctx); + + MessageSerializer ser = cctx.gridIO().messageFactory().serializer(req.directType()); + + if (ser != null) + ser.prepareMarshalCacheObjects(req, cctx, null); + } cctx.gridIO().sendToGridTopic(node, TOPIC_TX, req, SYSTEM_POOL); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java index f18f6d5288592..a86b6240ed06a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java @@ -1933,6 +1933,15 @@ private void submit( localUpdate(entries, topVer, curFut, plc); else { try { + for (DataStreamerEntry e : entries) { + e.getKey().prepareMarshal(cacheObjCtx); + + CacheObject val = e.getValue(); + + if (val != null) + val.prepareMarshal(cacheObjCtx); + } + if (updaterBytes == null) { assert rcvr != null; From 880c9b74c764d3d71242d95cb420fb8e8f11be21 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 7 May 2026 15:20:06 +0300 Subject: [PATCH 010/215] WIP --- .../processors/cache/GridCacheEntryInfo.java | 31 +++++------- .../processors/cache/GridCacheMessage.java | 47 ------------------- .../distributed/dht/GridDhtLockResponse.java | 10 ---- .../dht/GridDhtTxPrepareResponse.java | 13 ----- .../preloader/GridDhtForceKeysResponse.java | 12 ----- .../GridDhtPartitionSupplyMessage.java | 3 -- .../distributed/near/GridNearGetResponse.java | 13 ----- 7 files changed, 12 insertions(+), 117 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java index 52313dea6139c..9369e827aaccf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java @@ -18,17 +18,19 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.CacheIdAware; /** * Entry information that gets passed over wire. */ -public class GridCacheEntryInfo implements Message { +public class GridCacheEntryInfo implements MarshallableMessage, CacheIdAware { /** */ private static final int SIZE_OVERHEAD = 3 * 8 /* reference */ + 4 /* int */ + 2 * 8 /* long */ + 32 /* version */; @@ -63,10 +65,8 @@ public class GridCacheEntryInfo implements Message { /** Deleted flag. */ private boolean deleted; - /** - * @return Cache ID. - */ - public int cacheId() { + /** {@inheritDoc} */ + @Override public int cacheId() { return cacheId; } @@ -201,19 +201,8 @@ public int marshalledSize(CacheObjectContext ctx) throws IgniteCheckedException return SIZE_OVERHEAD + size; } - /** - * @param ctx Cache context. - * @throws IgniteCheckedException In case of error. - */ - public void marshal(GridCacheContext ctx) throws IgniteCheckedException { - marshal(ctx.cacheObjectContext()); - } - - /** - * @param ctx Cache context. - * @throws IgniteCheckedException In case of error. - */ - public void marshal(CacheObjectContext ctx) throws IgniteCheckedException { + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { if (expireTime == 0) expireTime = -1; else { @@ -224,6 +213,10 @@ public void marshal(CacheObjectContext ctx) throws IgniteCheckedException { } } + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + } + /** * Unmarshalls entry. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index 4aa7c9f51d1d5..1c133dee18428 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -285,36 +285,6 @@ public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) t // 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, - 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); - - CacheObject val = info.value(); - - if (val != null) { - val.finishUnmarshal(cacheObjCtx, ctx.deploy().globalLoader()); - - prepareObject(val.value(cacheObjCtx, false), ctx); - } - } - } - } - /** * @param info Entry to unmarshal. * @param ctx Context. @@ -330,23 +300,6 @@ protected final void unmarshalInfo(GridCacheEntryInfo info, GridCacheContext ctx info.unmarshal(ctx.cacheObjectContext(), ldr); } - /** - * @param infos Entries to marshal. - * @param ctx Context. - * @throws IgniteCheckedException If failed. - */ - protected final void marshalInfos( - Iterable 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. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index e73f606c827eb..0fc4d1551d02c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -123,16 +123,6 @@ public Collection preloadEntries() { return preloadEntries; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (preloadEntries != null) - marshalInfos(preloadEntries, cctx.shared(), cctx.cacheObjectContext()); - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java index 7c2406ec802e1..af5577fb03881 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java @@ -169,19 +169,6 @@ public void addPreloadEntry(GridCacheEntryInfo info) { preloadEntries.add(info); } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - if (preloadEntries != null) { - for (GridCacheEntryInfo info : preloadEntries) { - GridCacheContext cctx = ctx.cacheContext(info.cacheId()); - - info.marshal(cctx); - } - } - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index 65e848ada854a..3b68fa9cebc2b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -131,18 +131,6 @@ public void addInfo(GridCacheEntryInfo info) { infos.add(info); } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (infos != null) { - for (GridCacheEntryInfo info : infos) - info.marshal(cctx.cacheObjectContext()); - } - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index a800ab4d1f7a8..3ee23010c0c64 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -214,9 +214,6 @@ void addEntry0(int p, boolean historical, GridCacheEntryInfo info, GridCacheShar assert info.key() != null : info; assert info.value() != null || historical : info; - // Need to call this method to initialize info properly. - marshalInfo(info, ctx, cacheObjCtx); - msgSize += info.marshalledSize(cacheObjCtx); List infoCol = getInfosSafe().get(p); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java index 56f0aa1ca803d..61da734a27bec 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java @@ -173,19 +173,6 @@ public void error(@Nullable Throwable err) { errMsg = new ErrorMessage(err); } - /** {@inheritDoc} - * @param ctx*/ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (entries != null) { - for (GridCacheEntryInfo info : entries) - info.marshal(cctx); - } - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); From e65ee21cd0990a98cae75129ee5ed1dcaab8570c Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 7 May 2026 18:33:11 +0300 Subject: [PATCH 011/215] WIP --- .../processors/cache/GridCacheMessage.java | 45 +++++++++++++++++++ .../distributed/dht/GridDhtLockResponse.java | 10 +++++ .../GridDhtPartitionSupplyMessage.java | 3 ++ 3 files changed, 58 insertions(+) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index 1c133dee18428..140e883872b28 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -285,6 +285,34 @@ public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) t // 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, + GridCacheSharedContext ctx, + CacheObjectContext cacheObjCtx + ) throws IgniteCheckedException { + assert ctx != null; + + if (info != null) { + if (addDepInfo) { + if (info.key() != null) + prepareObject(info.key().value(cacheObjCtx, false), ctx); + + CacheObject val = info.value(); + + if (val != null) { + val.finishUnmarshal(cacheObjCtx, ctx.deploy().globalLoader()); + + prepareObject(val.value(cacheObjCtx, false), ctx); + } + } + } + } + /** * @param info Entry to unmarshal. * @param ctx Context. @@ -300,6 +328,23 @@ protected final void unmarshalInfo(GridCacheEntryInfo info, GridCacheContext ctx info.unmarshal(ctx.cacheObjectContext(), ldr); } + /** + * @param infos Entries to marshal. + * @param ctx Context. + * @throws IgniteCheckedException If failed. + */ + protected final void marshalInfos( + Iterable 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. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index 0fc4d1551d02c..e73f606c827eb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -123,6 +123,16 @@ public Collection preloadEntries() { return preloadEntries; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + GridCacheContext cctx = ctx.cacheContext(cacheId); + + if (preloadEntries != null) + marshalInfos(preloadEntries, cctx.shared(), cctx.cacheObjectContext()); + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index 3ee23010c0c64..a800ab4d1f7a8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -214,6 +214,9 @@ void addEntry0(int p, boolean historical, GridCacheEntryInfo info, GridCacheShar assert info.key() != null : info; assert info.value() != null || historical : info; + // Need to call this method to initialize info properly. + marshalInfo(info, ctx, cacheObjCtx); + msgSize += info.marshalledSize(cacheObjCtx); List infoCol = getInfosSafe().get(p); From 01892b94b7b7befe5c99760c65b482c23aff41df Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 7 May 2026 19:32:05 +0300 Subject: [PATCH 012/215] WIP --- .../internal/MessageSerializerGenerator.java | 44 ++++++------------- .../processors/cache/GridCacheMessage.java | 37 +++++++++++++++- .../GridCacheTtlUpdateRequest.java | 11 +++++ .../GridDistributedLockRequest.java | 10 +++++ .../GridDistributedLockResponse.java | 8 ++++ .../distributed/GridNearUnlockRequest.java | 8 ++++ .../distributed/dht/GridDhtUnlockRequest.java | 7 +++ .../atomic/GridDhtAtomicUpdateRequest.java | 10 +++++ .../atomic/GridDhtAtomicUpdateResponse.java | 11 +++++ .../GridNearAtomicFullUpdateRequest.java | 4 ++ .../GridNearAtomicSingleUpdateRequest.java | 12 +++++ .../atomic/GridNearAtomicUpdateResponse.java | 11 +++++ .../distributed/dht/atomic/UpdateErrors.java | 5 +++ .../preloader/GridDhtForceKeysRequest.java | 9 ++++ .../preloader/GridDhtForceKeysResponse.java | 10 +++++ .../distributed/near/GridNearGetRequest.java | 16 +++++++ .../near/GridNearSingleGetRequest.java | 11 +++++ .../near/GridNearSingleGetResponse.java | 12 +++++ 18 files changed, 203 insertions(+), 33 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 823ba4e8c5a60..4bfc0d6965513 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -276,7 +276,7 @@ private void generateCacheObjectMarshallMethods(List orderedFie indent++; - if (isGridCacheIdMessage(type) || isCacheIdAwareMessage(type)) + if (isCacheIdAwareMessage(type)) prepareCacheObjects.add(identedLine("GridCacheContext ctx = nested == null ? sctx.cacheContext(msg.cacheId()) : nested;")); else prepareCacheObjects.add(identedLine("GridCacheContext ctx = nested;")); @@ -408,11 +408,6 @@ private boolean isRecursableMessage(TypeMirror t) { return !te.equals(type); } - /** True if {@code te} extends {@code GridCacheIdMessage} and therefore carries its own per-cache {@code cacheId()}. */ - private boolean isGridCacheIdMessage(TypeElement te) { - return assignableFrom(te.asType(), type("org.apache.ignite.internal.processors.cache.GridCacheIdMessage")); - } - /** True if {@code te} extends {@code CacheIdAware} and therefore carries its own per-cache {@code cacheId()}. */ private boolean isCacheIdAwareMessage(TypeElement te) { return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.CacheIdAware")); @@ -520,18 +515,13 @@ private void emitMapSideIteration( indent++; - if (isGridCacheIdMessage(type)) - code.add(identedLine("msg.prepareMarshalCacheObject(%s, ctx);", accessor)); - else { - code.add(identedLine("if (%s != null)", var)); - - indent++; + code.add(identedLine("if (%s != null)", var)); - code.add(identedLine("%s.prepareMarshal(ctx.cacheObjectContext());", var)); + indent++; - indent--; - } + code.add(identedLine("%s.prepareMarshal(ctx.cacheObjectContext());", var)); + indent--; indent--; code.add(identedLine("}")); @@ -564,17 +554,13 @@ private void emitMapSideIteration( /** */ private void emitCoDirect(List code, String accessor) { - if (isGridCacheIdMessage(type)) - code.add(identedLine("msg.prepareMarshalCacheObject(%s, ctx);", accessor)); - else { - code.add(identedLine("if (%s != null)", accessor)); + code.add(identedLine("if (%s != null)", accessor)); - indent++; + indent++; - code.add(identedLine("%s.prepareMarshal(ctx.cacheObjectContext());", accessor)); + code.add(identedLine("%s.prepareMarshal(ctx.cacheObjectContext());", accessor)); - indent--; - } + indent--; } /** */ @@ -598,17 +584,13 @@ private void emitCoIterable(List code, String accessor, TypeMirror t, bo indent++; - if (isGridCacheIdMessage(type)) - code.add(identedLine("msg.prepareMarshalCacheObject(obj, ctx);")); - else { - code.add(identedLine("if (obj != null)")); + code.add(identedLine("if (obj != null)")); - indent++; + indent++; - code.add(identedLine("obj.prepareMarshal(ctx.cacheObjectContext());")); + code.add(identedLine("obj.prepareMarshal(ctx.cacheObjectContext());")); - indent--; - } + indent--; indent--; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index 140e883872b28..2719bfaef7203 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -509,6 +509,23 @@ protected final void unmarshalTx(Iterable txEntries, return byteCol; } + /** + * @param col Collection. + * @param ctx Cache context. + * @throws IgniteCheckedException If failed. + */ + @SuppressWarnings("ForLoopReplaceableByForEach") + public final void prepareMarshalCacheObjects(@Nullable List col, + GridCacheContext ctx) throws IgniteCheckedException { + if (col == null) + return; + + int size = col.size(); + + for (int i = 0; i < size; i++) + prepareMarshalCacheObject(col.get(i), ctx); + } + /** * @param obj Object. * @param ctx Context. @@ -516,13 +533,29 @@ protected final void unmarshalTx(Iterable txEntries, */ public 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()); } } + /** + * @param col Collection. + * @param ctx Cache context. + * @throws IgniteCheckedException If failed. + */ + protected final void prepareMarshalCacheObjects(@Nullable Collection col, + GridCacheContext ctx) throws IgniteCheckedException { + if (col == null) + return; + + for (CacheObject obj : col) { + if (obj != null) { + if (addDepInfo) + prepareObject(obj.value(ctx.cacheObjectContext(), false), ctx.shared()); + } + } + } + /** * @param col Collection. * @param ctx Context. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java index 3edaef8256731..c83e732f6181a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java @@ -155,6 +155,17 @@ public List nearVersions() { return nearVers; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + GridCacheContext cctx = ctx.cacheContext(cacheId); + + prepareMarshalCacheObjects(keys, cctx); + + prepareMarshalCacheObjects(nearKeys, cctx); + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index ad67d52fff18f..b02d75024fec5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -346,6 +346,16 @@ public long timeout() { return ctx.txLockMessageLogger(); } + /** {@inheritDoc} + * @param ctx*/ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + GridCacheContext cctx = ctx.cacheContext(cacheId); + + prepareMarshalCacheObjects(keys, cctx); + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java index 03000227d06c2..cbf10745a7a19 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java @@ -159,6 +159,14 @@ protected int valuesSize() { return ctx.txLockMessageLogger(); } + /** {@inheritDoc} + * @param ctx*/ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + prepareMarshalCacheObjects(vals, ctx.cacheContext(cacheId)); + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java index 2fb7c3daf9226..7f46f96774850 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java @@ -93,6 +93,14 @@ public void addKey(KeyCacheObject key) { return keys != null && !keys.isEmpty() ? keys.get(0).partition() : -1; } + /** {@inheritDoc} + * @param ctx*/ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + prepareMarshalCacheObjects(keys, ctx.cacheContext(cacheId)); + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index dbc831076f5de..8c5fc051a69e7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -70,6 +70,13 @@ public void addNearKey(KeyCacheObject key) nearKeys.add(key); } + /** {@inheritDoc} */ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + prepareMarshalCacheObjects(nearKeys, ctx.cacheContext(cacheId)); + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index ede157f28af63..4d06d1705daaf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -467,6 +467,16 @@ else if (conflictVers != null) GridCacheContext cctx = ctx.cacheContext(cacheId); + prepareMarshalCacheObjects(keys, cctx); + + prepareMarshalCacheObjects(vals, cctx); + + prepareMarshalCacheObjects(nearKeys, cctx); + + prepareMarshalCacheObjects(nearVals, cctx); + + prepareMarshalCacheObjects(prevVals, cctx); + if (forceTransformBackups) { // force addition of deployment info for entry processors if P2P is enabled globally. if (!addDepInfo && ctx.deploymentEnabled()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index c763930c2d154..097e240c988b3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -118,6 +118,17 @@ public void nearEvicted(List nearEvicted) { return partId; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + GridCacheContext cctx = ctx.cacheContext(cacheId); + + // Can be null if client near cache was removed, in this case assume do not need prepareMarshal. + if (cctx != null) + prepareMarshalCacheObjects(nearEvicted, cctx); + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index a7350c2756805..62fcf3966d916 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -336,6 +336,8 @@ else if (conflictVers != null) if (expiryPlc != null && expiryPlcBytes == null) expiryPlcBytes = CU.marshal(cctx, new IgniteExternalizableExpiryPolicy(expiryPlc)); + prepareMarshalCacheObjects(keys, cctx); + if (filter != null) { boolean hasFilter = false; @@ -362,6 +364,8 @@ else if (conflictVers != null) if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) invokeArgsBytes = Arrays.asList(marshalInvokeArguments(invokeArgs, cctx)); } + else + prepareMarshalCacheObjects(vals, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java index 394f003c14da6..25b31b062c7c3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java @@ -216,6 +216,18 @@ public GridNearAtomicSingleUpdateRequest() { return CU.EXPIRE_TIME_CALCULATE; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + GridCacheContext cctx = ctx.cacheContext(cacheId); + + prepareMarshalCacheObject(key, cctx); + + if (val != null) + prepareMarshalCacheObject(val, cctx); + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index 7ec70cf19e48a..38efb2c32037d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -337,6 +337,17 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { errs.addFailedKeys(keys, e); } + /** {@inheritDoc} + * @param ctx*/ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + GridCacheContext cctx = ctx.cacheContext(cacheId); + + if (nearUpdates != null) + prepareMarshalCacheObjects(nearUpdates.nearValues(), cctx); + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java index d1e0d942c38f5..0e42f82082251 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java @@ -115,6 +115,11 @@ void addFailedKeys(Collection keys, Throwable e) { errMsg.error().addSuppressed(e); } + /** */ + void prepareMarshal(GridCacheMessage msg, GridCacheContext cctx) throws IgniteCheckedException { + msg.prepareMarshalCacheObjects(failedKeys, cctx); + } + /** */ void finishUnmarshal(GridCacheMessage msg, GridCacheContext cctx, ClassLoader ldr) throws IgniteCheckedException { msg.finishUnmarshalCacheObjects(failedKeys, cctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 4628adfdabd3b..898ad4478f086 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -113,6 +113,15 @@ public Collection keys() { return topVer; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + GridCacheContext cctx = ctx.cacheContext(cacheId); + + prepareMarshalCacheObjects(keys, cctx); + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index 3b68fa9cebc2b..0f7391958f044 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -131,6 +131,16 @@ public void addInfo(GridCacheEntryInfo info) { infos.add(info); } + /** {@inheritDoc} */ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + GridCacheContext cctx = ctx.cacheContext(cacheId); + + if (missedKeys != null) + prepareMarshalCacheObjects(missedKeys, cctx); + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index da185e7aa3902..74ad48394405d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -280,6 +280,22 @@ public long accessTtl() { return txLbl; } + /** + * @param ctx Cache context. + * @throws IgniteCheckedException If failed. + */ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + assert ctx != null; + assert !F.isEmpty(keys); + assert readersFlags == null || keys.size() == readersFlags.size(); + + GridCacheContext cctx = ctx.cacheContext(cacheId); + + prepareMarshalCacheObjects(keys, cctx); + } + /** * @param ctx Context. * @param ldr Loader. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java index abceaf5bb9efe..07ca1355fc0f0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java @@ -249,6 +249,17 @@ public boolean recovery() { return (flags & RECOVERY_FLAG_MASK) != 0; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + assert key != null; + + GridCacheContext cctx = ctx.cacheContext(cacheId); + + prepareMarshalCacheObject(key, cctx); + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java index 397ed4a316e6d..b96972fb7e7de 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java @@ -144,6 +144,18 @@ public long futureId() { return futId; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + if (res != null) { + GridCacheContext cctx = ctx.cacheContext(cacheId); + + if (res instanceof CacheObject) + prepareMarshalCacheObject((CacheObject)res, cctx); + } + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); From 0774499b73560d8323cfa520c30362e7605791e5 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 8 May 2026 21:29:05 +0300 Subject: [PATCH 013/215] WIP --- .../internal/MessageSerializerGenerator.java | 76 ++++++++++++++++++- .../processors/cache/GridCacheMessage.java | 10 --- .../near/GridNearTxPrepareRequest.java | 5 -- .../cache/transactions/IgniteTxEntry.java | 27 +++---- 4 files changed, 85 insertions(+), 33 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 4bfc0d6965513..caecf87039a14 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -307,13 +307,19 @@ private enum FieldKind { CO_COLL, /** {@code CacheObject[]} / {@code KeyCacheObject[]}. */ CO_ARR, + /** {@code CacheEntryPredicate} scalar. */ + CEP, + /** {@code Collection}. */ + CEP_COLL, + /** {@code CacheEntryPredicate[]}. */ + CEP_ARR, /** Nested concrete {@code Message}. */ MSG, /** {@code Collection} with concrete element type. */ MSG_COLL, /** {@code Message[]} with concrete component type. */ MSG_ARR, - /** {@code Map} with at least one CO/Message side. */ + /** {@code Map} with at least one CacheObject/Message side. */ MAP, /** Skipped — abstract Message, cross-cache nested Message, Map with no traversable side, unsupported. */ SKIP @@ -329,6 +335,9 @@ private FieldKind classify(TypeMirror t) { if (isCacheObjectType(comp)) return FieldKind.CO_ARR; + + if (isCacheEntryPredicate(comp)) + return FieldKind.CEP_ARR; return isRecursableMessage(comp) ? FieldKind.MSG_ARR : FieldKind.SKIP; } @@ -339,6 +348,9 @@ private FieldKind classify(TypeMirror t) { if (isCacheObjectType(t)) return FieldKind.CO; + if (isCacheEntryPredicate(t)) + return FieldKind.CEP; + if (assignableFrom(erasedType(t), type(Map.class.getName()))) { List args = ((DeclaredType)t).getTypeArguments(); @@ -368,6 +380,9 @@ private FieldKind classify(TypeMirror t) { if (isCacheObjectType(arg)) return FieldKind.CO_COLL; + if (isCacheEntryPredicate(arg)) + return FieldKind.CEP_COLL; + return isRecursableMessage(arg) ? FieldKind.MSG_COLL : FieldKind.SKIP; } @@ -383,6 +398,9 @@ private FieldKind classifyMapSide(TypeMirror t) { if (isCacheObjectType(t)) return FieldKind.CO; + if (isCacheEntryPredicate(t)) + return FieldKind.CEP; + return isRecursableMessage(t) ? FieldKind.MSG : FieldKind.SKIP; } @@ -391,6 +409,11 @@ private boolean isCacheObjectType(TypeMirror type) { return assignableFrom(type, type("org.apache.ignite.internal.processors.cache.CacheObject")); } + /** */ + private boolean isCacheEntryPredicate(TypeMirror type) { + return assignableFrom(type, type("org.apache.ignite.internal.processors.cache.CacheEntryPredicate")); + } + /** True if {@code t} is a concrete non-abstract {@code Message} safe to recurse into (no self-ref). */ private boolean isRecursableMessage(TypeMirror t) { TypeMirror msgIface = type(MESSAGE_INTERFACE); @@ -440,6 +463,15 @@ private void emitCacheObjectCall(List code, VariableElement field) { emitCoIterable(code, accessor, t, kind == FieldKind.CO_ARR); break; + case CEP: + emitCepDirect(code, accessor); + break; + + case CEP_COLL: + case CEP_ARR: + emitCepIterable(code, accessor); + break; + case MSG: emitMsgDirect(code, accessor); break; @@ -601,6 +633,48 @@ private void emitCoIterable(List code, String accessor, TypeMirror t, bo code.add(identedLine("}")); } + private void emitCepDirect(List code, String accessor) { + code.add(identedLine("if (%s != null)", accessor)); + + indent++; + + code.add(identedLine("%s.prepareMarshal(ctx);", accessor)); + + indent--; + } + + private void emitCepIterable(List code, String accessor) { + String elementType = "org.apache.ignite.internal.processors.cache.CacheEntryPredicate"; + + imports.add(elementType); + + String simple = elementType.substring(elementType.lastIndexOf('.') + 1); + + code.add(identedLine("if (%s != null) {", accessor)); + + indent++; + + code.add(identedLine("for (%s obj : %s) {", simple, accessor)); + + indent++; + + code.add(identedLine("if (obj != null)")); + + indent++; + + code.add(identedLine("obj.prepareMarshal(ctx);")); + + indent--; + + indent--; + + code.add(identedLine("}")); + + indent--; + + code.add(identedLine("}")); + } + /** */ private void emitMsgDirect(List code, String accessor) { code.add(identedLine("if (%s != null)", accessor)); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index 2719bfaef7203..b22c45b9cea53 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -371,12 +371,9 @@ protected final void marshalTx(Iterable txEntries, GridCacheShare 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) { @@ -402,13 +399,6 @@ else if (p2pEnabled && e.entryProcessors() != null) { } } - /** - * @return {@code True} if entries expire policy should be marshalled. - */ - protected boolean transferExpiryPolicy() { - return false; - } - /** * @param txEntries Entries to unmarshal. * @param ctx Context. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java index 05b7f6ef918a1..a9ada7e55545a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java @@ -265,11 +265,6 @@ private Collection cloneEntries(Collection c) { return cp; } - /** {@inheritDoc} */ - @Override protected boolean transferExpiryPolicy() { - return true; - } - /** * Sets flag mask. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index d9f1e3deac4e2..45163be0b690b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -25,6 +25,7 @@ import javax.cache.processor.EntryProcessor; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; @@ -47,8 +48,8 @@ import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; @@ -60,7 +61,7 @@ * {@link #equals(Object)} method, as transaction entries should use referential * equality. */ -public class IgniteTxEntry implements GridPeerDeployAware, Message, CacheIdAware { +public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, CacheIdAware { /** */ private static final long serialVersionUID = 0L; @@ -1022,25 +1023,13 @@ public void filtersSet(boolean filtersSet) { this.filtersSet = filtersSet; } - /** - * @param ctx Context. - * @param transferExpiry {@code True} if expire policy should be marshalled. - * @throws IgniteCheckedException If failed. - */ - public void marshal(GridCacheSharedContext ctx, boolean transferExpiry) throws IgniteCheckedException { - if (filters != null) { - for (CacheEntryPredicate p : filters) { - if (p != null) - p.prepareMarshal(this.ctx); - } - } - + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { // Do not serialize filters if they are null. if (transformClosBytes == null && entryProcessorsCol != null) transformClosBytes = CU.marshal(this.ctx, entryProcessorsCol); - if (transferExpiry) - transferExpiryPlc = expiryPlc != null && expiryPlc != this.ctx.expiry(); + transferExpiryPlc = expiryPlc != null && expiryPlc != this.ctx.expiry(); if (transferExpiryPlc) { if (expiryPlcBytes == null) @@ -1050,6 +1039,10 @@ public void marshal(GridCacheSharedContext ctx, boolean transferExpiry) th expiryPlcBytes = null; } + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + } + /** * Prepares this entry to unmarshall. In particular, this method initialize a cache context. * From a87dcde9a49c1d83477f99de837fd4c568103be9 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 8 May 2026 21:52:32 +0300 Subject: [PATCH 014/215] WIP --- .../processors/cache/GridCacheMessage.java | 18 +++++++-------- .../GridCacheTtlUpdateRequest.java | 4 ++-- .../GridDistributedLockRequest.java | 2 +- .../GridDistributedLockResponse.java | 2 +- .../GridDistributedTxPrepareRequest.java | 5 ++--- .../distributed/GridNearUnlockRequest.java | 2 +- .../distributed/dht/GridDhtLockResponse.java | 2 +- .../dht/GridDhtTxPrepareRequest.java | 2 +- .../distributed/dht/GridDhtUnlockRequest.java | 2 +- .../atomic/GridDhtAtomicUpdateRequest.java | 14 ++++++------ .../atomic/GridDhtAtomicUpdateResponse.java | 2 +- .../GridNearAtomicFullUpdateRequest.java | 22 +++++-------------- ...idNearAtomicSingleUpdateFilterRequest.java | 18 ++------------- .../GridNearAtomicSingleUpdateRequest.java | 4 ++-- .../atomic/GridNearAtomicUpdateResponse.java | 2 +- .../distributed/dht/atomic/UpdateErrors.java | 2 +- .../preloader/GridDhtForceKeysRequest.java | 2 +- .../preloader/GridDhtForceKeysResponse.java | 2 +- .../GridDhtPartitionSupplyMessage.java | 2 +- .../distributed/near/GridNearGetRequest.java | 2 +- .../near/GridNearSingleGetRequest.java | 2 +- .../near/GridNearSingleGetResponse.java | 2 +- .../cache/query/GridCacheQueryResponse.java | 2 +- 23 files changed, 45 insertions(+), 72 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index b22c45b9cea53..1d1e564612ea3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -291,7 +291,7 @@ public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) t * @param cacheObjCtx Cache object context. * @throws IgniteCheckedException If failed. */ - protected final void marshalInfo(GridCacheEntryInfo info, + protected final void prepareInfo(GridCacheEntryInfo info, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx ) throws IgniteCheckedException { @@ -333,7 +333,7 @@ protected final void unmarshalInfo(GridCacheEntryInfo info, GridCacheContext ctx * @param ctx Context. * @throws IgniteCheckedException If failed. */ - protected final void marshalInfos( + protected final void prepareInfos( Iterable infos, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx @@ -342,7 +342,7 @@ protected final void marshalInfos( if (infos != null) for (GridCacheEntryInfo e : infos) - marshalInfo(e, ctx, cacheObjCtx); + prepareInfo(e, ctx, cacheObjCtx); } /** @@ -366,7 +366,7 @@ protected final void unmarshalInfos(Iterable infos * @param ctx Context. * @throws IgniteCheckedException If failed. */ - protected final void marshalTx(Iterable txEntries, GridCacheSharedContext ctx) + protected final void prepareTx(Iterable txEntries, GridCacheSharedContext ctx) throws IgniteCheckedException { assert ctx != null; @@ -480,7 +480,7 @@ protected final void unmarshalTx(Iterable txEntries, * @return Marshalled collection. * @throws IgniteCheckedException If failed. */ - @Nullable protected List marshalCollection(@Nullable Collection col, + @Nullable protected List marshalAndPrepareCollection(@Nullable Collection col, GridCacheContext ctx) throws IgniteCheckedException { assert ctx != null; @@ -505,7 +505,7 @@ protected final void unmarshalTx(Iterable txEntries, * @throws IgniteCheckedException If failed. */ @SuppressWarnings("ForLoopReplaceableByForEach") - public final void prepareMarshalCacheObjects(@Nullable List col, + public final void prepareCacheObjects(@Nullable List col, GridCacheContext ctx) throws IgniteCheckedException { if (col == null) return; @@ -513,7 +513,7 @@ public final void prepareMarshalCacheObjects(@Nullable List col, + protected final void prepareCacheObjects(@Nullable Collection col, GridCacheContext ctx) throws IgniteCheckedException { if (col == null) return; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java index c83e732f6181a..3750312df3113 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java @@ -161,9 +161,9 @@ public List nearVersions() { GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareMarshalCacheObjects(keys, cctx); + prepareCacheObjects(keys, cctx); - prepareMarshalCacheObjects(nearKeys, cctx); + prepareCacheObjects(nearKeys, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index b02d75024fec5..edba35b3ff27e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -353,7 +353,7 @@ public long timeout() { GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareMarshalCacheObjects(keys, cctx); + prepareCacheObjects(keys, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java index cbf10745a7a19..4bcb22b0b17b8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java @@ -164,7 +164,7 @@ protected int valuesSize() { @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { super.prepareMarshal(ctx); - prepareMarshalCacheObjects(vals, ctx.cacheContext(cacheId)); + prepareCacheObjects(vals, ctx.cacheContext(cacheId)); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 3bcbaa4e001c5..b26dc8bce8bf2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -26,7 +26,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; @@ -376,10 +375,10 @@ public void applicationAttributes(Map appAttrs) { super.prepareMarshal(ctx); if (writes != null) - marshalTx(writes, ctx); + prepareTx(writes, ctx); if (reads != null) - marshalTx(reads, ctx); + prepareTx(reads, ctx); if (dhtVers != null && dhtVerKeys == null) { dhtVerKeys = dhtVers.keySet(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java index 7f46f96774850..fb4feade50f68 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java @@ -98,7 +98,7 @@ public void addKey(KeyCacheObject key) { @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { super.prepareMarshal(ctx); - prepareMarshalCacheObjects(keys, ctx.cacheContext(cacheId)); + prepareCacheObjects(keys, ctx.cacheContext(cacheId)); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index e73f606c827eb..49e155a8dfab7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -130,7 +130,7 @@ public Collection preloadEntries() { GridCacheContext cctx = ctx.cacheContext(cacheId); if (preloadEntries != null) - marshalInfos(preloadEntries, cctx.shared(), cctx.cacheObjectContext()); + prepareInfos(preloadEntries, cctx.shared(), cctx.cacheObjectContext()); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 62b4e2e159434..3d43238e6310f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -337,7 +337,7 @@ public boolean skipCompletedVersion() { } if (nearWrites != null) - marshalTx(nearWrites, ctx); + prepareTx(nearWrites, ctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index 8c5fc051a69e7..d2d97808d3986 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -74,7 +74,7 @@ public void addNearKey(KeyCacheObject key) @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { super.prepareMarshal(ctx); - prepareMarshalCacheObjects(nearKeys, ctx.cacheContext(cacheId)); + prepareCacheObjects(nearKeys, ctx.cacheContext(cacheId)); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 4d06d1705daaf..6fcd2e5ab3bf3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -467,15 +467,15 @@ else if (conflictVers != null) GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareMarshalCacheObjects(keys, cctx); + prepareCacheObjects(keys, cctx); - prepareMarshalCacheObjects(vals, cctx); + prepareCacheObjects(vals, cctx); - prepareMarshalCacheObjects(nearKeys, cctx); + prepareCacheObjects(nearKeys, cctx); - prepareMarshalCacheObjects(nearVals, cctx); + prepareCacheObjects(nearVals, cctx); - prepareMarshalCacheObjects(prevVals, cctx); + prepareCacheObjects(prevVals, cctx); if (forceTransformBackups) { // force addition of deployment info for entry processors if P2P is enabled globally. @@ -486,10 +486,10 @@ else if (conflictVers != null) invokeArgsBytes = Arrays.asList(marshalInvokeArguments(invokeArgs, cctx)); if (entryProcessorsBytes == null) - entryProcessorsBytes = marshalCollection(entryProcessors, cctx); + entryProcessorsBytes = marshalAndPrepareCollection(entryProcessors, cctx); if (nearEntryProcessorsBytes == null) - nearEntryProcessorsBytes = marshalCollection(nearEntryProcessors, cctx); + nearEntryProcessorsBytes = marshalAndPrepareCollection(nearEntryProcessors, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index 097e240c988b3..b241f6fbd9327 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -126,7 +126,7 @@ public void nearEvicted(List nearEvicted) { // Can be null if client near cache was removed, in this case assume do not need prepareMarshal. if (cctx != null) - prepareMarshalCacheObjects(nearEvicted, cctx); + prepareCacheObjects(nearEvicted, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index 62fcf3966d916..4a4c868148448 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -336,22 +336,10 @@ else if (conflictVers != null) if (expiryPlc != null && expiryPlcBytes == null) expiryPlcBytes = CU.marshal(cctx, new IgniteExternalizableExpiryPolicy(expiryPlc)); - prepareMarshalCacheObjects(keys, cctx); + prepareCacheObjects(keys, cctx); - if (filter != null) { - boolean hasFilter = false; - - for (CacheEntryPredicate p : filter) { - if (p != null) { - hasFilter = true; - - p.prepareMarshal(cctx); - } - } - - if (!hasFilter) - filter = null; - } + if (filter != null && filter.length == 0) + filter = null; if (operation() == TRANSFORM) { // force addition of deployment info for entry processors if P2P is enabled globally. @@ -359,13 +347,13 @@ else if (conflictVers != null) addDepInfo = true; if (entryProcessorsBytes == null) - entryProcessorsBytes = marshalCollection(entryProcessors, cctx); + entryProcessorsBytes = marshalAndPrepareCollection(entryProcessors, cctx); if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) invokeArgsBytes = Arrays.asList(marshalInvokeArguments(invokeArgs, cctx)); } else - prepareMarshalCacheObjects(vals, cctx); + prepareCacheObjects(vals, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java index 7b072491d4f89..a5da3a9365838 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java @@ -95,22 +95,8 @@ public GridNearAtomicSingleUpdateFilterRequest() { @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { super.prepareMarshal(ctx); - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (filter != null) { - boolean hasFilter = false; - - for (CacheEntryPredicate p : filter) { - if (p != null) { - hasFilter = true; - - p.prepareMarshal(cctx); - } - } - - if (!hasFilter) - filter = null; - } + if (filter != null && filter.length == 0) + filter = null; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java index 25b31b062c7c3..67a18d83c7cd1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java @@ -222,10 +222,10 @@ public GridNearAtomicSingleUpdateRequest() { GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareMarshalCacheObject(key, cctx); + prepareCacheObject(key, cctx); if (val != null) - prepareMarshalCacheObject(val, cctx); + prepareCacheObject(val, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index 38efb2c32037d..a66dc49a2deb8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -345,7 +345,7 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { GridCacheContext cctx = ctx.cacheContext(cacheId); if (nearUpdates != null) - prepareMarshalCacheObjects(nearUpdates.nearValues(), cctx); + prepareCacheObjects(nearUpdates.nearValues(), cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java index 0e42f82082251..c0bcb272a3fe2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java @@ -117,7 +117,7 @@ void addFailedKeys(Collection keys, Throwable e) { /** */ void prepareMarshal(GridCacheMessage msg, GridCacheContext cctx) throws IgniteCheckedException { - msg.prepareMarshalCacheObjects(failedKeys, cctx); + msg.prepareCacheObjects(failedKeys, cctx); } /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 898ad4478f086..93d12397cd442 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -119,7 +119,7 @@ public Collection keys() { GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareMarshalCacheObjects(keys, cctx); + prepareCacheObjects(keys, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index 0f7391958f044..f4d14426e2e3d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -138,7 +138,7 @@ public void addInfo(GridCacheEntryInfo info) { GridCacheContext cctx = ctx.cacheContext(cacheId); if (missedKeys != null) - prepareMarshalCacheObjects(missedKeys, cctx); + prepareCacheObjects(missedKeys, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index a800ab4d1f7a8..9a1944a721a04 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -215,7 +215,7 @@ void addEntry0(int p, boolean historical, GridCacheEntryInfo info, GridCacheShar assert info.value() != null || historical : info; // Need to call this method to initialize info properly. - marshalInfo(info, ctx, cacheObjCtx); + prepareInfo(info, ctx, cacheObjCtx); msgSize += info.marshalledSize(cacheObjCtx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index 74ad48394405d..1ada1a83ed7af 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -293,7 +293,7 @@ public long accessTtl() { GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareMarshalCacheObjects(keys, cctx); + prepareCacheObjects(keys, cctx); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java index 07ca1355fc0f0..2e27d2d16485e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java @@ -257,7 +257,7 @@ public boolean recovery() { GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareMarshalCacheObject(key, cctx); + prepareCacheObject(key, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java index b96972fb7e7de..8bdcfccb953f7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java @@ -152,7 +152,7 @@ public long futureId() { GridCacheContext cctx = ctx.cacheContext(cacheId); if (res instanceof CacheObject) - prepareMarshalCacheObject((CacheObject)res, cctx); + prepareCacheObject((CacheObject)res, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index 6b295f2561182..da19ed40728e2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -111,7 +111,7 @@ public GridCacheQueryResponse(int cacheId, long reqId, Throwable err, boolean ad GridCacheContext cctx = ctx.cacheContext(cacheId); if (dataBytes == null && data != null) - dataBytes = marshalCollection(data, cctx); + dataBytes = marshalAndPrepareCollection(data, cctx); if (addDepInfo && !F.isEmpty(data)) { for (Object o : data) { From ee4c879cc7cc3ab1ae82dd41c37690c768d9cacf Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 8 May 2026 21:54:00 +0300 Subject: [PATCH 015/215] WIP --- .../apache/ignite/internal/MessageSerializerGenerator.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index caecf87039a14..9c875118caad8 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -277,7 +277,8 @@ private void generateCacheObjectMarshallMethods(List orderedFie indent++; if (isCacheIdAwareMessage(type)) - prepareCacheObjects.add(identedLine("GridCacheContext ctx = nested == null ? sctx.cacheContext(msg.cacheId()) : nested;")); + prepareCacheObjects.add( + identedLine("GridCacheContext ctx = nested == null ? sctx.cacheContext(msg.cacheId()) : nested;")); else prepareCacheObjects.add(identedLine("GridCacheContext ctx = nested;")); @@ -633,6 +634,7 @@ private void emitCoIterable(List code, String accessor, TypeMirror t, bo code.add(identedLine("}")); } + /** */ private void emitCepDirect(List code, String accessor) { code.add(identedLine("if (%s != null)", accessor)); @@ -643,6 +645,7 @@ private void emitCepDirect(List code, String accessor) { indent--; } + /** */ private void emitCepIterable(List code, String accessor) { String elementType = "org.apache.ignite.internal.processors.cache.CacheEntryPredicate"; From 53036be2c0cd8cdd4656e75e62a78e79580c8786 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 8 May 2026 21:56:56 +0300 Subject: [PATCH 016/215] WIP --- .../processors/cache/distributed/near/CacheVersionedValue.java | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java index a46c4d1ee1c4b..12432cbded298 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java @@ -20,7 +20,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.tostring.GridToStringInclude; From 76802b7144aef96ace0295022d3e55236e61abae Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 8 May 2026 22:19:20 +0300 Subject: [PATCH 017/215] WIP --- .../processors/cache/transactions/TxEntryValueHolder.java | 1 - .../plugin/extensions/communication/MessageSerializer.java | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java index 89a6ffe0dd4c2..1050b7fa22373 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index 9b24885cbe183..71ebb4765aa5d 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -47,8 +47,8 @@ public interface MessageSerializer { * non-null when invoking this method; resolution-with-null-skip happens at call sites. * * @param msg Message instance. - * @param ctx Cache object value context for {@code msg}'s direct {@code CacheObject} fields and non-cacheId-aware - * nested messages. Always non-null. + * @param sctx Shared context. + * @param nested Nested context. * @throws IgniteCheckedException If marshalling fails. */ public default void prepareMarshalCacheObjects(M msg, GridCacheSharedContext sctx, GridCacheContext nested) From 854aeb8de3b5f766c153e36ea76bdd3a6c0efca6 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 8 May 2026 22:29:19 +0300 Subject: [PATCH 018/215] WIP --- .../plugin/extensions/communication/MessageSerializer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index 71ebb4765aa5d..102ac89ee7510 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -51,7 +51,7 @@ public interface MessageSerializer { * @param nested Nested context. * @throws IgniteCheckedException If marshalling fails. */ - public default void prepareMarshalCacheObjects(M msg, GridCacheSharedContext sctx, GridCacheContext nested) + public default void prepareMarshalCacheObjects(M msg, GridCacheSharedContext sctx, GridCacheContext nested) throws IgniteCheckedException { // No-op by default. } From 049abc99959bc6e167fa59bc3945b92eaef33eef Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 8 May 2026 22:34:10 +0300 Subject: [PATCH 019/215] WIP --- .../processors/query/h2/twostep/msg/GridH2CacheObject.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java index d15b25c7b1b8f..d2db3800af5aa 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java @@ -43,7 +43,7 @@ public GridH2CacheObject() { /** * @param v Value. */ - public GridH2CacheObject(GridH2ValueCacheObject v) { + public GridH2CacheObject(GridH2ValueCacheObject v) { obj = v.getCacheObject(); } From b95ccefc32a4fe229501548efbc828a77ca9d6b6 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sun, 10 May 2026 15:47:11 +0300 Subject: [PATCH 020/215] WIP --- .../processors/query/h2/twostep/msg/GridH2CacheObject.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java index d2db3800af5aa..559f96bccad5c 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java @@ -42,9 +42,12 @@ public GridH2CacheObject() { /** * @param v Value. + * @throws IgniteCheckedException If failed. */ - public GridH2CacheObject(GridH2ValueCacheObject v) { + public GridH2CacheObject(GridH2ValueCacheObject v) throws IgniteCheckedException { obj = v.getCacheObject(); + + obj.prepareMarshal(v.valueContext()); } /** {@inheritDoc} */ From 0c02ce62bc862a83130a89a0c398a35caec2bf7f Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sun, 10 May 2026 19:42:51 +0300 Subject: [PATCH 021/215] WIP --- .../query/calcite/message/MessageServiceImpl.java | 9 ++++++++- .../processors/query/calcite/message/QueryTxEntry.java | 7 ++++--- .../processors/cache/transactions/IgniteTxManager.java | 8 +++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java index dd421bf1f6cc3..3e6c7aa8dd09a 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java @@ -39,6 +39,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; /** * @@ -184,8 +185,14 @@ public FailureProcessor failureProcessor() { /** */ protected void prepareMarshal(Message msg) throws IgniteCheckedException { try { - if (msg instanceof CalciteContextMarshallableMessage) + if (msg instanceof CalciteContextMarshallableMessage) { ((CalciteContextMarshallableMessage)msg).prepareMarshal(ctx); + + MessageSerializer ser = ctx.gridIO().messageFactory().serializer(msg.directType()); + + if (ser != null) + ser.prepareMarshalCacheObjects(msg, ctx, null); + } } catch (Exception e) { failureProcessor().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java index 8f5d44a466336..da49c14612be7 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java @@ -29,6 +29,7 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext; +import org.apache.ignite.plugin.extensions.communication.CacheIdAware; /** * Class to pass to remote nodes transaction changes. @@ -38,7 +39,7 @@ * @see ExecutionContext#transactionChanges(int, int[], Function, Comparator) * @see QueryStartRequest#queryTransactionEntries() */ -public class QueryTxEntry implements CalciteContextMarshallableMessage { +public class QueryTxEntry implements CalciteContextMarshallableMessage, CacheIdAware { /** Cache id. */ @Order(0) int cacheId; @@ -75,8 +76,8 @@ public QueryTxEntry(int cacheId, KeyCacheObject key, CacheObject val, GridCacheV this.ver = ver; } - /** @return Cache id. */ - public int cacheId() { + /** {@inheritDoc} */ + @Override public int cacheId() { return cacheId; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index d5e2111cf3429..740099834bf8c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -3367,9 +3367,15 @@ private class DeadlockDetectionListener implements GridMessageListener { res.futureId(req.futureId()); try { - if (!cctx.localNodeId().equals(nodeId)) + if (!cctx.localNodeId().equals(nodeId)) { res.prepareMarshal(cctx); + MessageSerializer ser = cctx.gridIO().messageFactory().serializer(req.directType()); + + if (ser != null) + ser.prepareMarshalCacheObjects(req, cctx, null); + } + cctx.gridIO().sendToGridTopic(nodeId, TOPIC_TX, res, SYSTEM_POOL); } catch (ClusterTopologyCheckedException e) { From 0f870766ece348b08a2aaddbfc2cd26bac4e28e2 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 12 May 2026 14:08:03 +0300 Subject: [PATCH 022/215] WIP --- .../internal/MessageSerializerGenerator.java | 76 ------------------- 1 file changed, 76 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 9c875118caad8..ab53c9eb6a7f2 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -308,12 +308,6 @@ private enum FieldKind { CO_COLL, /** {@code CacheObject[]} / {@code KeyCacheObject[]}. */ CO_ARR, - /** {@code CacheEntryPredicate} scalar. */ - CEP, - /** {@code Collection}. */ - CEP_COLL, - /** {@code CacheEntryPredicate[]}. */ - CEP_ARR, /** Nested concrete {@code Message}. */ MSG, /** {@code Collection} with concrete element type. */ @@ -336,9 +330,6 @@ private FieldKind classify(TypeMirror t) { if (isCacheObjectType(comp)) return FieldKind.CO_ARR; - - if (isCacheEntryPredicate(comp)) - return FieldKind.CEP_ARR; return isRecursableMessage(comp) ? FieldKind.MSG_ARR : FieldKind.SKIP; } @@ -349,9 +340,6 @@ private FieldKind classify(TypeMirror t) { if (isCacheObjectType(t)) return FieldKind.CO; - if (isCacheEntryPredicate(t)) - return FieldKind.CEP; - if (assignableFrom(erasedType(t), type(Map.class.getName()))) { List args = ((DeclaredType)t).getTypeArguments(); @@ -381,9 +369,6 @@ private FieldKind classify(TypeMirror t) { if (isCacheObjectType(arg)) return FieldKind.CO_COLL; - if (isCacheEntryPredicate(arg)) - return FieldKind.CEP_COLL; - return isRecursableMessage(arg) ? FieldKind.MSG_COLL : FieldKind.SKIP; } @@ -399,9 +384,6 @@ private FieldKind classifyMapSide(TypeMirror t) { if (isCacheObjectType(t)) return FieldKind.CO; - if (isCacheEntryPredicate(t)) - return FieldKind.CEP; - return isRecursableMessage(t) ? FieldKind.MSG : FieldKind.SKIP; } @@ -410,11 +392,6 @@ private boolean isCacheObjectType(TypeMirror type) { return assignableFrom(type, type("org.apache.ignite.internal.processors.cache.CacheObject")); } - /** */ - private boolean isCacheEntryPredicate(TypeMirror type) { - return assignableFrom(type, type("org.apache.ignite.internal.processors.cache.CacheEntryPredicate")); - } - /** True if {@code t} is a concrete non-abstract {@code Message} safe to recurse into (no self-ref). */ private boolean isRecursableMessage(TypeMirror t) { TypeMirror msgIface = type(MESSAGE_INTERFACE); @@ -464,15 +441,6 @@ private void emitCacheObjectCall(List code, VariableElement field) { emitCoIterable(code, accessor, t, kind == FieldKind.CO_ARR); break; - case CEP: - emitCepDirect(code, accessor); - break; - - case CEP_COLL: - case CEP_ARR: - emitCepIterable(code, accessor); - break; - case MSG: emitMsgDirect(code, accessor); break; @@ -634,50 +602,6 @@ private void emitCoIterable(List code, String accessor, TypeMirror t, bo code.add(identedLine("}")); } - /** */ - private void emitCepDirect(List code, String accessor) { - code.add(identedLine("if (%s != null)", accessor)); - - indent++; - - code.add(identedLine("%s.prepareMarshal(ctx);", accessor)); - - indent--; - } - - /** */ - private void emitCepIterable(List code, String accessor) { - String elementType = "org.apache.ignite.internal.processors.cache.CacheEntryPredicate"; - - imports.add(elementType); - - String simple = elementType.substring(elementType.lastIndexOf('.') + 1); - - code.add(identedLine("if (%s != null) {", accessor)); - - indent++; - - code.add(identedLine("for (%s obj : %s) {", simple, accessor)); - - indent++; - - code.add(identedLine("if (obj != null)")); - - indent++; - - code.add(identedLine("obj.prepareMarshal(ctx);")); - - indent--; - - indent--; - - code.add(identedLine("}")); - - indent--; - - code.add(identedLine("}")); - } - /** */ private void emitMsgDirect(List code, String accessor) { code.add(identedLine("if (%s != null)", accessor)); From 7aaa915a731cbd07781baa863e82787e290dac26 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 12 May 2026 15:44:46 +0300 Subject: [PATCH 023/215] WIP --- .../continuous/CacheContinuousQueryEntry.java | 56 ++++--------------- .../CacheContinuousQueryHandler.java | 6 ++ 2 files changed, 17 insertions(+), 45 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java index 70caf5f5342c9..5f6aaf84d0790 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java @@ -19,7 +19,6 @@ import javax.cache.event.EventType; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.deployment.GridDeploymentInfo; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; @@ -30,13 +29,14 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.CacheIdAware; +import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; /** * Continuous query entry. */ -public class CacheContinuousQueryEntry implements GridCacheDeployable, MarshallableMessage { +public class CacheContinuousQueryEntry implements GridCacheDeployable, Message, CacheIdAware { /** */ private static final byte BACKUP_ENTRY = 0b0001; @@ -56,27 +56,18 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Marshalla /** Key. */ @GridToStringInclude - KeyCacheObject key; - - /** */ @Order(2) - byte[] keyBytes; + KeyCacheObject key; /** New value. */ @GridToStringInclude - CacheObject newVal; - - /** */ @Order(3) - byte[] newValBytes; + CacheObject newVal; /** Old value. */ @GridToStringInclude - CacheObject oldVal; - - /** */ @Order(4) - byte[] oldValBytes; + CacheObject oldVal; /** Cache name. */ @Order(5) @@ -194,10 +185,8 @@ public byte flags() { return topVer; } - /** - * @return Cache ID. - */ - int cacheId() { + /** {@inheritDoc} */ + @Override public int cacheId() { return cacheId; } @@ -235,6 +224,9 @@ void markBackup() { void markFiltered() { flags |= FILTERED_ENTRY; depInfo = null; + key = null; + newVal = null; + oldVal = null; } /** @@ -349,30 +341,4 @@ CacheObject oldValue() { @Override public String toString() { return S.toString(CacheContinuousQueryEntry.class, this); } - - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (!isFiltered()) { - if (key != null) - keyBytes = marsh.marshal(key); - - if (newVal != null) - newValBytes = marsh.marshal(newVal); - - if (oldVal != null) - oldValBytes = marsh.marshal(oldVal); - } - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (keyBytes != null) - key = marsh.unmarshal(keyBytes, clsLdr); - - if (newValBytes != null) - newVal = marsh.unmarshal(newValBytes, clsLdr); - - if (oldValBytes != null) - oldVal = marsh.unmarshal(oldValBytes, clsLdr); - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java index 902b418f64fe3..b977fe87f4795 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java @@ -82,6 +82,7 @@ import org.apache.ignite.lang.IgniteAsyncCallback; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteClosure; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -928,6 +929,11 @@ protected CacheEntryEventFilter getEventFilter0() { */ private void prepareEntry(GridCacheContext cctx, UUID nodeId, CacheContinuousQueryEntry entry) throws IgniteCheckedException { + MessageSerializer ser = cctx.gridIO().messageFactory().serializer(entry.directType()); + + if (ser != null) + ser.prepareMarshalCacheObjects(entry, cctx.shared(), null); + if (cctx.kernalContext().config().isPeerClassLoadingEnabled() && cctx.discovery().node(nodeId) != null) cctx.deploy().prepare(entry); } From 5737bcd7c776450a81ac704b9369c1042abe2b48 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 13 May 2026 16:21:38 +0300 Subject: [PATCH 024/215] WIP --- .../distributed/dht/GridDhtCacheAdapter.java | 4 ++-- .../distributed/near/CacheVersionedValue.java | 14 ++++++++++++-- .../near/GridNearTxPrepareResponse.java | 18 +++++++++++++++++- .../cache/transactions/IgniteTxEntry.java | 9 +++++---- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java index 7277db3ccd698..ec2e09483c0d1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java @@ -1214,9 +1214,9 @@ protected void processNearSingleGetRequest(final UUID nodeId, final GridNearSing res0 = info; } else if (req.needVersion()) - res0 = new CacheVersionedValue(info.value(), info.version()); + res0 = new CacheVersionedValue(info.value(), info.version(), info.cacheId()); else - res0 = new CacheVersionedValue(info.value(), null); + res0 = new CacheVersionedValue(info.value(), null, info.cacheId()); } res = new GridNearSingleGetResponse( diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java index 12432cbded298..21d11e1d45393 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java @@ -24,12 +24,13 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.plugin.extensions.communication.CacheIdAware; import org.apache.ignite.plugin.extensions.communication.Message; /** * Cache object and version. */ -public class CacheVersionedValue implements Message { +public class CacheVersionedValue implements Message, CacheIdAware { /** Value. */ @Order(0) @GridToStringInclude @@ -39,6 +40,9 @@ public class CacheVersionedValue implements Message { @Order(1) @GridToStringInclude GridCacheVersion ver; + + /** */ + private int cacheId; /** */ public CacheVersionedValue() { @@ -49,9 +53,10 @@ public CacheVersionedValue() { * @param val Cache value. * @param ver Cache version. */ - public CacheVersionedValue(CacheObject val, GridCacheVersion ver) { + public CacheVersionedValue(CacheObject val, GridCacheVersion ver, int cacheId) { this.val = val; this.ver = ver; + this.cacheId = cacheId; } /** @@ -86,4 +91,9 @@ public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws Ignite @Override public String toString() { return S.toString(CacheVersionedValue.class, this); } + + /** {@inheritDoc} */ + @Override public int cacheId() { + return cacheId; + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index 34b71de34bfb9..c0994bfa5bd90 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -196,7 +196,7 @@ public void addOwnedValue(IgniteTxKey key, GridCacheVersion ver, CacheObject val if (ownedVals == null) ownedVals = new HashMap<>(); - CacheVersionedValue oVal = new CacheVersionedValue(val, ver); + CacheVersionedValue oVal = new CacheVersionedValue(val, ver, key.cacheId()); ownedVals.put(key, oVal); } @@ -235,6 +235,22 @@ public boolean hasOwnedValue(IgniteTxKey key) { return F.mapContainsKey(ownedVals, key); } + /** {@inheritDoc} */ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareMarshal(ctx); + + // There are separate collections for keys and values of the 'ownedVals' map, because IgniteTxKey + // can not be inserted directly in a map as a key during invocation of MessageReader#read. + // The IgniteTxKey's hash code calculation will fail due to delegation of calculation + // to KeyCacheObjectImpl#hashCode, which in turn fails with assertion error if KeyCacheObjectImpl#val + // has not initialized yet in KeyCacheObjectImpl#finishUnmarshal. + if (ownedVals != null && ownedValKeys == null) { + ownedValKeys = ownedVals.keySet(); + + ownedValVals = ownedVals.values(); + } + } + /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index 45163be0b690b..e8717d6d6445b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -1027,13 +1027,14 @@ public void filtersSet(boolean filtersSet) { @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { // Do not serialize filters if they are null. if (transformClosBytes == null && entryProcessorsCol != null) - transformClosBytes = CU.marshal(this.ctx, entryProcessorsCol); - - transferExpiryPlc = expiryPlc != null && expiryPlc != this.ctx.expiry(); + transformClosBytes = U.marshal(marsh, entryProcessorsCol); + + if (ctx.isNear()) + transferExpiryPlc = expiryPlc != null && expiryPlc != ctx.expiry(); if (transferExpiryPlc) { if (expiryPlcBytes == null) - expiryPlcBytes = CU.marshal(this.ctx, new IgniteExternalizableExpiryPolicy(expiryPlc)); + expiryPlcBytes = U.marshal(marsh, new IgniteExternalizableExpiryPolicy(expiryPlc)); } else expiryPlcBytes = null; From b59531f5a25a9b48ddf17d6fdde5c1e6c495df15 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 14 May 2026 15:49:37 +0300 Subject: [PATCH 025/215] WIP --- .../processors/cache/transactions/IgniteTxEntry.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index e8717d6d6445b..c6949c52e249c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -1028,9 +1028,8 @@ public void filtersSet(boolean filtersSet) { // Do not serialize filters if they are null. if (transformClosBytes == null && entryProcessorsCol != null) transformClosBytes = U.marshal(marsh, entryProcessorsCol); - - if (ctx.isNear()) - transferExpiryPlc = expiryPlc != null && expiryPlc != ctx.expiry(); + + transferExpiryPlc = expiryPlc != null && expiryPlc != ctx.expiry(); if (transferExpiryPlc) { if (expiryPlcBytes == null) From 95f9b90719f6afd99507bb1822ca63934a634876 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 14 May 2026 17:05:00 +0300 Subject: [PATCH 026/215] WIP --- .../processors/cache/transactions/IgniteTxManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 80ec3979f74d0..00a673e02df91 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -3370,10 +3370,10 @@ private class DeadlockDetectionListener implements GridMessageListener { if (!cctx.localNodeId().equals(nodeId)) { res.prepareMarshal(cctx); - MessageSerializer ser = cctx.gridIO().messageFactory().serializer(req.directType()); + MessageSerializer ser = cctx.gridIO().messageFactory().serializer(res.directType()); if (ser != null) - ser.prepareMarshalCacheObjects(req, cctx, null); + ser.prepareMarshalCacheObjects(res, cctx, null); } cctx.gridIO().sendToGridTopic(nodeId, TOPIC_TX, res, SYSTEM_POOL); From 1b2d240a02b9032472e2defda5758574117830f2 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 14 May 2026 18:44:56 +0300 Subject: [PATCH 027/215] WIP --- .../src/main/java/org/apache/ignite/internal/IgniteKernal.java | 2 +- .../internal/processors/cache/GridCacheIoManagerRetryTest.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index e30b0c453a7c5..1e2b5d9af58ff 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -1314,7 +1314,7 @@ else if (e instanceof IgniteCheckedException) } /** */ - private void initMessageFactory() throws IgniteCheckedException { + public void initMessageFactory() throws IgniteCheckedException { MessageFactoryProvider[] msgs = ctx.plugins().extensions(MessageFactoryProvider.class); List compMsgs = new ArrayList<>(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIoManagerRetryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIoManagerRetryTest.java index 0ab5cd5382219..39d54e07d8831 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIoManagerRetryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIoManagerRetryTest.java @@ -27,6 +27,7 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.GridTopic; +import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.managers.communication.GridIoManager; import org.apache.ignite.internal.managers.deployment.GridDeploymentManager; import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; @@ -128,6 +129,8 @@ private void doTest(Function action) throws Except cacheIoMgr.start(cctx); + ((IgniteKernal)cacheIoMgr.context().kernalContext().grid()).initMessageFactory(); + return cacheIoMgr; } From 9f4b2762a8fe6d224b4d840b296b62bd3d8eac77 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 14 May 2026 18:56:15 +0300 Subject: [PATCH 028/215] WIP --- .../apache/ignite/internal/MessageSerializerGenerator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index ab53c9eb6a7f2..e4261d4afc0a4 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -520,7 +520,7 @@ private void emitMapSideIteration( indent++; - code.add(identedLine("%s.prepareMarshal(ctx.cacheObjectContext());", var)); + code.add(identedLine("%s.prepareMarshal(ctx != null ? ctx.cacheObjectContext() : null);", var)); indent--; indent--; @@ -559,7 +559,7 @@ private void emitCoDirect(List code, String accessor) { indent++; - code.add(identedLine("%s.prepareMarshal(ctx.cacheObjectContext());", accessor)); + code.add(identedLine("%s.prepareMarshal(ctx != null ? ctx.cacheObjectContext() : null);", accessor)); indent--; } @@ -589,7 +589,7 @@ private void emitCoIterable(List code, String accessor, TypeMirror t, bo indent++; - code.add(identedLine("obj.prepareMarshal(ctx.cacheObjectContext());")); + code.add(identedLine("obj.prepareMarshal(ctx != null ? ctx.cacheObjectContext() : null);")); indent--; From 1f7b0fc1e25e839857d6db50fc91e493941a3a43 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 18 May 2026 20:16:29 +0300 Subject: [PATCH 029/215] WIP --- .../internal/MessageSerializerGenerator.java | 553 +++++------------- .../managers/communication/GridIoManager.java | 6 + .../ignite/spi/discovery/tcp/ServerImpl.java | 6 + .../spi/discovery/tcp/TcpDiscoverySpi.java | 6 + 4 files changed, 178 insertions(+), 393 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index e4261d4afc0a4..41b476dd144ee 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -100,6 +100,9 @@ public class MessageSerializerGenerator { /** Collection of lines for {@code readFrom} method. */ private final List read = new ArrayList<>(); + /** */ + private final List marshall = new ArrayList<>(); + /** Collection of message-specific imports. */ private final Set imports = new TreeSet<>(); @@ -115,9 +118,6 @@ public class MessageSerializerGenerator { /** The marshallable message type. */ private final TypeMirror marshallableMsgType; - /** */ - private final List prepareCacheObjects = new ArrayList<>(); - /** */ private int indent; @@ -193,10 +193,10 @@ private String generateSerializerCode(String serClsName) throws IOException { writer.write(TAB + "}" + NL); - if (!prepareCacheObjects.isEmpty()) { + if (!marshall.isEmpty()) { writer.write(NL); - for (String p: prepareCacheObjects) + for (String p: marshall) writer.write(p + NL); } @@ -213,23 +213,23 @@ private void writeConstructor(Writer writer, String serClsName) throws IOExcepti ++indent; - writer.write(identedLine(METHOD_JAVADOC)); + writer.write(indentedLine(METHOD_JAVADOC)); writer.write(NL); - writer.write(identedLine("public " + serClsName + "(Marshaller marshaller, ClassLoader clsLdr) {")); + writer.write(indentedLine("public " + serClsName + "(Marshaller marshaller, ClassLoader clsLdr) {")); writer.write(NL); ++indent; - writer.write(identedLine("this.marshaller = marshaller;")); + writer.write(indentedLine("this.marshaller = marshaller;")); writer.write(NL); - writer.write(identedLine("this.clsLdr = clsLdr;")); + writer.write(indentedLine("this.clsLdr = clsLdr;")); --indent; writer.write(NL); - writer.write(identedLine("}")); + writer.write(indentedLine("}")); writer.write(NL); --indent; @@ -257,407 +257,200 @@ private void generateMethods(List fields) throws Exception { /** */ private void generateCacheObjectMarshallMethods(List orderedFields) throws Exception { - List traversable = new ArrayList<>(); - - for (VariableElement field: orderedFields) { - if (classify(field.asType()) != FieldKind.SKIP) - traversable.add(field); - } - - if (traversable.isEmpty()) - return; - imports.add("org.apache.ignite.IgniteCheckedException"); imports.add("org.apache.ignite.internal.processors.cache.CacheObjectValueContext"); imports.add("org.apache.ignite.internal.processors.cache.GridCacheSharedContext"); imports.add("org.apache.ignite.internal.processors.cache.GridCacheContext"); - startCacheObjectMethod(prepareCacheObjects); + indent = 1; + + marshall.add(indentedLine(METHOD_JAVADOC)); + + marshall.add(indentedLine( + "@Override public void prepareMarshalCacheObjects(" + simpleNameWithGeneric(type) + + " msg, GridCacheSharedContext sctx, GridCacheContext nested) throws IgniteCheckedException {")); indent++; if (isCacheIdAwareMessage(type)) - prepareCacheObjects.add( - identedLine("GridCacheContext ctx = nested == null ? sctx.cacheContext(msg.cacheId()) : nested;")); + marshall.add( + indentedLine("GridCacheContext ctx = nested == null ? sctx.cacheContext(msg.cacheId()) : nested;")); else - prepareCacheObjects.add(identedLine("GridCacheContext ctx = nested;")); - - prepareCacheObjects.add(EMPTY); - - boolean first = true; + marshall.add(indentedLine("GridCacheContext ctx = nested;")); - for (VariableElement field: traversable) { - if (!first) - prepareCacheObjects.add(EMPTY); - - emitCacheObjectCall(prepareCacheObjects, field); - - first = false; + for (VariableElement field: orderedFields) { + if (!marshall.get(marshall.size() - 1).equals(EMPTY)) + marshall.add(EMPTY); + + List elemCode = new ArrayList<>(); + + marshall(field.asType(), fieldAccessor(field), elemCode); + + marshall.addAll(elemCode); } - indent--; + if (marshallableMessage()) + marshall.add(indentedLine("msg.prepareMarshal(marshaller);")); - prepareCacheObjects.add(identedLine("}")); - } + indent--; - /** Traversal kinds for {@link #generateCacheObjectMarshallMethods}. */ - private enum FieldKind { - /** {@code CacheObject} / {@code KeyCacheObject} scalar. */ - CO, - /** {@code Collection} / {@code Collection}. */ - CO_COLL, - /** {@code CacheObject[]} / {@code KeyCacheObject[]}. */ - CO_ARR, - /** Nested concrete {@code Message}. */ - MSG, - /** {@code Collection} with concrete element type. */ - MSG_COLL, - /** {@code Message[]} with concrete component type. */ - MSG_ARR, - /** {@code Map} with at least one CacheObject/Message side. */ - MAP, - /** Skipped — abstract Message, cross-cache nested Message, Map with no traversable side, unsupported. */ - SKIP + marshall.add(indentedLine("}")); } /** */ - private FieldKind classify(TypeMirror t) { + private void marshall(TypeMirror t, String accessor, List code) { if (t.getKind() == TypeKind.ARRAY) { TypeMirror comp = ((ArrayType)t).getComponentType(); - if (comp.getKind() != TypeKind.DECLARED) - return FieldKind.SKIP; - - if (isCacheObjectType(comp)) - return FieldKind.CO_ARR; - - return isRecursableMessage(comp) ? FieldKind.MSG_ARR : FieldKind.SKIP; - } - - if (t.getKind() != TypeKind.DECLARED) - return FieldKind.SKIP; - - if (isCacheObjectType(t)) - return FieldKind.CO; + if (comp.getKind() == TypeKind.DECLARED) { + imports.add(((QualifiedNameable)((DeclaredType)comp).asElement()).getQualifiedName().toString()); - if (assignableFrom(erasedType(t), type(Map.class.getName()))) { - List args = ((DeclaredType)t).getTypeArguments(); + code.add(indentedLine("if (%s != null) {", accessor)); - if (args.size() != 2) - return FieldKind.SKIP; - - FieldKind kSide = classifyMapSide(args.get(0)); - FieldKind vSide = classifyMapSide(args.get(1)); + indent++; - if (kSide == FieldKind.SKIP && vSide == FieldKind.SKIP) - return FieldKind.SKIP; + String el = "e" + indent; - return FieldKind.MAP; - } + code.add(indentedLine("for (%s %s : %s) {", ((DeclaredType)comp).asElement().getSimpleName().toString(), el, accessor)); - if (assignableFrom(erasedType(t), type(Collection.class.getName()))) { - List args = ((DeclaredType)t).getTypeArguments(); + indent++; - if (args.size() != 1) - return FieldKind.SKIP; + marshall(comp, el, code); - TypeMirror arg = args.get(0); + indent--; - if (arg.getKind() != TypeKind.DECLARED) - return FieldKind.SKIP; + code.add(indentedLine("}")); - if (isCacheObjectType(arg)) - return FieldKind.CO_COLL; + indent--; - return isRecursableMessage(arg) ? FieldKind.MSG_COLL : FieldKind.SKIP; + code.add(indentedLine("}")); + } } + else if (t.getKind() == TypeKind.DECLARED) { + if (isMessage(t)) { + code.add(indentedLine("if (%s != null)", accessor)); - return isRecursableMessage(t) ? FieldKind.MSG : FieldKind.SKIP; - } - - /** Classifies one side (key or value) of a {@code Map} field: {@link FieldKind#CO}, {@link FieldKind#MSG}, or - * {@link FieldKind#SKIP}. */ - private FieldKind classifyMapSide(TypeMirror t) { - if (t.getKind() != TypeKind.DECLARED) - return FieldKind.SKIP; - - if (isCacheObjectType(t)) - return FieldKind.CO; - - return isRecursableMessage(t) ? FieldKind.MSG : FieldKind.SKIP; - } - - /** */ - private boolean isCacheObjectType(TypeMirror type) { - return assignableFrom(type, type("org.apache.ignite.internal.processors.cache.CacheObject")); - } - - /** True if {@code t} is a concrete non-abstract {@code Message} safe to recurse into (no self-ref). */ - private boolean isRecursableMessage(TypeMirror t) { - TypeMirror msgIface = type(MESSAGE_INTERFACE); - - if (msgIface == null || !assignableFrom(t, msgIface)) - return false; - - Element el = env.getTypeUtils().asElement(t); + indent++; - if (!(el instanceof TypeElement)) - return false; + code.add(indentedLine( + "sctx.gridIO().messageFactory().serializer(%s.directType()).prepareMarshalCacheObjects(%s, sctx, ctx);", + accessor, + accessor)); - TypeElement te = (TypeElement)el; + indent--; + } + else if (isCacheObject(t)) { + code.add(indentedLine("if (%s != null)", accessor)); - return !te.equals(type); - } + indent++; - /** True if {@code te} extends {@code CacheIdAware} and therefore carries its own per-cache {@code cacheId()}. */ - private boolean isCacheIdAwareMessage(TypeElement te) { - return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.CacheIdAware")); - } + code.add(indentedLine("%s.prepareMarshal(ctx != null ? ctx.cacheObjectContext() : null);", accessor)); - /** */ - private void startCacheObjectMethod(List code) { - indent = 1; + indent--; + } + else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { + List args = ((DeclaredType)t).getTypeArguments(); - code.add(identedLine(METHOD_JAVADOC)); + TypeMirror keyType = args.get(0); + TypeMirror valType = args.get(1); - code.add(identedLine( - "@Override public void prepareMarshalCacheObjects(" + simpleNameWithGeneric(type) + - " msg, GridCacheSharedContext sctx, GridCacheContext nested) throws IgniteCheckedException {")); - } + String el = "e" + indent; - /** */ - private void emitCacheObjectCall(List code, VariableElement field) { - String accessor = fieldAccessor(field); - TypeMirror t = field.asType(); - FieldKind kind = classify(t); - - switch (kind) { - case CO: - emitCoDirect(code, accessor); - break; - - case CO_COLL: - case CO_ARR: - emitCoIterable(code, accessor, t, kind == FieldKind.CO_ARR); - break; - - case MSG: - emitMsgDirect(code, accessor); - break; - - case MSG_COLL: - emitMsgIterable(code, accessor, (DeclaredType)((DeclaredType)t).getTypeArguments().get(0)); - break; - - case MSG_ARR: - emitMsgIterable(code, accessor, (DeclaredType)((ArrayType)t).getComponentType()); - break; - - case MAP: - emitMapTraversal(code, accessor, (DeclaredType)t); - break; - - default: - throw new IllegalStateException("Unexpected kind: " + kind); - } - } + code.add(indentedLine("if (%s != null) {", accessor)); - /** */ - private void emitMapTraversal(List code, String accessor, DeclaredType mapType) { - List args = mapType.getTypeArguments(); - - TypeMirror keyT = args.get(0); - TypeMirror valT = args.get(1); + indent++; - FieldKind kSide = classifyMapSide(keyT); - FieldKind vSide = classifyMapSide(valT); + if (keyType.getKind() == TypeKind.DECLARED) { + imports.add(((QualifiedNameable)((DeclaredType)keyType).asElement()).getQualifiedName().toString()); + imports.add("java.util.Collection"); - code.add(identedLine("if (%s != null) {", accessor)); + String type = ((DeclaredType)keyType).asElement().getSimpleName().toString(); - indent++; + code.add(indentedLine("for (%s %s : ((Collection)%s.keySet())) {", type, el, type, accessor)); - if (kSide != FieldKind.SKIP) - emitMapSideIteration(code, accessor, keyT, kSide, true); + indent++; - if (kSide != FieldKind.SKIP && vSide != FieldKind.SKIP) - code.add(EMPTY); + marshall(keyType, el, code); - if (vSide != FieldKind.SKIP) - emitMapSideIteration(code, accessor, valT, vSide, false); + indent--; - indent--; + code.add(indentedLine("}")); + } - code.add(identedLine("}")); - } + if (valType.getKind() == TypeKind.DECLARED) { + imports.add(((QualifiedNameable)((DeclaredType)valType).asElement()).getQualifiedName().toString()); + imports.add("java.util.Collection"); - /** */ - private void emitMapSideIteration( - List code, - String accessor, - TypeMirror sideType, - FieldKind sideKind, - boolean isKey - ) { - String side = accessor + (isKey ? ".keySet()" : ".values()"); + String type = ((DeclaredType)valType).asElement().getSimpleName().toString(); - String var = isKey ? "k" : "v"; + code.add(indentedLine("for (%s %s : ((Collection)%s.values())) {", type, el, type, accessor)); - if (sideKind == FieldKind.CO) { - String elementType = "org.apache.ignite.internal.processors.cache.KeyCacheObject"; + indent++; - if (!assignableFrom(sideType, type(elementType))) - elementType = "org.apache.ignite.internal.processors.cache.CacheObject"; + marshall(valType, el, code); - imports.add(elementType); + indent--; - String simple = elementType.substring(elementType.lastIndexOf('.') + 1); - - code.add(identedLine("for (%s %s : %s) {", simple, var, side)); + code.add(indentedLine("}")); + } - indent++; + indent--; - code.add(identedLine("if (%s != null)", var)); + code.add(indentedLine("}")); + } + else if (assignableFrom(erasedType(t), type(Collection.class.getName()))) { + List args = ((DeclaredType)t).getTypeArguments(); - indent++; + TypeMirror arg = args.get(0); - code.add(identedLine("%s.prepareMarshal(ctx != null ? ctx.cacheObjectContext() : null);", var)); + if (arg.getKind() == TypeKind.DECLARED) { + imports.add(((QualifiedNameable)((DeclaredType)arg).asElement()).getQualifiedName().toString()); + imports.add("java.util.Collection"); - indent--; - indent--; + String el = "e" + indent; - code.add(identedLine("}")); - } - else { - assert sideKind == FieldKind.MSG : sideKind; + code.add(indentedLine("if (%s != null) {", accessor)); - DeclaredType msgType = (DeclaredType)sideType; - String elemSimple = msgType.asElement().getSimpleName().toString(); + indent++; - imports.add(((TypeElement)msgType.asElement()).getQualifiedName().toString()); + String type = ((DeclaredType)arg).asElement().getSimpleName().toString(); - code.add(identedLine("for (%s %s : %s) {", elemSimple, var, side)); + code.add(indentedLine("for (%s %s : (Collection)%s) {", type, el, type, accessor)); - indent++; + indent++; - code.add(identedLine("if (%s != null)", var)); + marshall(arg, el, code); - indent++; + indent--; - code.add(identedLine( - "sctx.gridIO().messageFactory().serializer(%s.directType()).prepareMarshalCacheObjects(%s, sctx, ctx);", var, var)); + code.add(indentedLine("}")); - indent--; - indent--; + indent--; - code.add(identedLine("}")); + code.add(indentedLine("}")); + } + } + else { + if (!code.isEmpty()) + code.add(indentedLine("// No-op.")); + } } - } - - /** */ - private void emitCoDirect(List code, String accessor) { - code.add(identedLine("if (%s != null)", accessor)); - - indent++; - - code.add(identedLine("%s.prepareMarshal(ctx != null ? ctx.cacheObjectContext() : null);", accessor)); - - indent--; - } - - /** */ - private void emitCoIterable(List code, String accessor, TypeMirror t, boolean isArr) { - String elementType = "org.apache.ignite.internal.processors.cache.KeyCacheObject"; - - TypeMirror elem = isArr ? ((ArrayType)t).getComponentType() : ((DeclaredType)t).getTypeArguments().get(0); - - if (!assignableFrom(elem, type(elementType))) - elementType = "org.apache.ignite.internal.processors.cache.CacheObject"; - - imports.add(elementType); - - String simple = elementType.substring(elementType.lastIndexOf('.') + 1); - - code.add(identedLine("if (%s != null) {", accessor)); - - indent++; - - code.add(identedLine("for (%s obj : %s) {", simple, accessor)); - - indent++; - - code.add(identedLine("if (obj != null)")); - - indent++; - - code.add(identedLine("obj.prepareMarshal(ctx != null ? ctx.cacheObjectContext() : null);")); - - indent--; - indent--; - - code.add(identedLine("}")); - - indent--; - - code.add(identedLine("}")); } /** */ - private void emitMsgDirect(List code, String accessor) { - code.add(identedLine("if (%s != null)", accessor)); - - indent++; - - code.add(identedLine( - "sctx.gridIO().messageFactory().serializer(%s.directType()).prepareMarshalCacheObjects(%s, sctx, ctx);", accessor, accessor)); - - indent--; + private boolean isCacheObject(TypeMirror type) { + return assignableFrom(type, type("org.apache.ignite.internal.processors.cache.CacheObject")); } /** */ - private void emitMsgIterable(List code, String accessor, DeclaredType elemType) { - String elemSimple = elemType.asElement().getSimpleName().toString(); - - imports.add(((TypeElement)elemType.asElement()).getQualifiedName().toString()); - - code.add(identedLine("if (%s != null) {", accessor)); - - indent++; - - code.add(identedLine("for (%s e : %s) {", elemSimple, accessor)); - - indent++; - - code.add(identedLine("if (e != null)")); - - indent++; - - code.add(identedLine("sctx.gridIO().messageFactory().serializer(e.directType()).prepareMarshalCacheObjects(e, sctx, ctx);")); - - indent--; - indent--; - - code.add(identedLine("}")); - - indent--; - - code.add(identedLine("}")); + private boolean isMessage(TypeMirror type) { + return assignableFrom(type, type(MESSAGE_INTERFACE)); } - /** Converts {@code CacheInvokeDirectResult} to {@code CACHE_INVOKE_DIRECT_RESULT}. */ - private static String camelToConstant(String simple) { - StringBuilder sb = new StringBuilder(simple.length() + 8); - - for (int i = 0; i < simple.length(); i++) { - char c = simple.charAt(i); - - if (i > 0 && Character.isUpperCase(c) && !Character.isUpperCase(simple.charAt(i - 1))) - sb.append('_'); - - sb.append(Character.toUpperCase(c)); - } - - return sb.toString(); + /** True if {@code te} extends {@code CacheIdAware} and therefore carries its own per-cache {@code cacheId()}. */ + private boolean isCacheIdAwareMessage(TypeElement te) { + return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.CacheIdAware")); } /** */ @@ -685,57 +478,31 @@ private String fieldAccessor(VariableElement field) { private void start(Collection code, boolean write) { indent = 1; - code.add(identedLine(METHOD_JAVADOC)); + code.add(indentedLine(METHOD_JAVADOC)); - code.add(identedLine("@Override public boolean %s(" + simpleNameWithGeneric(type) + " msg, %s) {", + code.add(indentedLine("@Override public boolean %s(" + simpleNameWithGeneric(type) + " msg, %s) {", write ? "writeTo" : "readFrom", write ? "MessageWriter writer" : "MessageReader reader")); indent++; if (write) { - code.add(identedLine("if (!writer.isHeaderWritten()) {")); + code.add(indentedLine("if (!writer.isHeaderWritten()) {")); indent++; returnFalseIfWriteFailed(code, "writer.writeHeader", "directType()"); - if (write && marshallableMessage()) { - imports.add("org.apache.ignite.IgniteCheckedException"); - imports.add("org.apache.ignite.IgniteException"); - - code.add(EMPTY); - - code.add(identedLine("try {")); - - indent++; - - code.add(identedLine("msg.prepareMarshal(marshaller);")); - - indent--; - - code.add(identedLine("}")); - code.add(identedLine("catch (IgniteCheckedException e) {")); - - indent++; - - code.add(identedLine("throw new IgniteException(\"Failed to marshal object \" + msg.getClass().getSimpleName(), e);")); - - indent--; - - code.add(identedLine("}")); - } - code.add(EMPTY); - code.add(identedLine("writer.onHeaderWritten();")); + code.add(indentedLine("writer.onHeaderWritten();")); indent--; - code.add(identedLine("}")); + code.add(indentedLine("}")); code.add(EMPTY); } - code.add(identedLine("switch (%s.state()) {", write ? "writer" : "reader")); + code.add(indentedLine("switch (%s.state()) {", write ? "writer" : "reader")); } /** @@ -764,14 +531,14 @@ private void processField(VariableElement field, int opt) throws Exception { * @param opt Case option. */ private void writeField(VariableElement field, int opt) throws Exception { - write.add(identedLine("case %d:", opt)); + write.add(indentedLine("case %d:", opt)); indent++; returnFalseIfWriteFailed(field); write.add(EMPTY); - write.add(identedLine("writer.incrementState();")); + write.add(indentedLine("writer.incrementState();")); write.add(EMPTY); indent--; @@ -792,14 +559,14 @@ private void writeField(VariableElement field, int opt) throws Exception { * @param opt Case option. */ private void readField(VariableElement field, int opt) throws Exception { - read.add(identedLine("case %d:", opt)); + read.add(indentedLine("case %d:", opt)); indent++; returnFalseIfReadFailed(field); read.add(EMPTY); - read.add(identedLine("reader.incrementState();")); + read.add(indentedLine("reader.incrementState();")); read.add(EMPTY); indent--; @@ -961,11 +728,11 @@ private String typeNameToFieldName(String typeName) { private void returnFalseIfWriteFailed(Collection code, String accessor, @Nullable String... args) { String argsStr = String.join(", ", args); - code.add(identedLine("if (!%s(msg.%s))", accessor, argsStr)); + code.add(indentedLine("if (!%s(msg.%s))", accessor, argsStr)); indent++; - code.add(identedLine(RETURN_FALSE_STMT)); + code.add(indentedLine(RETURN_FALSE_STMT)); indent--; } @@ -977,15 +744,15 @@ private void returnFalseIfWriteFailed(Collection code, VariableElement f String argsStr = String.join(", ", args); if (type.equals(field.getEnclosingElement())) - code.add(identedLine("if (!%s(msg.%s))", accessor, argsStr)); + code.add(indentedLine("if (!%s(msg.%s))", accessor, argsStr)); else { // Field has to be requested from a super class object. - code.add(identedLine("if (!%s(((%s)msg).%s))", accessor, field.getEnclosingElement().getSimpleName(), argsStr)); + code.add(indentedLine("if (!%s(((%s)msg).%s))", accessor, field.getEnclosingElement().getSimpleName(), argsStr)); } indent++; - code.add(identedLine(RETURN_FALSE_STMT)); + code.add(indentedLine(RETURN_FALSE_STMT)); indent--; } @@ -1000,16 +767,16 @@ private void returnFalseIfEnumWriteFailed( String mapperCall, String fieldGetterCall) { if (type.equals(field.getEnclosingElement())) - code.add(identedLine("if (!%s(%s(msg.%s)))", writerCall, mapperCall, fieldGetterCall)); + code.add(indentedLine("if (!%s(%s(msg.%s)))", writerCall, mapperCall, fieldGetterCall)); else { // Field has to be requested from a super class object. - code.add(identedLine("if (!%s(%s(((%s)msg).%s)))", + code.add(indentedLine("if (!%s(%s(((%s)msg).%s)))", writerCall, mapperCall, field.getEnclosingElement().getSimpleName(), fieldGetterCall)); } indent++; - code.add(identedLine(RETURN_FALSE_STMT)); + code.add(indentedLine(RETURN_FALSE_STMT)); indent--; } @@ -1303,20 +1070,20 @@ private void returnFalseIfReadFailed(VariableElement field, String mtd, String.. String argsStr = String.join(", ", args); if (type.equals(field.getEnclosingElement())) - read.add(identedLine("msg.%s = %s(%s);", field.getSimpleName().toString(), mtd, argsStr)); + read.add(indentedLine("msg.%s = %s(%s);", field.getSimpleName().toString(), mtd, argsStr)); else { // Field has to be requested from a super class object. - read.add(identedLine("((%s)msg).%s = %s(%s);", + read.add(indentedLine("((%s)msg).%s = %s(%s);", field.getEnclosingElement().getSimpleName(), field.getSimpleName().toString(), mtd, argsStr)); } read.add(EMPTY); - read.add(identedLine("if (!reader.isLastRead())")); + read.add(indentedLine("if (!reader.isLastRead())")); indent++; - read.add(identedLine(RETURN_FALSE_STMT)); + read.add(indentedLine(RETURN_FALSE_STMT)); indent--; } @@ -1335,20 +1102,20 @@ private void returnFalseIfEnumReadFailed(VariableElement field, String mapperDec readOp = line("%s(%s, reader.readByte())", mapperDecodeCallStmnt, enumValuesFieldName); if (type.equals(field.getEnclosingElement())) - read.add(identedLine("msg.%s = %s;", field.getSimpleName().toString(), readOp)); + read.add(indentedLine("msg.%s = %s;", field.getSimpleName().toString(), readOp)); else { // Field has to be requested from a super class object. - read.add(identedLine("((%s)msg).%s = %s;", + read.add(indentedLine("((%s)msg).%s = %s;", field.getEnclosingElement().getSimpleName(), field.getSimpleName().toString(), readOp)); } read.add(EMPTY); - read.add(identedLine("if (!reader.isLastRead())")); + read.add(indentedLine("if (!reader.isLastRead())")); indent++; - read.add(identedLine(RETURN_FALSE_STMT)); + read.add(indentedLine(RETURN_FALSE_STMT)); indent--; } @@ -1360,36 +1127,36 @@ private void finish(List code, boolean read, boolean marshallable) { if (EMPTY.equals(lastLine)) code.remove(code.size() - 1); - code.add(identedLine("}")); + code.add(indentedLine("}")); code.add(EMPTY); if (read && marshallable) { imports.add("org.apache.ignite.IgniteCheckedException"); imports.add("org.apache.ignite.IgniteException"); - code.add(identedLine("try {")); + code.add(indentedLine("try {")); indent++; - code.add(identedLine("msg.finishUnmarshal(marshaller, clsLdr);")); + code.add(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);")); indent--; - code.add(identedLine("}")); - code.add(identedLine("catch (IgniteCheckedException e) {")); + code.add(indentedLine("}")); + code.add(indentedLine("catch (IgniteCheckedException e) {")); indent++; - code.add(identedLine("throw new IgniteException(\"Failed to unmarshal object \" + msg.getClass().getSimpleName(), e);")); + code.add(indentedLine("throw new IgniteException(\"Failed to unmarshal object \" + msg.getClass().getSimpleName(), e);")); indent--; - code.add(identedLine("}")); + code.add(indentedLine("}")); code.add(EMPTY); } - code.add(identedLine("return true;")); + code.add(indentedLine("return true;")); } /** @@ -1397,7 +1164,7 @@ private void finish(List code, boolean read, boolean marshallable) { * * @return Line with current indent. */ - private String identedLine(String format, Object... args) { + private String indentedLine(String format, Object... args) { SB sb = new SB(); for (int i = 0; i < indent; i++) @@ -1429,9 +1196,9 @@ private void writeClassFields(Writer writer) throws IOException { indent = 1; for (String field: fields) { - writer.write(identedLine(METHOD_JAVADOC)); + writer.write(indentedLine(METHOD_JAVADOC)); writer.write(NL); - writer.write(identedLine(field)); + writer.write(indentedLine(field)); writer.write(NL); } writer.write(NL); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 9294efd015356..108603009eea2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -128,6 +128,7 @@ import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFormatter; import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageWriter; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.CommunicationListener; @@ -1984,6 +1985,11 @@ private void send( GridIoMessage ioMsg = createGridIoMessage(topic, topicOrd, msg, plc, ordered, timeout, skipOnTimeout); + MessageSerializer ser = ctx.io().messageFactory().serializer(ioMsg.directType()); + + if (ser != null) + ser.prepareMarshalCacheObjects(ioMsg, ctx.cache().context(), null); + if (locNodeId.equals(node.id())) { assert plc != P2P_POOL; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java index 0861b7f88be95..dc45dda94c4a3 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java @@ -117,6 +117,7 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.security.SecurityCredentials; import org.apache.ignite.spi.IgniteNodeValidationResult; import org.apache.ignite.spi.IgniteSpiContext; @@ -3347,6 +3348,11 @@ private void sendMessageToClients(TcpDiscoveryAbstractMessage msg) { byte[] msgBytes; try { + MessageSerializer ser = spi.messageFactory().serializer(msg.directType()); + + if (ser != null) + ser.prepareMarshalCacheObjects(msg, ((IgniteEx)spi.ignite()).context().cache().context(), null); + msgBytes = clientMsgSer.serializeMessage(msg); } catch (IgniteCheckedException | IOException e) { diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java index 16d4578101dcc..28fbb5086808b 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java @@ -73,6 +73,7 @@ import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.MessageFactory; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.spi.IgniteSpiAdapter; @@ -1764,6 +1765,11 @@ protected void writeMessage( assert sock != null; assert msg != null; + MessageSerializer ser = messageFactory().serializer(msg.directType()); + + if (ser != null) + ser.prepareMarshalCacheObjects(msg, ((IgniteEx)ignite()).context().cache().context(), null); + try (SocketTimeoutObject ignored = startTimer(sock, timeout)) { ses.writeMessage(msg); } From bd9c1bc862519739bc2788792dac8daa011b3525 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 18 May 2026 20:19:34 +0300 Subject: [PATCH 030/215] WIP --- .../processors/query/calcite/message/MessageServiceImpl.java | 2 +- .../apache/ignite/internal/MessageSerializerGenerator.java | 4 ++-- .../ignite/internal/managers/communication/GridIoManager.java | 2 +- .../ignite/internal/processors/cache/GridCacheIoManager.java | 2 +- .../cache/query/continuous/CacheContinuousQueryHandler.java | 2 +- .../processors/cache/transactions/IgniteTxManager.java | 4 ++-- .../plugin/extensions/communication/MessageSerializer.java | 2 +- .../java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java | 2 +- .../org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java index 3e6c7aa8dd09a..3ecba752df038 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java @@ -191,7 +191,7 @@ protected void prepareMarshal(Message msg) throws IgniteCheckedException { MessageSerializer ser = ctx.gridIO().messageFactory().serializer(msg.directType()); if (ser != null) - ser.prepareMarshalCacheObjects(msg, ctx, null); + ser.prepareMarshal(msg, ctx, null); } } catch (Exception e) { diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 41b476dd144ee..5beb5f176b576 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -267,7 +267,7 @@ private void generateCacheObjectMarshallMethods(List orderedFie marshall.add(indentedLine(METHOD_JAVADOC)); marshall.add(indentedLine( - "@Override public void prepareMarshalCacheObjects(" + simpleNameWithGeneric(type) + + "@Override public void prepareMarshal(" + simpleNameWithGeneric(type) + " msg, GridCacheSharedContext sctx, GridCacheContext nested) throws IgniteCheckedException {")); indent++; @@ -333,7 +333,7 @@ else if (t.getKind() == TypeKind.DECLARED) { indent++; code.add(indentedLine( - "sctx.gridIO().messageFactory().serializer(%s.directType()).prepareMarshalCacheObjects(%s, sctx, ctx);", + "sctx.gridIO().messageFactory().serializer(%s.directType()).prepareMarshal(%s, sctx, ctx);", accessor, accessor)); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 108603009eea2..d5e08319e4657 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1988,7 +1988,7 @@ private void send( MessageSerializer ser = ctx.io().messageFactory().serializer(ioMsg.directType()); if (ser != null) - ser.prepareMarshalCacheObjects(ioMsg, ctx.cache().context(), null); + ser.prepareMarshal(ioMsg, ctx.cache().context(), null); if (locNodeId.equals(node.id())) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index c684030b7c039..7a965d03d5521 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -1101,7 +1101,7 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I MessageSerializer ser = cctx.gridIO().messageFactory().serializer(msg.directType()); if (ser != null) - ser.prepareMarshalCacheObjects(msg, cctx, null); + ser.prepareMarshal(msg, cctx, null); if (msg instanceof GridCacheDeployable && msg.addDeploymentInfo()) cctx.deploy().prepare((GridCacheDeployable)msg); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java index b977fe87f4795..061875f76bdb6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java @@ -932,7 +932,7 @@ private void prepareEntry(GridCacheContext cctx, UUID nodeId, CacheContinuousQue MessageSerializer ser = cctx.gridIO().messageFactory().serializer(entry.directType()); if (ser != null) - ser.prepareMarshalCacheObjects(entry, cctx.shared(), null); + ser.prepareMarshal(entry, cctx.shared(), null); if (cctx.kernalContext().config().isPeerClassLoadingEnabled() && cctx.discovery().node(nodeId) != null) cctx.deploy().prepare(entry); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 00a673e02df91..1dd91a8e79e0b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -2437,7 +2437,7 @@ void txLocksInfo(UUID nodeId, TxDeadlockFuture fut, Set txKeys) { MessageSerializer ser = cctx.gridIO().messageFactory().serializer(req.directType()); if (ser != null) - ser.prepareMarshalCacheObjects(req, cctx, null); + ser.prepareMarshal(req, cctx, null); } cctx.gridIO().sendToGridTopic(node, TOPIC_TX, req, SYSTEM_POOL); @@ -3373,7 +3373,7 @@ private class DeadlockDetectionListener implements GridMessageListener { MessageSerializer ser = cctx.gridIO().messageFactory().serializer(res.directType()); if (ser != null) - ser.prepareMarshalCacheObjects(res, cctx, null); + ser.prepareMarshal(res, cctx, null); } cctx.gridIO().sendToGridTopic(nodeId, TOPIC_TX, res, SYSTEM_POOL); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index 102ac89ee7510..069edccd6d4d2 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -51,7 +51,7 @@ public interface MessageSerializer { * @param nested Nested context. * @throws IgniteCheckedException If marshalling fails. */ - public default void prepareMarshalCacheObjects(M msg, GridCacheSharedContext sctx, GridCacheContext nested) + public default void prepareMarshal(M msg, GridCacheSharedContext sctx, GridCacheContext nested) throws IgniteCheckedException { // No-op by default. } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java index dc45dda94c4a3..1f0119d75ef49 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java @@ -3351,7 +3351,7 @@ private void sendMessageToClients(TcpDiscoveryAbstractMessage msg) { MessageSerializer ser = spi.messageFactory().serializer(msg.directType()); if (ser != null) - ser.prepareMarshalCacheObjects(msg, ((IgniteEx)spi.ignite()).context().cache().context(), null); + ser.prepareMarshal(msg, ((IgniteEx)spi.ignite()).context().cache().context(), null); msgBytes = clientMsgSer.serializeMessage(msg); } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java index 28fbb5086808b..b4e7017bf5492 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java @@ -1768,7 +1768,7 @@ protected void writeMessage( MessageSerializer ser = messageFactory().serializer(msg.directType()); if (ser != null) - ser.prepareMarshalCacheObjects(msg, ((IgniteEx)ignite()).context().cache().context(), null); + ser.prepareMarshal(msg, ((IgniteEx)ignite()).context().cache().context(), null); try (SocketTimeoutObject ignored = startTimer(sock, timeout)) { ses.writeMessage(msg); From 95d644530c35267e64c800c1ffb9231d67b24c8c Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 19 May 2026 16:48:19 +0300 Subject: [PATCH 031/215] WIP --- .../internal/MessageSerializerGenerator.java | 68 ++++++++++++++----- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 5beb5f176b576..ea83ecf2a7177 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.BitSet; import java.util.Collection; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -282,11 +283,7 @@ private void generateCacheObjectMarshallMethods(List orderedFie if (!marshall.get(marshall.size() - 1).equals(EMPTY)) marshall.add(EMPTY); - List elemCode = new ArrayList<>(); - - marshall(field.asType(), fieldAccessor(field), elemCode); - - marshall.addAll(elemCode); + marshall.addAll(marshall(field.asType(), fieldAccessor(field))); } if (marshallableMessage()) @@ -298,11 +295,13 @@ private void generateCacheObjectMarshallMethods(List orderedFie } /** */ - private void marshall(TypeMirror t, String accessor, List code) { + private List marshall(TypeMirror t, String accessor) { if (t.getKind() == TypeKind.ARRAY) { TypeMirror comp = ((ArrayType)t).getComponentType(); if (comp.getKind() == TypeKind.DECLARED) { + List code = new ArrayList<>(); + imports.add(((QualifiedNameable)((DeclaredType)comp).asElement()).getQualifiedName().toString()); code.add(indentedLine("if (%s != null) {", accessor)); @@ -315,7 +314,9 @@ private void marshall(TypeMirror t, String accessor, List code) { indent++; - marshall(comp, el, code); + List res = marshall(comp, el); + + code.addAll(res); indent--; @@ -324,10 +325,17 @@ private void marshall(TypeMirror t, String accessor, List code) { indent--; code.add(indentedLine("}")); + + if (res.isEmpty()) + return Collections.emptyList(); + else + return code; } } else if (t.getKind() == TypeKind.DECLARED) { if (isMessage(t)) { + List code = new ArrayList<>(); + code.add(indentedLine("if (%s != null)", accessor)); indent++; @@ -338,8 +346,12 @@ else if (t.getKind() == TypeKind.DECLARED) { accessor)); indent--; + + return code; } else if (isCacheObject(t)) { + List code = new ArrayList<>(); + code.add(indentedLine("if (%s != null)", accessor)); indent++; @@ -347,6 +359,8 @@ else if (isCacheObject(t)) { code.add(indentedLine("%s.prepareMarshal(ctx != null ? ctx.cacheObjectContext() : null);", accessor)); indent--; + + return code; } else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { List args = ((DeclaredType)t).getTypeArguments(); @@ -354,13 +368,20 @@ else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { TypeMirror keyType = args.get(0); TypeMirror valType = args.get(1); - String el = "e" + indent; + List code = new ArrayList<>(); code.add(indentedLine("if (%s != null) {", accessor)); indent++; - if (keyType.getKind() == TypeKind.DECLARED) { + String el = "e" + indent; + + indent++; // Emulating subsequent indent. + List keyRes = marshall(keyType, el); + List valRes = marshall(valType, el); + indent--; + + if (!keyRes.isEmpty() && keyType.getKind() == TypeKind.DECLARED) { imports.add(((QualifiedNameable)((DeclaredType)keyType).asElement()).getQualifiedName().toString()); imports.add("java.util.Collection"); @@ -370,14 +391,14 @@ else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { indent++; - marshall(keyType, el, code); + code.addAll(keyRes); indent--; code.add(indentedLine("}")); } - if (valType.getKind() == TypeKind.DECLARED) { + if (!valRes.isEmpty() && valType.getKind() == TypeKind.DECLARED) { imports.add(((QualifiedNameable)((DeclaredType)valType).asElement()).getQualifiedName().toString()); imports.add("java.util.Collection"); @@ -387,7 +408,7 @@ else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { indent++; - marshall(valType, el, code); + code.addAll(valRes); indent--; @@ -397,6 +418,11 @@ else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { indent--; code.add(indentedLine("}")); + + if (!keyRes.isEmpty() || !valRes.isEmpty()) + return Collections.emptyList(); + else + return code; } else if (assignableFrom(erasedType(t), type(Collection.class.getName()))) { List args = ((DeclaredType)t).getTypeArguments(); @@ -404,6 +430,8 @@ else if (assignableFrom(erasedType(t), type(Collection.class.getName()))) { TypeMirror arg = args.get(0); if (arg.getKind() == TypeKind.DECLARED) { + List code = new ArrayList<>(); + imports.add(((QualifiedNameable)((DeclaredType)arg).asElement()).getQualifiedName().toString()); imports.add("java.util.Collection"); @@ -419,7 +447,9 @@ else if (assignableFrom(erasedType(t), type(Collection.class.getName()))) { indent++; - marshall(arg, el, code); + List res = marshall(arg, el); + + code.addAll(res); indent--; @@ -428,14 +458,16 @@ else if (assignableFrom(erasedType(t), type(Collection.class.getName()))) { indent--; code.add(indentedLine("}")); + + if (res.isEmpty()) + return Collections.emptyList(); + else + return code; } } - else { - if (!code.isEmpty()) - code.add(indentedLine("// No-op.")); - } } - + + return Collections.emptyList(); } /** */ From 4e392b6d5e5a113e5a48e112dd8d71c87c0bd454 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 19 May 2026 17:02:00 +0300 Subject: [PATCH 032/215] WIP --- .../org/apache/ignite/internal/MessageSerializerGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index ea83ecf2a7177..1e310911bc4f4 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -419,7 +419,7 @@ else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { code.add(indentedLine("}")); - if (!keyRes.isEmpty() || !valRes.isEmpty()) + if (keyRes.isEmpty() && valRes.isEmpty()) return Collections.emptyList(); else return code; From faa5d293ac0ee42dc28b8f28805da0e864a84577 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 19 May 2026 17:14:39 +0300 Subject: [PATCH 033/215] WIP --- .../org/apache/ignite/spi/discovery/tcp/ServerImpl.java | 6 ------ .../ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java | 6 +++++- .../apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java | 6 ------ 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java index 1f0119d75ef49..0861b7f88be95 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java @@ -117,7 +117,6 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.security.SecurityCredentials; import org.apache.ignite.spi.IgniteNodeValidationResult; import org.apache.ignite.spi.IgniteSpiContext; @@ -3348,11 +3347,6 @@ private void sendMessageToClients(TcpDiscoveryAbstractMessage msg) { byte[] msgBytes; try { - MessageSerializer ser = spi.messageFactory().serializer(msg.directType()); - - if (ser != null) - ser.prepareMarshal(msg, ((IgniteEx)spi.ignite()).context().cache().context(), null); - msgBytes = clientMsgSer.serializeMessage(msg); } catch (IgniteCheckedException | IOException e) { diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java index b8fc471493069..fc3ba41c21ece 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java @@ -32,6 +32,7 @@ import javax.net.ssl.SSLSocket; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.direct.DirectMessageReader; import org.apache.ignite.internal.direct.DirectMessageWriter; import org.apache.ignite.internal.managers.communication.UnknownMessageException; @@ -238,9 +239,12 @@ public Socket socket() { * @param out Output stream to write serialized message. * @throws IOException If serialization fails. */ - void serializeMessage(Message m, OutputStream out) throws IOException { + void serializeMessage(Message m, OutputStream out) throws IOException, IgniteCheckedException { MessageSerializer msgSer = spi.messageFactory().serializer(m.directType()); + if (msgSer != null) + msgSer.prepareMarshal(m, ((IgniteEx)spi.ignite()).context().cache().context(), null); + msgWriter.reset(); msgWriter.setBuffer(msgBuf); diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java index b4e7017bf5492..16d4578101dcc 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java @@ -73,7 +73,6 @@ import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.MessageFactory; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.spi.IgniteSpiAdapter; @@ -1765,11 +1764,6 @@ protected void writeMessage( assert sock != null; assert msg != null; - MessageSerializer ser = messageFactory().serializer(msg.directType()); - - if (ser != null) - ser.prepareMarshal(msg, ((IgniteEx)ignite()).context().cache().context(), null); - try (SocketTimeoutObject ignored = startTimer(sock, timeout)) { ses.writeMessage(msg); } From 9b04411b497e851f944a68814e36bf2839ff78f3 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 19 May 2026 18:22:01 +0300 Subject: [PATCH 034/215] WIP --- .../internal/GridEventConsumeHandler.java | 2 +- .../processors/cache/GridCacheDeployable.java | 2 +- .../cache/GridCacheDeploymentManager.java | 2 +- .../processors/cache/GridCacheIoManager.java | 2 +- .../processors/cache/GridCacheMessage.java | 108 +++++++++++------- .../GridCacheTtlUpdateRequest.java | 8 +- .../GridDistributedLockRequest.java | 6 +- .../GridDistributedLockResponse.java | 6 +- .../GridDistributedTxPrepareRequest.java | 29 +++-- .../distributed/GridNearUnlockRequest.java | 6 +- .../distributed/dht/GridDhtLockRequest.java | 38 +++--- .../distributed/dht/GridDhtLockResponse.java | 6 +- .../dht/GridDhtTxPrepareRequest.java | 31 +++-- .../distributed/dht/GridDhtUnlockRequest.java | 6 +- .../TransactionAttributesAwareRequest.java | 4 +- ...omicApplicationAttributesAwareRequest.java | 4 +- .../atomic/GridDhtAtomicUpdateRequest.java | 42 +++++-- .../atomic/GridDhtAtomicUpdateResponse.java | 6 +- .../GridNearAtomicFullUpdateRequest.java | 31 +++-- ...idNearAtomicSingleUpdateFilterRequest.java | 22 ++-- ...idNearAtomicSingleUpdateInvokeRequest.java | 28 +++-- .../GridNearAtomicSingleUpdateRequest.java | 8 +- .../atomic/GridNearAtomicUpdateResponse.java | 6 +- .../distributed/dht/atomic/UpdateErrors.java | 2 +- .../preloader/GridDhtForceKeysRequest.java | 6 +- .../preloader/GridDhtForceKeysResponse.java | 6 +- .../GridDhtPartitionSupplyMessage.java | 2 +- .../GridDhtPartitionsExchangeFuture.java | 2 +- .../distributed/near/GridNearGetRequest.java | 6 +- .../near/GridNearSingleGetRequest.java | 6 +- .../near/GridNearSingleGetResponse.java | 6 +- .../near/GridNearTxPrepareResponse.java | 33 +++--- .../IncrementalSnapshotAwareMessage.java | 4 +- .../cache/query/GridCacheQueryRequest.java | 50 +++++--- .../cache/query/GridCacheQueryResponse.java | 23 +++- .../continuous/CacheContinuousQueryEntry.java | 2 +- .../cache/transactions/IgniteTxManager.java | 4 +- .../cache/transactions/TxLocksRequest.java | 30 ++--- .../cache/transactions/TxLocksResponse.java | 70 ++++++------ ...adlockDetectionMessageMarshallingTest.java | 2 +- .../p2p/ClassLoadingProblemExceptionTest.java | 2 +- 41 files changed, 394 insertions(+), 265 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java index 1ac2ce2bc9227..354284e03ed0f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java @@ -563,7 +563,7 @@ void p2pUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr) throws IgniteChec } /** {@inheritDoc} */ - @Override public void prepare(GridDeploymentInfo depInfo) { + @Override public void prepareDeployment(GridDeploymentInfo depInfo) { assert evt instanceof CacheEvent; this.depInfo = depInfo; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeployable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeployable.java index 057ce897bac52..9d8f289bbe1c1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeployable.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeployable.java @@ -28,7 +28,7 @@ public interface GridCacheDeployable { * * @param depInfo Deployment information. */ - public void prepare(GridDeploymentInfo depInfo); + public void prepareDeployment(GridDeploymentInfo depInfo); /** * @return Deployment bean. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java index ce2ceaa577771..29abdca600257 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java @@ -411,7 +411,7 @@ public void prepare(GridCacheDeployable deployable) throws IgnitePeerToPeerClass checkDeploymentIsCorrect(dep, deployable, true); if (dep != null) - deployable.prepare(dep); + deployable.prepareDeployment(dep); if (log.isDebugEnabled()) log.debug("Prepared grid cache deployable [dep=" + dep + ", deployable=" + deployable + ']'); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index 7a965d03d5521..ffd40d04f5429 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -1096,7 +1096,7 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I msg.messageId(idGen.incrementAndGet()); if (destNodeId == null || !cctx.localNodeId().equals(destNodeId)) { - msg.prepareMarshal(cctx); + msg.prepareDeployment(cctx); MessageSerializer ser = cctx.gridIO().messageFactory().serializer(msg.directType()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index 1d1e564612ea3..a4a3a0a2aeba3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -32,7 +32,6 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.T2; -import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; @@ -204,8 +203,8 @@ public void lastAffinityChangedTopologyVersion(AffinityTopologyVersion topVer) { * @param ctx Context. * @throws IgniteCheckedException If failed. */ - protected final void prepareObject(@Nullable Object o, GridCacheContext ctx) throws IgniteCheckedException { - prepareObject(o, ctx.shared()); + protected final void prepareObjectDeployment(@Nullable Object o, GridCacheContext ctx) throws IgniteCheckedException { + prepareObjectDeployment(o, ctx.shared()); } /** @@ -213,14 +212,14 @@ protected final void prepareObject(@Nullable Object o, GridCacheContext ctx) thr * @param ctx Context. * @throws IgniteCheckedException If failed. */ - protected final void prepareObject(@Nullable Object o, GridCacheSharedContext ctx) throws IgniteCheckedException { + protected final void prepareObjectDeployment(@Nullable Object o, GridCacheSharedContext ctx) throws IgniteCheckedException { assert addDepInfo || forceAddDepInfo; if (!skipPrepare && o != null) { GridDeploymentInfo d = ctx.deploy().globalDeploymentInfo(); if (d != null) { - prepare(d); + prepareDeployment(d); // Global deployment has been injected. skipPrepare = true; @@ -233,16 +232,16 @@ protected final void prepareObject(@Nullable Object o, GridCacheSharedContext ct ClassLoader ldr = U.detectClassLoader(cls); if (ldr instanceof GridDeploymentInfo) - prepare((GridDeploymentInfo)ldr); + prepareDeployment((GridDeploymentInfo)ldr); } } } /** * @param depInfo Deployment to set. - * @see GridCacheDeployable#prepare(GridDeploymentInfo) + * @see GridCacheDeployable#prepareDeployment(GridDeploymentInfo) */ - public final void prepare(GridDeploymentInfo depInfo) { + public final void prepareDeployment(GridDeploymentInfo depInfo) { if (depInfo != this.depInfo) { if (this.depInfo != null && depInfo instanceof GridDeployment) // Make sure not to replace remote deployment with local. @@ -269,13 +268,13 @@ public GridDeploymentInfoBean deployInfo() { * @param ctx Cache context. * @throws IgniteCheckedException If failed. */ - public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + public void prepareDeployment(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. + * unmarshalling state marshalled in {@link #prepareDeployment(GridCacheSharedContext)} method. * * @param ctx Context. * @param ldr Class loader. @@ -291,7 +290,7 @@ public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) t * @param cacheObjCtx Cache object context. * @throws IgniteCheckedException If failed. */ - protected final void prepareInfo(GridCacheEntryInfo info, + protected final void prepareInfoDeployment(GridCacheEntryInfo info, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx ) throws IgniteCheckedException { @@ -300,14 +299,14 @@ protected final void prepareInfo(GridCacheEntryInfo info, if (info != null) { if (addDepInfo) { if (info.key() != null) - prepareObject(info.key().value(cacheObjCtx, false), ctx); + prepareObjectDeployment(info.key().value(cacheObjCtx, false), ctx); CacheObject val = info.value(); if (val != null) { val.finishUnmarshal(cacheObjCtx, ctx.deploy().globalLoader()); - prepareObject(val.value(cacheObjCtx, false), ctx); + prepareObjectDeployment(val.value(cacheObjCtx, false), ctx); } } } @@ -333,7 +332,7 @@ protected final void unmarshalInfo(GridCacheEntryInfo info, GridCacheContext ctx * @param ctx Context. * @throws IgniteCheckedException If failed. */ - protected final void prepareInfos( + protected final void prepareInfosDeployment( Iterable infos, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx @@ -342,7 +341,7 @@ protected final void prepareInfos( if (infos != null) for (GridCacheEntryInfo e : infos) - prepareInfo(e, ctx, cacheObjCtx); + prepareInfoDeployment(e, ctx, cacheObjCtx); } /** @@ -366,7 +365,7 @@ protected final void unmarshalInfos(Iterable infos * @param ctx Context. * @throws IgniteCheckedException If failed. */ - protected final void prepareTx(Iterable txEntries, GridCacheSharedContext ctx) + protected final void prepareTxDeployment(Iterable txEntries, GridCacheSharedContext ctx) throws IgniteCheckedException { assert ctx != null; @@ -378,14 +377,14 @@ protected final void prepareTx(Iterable txEntries, GridCacheShare if (addDepInfo) { if (e.key() != null) - prepareObject(e.key().value(cctx.cacheObjectContext(), false), ctx); + prepareObjectDeployment(e.key().value(cctx.cacheObjectContext(), false), ctx); if (e.value() != null) - prepareObject(e.value().value(cctx.cacheObjectContext(), false), ctx); + prepareObjectDeployment(e.value().value(cctx.cacheObjectContext(), false), ctx); if (e.entryProcessors() != null) { for (T2, Object[]> entProc : e.entryProcessors()) - prepareObject(entProc.get1(), ctx); + prepareObjectDeployment(entProc.get1(), ctx); } } else if (p2pEnabled && e.entryProcessors() != null) { @@ -393,7 +392,7 @@ else if (p2pEnabled && e.entryProcessors() != null) { forceAddDepInfo = true; for (T2, Object[]> entProc : e.entryProcessors()) - prepareObject(entProc.get1(), ctx); + prepareObjectDeployment(entProc.get1(), ctx); } } } @@ -422,13 +421,12 @@ protected final void unmarshalTx(Iterable txEntries, /** * @param args Arguments to marshal. - * @param ctx Context. + * @param marsh Marshaller. * @return Marshalled collection. * @throws IgniteCheckedException If failed. */ - @Nullable protected final byte[][] marshalInvokeArguments(@Nullable Object[] args, GridCacheContext ctx) + @Nullable protected final byte[][] marshallInvokeArguments(@Nullable Object[] args, Marshaller marsh) throws IgniteCheckedException { - assert ctx != null; if (args == null || args.length == 0) return null; @@ -438,15 +436,31 @@ protected final void unmarshalTx(Iterable txEntries, 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); + argsBytes[i] = arg == null ? null : U.marshal(marsh, arg); } return argsBytes; } + /** + * @param args Arguments to marshal. + * @param ctx Context. + * @throws IgniteCheckedException If failed. + */ + @Nullable protected final void prepareInvokeArgumentsDeployment(@Nullable Object[] args, GridCacheContext ctx) + throws IgniteCheckedException { + assert ctx != null; + + if (args == null) + return; + + for (int i = 0; i < args.length; i++) { + Object arg = args[i]; + + if (addDepInfo) + prepareObjectDeployment(arg, ctx.shared()); + } + } /** * @param byteCol Collection to unmarshal. @@ -476,27 +490,35 @@ protected final void unmarshalTx(Iterable txEntries, /** * @param col Collection to marshal. - * @param ctx Context. + * @param marsh Marshaller. * @return Marshalled collection. * @throws IgniteCheckedException If failed. */ - @Nullable protected List marshalAndPrepareCollection(@Nullable Collection col, - GridCacheContext ctx) throws IgniteCheckedException { - assert ctx != null; - + @Nullable protected List marshallCollection(@Nullable Collection col, Marshaller marsh) throws IgniteCheckedException { if (col == null) return null; List byteCol = new ArrayList<>(col.size()); + for (Object o : col) + byteCol.add(o == null ? null : U.marshal(marsh, o)); + + return byteCol; + } + + /** + * @param col Collection to marshal. + * @param ctx Context. + * @throws IgniteCheckedException If failed. + */ + @Nullable protected void prepareCollectionDeployment(@Nullable Collection col, + GridCacheContext ctx) throws IgniteCheckedException { + assert ctx != null; + for (Object o : col) { if (addDepInfo) - prepareObject(o, ctx.shared()); - - byteCol.add(o == null ? null : CU.marshal(ctx, o)); + prepareObjectDeployment(o, ctx.shared()); } - - return byteCol; } /** @@ -505,7 +527,7 @@ protected final void unmarshalTx(Iterable txEntries, * @throws IgniteCheckedException If failed. */ @SuppressWarnings("ForLoopReplaceableByForEach") - public final void prepareCacheObjects(@Nullable List col, + public final void prepareCacheObjectsDeployment(@Nullable List col, GridCacheContext ctx) throws IgniteCheckedException { if (col == null) return; @@ -513,7 +535,7 @@ public final void prepareCacheObjects(@Nullable List col, int size = col.size(); for (int i = 0; i < size; i++) - prepareCacheObject(col.get(i), ctx); + prepareCacheObjectDeployment(col.get(i), ctx); } /** @@ -521,10 +543,10 @@ public final void prepareCacheObjects(@Nullable List col, * @param ctx Context. * @throws IgniteCheckedException If failed. */ - public final void prepareCacheObject(CacheObject obj, GridCacheContext ctx) throws IgniteCheckedException { + public final void prepareCacheObjectDeployment(CacheObject obj, GridCacheContext ctx) throws IgniteCheckedException { if (obj != null) { if (addDepInfo) - prepareObject(obj.value(ctx.cacheObjectContext(), false), ctx.shared()); + prepareObjectDeployment(obj.value(ctx.cacheObjectContext(), false), ctx.shared()); } } @@ -533,7 +555,7 @@ public final void prepareCacheObject(CacheObject obj, GridCacheContext ctx) thro * @param ctx Cache context. * @throws IgniteCheckedException If failed. */ - protected final void prepareCacheObjects(@Nullable Collection col, + protected final void prepareCacheObjectsDeployment(@Nullable Collection col, GridCacheContext ctx) throws IgniteCheckedException { if (col == null) return; @@ -541,7 +563,7 @@ protected final void prepareCacheObjects(@Nullable Collection nearVersions() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareCacheObjects(keys, cctx); + prepareCacheObjectsDeployment(keys, cctx); - prepareCacheObjects(nearKeys, cctx); + prepareCacheObjectsDeployment(nearKeys, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index edba35b3ff27e..7616318ed7336 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -348,12 +348,12 @@ public long timeout() { /** {@inheritDoc} * @param ctx*/ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareCacheObjects(keys, cctx); + prepareCacheObjectsDeployment(keys, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java index 4bcb22b0b17b8..c9f2fb14ebc17 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java @@ -161,10 +161,10 @@ protected int valuesSize() { /** {@inheritDoc} * @param ctx*/ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); - prepareCacheObjects(vals, ctx.cacheContext(cacheId)); + prepareCacheObjectsDeployment(vals, ctx.cacheContext(cacheId)); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index b26dc8bce8bf2..958da951dc386 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -25,6 +25,7 @@ import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; @@ -37,6 +38,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; @@ -45,7 +47,7 @@ * Transaction prepare request for optimistic and eventually consistent * transactions. */ -public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage implements IgniteTxStateAware { +public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage implements IgniteTxStateAware, MarshallableMessage { /** */ private static final int NEED_RETURN_VALUE_FLAG_MASK = 0x01; @@ -371,19 +373,14 @@ public void applicationAttributes(Map appAttrs) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); if (writes != null) - prepareTx(writes, ctx); + prepareTxDeployment(writes, ctx); if (reads != null) - prepareTx(reads, ctx); - - if (dhtVers != null && dhtVerKeys == null) { - dhtVerKeys = dhtVers.keySet(); - dhtVerVals = dhtVers.values(); - } + prepareTxDeployment(reads, ctx); } /** {@inheritDoc} */ @@ -445,6 +442,18 @@ private boolean isFlag(int mask) { return (flags & mask) != 0; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (dhtVers != null && dhtVerKeys == null) { + dhtVerKeys = dhtVers.keySet(); + dhtVerVals = dhtVers.values(); + } + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + + } /** {@inheritDoc} */ @Override public String toString() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java index fb4feade50f68..78086afad7bc9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java @@ -95,10 +95,10 @@ public void addKey(KeyCacheObject key) { /** {@inheritDoc} * @param ctx*/ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); - prepareCacheObjects(keys, ctx.cacheContext(cacheId)); + prepareCacheObjectsDeployment(keys, ctx.cacheContext(cacheId)); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 315997cecd8a6..f771d635dedb7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.UUID; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; @@ -32,6 +33,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,7 +41,7 @@ /** * DHT lock request. */ -public class GridDhtLockRequest extends GridDistributedLockRequest { +public class GridDhtLockRequest extends GridDistributedLockRequest implements MarshallableMessage { /** Invalidate reader flags. */ @Order(0) BitSet invalidateEntries; @@ -257,9 +259,24 @@ public long accessTtl() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { + super.finishUnmarshal(ctx, ldr); + + if (ownedKeys != null) { + owned = new GridLeanMap<>(ownedKeys.length); + + for (int i = 0; i < ownedKeys.length; i++) { + ownedKeys[i].finishUnmarshal(ctx.cacheContext(cacheId).cacheObjectContext(), ldr); + owned.put(ownedKeys[i], ownedValues[i]); + } + + ownedKeys = null; + ownedValues = null; + } + } + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { if (owned != null && ownedKeys == null) { ownedKeys = new KeyCacheObject[owned.size()]; ownedValues = new GridCacheVersion[ownedKeys.length]; @@ -275,23 +292,10 @@ public long accessTtl() { } /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - if (ownedKeys != null) { - owned = new GridLeanMap<>(ownedKeys.length); + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - for (int i = 0; i < ownedKeys.length; i++) { - ownedKeys[i].finishUnmarshal(ctx.cacheContext(cacheId).cacheObjectContext(), ldr); - owned.put(ownedKeys[i], ownedValues[i]); - } - - ownedKeys = null; - ownedValues = null; - } } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtLockRequest.class, this, "super", super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index 49e155a8dfab7..1a2690b843cc2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -124,13 +124,13 @@ public Collection preloadEntries() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); if (preloadEntries != null) - prepareInfos(preloadEntries, cctx.shared(), cctx.cacheObjectContext()); + prepareInfosDeployment(preloadEntries, cctx.shared(), cctx.cacheObjectContext()); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 3d43238e6310f..76a81ea00f0ee 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.UUID; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; @@ -39,12 +40,13 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.marshaller.Marshaller; import org.jetbrains.annotations.Nullable; /** * DHT prepare request. */ -public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest { +public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest implements MarshallableMessage { /** Max order. */ @Order(0) UUID nearNodeId; @@ -320,24 +322,20 @@ public boolean skipCompletedVersion() { * * @param ctx */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); if (owned != null && ownedKeys == null) { - ownedKeys = owned.keySet(); - - ownedVals = owned.values(); - - for (IgniteTxKey key: ownedKeys) { + for (IgniteTxKey key: owned.keySet()) { GridCacheContext cctx = ctx.cacheContext(key.cacheId()); if (addDepInfo) - prepareObject(key, cctx); + prepareObjectDeployment(key, cctx); } } if (nearWrites != null) - prepareTx(nearWrites, ctx); + prepareTxDeployment(nearWrites, ctx); } /** {@inheritDoc} */ @@ -389,7 +387,20 @@ public boolean skipCompletedVersion() { } } + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (owned != null && ownedKeys == null) { + ownedKeys = owned.keySet(); + + ownedVals = owned.values(); + } + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + } + /** {@inheritDoc} */ @Override public int partition() { return U.safeAbs(version().hashCode()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index d2d97808d3986..c8677d3e2720c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -71,10 +71,10 @@ public void addNearKey(KeyCacheObject key) } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); - prepareCacheObjects(nearKeys, ctx.cacheContext(cacheId)); + prepareCacheObjectsDeployment(nearKeys, ctx.cacheContext(cacheId)); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/TransactionAttributesAwareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/TransactionAttributesAwareRequest.java index 4cc026c390cda..36b7a66ea4f7e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/TransactionAttributesAwareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/TransactionAttributesAwareRequest.java @@ -58,8 +58,8 @@ public Map applicationAttributes() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - payload.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + payload.prepareDeployment(ctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicApplicationAttributesAwareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicApplicationAttributesAwareRequest.java index 7c37b474dd2b7..238a65b7ff3dd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicApplicationAttributesAwareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicApplicationAttributesAwareRequest.java @@ -58,8 +58,8 @@ public Map applicationAttributes() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - payload.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + payload.prepareDeployment(ctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 6fcd2e5ab3bf3..d589c46f90dd3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -23,6 +23,7 @@ import java.util.UUID; import javax.cache.processor.EntryProcessor; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; @@ -36,13 +37,14 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.marshaller.Marshaller; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Lite dht cache backup update request. */ -public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest { +public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements MarshallableMessage { /** Keys to update. */ @GridToStringInclude @Order(0) @@ -462,20 +464,20 @@ else if (conflictVers != null) } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareCacheObjects(keys, cctx); + prepareCacheObjectsDeployment(keys, cctx); - prepareCacheObjects(vals, cctx); + prepareCacheObjectsDeployment(vals, cctx); - prepareCacheObjects(nearKeys, cctx); + prepareCacheObjectsDeployment(nearKeys, cctx); - prepareCacheObjects(nearVals, cctx); + prepareCacheObjectsDeployment(nearVals, cctx); - prepareCacheObjects(prevVals, cctx); + prepareCacheObjectsDeployment(prevVals, cctx); if (forceTransformBackups) { // force addition of deployment info for entry processors if P2P is enabled globally. @@ -483,13 +485,13 @@ else if (conflictVers != null) addDepInfo = true; if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) - invokeArgsBytes = Arrays.asList(marshalInvokeArguments(invokeArgs, cctx)); + prepareInvokeArgumentsDeployment(invokeArgs, cctx); if (entryProcessorsBytes == null) - entryProcessorsBytes = marshalAndPrepareCollection(entryProcessors, cctx); + prepareCollectionDeployment(entryProcessors, cctx); if (nearEntryProcessorsBytes == null) - nearEntryProcessorsBytes = marshalAndPrepareCollection(nearEntryProcessors, cctx); + prepareCollectionDeployment(nearEntryProcessors, cctx); } } @@ -527,6 +529,24 @@ else if (conflictVers != null) prevVals = null; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (forceTransformBackups) { + if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) + invokeArgsBytes = Arrays.asList(marshallInvokeArguments(invokeArgs, marsh)); + + if (entryProcessorsBytes == null) + entryProcessorsBytes = marshallCollection(entryProcessors, marsh); + + if (nearEntryProcessorsBytes == null) + nearEntryProcessorsBytes = marshallCollection(nearEntryProcessors, marsh); + } + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + + } /** {@inheritDoc} */ @Override public String toString() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index b241f6fbd9327..9bab174411736 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -119,14 +119,14 @@ public void nearEvicted(List nearEvicted) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); // Can be null if client near cache was removed, in this case assume do not need prepareMarshal. if (cctx != null) - prepareCacheObjects(nearEvicted, cctx); + prepareCacheObjectsDeployment(nearEvicted, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index 4a4c868148448..5082d1c25160d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -25,6 +25,7 @@ import javax.cache.processor.EntryProcessor; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; @@ -41,6 +42,7 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.Marshaller; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -51,7 +53,7 @@ /** * Lite DHT cache update request sent from near node to primary node. */ -public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest { +public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements MarshallableMessage { /** Keys to update. */ @Order(0) @GridToStringInclude @@ -328,15 +330,15 @@ else if (conflictVers != null) } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); if (expiryPlc != null && expiryPlcBytes == null) expiryPlcBytes = CU.marshal(cctx, new IgniteExternalizableExpiryPolicy(expiryPlc)); - prepareCacheObjects(keys, cctx); + prepareCacheObjectsDeployment(keys, cctx); if (filter != null && filter.length == 0) filter = null; @@ -347,13 +349,13 @@ else if (conflictVers != null) addDepInfo = true; if (entryProcessorsBytes == null) - entryProcessorsBytes = marshalAndPrepareCollection(entryProcessors, cctx); + prepareCollectionDeployment(entryProcessors, cctx); if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) - invokeArgsBytes = Arrays.asList(marshalInvokeArguments(invokeArgs, cctx)); + prepareInvokeArgumentsDeployment(invokeArgs, cctx); } else - prepareCacheObjects(vals, cctx); + prepareCacheObjectsDeployment(vals, cctx); } /** {@inheritDoc} */ @@ -404,6 +406,21 @@ else if (conflictVers != null) keys = null; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (operation() == TRANSFORM) { + if (entryProcessorsBytes == null) + entryProcessorsBytes = marshallCollection(entryProcessors, marsh); + + if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) + invokeArgsBytes = Arrays.asList(marshallInvokeArguments(invokeArgs, marsh)); + } + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + + } /** {@inheritDoc} */ @Override public String toString() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java index a5da3a9365838..9555f9a475ff5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java @@ -21,6 +21,7 @@ import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; @@ -28,13 +29,14 @@ import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.marshaller.Marshaller; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * */ -public class GridNearAtomicSingleUpdateFilterRequest extends GridNearAtomicSingleUpdateRequest { +public class GridNearAtomicSingleUpdateFilterRequest extends GridNearAtomicSingleUpdateRequest implements MarshallableMessage { /** Filter. */ @Order(0) CacheEntryPredicate[] filter; @@ -91,14 +93,6 @@ public GridNearAtomicSingleUpdateFilterRequest() { return filter; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - if (filter != null && filter.length == 0) - filter = null; - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); @@ -113,6 +107,16 @@ public GridNearAtomicSingleUpdateFilterRequest() { } } + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (filter != null && filter.length == 0) + filter = null; + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + + } /** {@inheritDoc} */ @Override public String toString() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index 2b2e44f5e7ea7..afe5ed3d0ecb1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -24,6 +24,7 @@ import javax.cache.processor.EntryProcessor; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; @@ -33,9 +34,9 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.Marshaller; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -44,7 +45,7 @@ /** * */ -public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest { +public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest implements MarshallableMessage { /** Optional arguments for entry processor. */ private @Nullable Object[] invokeArgs; @@ -160,8 +161,8 @@ public GridNearAtomicSingleUpdateInvokeRequest() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); @@ -171,13 +172,11 @@ public GridNearAtomicSingleUpdateInvokeRequest() { if (entryProc != null && entryProcBytes == null) { if (addDepInfo) - prepareObject(entryProc, cctx); - - entryProcBytes = CU.marshal(cctx, entryProc); + prepareObjectDeployment(entryProc, cctx); } if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) - invokeArgsBytes = Arrays.asList(marshalInvokeArguments(invokeArgs, cctx)); + prepareInvokeArgumentsDeployment(invokeArgs, cctx); } /** {@inheritDoc} */ @@ -198,6 +197,19 @@ public GridNearAtomicSingleUpdateInvokeRequest() { entryProc = null; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (entryProc != null && entryProcBytes == null) + entryProcBytes = U.marshal(marsh, entryProc); + + if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) + invokeArgsBytes = Arrays.asList(marshallInvokeArguments(invokeArgs, marsh)); + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + + } /** {@inheritDoc} */ @Override public String toString() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java index 67a18d83c7cd1..f9428a4497770 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java @@ -217,15 +217,15 @@ public GridNearAtomicSingleUpdateRequest() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareCacheObject(key, cctx); + prepareCacheObjectDeployment(key, cctx); if (val != null) - prepareCacheObject(val, cctx); + prepareCacheObjectDeployment(val, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index a66dc49a2deb8..d42596aedb39e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -339,13 +339,13 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { /** {@inheritDoc} * @param ctx*/ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); if (nearUpdates != null) - prepareCacheObjects(nearUpdates.nearValues(), cctx); + prepareCacheObjectsDeployment(nearUpdates.nearValues(), cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java index c0bcb272a3fe2..105292b3798d3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java @@ -117,7 +117,7 @@ void addFailedKeys(Collection keys, Throwable e) { /** */ void prepareMarshal(GridCacheMessage msg, GridCacheContext cctx) throws IgniteCheckedException { - msg.prepareCacheObjects(failedKeys, cctx); + msg.prepareCacheObjectsDeployment(failedKeys, cctx); } /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 93d12397cd442..8038375f1e9d0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -114,12 +114,12 @@ public Collection keys() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareCacheObjects(keys, cctx); + prepareCacheObjectsDeployment(keys, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index f4d14426e2e3d..45e9f1e2f0965 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -132,13 +132,13 @@ public void addInfo(GridCacheEntryInfo info) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); if (missedKeys != null) - prepareCacheObjects(missedKeys, cctx); + prepareCacheObjectsDeployment(missedKeys, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index 9a1944a721a04..4c90b909c9efb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -215,7 +215,7 @@ void addEntry0(int p, boolean historical, GridCacheEntryInfo info, GridCacheShar assert info.value() != null || historical : info; // Need to call this method to initialize info properly. - prepareInfo(info, ctx, cacheObjCtx); + prepareInfoDeployment(info, ctx, cacheObjCtx); msgSize += info.marshalledSize(cacheObjCtx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java index 733f9b0adc462..0ccb732f850aa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java @@ -3865,7 +3865,7 @@ else if (exchCtx.events().hasServerLeft()) else if (forceAffReassignment) msg.idealAffinityDiff(idealAffDiff); - msg.prepareMarshal(cctx); + msg.prepareDeployment(cctx); timeBag.finishGlobalStage("Full message preparing"); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index 1ada1a83ed7af..c92b4639f5b02 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -284,8 +284,8 @@ public long accessTtl() { * @param ctx Cache context. * @throws IgniteCheckedException If failed. */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); assert ctx != null; assert !F.isEmpty(keys); @@ -293,7 +293,7 @@ public long accessTtl() { GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareCacheObjects(keys, cctx); + prepareCacheObjectsDeployment(keys, cctx); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java index 2e27d2d16485e..ded6016b3a5c9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java @@ -250,14 +250,14 @@ public boolean recovery() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); assert key != null; GridCacheContext cctx = ctx.cacheContext(cacheId); - prepareCacheObject(key, cctx); + prepareCacheObjectDeployment(key, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java index 8bdcfccb953f7..28c80f2dc963c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java @@ -145,14 +145,14 @@ public long futureId() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); if (res != null) { GridCacheContext cctx = ctx.cacheContext(cacheId); if (res instanceof CacheObject) - prepareCacheObject((CacheObject)res, cctx); + prepareCacheObjectDeployment((CacheObject)res, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index c0994bfa5bd90..5dffe6ad9d47c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -23,6 +23,7 @@ import java.util.Iterator; import java.util.Map; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; @@ -37,12 +38,13 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.marshaller.Marshaller; import org.jetbrains.annotations.Nullable; /** * Near cache prepare response. */ -public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse { +public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse implements MarshallableMessage { /** Versions that are less than lock version ({@link #version()}). */ @GridToStringInclude @Order(0) @@ -235,22 +237,6 @@ public boolean hasOwnedValue(IgniteTxKey key) { return F.mapContainsKey(ownedVals, key); } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - // There are separate collections for keys and values of the 'ownedVals' map, because IgniteTxKey - // can not be inserted directly in a map as a key during invocation of MessageReader#read. - // The IgniteTxKey's hash code calculation will fail due to delegation of calculation - // to KeyCacheObjectImpl#hashCode, which in turn fails with assertion error if KeyCacheObjectImpl#val - // has not initialized yet in KeyCacheObjectImpl#finishUnmarshal. - if (ownedVals != null && ownedValKeys == null) { - ownedValKeys = ownedVals.keySet(); - - ownedValVals = ownedVals.values(); - } - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); @@ -301,7 +287,20 @@ public boolean hasOwnedValue(IgniteTxKey key) { } } + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (ownedVals != null && ownedValKeys == null) { + ownedValKeys = ownedVals.keySet(); + + ownedValVals = ownedVals.values(); + } + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearTxPrepareResponse.class, this, "super", super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotAwareMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotAwareMessage.java index 5a0824c9a5d41..1032504d60ad5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotAwareMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotAwareMessage.java @@ -82,8 +82,8 @@ public long snapshotTopologyVersion() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - payload.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + payload.prepareDeployment(ctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 592cf335b2904..5e1fba2884fbe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -19,6 +19,7 @@ import java.util.Collection; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObjectContext; @@ -29,7 +30,6 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiPredicate; @@ -45,7 +45,7 @@ /** * Query request. */ -public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable { +public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, MarshallableMessage { /** */ private static final int FLAG_DATA_PAGE_SCAN_DFLT = 0b00; @@ -407,46 +407,36 @@ private static byte setDataPageScanEnabled(int flags, Boolean enabled) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); if (keyValFilter != null && keyValFilterBytes == null) { if (addDepInfo) - prepareObject(keyValFilter, cctx); - - keyValFilterBytes = CU.marshal(cctx, keyValFilter); + prepareObjectDeployment(keyValFilter, cctx); } if (rdc != null && rdcBytes == null) { if (addDepInfo) - prepareObject(rdc, cctx); - - rdcBytes = CU.marshal(cctx, rdc); + prepareObjectDeployment(rdc, cctx); } if (trans != null && transBytes == null) { if (addDepInfo) - prepareObject(trans, cctx); - - transBytes = CU.marshal(cctx, trans); + prepareObjectDeployment(trans, cctx); } if (!F.isEmpty(args) && argsBytes == null) { if (addDepInfo) { for (Object arg : args) - prepareObject(arg, cctx); + prepareObjectDeployment(arg, cctx); } - - argsBytes = CU.marshal(cctx, args); } if (idxQryDesc != null && idxQryDescBytes == null) { if (addDepInfo) - prepareObject(idxQryDesc, cctx); - - idxQryDescBytes = CU.marshal(cctx, idxQryDesc); + prepareObjectDeployment(idxQryDesc, cctx); } } @@ -654,6 +644,28 @@ public Collection skipKeys() { return part; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (keyValFilter != null && keyValFilterBytes == null) + keyValFilterBytes = U.marshal(marsh, keyValFilter); + + if (rdc != null && rdcBytes == null) + rdcBytes = U.marshal(marsh, rdc); + + if (trans != null && transBytes == null) + transBytes = U.marshal(marsh, trans); + + if (!F.isEmpty(args) && argsBytes == null) + argsBytes = U.marshal(marsh, args); + + if (idxQryDesc != null && idxQryDescBytes == null) + idxQryDescBytes = U.marshal(marsh, idxQryDesc); + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + + } /** {@inheritDoc} */ @Override public String toString() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index da19ed40728e2..78dcd963c55f7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.cache.query.index.IndexQueryResultMeta; import org.apache.ignite.internal.managers.communication.ErrorMessage; @@ -40,7 +41,7 @@ /** * Page of cache query response. */ -public class GridCacheQueryResponse extends GridCacheIdMessage implements GridCacheDeployable { +public class GridCacheQueryResponse extends GridCacheIdMessage implements GridCacheDeployable, MarshallableMessage { /** */ @Order(0) boolean finished; @@ -105,21 +106,21 @@ public GridCacheQueryResponse(int cacheId, long reqId, Throwable err, boolean ad /** {@inheritDoc} * @param ctx*/ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + super.prepareDeployment(ctx); GridCacheContext cctx = ctx.cacheContext(cacheId); if (dataBytes == null && data != null) - dataBytes = marshalAndPrepareCollection(data, cctx); + prepareCollectionDeployment(data, cctx); if (addDepInfo && !F.isEmpty(data)) { for (Object o : data) { if (o instanceof Map.Entry) { Map.Entry e = (Map.Entry)o; - prepareObject(e.getKey(), cctx); - prepareObject(e.getValue(), cctx); + prepareObjectDeployment(e.getKey(), cctx); + prepareObjectDeployment(e.getValue(), cctx); } } } @@ -233,6 +234,16 @@ public boolean fields() { return fields; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (dataBytes == null && data != null) + dataBytes = marshallCollection(data, marsh); + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + + } /** {@inheritDoc} */ @Override public String toString() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java index 5f6aaf84d0790..9acf37ef7a23d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java @@ -327,7 +327,7 @@ CacheObject oldValue() { } /** {@inheritDoc} */ - @Override public void prepare(GridDeploymentInfo depInfo) { + @Override public void prepareDeployment(GridDeploymentInfo depInfo) { this.depInfo = depInfo; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 1dd91a8e79e0b..56fbaabb4ca24 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -2432,7 +2432,7 @@ void txLocksInfo(UUID nodeId, TxDeadlockFuture fut, Set txKeys) { try { if (!cctx.localNodeId().equals(nodeId)) { - req.prepareMarshal(cctx); + req.prepareDeployment(cctx); MessageSerializer ser = cctx.gridIO().messageFactory().serializer(req.directType()); @@ -3368,7 +3368,7 @@ private class DeadlockDetectionListener implements GridMessageListener { try { if (!cctx.localNodeId().equals(nodeId)) { - res.prepareMarshal(cctx); + res.prepareDeployment(cctx); MessageSerializer ser = cctx.gridIO().messageFactory().serializer(res.directType()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java index a3221cd2173ea..dab495aeb2698 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.Set; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; @@ -28,11 +29,12 @@ import org.apache.ignite.internal.util.typedef.internal.A; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.Marshaller; /** * Transactions lock list request. */ -public class TxLocksRequest extends GridCacheMessage { +public class TxLocksRequest extends GridCacheMessage implements MarshallableMessage { /** Future ID. */ @Order(0) long futId; @@ -88,18 +90,6 @@ public Collection txKeys() { return addDepInfo; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - txKeysArr = new IgniteTxKey[txKeys.size()]; - - int i = 0; - - for (IgniteTxKey key : txKeys) - txKeysArr[i++] = key; - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); @@ -115,4 +105,18 @@ public Collection txKeys() { txKeysArr = null; } + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + txKeysArr = new IgniteTxKey[txKeys.size()]; + + int i = 0; + + for (IgniteTxKey key : txKeys) + txKeysArr[i++] = key; + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index a00fa1be14032..fe01c2f31967d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.Set; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; @@ -31,11 +32,12 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.Marshaller; /** * Transactions lock list response. */ -public class TxLocksResponse extends GridCacheMessage { +public class TxLocksResponse extends GridCacheMessage implements MarshallableMessage { /** Future ID. */ @Order(0) long futId; @@ -136,38 +138,6 @@ public void addKey(IgniteTxKey key) { return S.toString(TxLocksResponse.class, this); } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareMarshal(ctx); - - if (nearTxKeyLocks != null && !nearTxKeyLocks.isEmpty()) { - int len = nearTxKeyLocks.size(); - - nearTxKeysArr = new IgniteTxKey[len]; - locksArr = (List[])new List[len]; - - int i = 0; - - for (Map.Entry> entry : nearTxKeyLocks.entrySet()) { - IgniteTxKey key = entry.getKey(); - - nearTxKeysArr[i] = key; - locksArr[i] = entry.getValue(); - - i++; - } - } - - if (txKeys != null && !txKeys.isEmpty()) { - txKeysArr = new IgniteTxKey[txKeys.size()]; - - int i = 0; - - for (IgniteTxKey key : txKeys) - txKeysArr[i++] = key; - } - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { try { @@ -203,4 +173,38 @@ public void addKey(IgniteTxKey key) { } } + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (nearTxKeyLocks != null && !nearTxKeyLocks.isEmpty()) { + int len = nearTxKeyLocks.size(); + + nearTxKeysArr = new IgniteTxKey[len]; + locksArr = (List[])new List[len]; + + int i = 0; + + for (Map.Entry> entry : nearTxKeyLocks.entrySet()) { + IgniteTxKey key = entry.getKey(); + + nearTxKeysArr[i] = key; + locksArr[i] = entry.getValue(); + + i++; + } + } + + if (txKeys != null && !txKeys.isEmpty()) { + txKeysArr = new IgniteTxKey[txKeys.size()]; + + int i = 0; + + for (IgniteTxKey key : txKeys) + txKeysArr[i++] = key; + } + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java index a6d6375c1ed87..39ca06b06ec70 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java @@ -86,7 +86,7 @@ public void testMessageUnmarshallWithoutCacheContext() throws Exception { TxLocksResponse msg = new TxLocksResponse(); msg.addKey(cctx.txKey(key)); - msg.prepareMarshal(cctx.shared()); + msg.prepareDeployment(cctx.shared()); ((IgniteKernal)ignite).context().cache().context().gridIO().sendToCustomTopic( ((IgniteKernal)client).localNode(), TOPIC, msg, GridIoPolicy.PUBLIC_POOL); diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExceptionTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExceptionTest.java index 44a39859e05b7..3c4853ca04efe 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExceptionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExceptionTest.java @@ -197,7 +197,7 @@ private class TestCommunicationSpi extends TcpCommunicationSpi { GridCacheQueryRequest qryReq = (GridCacheQueryRequest)m; if (qryReq.deployInfo() != null) { - qryReq.prepare( + qryReq.prepareDeployment( new GridDeploymentInfoBean( IgniteUuid.fromUuid(UUID.randomUUID()), qryReq.deployInfo().userVersion(), From 0ec4e94eeea68c1f21731c9c73555fd84032787e Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 19 May 2026 19:08:53 +0300 Subject: [PATCH 035/215] WIP --- .../apache/ignite/internal/MessageSerializerGenerator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 1e310911bc4f4..f43527ce02c4e 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -253,11 +253,11 @@ private void generateMethods(List fields) throws Exception { finish(write, false, false); finish(read, true, marshallableMessage()); - generateCacheObjectMarshallMethods(fields); + generateMarshallMethods(fields); } /** */ - private void generateCacheObjectMarshallMethods(List orderedFields) throws Exception { + private void generateMarshallMethods(List orderedFields) throws Exception { imports.add("org.apache.ignite.IgniteCheckedException"); imports.add("org.apache.ignite.internal.processors.cache.CacheObjectValueContext"); imports.add("org.apache.ignite.internal.processors.cache.GridCacheSharedContext"); From 2948fb30153f898679c435e9d12c08361b1db578 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 20 May 2026 18:15:00 +0300 Subject: [PATCH 036/215] WIP --- .../dht/preloader/GridDhtPartitionsExchangeFuture.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java index 0ccb732f850aa..ace55d5bdd2eb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java @@ -128,6 +128,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgniteRunnable; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.jetbrains.annotations.Nullable; import static java.util.Collections.emptySet; @@ -3867,6 +3868,11 @@ else if (forceAffReassignment) msg.prepareDeployment(cctx); + MessageSerializer ser = cctx.gridIO().messageFactory().serializer(msg.directType()); + + if (ser != null) + ser.prepareMarshal(msg, cctx, null); + timeBag.finishGlobalStage("Full message preparing"); synchronized (mux) { From 104d4c2ec3300226112032952d979e904b369dd8 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 20 May 2026 19:07:51 +0300 Subject: [PATCH 037/215] WIP --- .../org/apache/ignite/internal/MessageSerializerGenerator.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index f43527ce02c4e..f92806061511f 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -286,6 +286,8 @@ private void generateMarshallMethods(List orderedFields) throws marshall.addAll(marshall(field.asType(), fieldAccessor(field))); } + marshall.add(EMPTY); + if (marshallableMessage()) marshall.add(indentedLine("msg.prepareMarshal(marshaller);")); From 315632358b9163320880a0cfa381a414d8cf911d Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 20 May 2026 19:18:08 +0300 Subject: [PATCH 038/215] WIP --- .../apache/ignite/internal/MessageSerializerGenerator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index f92806061511f..216274253fa5e 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -285,11 +285,12 @@ private void generateMarshallMethods(List orderedFields) throws marshall.addAll(marshall(field.asType(), fieldAccessor(field))); } - - marshall.add(EMPTY); - if (marshallableMessage()) + if (marshallableMessage()) { + marshall.add(EMPTY); + marshall.add(indentedLine("msg.prepareMarshal(marshaller);")); + } indent--; From 9a106936079f876c255ec229c1f8d395bf5574c6 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 20 May 2026 19:51:48 +0300 Subject: [PATCH 039/215] WIP --- .../internal/MessageSerializerGenerator.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 216274253fa5e..1189111951a71 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -47,6 +47,7 @@ import javax.lang.model.type.PrimitiveType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; +import javax.lang.model.type.TypeVariable; import javax.lang.model.util.Elements; import javax.tools.Diagnostic; import javax.tools.FileObject; @@ -335,7 +336,7 @@ private List marshall(TypeMirror t, String accessor) { return code; } } - else if (t.getKind() == TypeKind.DECLARED) { + else if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { if (isMessage(t)) { List code = new ArrayList<>(); @@ -384,11 +385,15 @@ else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { List valRes = marshall(valType, el); indent--; - if (!keyRes.isEmpty() && keyType.getKind() == TypeKind.DECLARED) { - imports.add(((QualifiedNameable)((DeclaredType)keyType).asElement()).getQualifiedName().toString()); + if (!keyRes.isEmpty() && (keyType.getKind() == TypeKind.DECLARED || keyType.getKind() == TypeKind.TYPEVAR)) { + Element elem = keyType.getKind() == TypeKind.DECLARED ? + ((DeclaredType)keyType).asElement() : + ((DeclaredType)((TypeVariable)keyType).getUpperBound()).asElement(); + + imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); imports.add("java.util.Collection"); - String type = ((DeclaredType)keyType).asElement().getSimpleName().toString(); + String type = elem.getSimpleName().toString(); code.add(indentedLine("for (%s %s : ((Collection)%s.keySet())) {", type, el, type, accessor)); @@ -401,11 +406,15 @@ else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { code.add(indentedLine("}")); } - if (!valRes.isEmpty() && valType.getKind() == TypeKind.DECLARED) { - imports.add(((QualifiedNameable)((DeclaredType)valType).asElement()).getQualifiedName().toString()); - imports.add("java.util.Collection"); + if (!valRes.isEmpty() && (valType.getKind() == TypeKind.DECLARED || valType.getKind() == TypeKind.TYPEVAR)) { + Element elem = valType.getKind() == TypeKind.DECLARED ? + ((DeclaredType)valType).asElement() : + ((DeclaredType)((TypeVariable)valType).getUpperBound()).asElement(); + + imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); + imports.add("java.util.Collection"); - String type = ((DeclaredType)valType).asElement().getSimpleName().toString(); + String type = elem.getSimpleName().toString(); code.add(indentedLine("for (%s %s : ((Collection)%s.values())) {", type, el, type, accessor)); From 25f391bad380797f2c5d18ad2b6af4c334ccd475 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 20 May 2026 19:56:48 +0300 Subject: [PATCH 040/215] WIP --- .../internal/MessageSerializerGenerator.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 1189111951a71..25414b1ae7263 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -386,9 +386,7 @@ else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { indent--; if (!keyRes.isEmpty() && (keyType.getKind() == TypeKind.DECLARED || keyType.getKind() == TypeKind.TYPEVAR)) { - Element elem = keyType.getKind() == TypeKind.DECLARED ? - ((DeclaredType)keyType).asElement() : - ((DeclaredType)((TypeVariable)keyType).getUpperBound()).asElement(); + Element elem = element(keyType); imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); imports.add("java.util.Collection"); @@ -407,9 +405,7 @@ else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { } if (!valRes.isEmpty() && (valType.getKind() == TypeKind.DECLARED || valType.getKind() == TypeKind.TYPEVAR)) { - Element elem = valType.getKind() == TypeKind.DECLARED ? - ((DeclaredType)valType).asElement() : - ((DeclaredType)((TypeVariable)valType).getUpperBound()).asElement(); + Element elem = element(valType); imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); imports.add("java.util.Collection"); @@ -441,10 +437,12 @@ else if (assignableFrom(erasedType(t), type(Collection.class.getName()))) { TypeMirror arg = args.get(0); - if (arg.getKind() == TypeKind.DECLARED) { + if ((arg.getKind() == TypeKind.DECLARED || arg.getKind() == TypeKind.TYPEVAR)) { List code = new ArrayList<>(); - imports.add(((QualifiedNameable)((DeclaredType)arg).asElement()).getQualifiedName().toString()); + Element elem = element(arg); + + imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); imports.add("java.util.Collection"); String el = "e" + indent; @@ -453,7 +451,7 @@ else if (assignableFrom(erasedType(t), type(Collection.class.getName()))) { indent++; - String type = ((DeclaredType)arg).asElement().getSimpleName().toString(); + String type = elem.getSimpleName().toString(); code.add(indentedLine("for (%s %s : (Collection)%s) {", type, el, type, accessor)); @@ -503,6 +501,13 @@ private String fieldAccessor(VariableElement field) { return "msg." + name; } + + /** */ + private Element element(TypeMirror type) { + return type.getKind() == TypeKind.DECLARED ? + ((DeclaredType)type).asElement() : + ((DeclaredType)((TypeVariable)type).getUpperBound()).asElement(); + } /** * Generates start of write/read methods: From 5eca804baa1f413be8379b6d0e14b04e9b4a0bf8 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 21 May 2026 19:18:37 +0300 Subject: [PATCH 041/215] WIP --- .../internal/MessageSerializerGenerator.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 25414b1ae7263..72961bca47b79 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -280,11 +280,15 @@ private void generateMarshallMethods(List orderedFields) throws else marshall.add(indentedLine("GridCacheContext ctx = nested;")); - for (VariableElement field: orderedFields) { - if (!marshall.get(marshall.size() - 1).equals(EMPTY)) - marshall.add(EMPTY); - - marshall.addAll(marshall(field.asType(), fieldAccessor(field))); + for (VariableElement field : orderedFields) { + List marshalled = marshall(field.asType(), fieldAccessor(field)); + + if (!marshalled.isEmpty()) { + if (!marshall.get(marshall.size() - 1).equals(EMPTY)) + marshall.add(EMPTY); + + marshall.addAll(marshalled); + } } if (marshallableMessage()) { From 1915b2d487f8df593f991aab1426f8c2eedb4b95 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 21 May 2026 19:42:46 +0300 Subject: [PATCH 042/215] WIP --- .../internal/processors/cache/CacheEntryPredicate.java | 6 ------ .../processors/cache/CacheEntryPredicateAdapter.java | 5 ----- 2 files changed, 11 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java index 36312a1591135..93e06fc27c73a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java @@ -25,12 +25,6 @@ * */ public interface CacheEntryPredicate extends IgnitePredicate, Message { - /** - * @param ctx Context. - * @throws IgniteCheckedException If failed. - */ - public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException; - /** * @param ctx Context. * @param ldr Class loader. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java index 69da0dbec23f3..b1017e9708ae8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java @@ -124,9 +124,4 @@ public CacheEntryPredicateType type() { if (type == CacheEntryPredicateType.VALUE) val.finishUnmarshal(ctx.cacheObjectContext(), ldr); } - - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException { - } - } From 7acf8c2b679f99906fcbfd96593d0801644af67b Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 21 May 2026 20:04:13 +0300 Subject: [PATCH 043/215] WIP --- .../cache/transactions/IgniteTxManager.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 56fbaabb4ca24..9a925d1a4a449 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -114,7 +114,6 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteOutClosure; import org.apache.ignite.lang.IgniteReducer; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.spi.systemview.view.TransactionView; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; @@ -2431,14 +2430,8 @@ void txLocksInfo(UUID nodeId, TxDeadlockFuture fut, Set txKeys) { TxLocksRequest req = new TxLocksRequest(fut.futureId(), txKeys); try { - if (!cctx.localNodeId().equals(nodeId)) { + if (!cctx.localNodeId().equals(nodeId)) req.prepareDeployment(cctx); - - MessageSerializer ser = cctx.gridIO().messageFactory().serializer(req.directType()); - - if (ser != null) - ser.prepareMarshal(req, cctx, null); - } cctx.gridIO().sendToGridTopic(node, TOPIC_TX, req, SYSTEM_POOL); } @@ -3367,15 +3360,9 @@ private class DeadlockDetectionListener implements GridMessageListener { res.futureId(req.futureId()); try { - if (!cctx.localNodeId().equals(nodeId)) { + if (!cctx.localNodeId().equals(nodeId)) res.prepareDeployment(cctx); - MessageSerializer ser = cctx.gridIO().messageFactory().serializer(res.directType()); - - if (ser != null) - ser.prepareMarshal(res, cctx, null); - } - cctx.gridIO().sendToGridTopic(nodeId, TOPIC_TX, res, SYSTEM_POOL); } catch (ClusterTopologyCheckedException e) { From 2b5417c0ed0b6602d6e7cda3fcbdec6953328044 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 21 May 2026 20:08:48 +0300 Subject: [PATCH 044/215] WIP --- .../internal/processors/cache/GridCacheIoManager.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index ffd40d04f5429..ef68949ff6bfe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -92,7 +92,6 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; @@ -1097,11 +1096,6 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I if (destNodeId == null || !cctx.localNodeId().equals(destNodeId)) { msg.prepareDeployment(cctx); - - MessageSerializer ser = cctx.gridIO().messageFactory().serializer(msg.directType()); - - if (ser != null) - ser.prepareMarshal(msg, cctx, null); if (msg instanceof GridCacheDeployable && msg.addDeploymentInfo()) cctx.deploy().prepare((GridCacheDeployable)msg); From 3b547e8ca9dfd2367055e5fad1ae29ac26880b47 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 21 May 2026 20:10:24 +0300 Subject: [PATCH 045/215] WIP --- .../dht/preloader/GridDhtPartitionsExchangeFuture.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java index ace55d5bdd2eb..0ccb732f850aa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java @@ -128,7 +128,6 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgniteRunnable; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.jetbrains.annotations.Nullable; import static java.util.Collections.emptySet; @@ -3868,11 +3867,6 @@ else if (forceAffReassignment) msg.prepareDeployment(cctx); - MessageSerializer ser = cctx.gridIO().messageFactory().serializer(msg.directType()); - - if (ser != null) - ser.prepareMarshal(msg, cctx, null); - timeBag.finishGlobalStage("Full message preparing"); synchronized (mux) { From 6da0195a2d01d6c2344ae8694bce35079730a29f Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 21 May 2026 20:12:11 +0300 Subject: [PATCH 046/215] WIP --- .../cache/query/continuous/CacheContinuousQueryHandler.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java index 061875f76bdb6..902b418f64fe3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java @@ -82,7 +82,6 @@ import org.apache.ignite.lang.IgniteAsyncCallback; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteClosure; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -929,11 +928,6 @@ protected CacheEntryEventFilter getEventFilter0() { */ private void prepareEntry(GridCacheContext cctx, UUID nodeId, CacheContinuousQueryEntry entry) throws IgniteCheckedException { - MessageSerializer ser = cctx.gridIO().messageFactory().serializer(entry.directType()); - - if (ser != null) - ser.prepareMarshal(entry, cctx.shared(), null); - if (cctx.kernalContext().config().isPeerClassLoadingEnabled() && cctx.discovery().node(nodeId) != null) cctx.deploy().prepare(entry); } From d2eea1f6ed0b25f3ec3147a914790f04056d6281 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 21 May 2026 20:13:39 +0300 Subject: [PATCH 047/215] WIP --- .../query/calcite/message/MessageServiceImpl.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java index 688bff49a6aba..4c8a699ca9c68 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java @@ -39,7 +39,6 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; /** * @@ -185,14 +184,8 @@ public FailureProcessor failureProcessor() { /** */ protected void prepareMarshal(Message msg) throws IgniteCheckedException { try { - if (msg instanceof CalciteContextMarshallableMessage) { + if (msg instanceof CalciteContextMarshallableMessage) ((CalciteContextMarshallableMessage)msg).prepareMarshal(ctx); - - MessageSerializer ser = ctx.gridIO().messageFactory().serializer(msg.directType()); - - if (ser != null) - ser.prepareMarshal(msg, ctx, null); - } } catch (Exception e) { failureProcessor().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); From e98f17df26b9f6af77e0ab8958da5ca8a4402717 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 22 May 2026 17:16:55 +0300 Subject: [PATCH 048/215] WIP --- .../ignite/internal/MessageSerializerGenerator.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 72961bca47b79..c7ee7380be297 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -280,6 +280,12 @@ private void generateMarshallMethods(List orderedFields) throws else marshall.add(indentedLine("GridCacheContext ctx = nested;")); + if (marshallableMessage()) { + marshall.add(EMPTY); + + marshall.add(indentedLine("msg.prepareMarshal(marshaller);")); + } + for (VariableElement field : orderedFields) { List marshalled = marshall(field.asType(), fieldAccessor(field)); @@ -290,12 +296,6 @@ private void generateMarshallMethods(List orderedFields) throws marshall.addAll(marshalled); } } - - if (marshallableMessage()) { - marshall.add(EMPTY); - - marshall.add(indentedLine("msg.prepareMarshal(marshaller);")); - } indent--; From 4a5f0c060b32ed7a0cc4de385abe20c2aa1901d8 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 22 May 2026 19:49:30 +0300 Subject: [PATCH 049/215] WIP --- .../zk/internal/DiscoveryMessageParser.java | 16 +++++++++++++++- .../zk/internal/ZookeeperDiscoveryImpl.java | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index d29a73f7039f4..8158f0d8e917a 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -25,12 +25,15 @@ import java.nio.ByteBuffer; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.direct.DirectMessageReader; import org.apache.ignite.internal.direct.DirectMessageWriter; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.spi.IgniteSpiException; +import org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi; import static org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.makeMessageType; @@ -45,8 +48,12 @@ public class DiscoveryMessageParser { private final MessageFactory msgFactory; /** */ - public DiscoveryMessageParser(MessageFactory msgFactory) { + private final ZookeeperDiscoverySpi spi; + + /** */ + public DiscoveryMessageParser(MessageFactory msgFactory, ZookeeperDiscoverySpi spi) { this.msgFactory = msgFactory; + this.spi = spi; } /** Marshals discovery message to bytes array. */ @@ -85,6 +92,13 @@ private void serializeMessage(Message m, OutputStream out) throws IOException { MessageSerializer msgSer = msgFactory.serializer(m.directType()); + try { + msgSer.prepareMarshal(m, ((IgniteEx)spi.ignite()).context().cache().context(), null); + } + catch (IgniteCheckedException e) { + throw new IgniteSpiException("Failed to marshal joining node data", e); + } + boolean finished; do { diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java index 0d0531d1a9a2c..96d29f66b9c15 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java @@ -270,7 +270,7 @@ public ZookeeperDiscoveryImpl( this.stats = stats; - msgParser = new DiscoveryMessageParser(msgFactory); + msgParser = new DiscoveryMessageParser(msgFactory, spi); } /** From 3c10d5aa0bd463e25c0073fc661e293e45408fa2 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 22 May 2026 20:08:40 +0300 Subject: [PATCH 050/215] WIP --- .../ignite/internal/managers/communication/GridIoManager.java | 3 +-- .../apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 034105e2054e9..8039a32911849 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1981,8 +1981,7 @@ private void send( MessageSerializer ser = ctx.io().messageFactory().serializer(ioMsg.directType()); - if (ser != null) - ser.prepareMarshal(ioMsg, ctx.cache().context(), null); + ser.prepareMarshal(ioMsg, ctx.cache().context(), null); if (locNodeId.equals(node.id())) { diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java index fc3ba41c21ece..b59ebfe30e364 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java @@ -242,8 +242,7 @@ public Socket socket() { void serializeMessage(Message m, OutputStream out) throws IOException, IgniteCheckedException { MessageSerializer msgSer = spi.messageFactory().serializer(m.directType()); - if (msgSer != null) - msgSer.prepareMarshal(m, ((IgniteEx)spi.ignite()).context().cache().context(), null); + msgSer.prepareMarshal(m, ((IgniteEx)spi.ignite()).context().cache().context(), null); msgWriter.reset(); msgWriter.setBuffer(msgBuf); From e5e8e67c692cb9467c5402472663293293a52d2c Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 22 May 2026 20:18:47 +0300 Subject: [PATCH 051/215] WIP --- .../ignite/internal/managers/communication/GridIoManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 8039a32911849..5332e948c6fd9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1930,6 +1930,10 @@ private IgniteInternalFuture openChannel( false ); + MessageSerializer ser = ctx.io().messageFactory().serializer(ioMsg.directType()); + + ser.prepareMarshal(ioMsg, ctx.cache().context(), null); + try { return ((TcpCommunicationSpi)(CommunicationSpi)getSpi()).openChannel(node, ioMsg); } From a6ecdbe95d79f12e2eb97433b09f3f2e37ce12ce Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 22 May 2026 22:33:21 +0300 Subject: [PATCH 052/215] WIP --- .../dht/preloader/GridDhtPartitionsFullMessage.java | 8 +++++++- .../snapshot/IncrementalSnapshotVerifyResult.java | 11 +++++++++-- .../service/ServiceSingleNodeDeploymentResult.java | 11 +++++++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index f8fc363a829dd..d2f183c739f12 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -393,7 +393,13 @@ public void rebalanced(boolean rebalanced) { if (!F.isEmpty(parts) && locParts == null) locParts = copyPartitionsMap(parts); - errMsgs = errs == null ? null : F.viewReadOnly(errs, ErrorMessage::new); + if (errs != null) { + errMsgs = new HashMap<>(); + + for (Map.Entry entry : errs.entrySet()) { + errMsgs.put(entry.getKey(), new ErrorMessage(entry.getValue())); + } + } } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotVerifyResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotVerifyResult.java index 641e123ffff69..b6614c8535c38 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotVerifyResult.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotVerifyResult.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.cache.persistence.snapshot; +import java.util.ArrayList; import java.util.Collection; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; @@ -24,7 +25,6 @@ import org.apache.ignite.internal.processors.cache.verify.PartitionHashRecord; import org.apache.ignite.internal.processors.cache.verify.TransactionsHashRecord; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; @@ -64,7 +64,14 @@ public IncrementalSnapshotVerifyResult() { this.txHashRes = txHashRes; this.partHashRes = partHashRes; this.partiallyCommittedTxs = partiallyCommittedTxs; - this.exceptions = exceptions == null ? null : F.viewReadOnly(exceptions, ErrorMessage::new); + + if (exceptions != null) { + this.exceptions = new ArrayList<>(); + + for (Throwable th : exceptions) { + this.exceptions.add(new ErrorMessage(th)); + } + } } /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceSingleNodeDeploymentResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceSingleNodeDeploymentResult.java index 10ceefb8284aa..cefe1ae00f9f6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceSingleNodeDeploymentResult.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceSingleNodeDeploymentResult.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.service; import java.io.Serializable; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import org.apache.ignite.internal.Order; @@ -76,8 +77,14 @@ public Collection errors() { * @param errors Exceptions. */ public void errors(@Nullable Collection errors) { - if (!F.isEmpty(errors)) - this.errors = F.viewReadOnly(errors, ErrorMessage::new); + if (errors == null) + return; + + this.errors = new ArrayList<>(); + + for (Throwable th : errors) { + this.errors.add(new ErrorMessage(th)); + } } /** {@inheritDoc} */ From aba6a868cd7438624bbf9f2388bcd6af3bfd9642 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sun, 24 May 2026 22:33:47 +0300 Subject: [PATCH 053/215] WIP --- .../DiscoveryUnmarshalVulnerabilityTest.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index 830e9aa27e4c5..46627c7ed013c 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -26,10 +26,13 @@ import java.net.Socket; import java.nio.ByteBuffer; import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.CoreMessagesProvider; import org.apache.ignite.internal.direct.DirectMessageWriter; import org.apache.ignite.internal.plugin.AbstractMarshallableMessageFactoryProvider; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshallers; @@ -48,6 +51,7 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_ENABLE_OBJECT_INPUT_FILTER_AUTOCONFIGURATION; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHALLER_BLACKLIST; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHALLER_WHITELIST; +import static org.apache.ignite.marshaller.Marshallers.jdk; import static org.apache.ignite.testframework.GridTestUtils.loadSerializer; /** @@ -60,6 +64,9 @@ public class DiscoveryUnmarshalVulnerabilityTest extends GridCommonAbstractTest /** */ private LogListener lsnr; + + /** */ + private MessageSerializer serializer; /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { @@ -82,10 +89,12 @@ public class DiscoveryUnmarshalVulnerabilityTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { MessageFactoryProvider msgFactoryProvider = new AbstractMarshallableMessageFactoryProvider() { @Override public void registerAll(MessageFactory factory) { + serializer = new MessageSerializerWrapper(this); + factory.register( CoreMessagesProvider.MAX_MESSAGE_ID + 1, ExploitMessage::new, - new MessageSerializerWrapper(this)); + serializer); } }; @@ -214,7 +223,7 @@ private void attack(byte[] data) throws IOException { } /** */ - private byte[] serializedMessage() { + private byte[] serializedMessage() throws IgniteCheckedException { ByteBuffer buf = ByteBuffer.allocate(4096); MessageFactory msgFactory = ((TcpDiscoverySpi)grid().configuration().getDiscoverySpi()).messageFactory(); @@ -222,7 +231,11 @@ private byte[] serializedMessage() { DirectMessageWriter writer = new DirectMessageWriter(msgFactory); writer.setBuffer(buf); - writer.writeMessage(new ExploitMessage(new Exploit())); + ExploitMessage msg = new ExploitMessage(new Exploit()); + + serializer.prepareMarshal(msg, grid().context().cache().context(), null); + + writer.writeMessage(msg); return buf.flip().compact().array(); } @@ -267,6 +280,12 @@ private MessageSerializerWrapper(AbstractMarshallableMessageFactoryProvider prov return serde.readFrom(msg, reader); } + /** {@inheritDoc} */ + @Override public void prepareMarshal(ExploitMessage msg, GridCacheSharedContext sctx, + GridCacheContext nested) throws IgniteCheckedException { + msg.prepareMarshal(jdk()); + } + /** */ private void initIfNecessary() { if (init.get() && init.compareAndSet(true, false)) From 09da2ceebc7e243af1621a1fdffe30f5f87ff934 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 25 May 2026 22:44:03 +0300 Subject: [PATCH 054/215] WIP --- .../IgniteCacheContinuousQueryImmutableEntryTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryImmutableEntryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryImmutableEntryTest.java index a41490c0e405f..285ddb2362bb2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryImmutableEntryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryImmutableEntryTest.java @@ -182,11 +182,11 @@ public void testCacheContinuousQueryEntrySerialization() { // Key and value shouldn't be serialized in case an event is filtered. assertNull(e1.key()); - assertNotNull(e0.key()); + assertNull(e0.key()); assertNull(e1.oldValue()); - assertNotNull(e0.oldValue()); + assertNull(e0.oldValue()); assertNull(e1.newValue()); - assertNotNull(e0.newValue()); + assertNull(e0.newValue()); } /** @@ -207,7 +207,7 @@ private static class CacheEventFilter implements CacheEntryEventFilter evt) { evts.add(evt); - return false; + return true; } } From aaafe762911bd51bc17884e73be7bbd05a549734 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 26 May 2026 22:33:47 +0300 Subject: [PATCH 055/215] WIP --- .../ignite/internal/MessageSerializerGenerator.java | 8 ++++---- .../internal/managers/communication/GridIoManager.java | 8 ++++---- .../extensions/communication/MessageSerializer.java | 6 +++--- .../ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java | 2 +- .../tcp/DiscoveryUnmarshalVulnerabilityTest.java | 6 +++--- .../spi/discovery/zk/internal/DiscoveryMessageParser.java | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index c7ee7380be297..7e0c1b5cbb52e 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -261,7 +261,7 @@ private void generateMethods(List fields) throws Exception { private void generateMarshallMethods(List orderedFields) throws Exception { imports.add("org.apache.ignite.IgniteCheckedException"); imports.add("org.apache.ignite.internal.processors.cache.CacheObjectValueContext"); - imports.add("org.apache.ignite.internal.processors.cache.GridCacheSharedContext"); + imports.add("org.apache.ignite.internal.GridKernalContext"); imports.add("org.apache.ignite.internal.processors.cache.GridCacheContext"); indent = 1; @@ -270,13 +270,13 @@ private void generateMarshallMethods(List orderedFields) throws marshall.add(indentedLine( "@Override public void prepareMarshal(" + simpleNameWithGeneric(type) + - " msg, GridCacheSharedContext sctx, GridCacheContext nested) throws IgniteCheckedException {")); + " msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException {")); indent++; if (isCacheIdAwareMessage(type)) marshall.add( - indentedLine("GridCacheContext ctx = nested == null ? sctx.cacheContext(msg.cacheId()) : nested;")); + indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.cacheId()) : nested;")); else marshall.add(indentedLine("GridCacheContext ctx = nested;")); @@ -349,7 +349,7 @@ else if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { indent++; code.add(indentedLine( - "sctx.gridIO().messageFactory().serializer(%s.directType()).prepareMarshal(%s, sctx, ctx);", + "kctx.messageFactory().serializer(%s.directType()).prepareMarshal(%s, kctx, ctx);", accessor, accessor)); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 5332e948c6fd9..2b8c027f15d82 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1930,9 +1930,9 @@ private IgniteInternalFuture openChannel( false ); - MessageSerializer ser = ctx.io().messageFactory().serializer(ioMsg.directType()); + MessageSerializer ser = ctx.messageFactory().serializer(ioMsg.directType()); - ser.prepareMarshal(ioMsg, ctx.cache().context(), null); + ser.prepareMarshal(ioMsg, ctx, null); try { return ((TcpCommunicationSpi)(CommunicationSpi)getSpi()).openChannel(node, ioMsg); @@ -1983,9 +1983,9 @@ private void send( GridIoMessage ioMsg = createGridIoMessage(topic, msg, plc, ordered, timeout, skipOnTimeout); - MessageSerializer ser = ctx.io().messageFactory().serializer(ioMsg.directType()); + MessageSerializer ser = ctx.messageFactory().serializer(ioMsg.directType()); - ser.prepareMarshal(ioMsg, ctx.cache().context(), null); + ser.prepareMarshal(ioMsg, ctx, null); if (locNodeId.equals(node.id())) { diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index 069edccd6d4d2..6e597ae9121d6 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -18,8 +18,8 @@ package org.apache.ignite.plugin.extensions.communication; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; /** Message serialization logic. */ public interface MessageSerializer { @@ -47,11 +47,11 @@ public interface MessageSerializer { * non-null when invoking this method; resolution-with-null-skip happens at call sites. * * @param msg Message instance. - * @param sctx Shared context. + * @param ctx Kernal context. * @param nested Nested context. * @throws IgniteCheckedException If marshalling fails. */ - public default void prepareMarshal(M msg, GridCacheSharedContext sctx, GridCacheContext nested) + public default void prepareMarshal(M msg, GridKernalContext ctx, GridCacheContext nested) throws IgniteCheckedException { // No-op by default. } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java index b59ebfe30e364..15e99228b5194 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java @@ -242,7 +242,7 @@ public Socket socket() { void serializeMessage(Message m, OutputStream out) throws IOException, IgniteCheckedException { MessageSerializer msgSer = spi.messageFactory().serializer(m.directType()); - msgSer.prepareMarshal(m, ((IgniteEx)spi.ignite()).context().cache().context(), null); + msgSer.prepareMarshal(m, ((IgniteEx)spi.ignite()).context(), null); msgWriter.reset(); msgWriter.setBuffer(msgBuf); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index 46627c7ed013c..9cf44281893f3 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -29,10 +29,10 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.CoreMessagesProvider; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.direct.DirectMessageWriter; import org.apache.ignite.internal.plugin.AbstractMarshallableMessageFactoryProvider; import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshallers; @@ -233,7 +233,7 @@ private byte[] serializedMessage() throws IgniteCheckedException { ExploitMessage msg = new ExploitMessage(new Exploit()); - serializer.prepareMarshal(msg, grid().context().cache().context(), null); + serializer.prepareMarshal(msg, grid().context(), null); writer.writeMessage(msg); @@ -281,7 +281,7 @@ private MessageSerializerWrapper(AbstractMarshallableMessageFactoryProvider prov } /** {@inheritDoc} */ - @Override public void prepareMarshal(ExploitMessage msg, GridCacheSharedContext sctx, + @Override public void prepareMarshal(ExploitMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { msg.prepareMarshal(jdk()); } diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index 8158f0d8e917a..efba2098bddb9 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -93,7 +93,7 @@ private void serializeMessage(Message m, OutputStream out) throws IOException { MessageSerializer msgSer = msgFactory.serializer(m.directType()); try { - msgSer.prepareMarshal(m, ((IgniteEx)spi.ignite()).context().cache().context(), null); + msgSer.prepareMarshal(m, ((IgniteEx)spi.ignite()).context(), null); } catch (IgniteCheckedException e) { throw new IgniteSpiException("Failed to marshal joining node data", e); From d60a650b151ab8efb7b5a1bb4c0c3a67f11b23cc Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 26 May 2026 23:41:14 +0300 Subject: [PATCH 056/215] WIP --- .../snapshot/IncrementalSnapshotTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java index 6224135de075f..1028299f7bf91 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java @@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.UnaryOperator; import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cluster.ClusterState; @@ -51,6 +52,7 @@ import static org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.RESTORE_CACHE_GROUP_SNAPSHOT_PREPARE; import static org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.RESTORE_CACHE_GROUP_SNAPSHOT_START; import static org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.RESTORE_INCREMENTAL_SNAPSHOT_START; +import static org.apache.ignite.marshaller.Marshallers.jdk; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause; import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; @@ -426,8 +428,18 @@ public void testStagesFail() throws Exception { DistributedProcess.DistributedProcessType stage = failStage.get(); - if (stage != null && stage.ordinal() == singleMsg.type()) - GridTestUtils.setFieldValue(singleMsg, "errMsg", new ErrorMessage(new IgniteException("Test exception."))); + if (stage != null && stage.ordinal() == singleMsg.type()) { + ErrorMessage em = new ErrorMessage(new IgniteException("Test exception.")); + + try { + em.prepareMarshal(jdk()); + } + catch (IgniteCheckedException e) { + throw new RuntimeException(e); + } + + GridTestUtils.setFieldValue(singleMsg, "errMsg", em); + } } return false; From e2c4570f2f6e1bd56bdf9dc34860a0e6d6afc422 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 26 May 2026 23:43:29 +0300 Subject: [PATCH 057/215] Revert "WIP" This reverts commit d60a650b151ab8efb7b5a1bb4c0c3a67f11b23cc. --- .../snapshot/IncrementalSnapshotTest.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java index 1028299f7bf91..6224135de075f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java @@ -23,7 +23,6 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.UnaryOperator; import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cluster.ClusterState; @@ -52,7 +51,6 @@ import static org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.RESTORE_CACHE_GROUP_SNAPSHOT_PREPARE; import static org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.RESTORE_CACHE_GROUP_SNAPSHOT_START; import static org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.RESTORE_INCREMENTAL_SNAPSHOT_START; -import static org.apache.ignite.marshaller.Marshallers.jdk; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause; import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; @@ -428,18 +426,8 @@ public void testStagesFail() throws Exception { DistributedProcess.DistributedProcessType stage = failStage.get(); - if (stage != null && stage.ordinal() == singleMsg.type()) { - ErrorMessage em = new ErrorMessage(new IgniteException("Test exception.")); - - try { - em.prepareMarshal(jdk()); - } - catch (IgniteCheckedException e) { - throw new RuntimeException(e); - } - - GridTestUtils.setFieldValue(singleMsg, "errMsg", em); - } + if (stage != null && stage.ordinal() == singleMsg.type()) + GridTestUtils.setFieldValue(singleMsg, "errMsg", new ErrorMessage(new IgniteException("Test exception."))); } return false; From b8df11594dfdd4266a4ba286caf834854d32793e Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 26 May 2026 23:41:14 +0300 Subject: [PATCH 058/215] WIP --- .../snapshot/IncrementalSnapshotTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java index 6224135de075f..1028299f7bf91 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java @@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.UnaryOperator; import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cluster.ClusterState; @@ -51,6 +52,7 @@ import static org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.RESTORE_CACHE_GROUP_SNAPSHOT_PREPARE; import static org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.RESTORE_CACHE_GROUP_SNAPSHOT_START; import static org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.RESTORE_INCREMENTAL_SNAPSHOT_START; +import static org.apache.ignite.marshaller.Marshallers.jdk; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause; import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; @@ -426,8 +428,18 @@ public void testStagesFail() throws Exception { DistributedProcess.DistributedProcessType stage = failStage.get(); - if (stage != null && stage.ordinal() == singleMsg.type()) - GridTestUtils.setFieldValue(singleMsg, "errMsg", new ErrorMessage(new IgniteException("Test exception."))); + if (stage != null && stage.ordinal() == singleMsg.type()) { + ErrorMessage em = new ErrorMessage(new IgniteException("Test exception.")); + + try { + em.prepareMarshal(jdk()); + } + catch (IgniteCheckedException e) { + throw new RuntimeException(e); + } + + GridTestUtils.setFieldValue(singleMsg, "errMsg", em); + } } return false; From 5cff2da10e5c51ed8c7c0f0f24a5480d07f32885 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 27 May 2026 18:04:50 +0300 Subject: [PATCH 059/215] WIP --- .../datastreamer/DataStreamerImplSelfTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java index 625f290d1c6fc..ddb5a7f0cc985 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java @@ -32,6 +32,7 @@ import javax.cache.CacheException; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; @@ -51,6 +52,7 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.stream.StreamReceiver; import org.apache.ignite.testframework.GridTestUtils; @@ -713,6 +715,15 @@ private static class StaleTopologyCommunicationSpi extends TcpCommunicationSpi { ioMsg.skipOnTimeout() ); + MessageSerializer msgSer = ((IgniteEx)ignite).context().messageFactory().serializer(msg.directType()); + + try { + msgSer.prepareMarshal(msg, ((IgniteEx)ignite).context(), null); + } + catch (IgniteCheckedException e) { + throw new RuntimeException(e); + } + needStaleTop = false; } } From 78c19b6ba41193ee731b3c1c23534e6956969644 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 27 May 2026 20:02:45 +0300 Subject: [PATCH 060/215] WIP --- .../IgniteExceptionInNioWorkerSelfTest.java | 49 +++++++++++++++++-- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java index bceb60e4f6375..81741222dd802 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java @@ -18,11 +18,19 @@ package org.apache.ignite.internal.util.nio; import java.util.UUID; +import org.apache.ignite.IgniteException; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.GridTopic; import org.apache.ignite.internal.IgniteDiagnosticRequest; import org.apache.ignite.internal.IgniteKernal; +import org.apache.ignite.plugin.AbstractTestPluginProvider; +import org.apache.ignite.plugin.ExtensionRegistry; +import org.apache.ignite.plugin.PluginContext; +import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; +import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageWriter; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Test; @@ -43,6 +51,8 @@ public class IgniteExceptionInNioWorkerSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(ccfg); + cfg.setPluginProviders(new BrokenMessageProvider()); + return cfg; } @@ -73,19 +83,48 @@ public void testBrokenMessage() throws Exception { * */ private static class BrokenMessage extends IgniteDiagnosticRequest { + // No-op. + } + + /** */ + private static class BrokenMessageSerializer implements MessageSerializer { /** */ private boolean fail = true; - /** {@inheritDoc} */ - @Override public short directType() { + @Override public boolean writeTo(BrokenMessage msg, MessageWriter writer) { + if (!writer.isHeaderWritten()) { + if (!writer.writeHeader(msg.directType())) + return false; + + writer.onHeaderWritten(); + } + if (fail) { fail = false; - return (byte)242; + throw new IgniteException("Broken message"); } - // IgniteDiagnosticRequest as an example. - return 13003; + return true; + } + + @Override public boolean readFrom(BrokenMessage msg, MessageReader reader) { + return true; + } + } + + /** */ + public static class BrokenMessageProvider extends AbstractTestPluginProvider { + /** {@inheritDoc} */ + @Override public String name() { + return getClass().getName(); + } + + /** {@inheritDoc} */ + @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) { + registry.registerExtension(MessageFactoryProvider.class, (factory) -> + factory.register(-42, BrokenMessage::new, new BrokenMessageSerializer()) + ); } } } From ebe56fafa6ad64a38da79c1dcdd22af7cb4b97a0 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 28 May 2026 13:52:50 +0300 Subject: [PATCH 061/215] WIP --- .../internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java index 81741222dd802..0f46c4715f857 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java @@ -91,6 +91,7 @@ private static class BrokenMessageSerializer implements MessageSerializer Date: Thu, 28 May 2026 16:20:33 +0300 Subject: [PATCH 062/215] WIP --- .../internal/MessageSerializerGenerator.java | 130 +++++++++++------- ...actMarshallableMessageFactoryProvider.java | 2 +- .../communication/MessageSerializer.java | 21 ++- .../tcp/internal/GridNioServerWrapper.java | 2 +- .../direct/DirectMarshallingMessagesTest.java | 2 +- .../GridCommunicationSendMessageSelfTest.java | 5 +- .../IgniteMessageFactoryImplTest.java | 9 +- .../MessageDirectTypeIdConflictTest.java | 4 +- ...ommunicationSpiSslVolatilePayloadTest.java | 3 +- .../GridCacheMessageSelfTest.java | 11 +- .../spi/communication/GridTestMessage.java | 3 +- ...DiscoveryDeserializationExceptionTest.java | 3 +- .../msg/GridH2ValueMessageFactory.java | 57 ++++---- .../zk/internal/ZkMessageFactory.java | 11 +- 14 files changed, 157 insertions(+), 106 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index d71d9d3e676e8..975cc1e630430 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -171,10 +171,10 @@ void generate(TypeElement type, List fields) throws Exception { /** Generates full code for a serializer class. */ private String generateSerializerCode(String serClsName) throws IOException { - if (marshallableMessage()) { + if (marshallableMessage()) fields.add("private final Marshaller marshaller;"); - fields.add("private final ClassLoader clsLdr;"); - } + + fields.add("private final ClassLoader clsLdr;"); try (Writer writer = new StringWriter()) { writeClassHeader(writer, env.getElementUtils().getPackageOf(type).toString(), serClsName); @@ -210,21 +210,25 @@ private String generateSerializerCode(String serClsName) throws IOException { /** */ private void writeConstructor(Writer writer, String serClsName) throws IOException { - if (!marshallableMessage()) - return; - ++indent; writer.write(indentedLine(METHOD_JAVADOC)); writer.write(NL); - writer.write(indentedLine("public " + serClsName + "(Marshaller marshaller, ClassLoader clsLdr) {")); + + if (marshallableMessage()) + writer.write(indentedLine("public " + serClsName + "(Marshaller marshaller, ClassLoader clsLdr) {")); + else + writer.write(indentedLine("public " + serClsName + "(ClassLoader clsLdr) {")); writer.write(NL); ++indent; - writer.write(indentedLine("this.marshaller = marshaller;")); - writer.write(NL); + if (marshallableMessage()) { + writer.write(indentedLine("this.marshaller = marshaller;")); + writer.write(NL); + } + writer.write(indentedLine("this.clsLdr = clsLdr;")); --indent; @@ -251,14 +255,15 @@ private void generateMethods(List fields) throws Exception { indent--; - finish(write, false, false); - finish(read, true, marshallableMessage()); + finish(write); + finish(read); generateMarshallMethods(fields); + generateUnmarshallMethods(fields); } /** */ - private void generateMarshallMethods(List orderedFields) throws Exception { + private void generateMarshallMethods(List orderedFields){ imports.add("org.apache.ignite.IgniteCheckedException"); imports.add("org.apache.ignite.internal.processors.cache.CacheObjectValueContext"); imports.add("org.apache.ignite.internal.GridKernalContext"); @@ -287,7 +292,7 @@ private void generateMarshallMethods(List orderedFields) throws } for (VariableElement field : orderedFields) { - List marshalled = marshall(field.asType(), fieldAccessor(field)); + List marshalled = marshall(field.asType(), fieldAccessor(field), false); if (!marshalled.isEmpty()) { if (!marshall.get(marshall.size() - 1).equals(EMPTY)) @@ -303,7 +308,49 @@ private void generateMarshallMethods(List orderedFields) throws } /** */ - private List marshall(TypeMirror t, String accessor) { + private void generateUnmarshallMethods(List orderedFields){ + marshall.add(EMPTY); + + indent = 1; + + marshall.add(indentedLine(METHOD_JAVADOC)); + + marshall.add(indentedLine( + "@Override public void finishUnmarshal(" + simpleNameWithGeneric(type) + + " msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException {")); + + indent++; + + if (isCacheIdAwareMessage(type)) + marshall.add( + indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.cacheId()) : nested;")); + else + marshall.add(indentedLine("GridCacheContext ctx = nested;")); + + for (VariableElement field : orderedFields) { + List unmarshalled = marshall(field.asType(), fieldAccessor(field), true); + + if (!unmarshalled.isEmpty()) { + if (!marshall.get(marshall.size() - 1).equals(EMPTY)) + marshall.add(EMPTY); + + marshall.addAll(unmarshalled); + } + } + + if (marshallableMessage()) { + marshall.add(EMPTY); + + marshall.add(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);")); + } + + indent--; + + marshall.add(indentedLine("}")); + } + + /** */ + private List marshall(TypeMirror t, String accessor, boolean unmarshall) { if (t.getKind() == TypeKind.ARRAY) { TypeMirror comp = ((ArrayType)t).getComponentType(); @@ -322,7 +369,7 @@ private List marshall(TypeMirror t, String accessor) { indent++; - List res = marshall(comp, el); + List res = marshall(comp, el, unmarshall); code.addAll(res); @@ -348,10 +395,16 @@ else if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { indent++; - code.add(indentedLine( - "kctx.messageFactory().serializer(%s.directType()).prepareMarshal(%s, kctx, ctx);", - accessor, - accessor)); + if (!unmarshall) + code.add(indentedLine( + "kctx.messageFactory().serializer(%s.directType()).prepareMarshal(%s, kctx, ctx);", + accessor, + accessor)); + else + code.add(indentedLine( + "kctx.messageFactory().serializer(%s.directType()).finishUnmarshal(%s, kctx, ctx);", + accessor, + accessor)); indent--; @@ -364,7 +417,10 @@ else if (isCacheObject(t)) { indent++; - code.add(indentedLine("%s.prepareMarshal(ctx != null ? ctx.cacheObjectContext() : null);", accessor)); + if (!unmarshall) + code.add(indentedLine("%s.prepareMarshal(ctx != null ? ctx.cacheObjectContext() : null);", accessor)); + else + code.add(indentedLine("%s.finishUnmarshal(ctx != null ? ctx.cacheObjectContext() : null, clsLdr);", accessor)); indent--; @@ -385,8 +441,8 @@ else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { String el = "e" + indent; indent++; // Emulating subsequent indent. - List keyRes = marshall(keyType, el); - List valRes = marshall(valType, el); + List keyRes = marshall(keyType, el, unmarshall); + List valRes = marshall(valType, el, unmarshall); indent--; if (!keyRes.isEmpty() && (keyType.getKind() == TypeKind.DECLARED || keyType.getKind() == TypeKind.TYPEVAR)) { @@ -461,7 +517,7 @@ else if (assignableFrom(erasedType(t), type(Collection.class.getName()))) { indent++; - List res = marshall(arg, el); + List res = marshall(arg, el, unmarshall); code.addAll(res); @@ -1180,7 +1236,7 @@ private void returnFalseIfEnumReadFailed(VariableElement field, String mapperDec } /** */ - private void finish(List code, boolean read, boolean marshallable) { + private void finish(List code) { String lastLine = code.get(code.size() - 1); if (EMPTY.equals(lastLine)) @@ -1189,32 +1245,6 @@ private void finish(List code, boolean read, boolean marshallable) { code.add(indentedLine("}")); code.add(EMPTY); - if (read && marshallable) { - imports.add("org.apache.ignite.IgniteCheckedException"); - imports.add("org.apache.ignite.IgniteException"); - - code.add(indentedLine("try {")); - - indent++; - - code.add(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);")); - - indent--; - - code.add(indentedLine("}")); - code.add(indentedLine("catch (IgniteCheckedException e) {")); - - indent++; - - code.add(indentedLine("throw new IgniteException(\"Failed to unmarshal object \" + msg.getClass().getSimpleName(), e);")); - - indent--; - - code.add(indentedLine("}")); - - code.add(EMPTY); - } - code.add(indentedLine("return true;")); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java index 5ac1f2472997f..39e3dffedc3e3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java @@ -73,7 +73,7 @@ protected static void register(MessageFactory factory, Class serializer = marshallable ? (MessageSerializer)serCls.getConstructor(Marshaller.class, ClassLoader.class).newInstance(marsh, clsLrd) - : (MessageSerializer)serCls.getConstructor().newInstance(); + : (MessageSerializer)serCls.getConstructor(ClassLoader.class).newInstance(clsLrd); } catch (Exception e) { throw new IgniteException("Failed to register message of type " + cls.getSimpleName(), e); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index 6e597ae9121d6..47202e3b13b25 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -42,17 +42,26 @@ public interface MessageSerializer { public boolean readFrom(M msg, MessageReader reader); /** - * Runs {@code CacheObject.prepareMarshal} for {@code @Order} cache-object fields on the user thread, so the NIO - * worker never does it. Default is a no-op. The caller is responsible for guaranteeing that {@code ctx} is - * non-null when invoking this method; resolution-with-null-skip happens at call sites. + * Marshalls cache-object fields on the user thread. * * @param msg Message instance. - * @param ctx Kernal context. + * @param kctx Kernal context. * @param nested Nested context. * @throws IgniteCheckedException If marshalling fails. */ - public default void prepareMarshal(M msg, GridKernalContext ctx, GridCacheContext nested) - throws IgniteCheckedException { + public default void prepareMarshal(M msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + // No-op by default. + } + + /** + * Unmarshalls cache-object fields on the user thread. + * + * @param msg Message instance. + * @param kctx Kernal context. + * @param nested Nested context. + * @throws IgniteCheckedException If unmarshalling fails. + */ + public default void finishUnmarshal(M msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { // No-op by default. } } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java index df7935c6c2f41..beba50cc4695f 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java @@ -826,7 +826,7 @@ public GridNioServer resetNioServer() throws IgniteCheckedException { @Override public MessageSerializer serializer(short type) { // Enable sending wait message for a communication peer while context isn't initialized. if (impl == null && type == CoreMessagesProvider.HANDSHAKE_WAIT_MSG_TYPE) - return new HandshakeWaitMessageSerializer(); + return new HandshakeWaitMessageSerializer(U.gridClassLoader()); return get().serializer(type); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/direct/DirectMarshallingMessagesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/direct/DirectMarshallingMessagesTest.java index ea37b6abe4545..77cf4814eaea8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/direct/DirectMarshallingMessagesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/direct/DirectMarshallingMessagesTest.java @@ -50,7 +50,7 @@ public class DirectMarshallingMessagesTest extends GridCommonAbstractTest { factory -> factory.register( TestNestedContainersMessage.TYPE, TestNestedContainersMessage::new, - new TestNestedContainersMessageSerializer() + new TestNestedContainersMessageSerializer(U.gridClassLoader()) ) }); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java index 90d9027ad7b67..4a65f5c912d04 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java @@ -20,6 +20,7 @@ import java.util.UUID; import java.util.concurrent.CountDownLatch; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.AbstractTestPluginProvider; import org.apache.ignite.plugin.ExtensionRegistry; import org.apache.ignite.plugin.PluginContext; @@ -151,8 +152,8 @@ public static class TestPluginProvider extends AbstractTestPluginProvider { @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) { registry.registerExtension(MessageFactoryProvider.class, new MessageFactoryProvider() { @Override public void registerAll(MessageFactory factory) { - factory.register(DIRECT_TYPE, TestValidByteIdMessage::new, new TestValidByteIdMessageSerializer()); - factory.register(DIRECT_TYPE_OVER_BYTE, TestOverByteIdMessage::new, new TestOverByteIdMessageSerializer()); + factory.register(DIRECT_TYPE, TestValidByteIdMessage::new, new TestValidByteIdMessageSerializer(U.gridClassLoader())); + factory.register(DIRECT_TYPE_OVER_BYTE, TestOverByteIdMessage::new, new TestOverByteIdMessageSerializer(U.gridClassLoader())); } }); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImplTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImplTest.java index 838474c82c7d1..b89beeec8b82c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImplTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImplTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.internal.CoreMessagesProvider; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; @@ -107,8 +108,8 @@ public void testRegisterTheSameType() { private static class TestMessageFactoryPovider implements MessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - factory.register(TEST_MSG_1_TYPE, TestMessage1::new, new TestMessage1Serializer()); - factory.register(TEST_MSG_42_TYPE, TestMessage42::new, new TestMessage42Serializer()); + factory.register(TEST_MSG_1_TYPE, TestMessage1::new, new TestMessage1Serializer(U.gridClassLoader())); + factory.register(TEST_MSG_42_TYPE, TestMessage42::new, new TestMessage42Serializer(U.gridClassLoader())); } } @@ -118,7 +119,7 @@ private static class TestMessageFactoryPovider implements MessageFactoryProvider private static class TestMessageFactoryPoviderWithTheSameDirectType implements MessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - factory.register(TEST_MSG_1_TYPE, TestMessage1::new, new TestMessage1Serializer()); + factory.register(TEST_MSG_1_TYPE, TestMessage1::new, new TestMessage1Serializer(U.gridClassLoader())); } } @@ -128,7 +129,7 @@ private static class TestMessageFactoryPoviderWithTheSameDirectType implements M private static class TestMessageFactory implements MessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - factory.register(TEST_MSG_2_TYPE, TestMessage2::new, new TestMessage2Serializer()); + factory.register(TEST_MSG_2_TYPE, TestMessage2::new, new TestMessage2Serializer(U.gridClassLoader())); } } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java index f540a08293d02..744f5dc2e9a5a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java @@ -20,6 +20,7 @@ import java.util.concurrent.Callable; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.AbstractTestPluginProvider; import org.apache.ignite.plugin.ExtensionRegistry; import org.apache.ignite.plugin.PluginContext; @@ -81,7 +82,8 @@ public static class TestPluginProvider extends AbstractTestPluginProvider { @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) { registry.registerExtension(MessageFactoryProvider.class, new MessageFactoryProvider() { @Override public void registerAll(MessageFactory factory) { - factory.register(DIRECT_TYPE, DuplicateDirectTypeIdMessage::new, new DuplicateDirectTypeIdMessageSerializer()); + factory.register(DIRECT_TYPE, + DuplicateDirectTypeIdMessage::new, new DuplicateDirectTypeIdMessageSerializer(U.gridClassLoader())); } }); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/TcpCommunicationSpiSslVolatilePayloadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/TcpCommunicationSpiSslVolatilePayloadTest.java index 9be2ee3156092..e0259a5ee4040 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/TcpCommunicationSpiSslVolatilePayloadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/TcpCommunicationSpiSslVolatilePayloadTest.java @@ -96,7 +96,8 @@ public class TcpCommunicationSpiSslVolatilePayloadTest extends GridAbstractCommu /** {@inheritDoc} */ @Override protected MessageFactoryProvider customMessageFactory() { return f -> f.register( - TestVolatilePayloadMessage.DIRECT_TYPE, TestVolatilePayloadMessage::new, new TestVolatilePayloadMessageSerializer() + TestVolatilePayloadMessage.DIRECT_TYPE, + TestVolatilePayloadMessage::new, new TestVolatilePayloadMessageSerializer(U.gridClassLoader()) ); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java index 5357052713835..ecb8a67eb653e 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java @@ -34,6 +34,7 @@ import org.apache.ignite.internal.managers.communication.GridMessageListener; import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.util.typedef.CI2; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.AbstractTestPluginProvider; import org.apache.ignite.plugin.ExtensionRegistry; import org.apache.ignite.plugin.PluginContext; @@ -231,11 +232,11 @@ public static class TestPluginProvider extends AbstractTestPluginProvider { /** {@inheritDoc} */ @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) { registry.registerExtension(MessageFactoryProvider.class, factory -> { - factory.register(TestMessage.DIRECT_TYPE, TestMessage::new, new TestMessageSerializer()); - factory.register(GridTestMessage.DIRECT_TYPE, GridTestMessage::new, new GridTestMessageSerializer()); - factory.register(TestMessage1.DIRECT_TYPE, TestMessage1::new, new TestMessage1Serializer()); - factory.register(TestMessage2.DIRECT_TYPE, TestMessage2::new, new TestMessage2Serializer()); - factory.register(TestBadMessage.DIRECT_TYPE, TestBadMessage::new, new TestBadMessageSerializer()); + factory.register(TestMessage.DIRECT_TYPE, TestMessage::new, new TestMessageSerializer(U.gridClassLoader())); + factory.register(GridTestMessage.DIRECT_TYPE, GridTestMessage::new, new GridTestMessageSerializer(U.gridClassLoader())); + factory.register(TestMessage1.DIRECT_TYPE, TestMessage1::new, new TestMessage1Serializer(U.gridClassLoader())); + factory.register(TestMessage2.DIRECT_TYPE, TestMessage2::new, new TestMessage2Serializer(U.gridClassLoader())); + factory.register(TestBadMessage.DIRECT_TYPE, TestBadMessage::new, new TestBadMessageSerializer(U.gridClassLoader())); }); } } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java index 83a6ea91775b7..21c115a4e019d 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java @@ -20,6 +20,7 @@ import java.util.Objects; import java.util.UUID; import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; @@ -32,7 +33,7 @@ public class GridTestMessage implements Message { /** */ public static final MessageFactoryProvider GRID_TEST_MESSAGE_FACTORY = f -> f.register( - GridTestMessage.DIRECT_TYPE, GridTestMessage::new, new GridTestMessageSerializer()); + GridTestMessage.DIRECT_TYPE, GridTestMessage::new, new GridTestMessageSerializer(U.gridClassLoader())); /** */ @Order(0) diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryDeserializationExceptionTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryDeserializationExceptionTest.java index cfe047d58e75d..10aeab8dab0d4 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryDeserializationExceptionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryDeserializationExceptionTest.java @@ -25,6 +25,7 @@ import org.apache.ignite.failure.FailureContext; import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.AbstractTestPluginProvider; import org.apache.ignite.plugin.ExtensionRegistry; import org.apache.ignite.plugin.PluginContext; @@ -138,7 +139,7 @@ public static class NotRegisteredMessageProvider extends AbstractTestPluginProvi /** {@inheritDoc} */ @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) { registry.registerExtension(MessageFactoryProvider.class, (factory) -> - factory.register(MSG_DIRECT_TYPE, NotRegisteredMessage::new, new NotRegisteredMessageSerializer()) + factory.register(MSG_DIRECT_TYPE, NotRegisteredMessage::new, new NotRegisteredMessageSerializer(U.gridClassLoader())) ); } } diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java index b26089afd70fe..c22e32703714f 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java @@ -26,6 +26,7 @@ import org.apache.ignite.internal.processors.query.h2.QueryTable; import org.apache.ignite.internal.processors.query.h2.QueryTableSerializer; import org.apache.ignite.internal.processors.query.h2.opt.GridH2ValueCacheObject; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; @@ -37,34 +38,34 @@ public class GridH2ValueMessageFactory implements MessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - factory.register(-4, () -> GridH2Null.INSTANCE, new GridH2NullSerializer()); - factory.register(-5, GridH2Boolean::new, new GridH2BooleanSerializer()); - factory.register(-6, GridH2Byte::new, new GridH2ByteSerializer()); - factory.register(-7, GridH2Short::new, new GridH2ShortSerializer()); - factory.register(-8, GridH2Integer::new, new GridH2IntegerSerializer()); - factory.register(-9, GridH2Long::new, new GridH2LongSerializer()); - factory.register(-10, GridH2Decimal::new, new GridH2DecimalSerializer()); - factory.register(-11, GridH2Double::new, new GridH2DoubleSerializer()); - factory.register(-12, GridH2Float::new, new GridH2FloatSerializer()); - factory.register(-13, GridH2Time::new, new GridH2TimeSerializer()); - factory.register(-14, GridH2Date::new, new GridH2DateSerializer()); - factory.register(-15, GridH2Timestamp::new, new GridH2TimestampSerializer()); - factory.register(-16, GridH2Bytes::new, new GridH2BytesSerializer()); - factory.register(-17, GridH2String::new, new GridH2StringSerializer()); - factory.register(-18, GridH2Array::new, new GridH2ArraySerializer()); - factory.register(-19, GridH2JavaObject::new, new GridH2JavaObjectSerializer()); - factory.register(-20, GridH2Uuid::new, new GridH2UuidSerializer()); - factory.register(-21, GridH2Geometry::new, new GridH2GeometrySerializer()); - factory.register(-22, GridH2CacheObject::new, new GridH2CacheObjectSerializer()); - factory.register(-30, GridH2IndexRangeRequest::new, new GridH2IndexRangeRequestSerializer()); - factory.register(-31, GridH2IndexRangeResponse::new, new GridH2IndexRangeResponseSerializer()); - factory.register(-32, GridH2RowMessage::new, new GridH2RowMessageSerializer()); - factory.register(-33, GridH2QueryRequest::new, new GridH2QueryRequestSerializer()); - factory.register(-34, GridH2RowRange::new, new GridH2RowRangeSerializer()); - factory.register(-35, GridH2RowRangeBounds::new, new GridH2RowRangeBoundsSerializer()); - factory.register(-54, QueryTable::new, new QueryTableSerializer()); - factory.register(-55, GridH2DmlRequest::new, new GridH2DmlRequestSerializer()); - factory.register(-56, GridH2DmlResponse::new, new GridH2DmlResponseSerializer()); + factory.register(-4, () -> GridH2Null.INSTANCE, new GridH2NullSerializer(U.gridClassLoader())); + factory.register(-5, GridH2Boolean::new, new GridH2BooleanSerializer(U.gridClassLoader())); + factory.register(-6, GridH2Byte::new, new GridH2ByteSerializer(U.gridClassLoader())); + factory.register(-7, GridH2Short::new, new GridH2ShortSerializer(U.gridClassLoader())); + factory.register(-8, GridH2Integer::new, new GridH2IntegerSerializer(U.gridClassLoader())); + factory.register(-9, GridH2Long::new, new GridH2LongSerializer(U.gridClassLoader())); + factory.register(-10, GridH2Decimal::new, new GridH2DecimalSerializer(U.gridClassLoader())); + factory.register(-11, GridH2Double::new, new GridH2DoubleSerializer(U.gridClassLoader())); + factory.register(-12, GridH2Float::new, new GridH2FloatSerializer(U.gridClassLoader())); + factory.register(-13, GridH2Time::new, new GridH2TimeSerializer(U.gridClassLoader())); + factory.register(-14, GridH2Date::new, new GridH2DateSerializer(U.gridClassLoader())); + factory.register(-15, GridH2Timestamp::new, new GridH2TimestampSerializer(U.gridClassLoader())); + factory.register(-16, GridH2Bytes::new, new GridH2BytesSerializer(U.gridClassLoader())); + factory.register(-17, GridH2String::new, new GridH2StringSerializer(U.gridClassLoader())); + factory.register(-18, GridH2Array::new, new GridH2ArraySerializer(U.gridClassLoader())); + factory.register(-19, GridH2JavaObject::new, new GridH2JavaObjectSerializer(U.gridClassLoader())); + factory.register(-20, GridH2Uuid::new, new GridH2UuidSerializer(U.gridClassLoader())); + factory.register(-21, GridH2Geometry::new, new GridH2GeometrySerializer(U.gridClassLoader())); + factory.register(-22, GridH2CacheObject::new, new GridH2CacheObjectSerializer(U.gridClassLoader())); + factory.register(-30, GridH2IndexRangeRequest::new, new GridH2IndexRangeRequestSerializer(U.gridClassLoader())); + factory.register(-31, GridH2IndexRangeResponse::new, new GridH2IndexRangeResponseSerializer(U.gridClassLoader())); + factory.register(-32, GridH2RowMessage::new, new GridH2RowMessageSerializer(U.gridClassLoader())); + factory.register(-33, GridH2QueryRequest::new, new GridH2QueryRequestSerializer(U.gridClassLoader())); + factory.register(-34, GridH2RowRange::new, new GridH2RowRangeSerializer(U.gridClassLoader())); + factory.register(-35, GridH2RowRangeBounds::new, new GridH2RowRangeBoundsSerializer(U.gridClassLoader())); + factory.register(-54, QueryTable::new, new QueryTableSerializer(U.gridClassLoader())); + factory.register(-55, GridH2DmlRequest::new, new GridH2DmlRequestSerializer(U.gridClassLoader())); + factory.register(-56, GridH2DmlResponse::new, new GridH2DmlResponseSerializer(U.gridClassLoader())); } /** diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java index 39d89b32af878..393ea9f8e5a89 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java @@ -17,6 +17,7 @@ package org.apache.ignite.spi.discovery.zk.internal; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; @@ -24,9 +25,11 @@ public class ZkMessageFactory implements MessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - factory.register(400, ZkCommunicationErrorResolveFinishMessage::new, new ZkCommunicationErrorResolveFinishMessageSerializer()); - factory.register(401, ZkCommunicationErrorResolveStartMessage::new, new ZkCommunicationErrorResolveStartMessageSerializer()); - factory.register(402, ZkForceNodeFailMessage::new, new ZkForceNodeFailMessageSerializer()); - factory.register(403, ZkNoServersMessage::new, new ZkNoServersMessageSerializer()); + factory.register(400, + ZkCommunicationErrorResolveFinishMessage::new, new ZkCommunicationErrorResolveFinishMessageSerializer(U.gridClassLoader())); + factory.register(401, + ZkCommunicationErrorResolveStartMessage::new, new ZkCommunicationErrorResolveStartMessageSerializer(U.gridClassLoader())); + factory.register(402, ZkForceNodeFailMessage::new, new ZkForceNodeFailMessageSerializer(U.gridClassLoader())); + factory.register(403, ZkNoServersMessage::new, new ZkNoServersMessageSerializer(U.gridClassLoader())); } } From 267449fef00c93ce907f3a677ba42331f79becce Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 28 May 2026 19:16:12 +0300 Subject: [PATCH 063/215] WIP --- .../CalciteContextMarshallableMessage.java | 8 +- .../query/calcite/message/QueryTxEntry.java | 17 --- .../apache/ignite/internal/TxEntriesInfo.java | 11 -- .../processors/cache/CacheEntryPredicate.java | 8 -- .../cache/CacheEntryPredicateAdapter.java | 7 - .../cache/CacheInvokeDirectResult.java | 14 -- .../processors/cache/GridCacheEntryInfo.java | 38 +----- .../processors/cache/GridCacheIoManager.java | 5 +- .../processors/cache/GridCacheMessage.java | 129 +----------------- .../processors/cache/GridCacheReturn.java | 8 +- .../GridCacheTtlUpdateRequest.java | 12 -- .../GridDistributedLockRequest.java | 12 +- .../GridDistributedLockResponse.java | 10 +- .../GridDistributedTxPrepareRequest.java | 43 ++---- .../distributed/GridNearUnlockRequest.java | 10 +- .../distributed/dht/GridDhtLockRequest.java | 26 ++-- .../distributed/dht/GridDhtLockResponse.java | 11 +- .../dht/GridDhtTxFinishResponse.java | 20 +-- .../dht/GridDhtTxLocalAdapter.java | 2 +- .../dht/GridDhtTxPrepareRequest.java | 56 ++------ .../dht/GridDhtTxPrepareResponse.java | 25 ---- .../distributed/dht/GridDhtTxRemote.java | 2 +- .../distributed/dht/GridDhtUnlockRequest.java | 7 - .../TransactionAttributesAwareRequest.java | 5 - ...omicApplicationAttributesAwareRequest.java | 5 - .../dht/atomic/GridDhtAtomicNearResponse.java | 10 -- .../GridDhtAtomicSingleUpdateRequest.java | 28 ---- .../atomic/GridDhtAtomicUpdateRequest.java | 37 ++--- .../atomic/GridDhtAtomicUpdateResponse.java | 12 -- .../GridNearAtomicFullUpdateRequest.java | 44 ++---- ...idNearAtomicSingleUpdateFilterRequest.java | 16 --- ...idNearAtomicSingleUpdateInvokeRequest.java | 15 +- .../GridNearAtomicSingleUpdateRequest.java | 12 -- .../atomic/GridNearAtomicUpdateResponse.java | 16 --- .../distributed/dht/atomic/UpdateErrors.java | 13 -- .../preloader/GridDhtForceKeysRequest.java | 9 -- .../preloader/GridDhtForceKeysResponse.java | 18 +-- .../GridDhtPartitionSupplyMessage.java | 19 +-- .../GridDhtPartitionsSingleMessage.java | 31 +---- .../distributed/near/CacheVersionedValue.java | 15 -- .../distributed/near/GridNearGetFuture.java | 2 - .../distributed/near/GridNearGetRequest.java | 31 ++--- .../distributed/near/GridNearGetResponse.java | 15 -- .../near/GridNearSingleGetRequest.java | 11 -- .../near/GridNearSingleGetResponse.java | 17 --- .../near/GridNearTxPrepareResponse.java | 56 ++------ .../distributed/near/GridNearTxRemote.java | 4 +- .../IncrementalSnapshotAwareMessage.java | 8 +- .../cache/query/GridCacheQueryRequest.java | 45 ++---- .../cache/query/GridCacheQueryResponse.java | 61 +-------- .../continuous/CacheContinuousQueryEntry.java | 23 +--- .../CacheContinuousQueryHandler.java | 2 - .../cache/transactions/IgniteTxEntry.java | 70 ++-------- .../cache/transactions/IgniteTxHandler.java | 24 +++- .../cache/transactions/IgniteTxKey.java | 13 -- .../cache/transactions/IgniteTxManager.java | 5 +- .../transactions/TxEntryValueHolder.java | 12 -- .../cache/transactions/TxLocksRequest.java | 19 +-- .../cache/transactions/TxLocksResponse.java | 54 +++----- ...adlockDetectionMessageMarshallingTest.java | 2 +- 60 files changed, 187 insertions(+), 1073 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteContextMarshallableMessage.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteContextMarshallableMessage.java index f6ba42de95933..f81fd1709c088 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteContextMarshallableMessage.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteContextMarshallableMessage.java @@ -28,7 +28,9 @@ public interface CalciteContextMarshallableMessage extends Message { * * @param ctx Cache shared context. */ - void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException; + default void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + // No-op. + } /** * Prepares the message before processing. @@ -36,5 +38,7 @@ public interface CalciteContextMarshallableMessage extends Message { * @param ctx Cache shared context. * @param clsLdr Class loader. */ - void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader clsLdr) throws IgniteCheckedException; + default void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader clsLdr) throws IgniteCheckedException { + // No-op. + } } diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java index da49c14612be7..cad5e8afb75f1 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java @@ -20,12 +20,9 @@ import java.util.Collection; import java.util.Comparator; import java.util.function.Function; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.CacheObjectContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext; @@ -95,18 +92,4 @@ public CacheObject value() { public GridCacheVersion version() { return ver; } - - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - CacheObjectContext coctx = ctx.cacheContext(cacheId).cacheObjectContext(); - - key.finishUnmarshal(coctx, ldr); - - if (val != null) - val.finishUnmarshal(coctx, ldr); - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java index a5a9fcc6bc2f7..25f04b06f2bbb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.HashSet; import java.util.Objects; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheMapEntry; import org.apache.ignite.internal.processors.cache.KeyCacheObject; @@ -65,16 +64,6 @@ public TxEntriesInfo() { return; } - try { - for (KeyCacheObject key : keys) - key.finishUnmarshal(cctx.cacheObjectContext(), null); - } - catch (IgniteCheckedException e) { - ctx.cluster().diagnosticLog().error("Failed to unmarshal key: " + e, e); - - sb.append("Failed to unmarshal key: ").append(e).append(U.nl()); - } - sb.append("Cache entries [cacheId=").append(cacheId) .append(", cacheName=").append(cctx.name()).append("]: "); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java index 93e06fc27c73a..d8c8e7083ee62 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java @@ -17,7 +17,6 @@ package org.apache.ignite.internal.processors.cache; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.plugin.extensions.communication.Message; @@ -25,13 +24,6 @@ * */ public interface CacheEntryPredicate extends IgnitePredicate, Message { - /** - * @param ctx Context. - * @param ldr Class loader. - * @throws IgniteCheckedException If failed. - */ - public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException; - /** * @param locked Entry locked */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java index b1017e9708ae8..d41a3da341e63 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache; import java.util.Objects; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -118,10 +117,4 @@ public CacheEntryPredicateType type() { throw new IllegalStateException("Unknown cache entry predicate type: " + type); } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException { - if (type == CacheEntryPredicateType.VALUE) - val.finishUnmarshal(ctx.cacheObjectContext(), ldr); - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java index 2f76570ff6ee5..4490be4c1dfc9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java @@ -19,7 +19,6 @@ import javax.cache.processor.EntryProcessor; import javax.cache.processor.MutableEntry; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -126,19 +125,6 @@ public void marshalResult(GridCacheContext ctx) { } } - /** - * @param ctx Cache context. - * @param ldr Class loader. - * @throws IgniteCheckedException If failed. - */ - public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException { - key.finishUnmarshal(ctx.cacheObjectContext(), ldr); - - if (res != null) - res.finishUnmarshal(ctx.cacheObjectContext(), ldr); - } - - /** {@inheritDoc} */ @Override public String toString() { return S.toString(CacheInvokeDirectResult.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java index 9369e827aaccf..86917aeb48573 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java @@ -175,16 +175,6 @@ public void setDeleted(boolean deleted) { this.deleted = deleted; } - /** - * @param ctx Context. - * @param ldr Loader. - * @throws IgniteCheckedException If failed. - */ - public void unmarshalValue(GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException { - if (val != null) - val.finishUnmarshal(ctx.cacheObjectContext(), ldr); - } - /** * @param ctx Cache object context. * @return Marshalled size. @@ -215,32 +205,6 @@ public int marshalledSize(CacheObjectContext ctx) throws IgniteCheckedException /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - } - - /** - * Unmarshalls entry. - * - * @param ctx Cache context. - * @param clsLdr Class loader. - * @throws IgniteCheckedException If unmarshalling failed. - */ - public void unmarshal(GridCacheContext ctx, ClassLoader clsLdr) throws IgniteCheckedException { - unmarshal(ctx.cacheObjectContext(), clsLdr); - } - - /** - * Unmarshalls entry. - * - * @param ctx Cache context. - * @param clsLdr Class loader. - * @throws IgniteCheckedException If unmarshalling failed. - */ - public void unmarshal(CacheObjectContext ctx, ClassLoader clsLdr) throws IgniteCheckedException { - key.finishUnmarshal(ctx, clsLdr); - - if (val != null) - val.finishUnmarshal(ctx, clsLdr); - long remaining = expireTime; expireTime = remaining < 0 ? 0 : U.currentTimeMillis() + remaining; @@ -249,7 +213,7 @@ public void unmarshal(CacheObjectContext ctx, ClassLoader clsLdr) throws IgniteC if (expireTime < 0) expireTime = 0; } - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridCacheEntryInfo.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index ef68949ff6bfe..354db9d1010df 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -92,6 +92,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; @@ -1551,7 +1552,9 @@ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) { log.debug("Set P2P context [senderId=" + nodeId + ", msg=" + cacheMsg + ']'); } - cacheMsg.finishUnmarshal(cctx, cctx.deploy().globalLoader()); + MessageSerializer ser = cctx.kernalContext().messageFactory().serializer(cacheMsg.directType()); + + ser.finishUnmarshal(cacheMsg, cctx.kernalContext(), null); } catch (IgniteCheckedException e) { cacheMsg.onClassError(e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index a4a3a0a2aeba3..52f7b0a8f2c09 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -272,18 +272,6 @@ public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteChe // No-op. } - /** - * This method is called after the message is deserialized and is responsible for - * unmarshalling state marshalled in {@link #prepareDeployment(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. @@ -312,21 +300,6 @@ protected final void prepareInfoDeployment(GridCacheEntryInfo info, } } - /** - * @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); - } - /** * @param infos Entries to marshal. * @param ctx Context. @@ -344,22 +317,6 @@ protected final void prepareInfosDeployment( prepareInfoDeployment(e, ctx, cacheObjCtx); } - /** - * @param infos Entries to unmarshal. - * @param ctx Context. - * @param ldr Loader. - * @throws IgniteCheckedException If failed. - */ - protected final void unmarshalInfos(Iterable infos, - GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException { - assert ldr != null; - assert ctx != null; - - if (infos != null) - for (GridCacheEntryInfo e : infos) - unmarshalInfo(e, ctx, ldr); - } - /** * @param txEntries Entries to marshal. * @param ctx Context. @@ -398,27 +355,6 @@ else if (p2pEnabled && e.entryProcessors() != null) { } } - /** - * @param txEntries Entries to unmarshal. - * @param ctx Context. - * @param ldr Loader. - * @throws IgniteCheckedException If failed. - */ - protected final void unmarshalTx(Iterable txEntries, - GridCacheSharedContext ctx, - ClassLoader ldr) throws IgniteCheckedException { - assert ldr != null; - assert ctx != null; - - if (txEntries != null) { - for (IgniteTxEntry e : txEntries) { - e.prepareUnmarshal(ctx, topologyVersion(), false); - - e.unmarshal(ctx, false, ldr); - } - } - } - /** * @param args Arguments to marshal. * @param marsh Marshaller. @@ -464,26 +400,21 @@ protected final void unmarshalTx(Iterable txEntries, /** * @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, + Marshaller marsh, ClassLoader ldr) throws IgniteCheckedException { - assert ldr != null; - assert ctx != null; - if (byteCol == null) return null; Object[] args = new Object[byteCol.length]; - Marshaller marsh = ctx.marshaller(); - for (int i = 0; i < byteCol.length; i++) - args[i] = byteCol[i] == null ? null : U.unmarshal(marsh, byteCol[i], U.resolveClassLoader(ldr, ctx.gridConfig())); + args[i] = byteCol[i] == null ? null : U.unmarshal(marsh, byteCol[i], ldr); return args; } @@ -568,70 +499,22 @@ protected final void prepareCacheObjectsDeployment(@Nullable Collection col, - GridCacheContext ctx, - ClassLoader ldr - ) throws IgniteCheckedException { - if (col == null) - return; - - int size = col.size(); - - for (int i = 0; i < size; i++) { - CacheObject obj = col.get(i); - - if (obj != null) - obj.finishUnmarshal(ctx.cacheObjectContext(), ldr); - } - } - - /** - * @param col Collection. - * @param ctx Context. - * @param ldr Class loader. - * @throws IgniteCheckedException If failed. - */ - protected final void finishUnmarshalCacheObjects(@Nullable Collection col, - GridCacheContext ctx, - ClassLoader ldr - ) throws IgniteCheckedException { - if (col == null) - return; - - for (CacheObject obj : col) { - if (obj != null) - obj.finishUnmarshal(ctx.cacheObjectContext(), ldr); - } - } - /** * @param byteCol Collection to unmarshal. - * @param ctx Context. + * @param marsh Marshaller. * @param ldr Loader. * @return Unmarshalled collection. * @throws IgniteCheckedException If failed. */ @Nullable protected List unmarshalCollection(@Nullable Collection byteCol, - GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - assert ldr != null; - assert ctx != null; - + Marshaller marsh, ClassLoader ldr) throws IgniteCheckedException { if (byteCol == null) return null; List col = new ArrayList<>(byteCol.size()); - Marshaller marsh = ctx.marshaller(); - for (byte[] bytes : byteCol) - col.add(bytes == null ? null : U.unmarshal(marsh, bytes, U.resolveClassLoader(ldr, ctx.gridConfig()))); + col.add(bytes == null ? null : U.unmarshal(marsh, bytes, ldr)); return col; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index 2ca5fa2376f4e..bffb81619672c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -335,16 +335,10 @@ public void marshalResult(GridCacheContext ctx) { public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException { loc = true; - if (cacheObj != null) { - cacheObj.finishUnmarshal(ctx.cacheObjectContext(), ldr); - + if (cacheObj != null) v = ctx.cacheObjectContext().unwrapBinaryIfNeeded(cacheObj, true, false, ldr); - } if (invokeRes && invokeResCol != null) { - for (CacheInvokeDirectResult res : invokeResCol) - res.finishUnmarshal(ctx, ldr); - Map map0 = U.newHashMap(invokeResCol.size()); for (CacheInvokeDirectResult res : invokeResCol) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java index 1dff6dd3fe341..d8f00c54b6bfa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java @@ -166,18 +166,6 @@ public List nearVersions() { prepareCacheObjectsDeployment(nearKeys, cctx); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) - throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - finishUnmarshalCacheObjects(keys, cctx, ldr); - - finishUnmarshalCacheObjects(nearKeys, cctx, ldr); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index 7616318ed7336..738e65620bed4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -355,17 +355,7 @@ public long timeout() { prepareCacheObjectsDeployment(keys, cctx); } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - finishUnmarshalCacheObjects(keys, cctx, ldr); - } - - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDistributedLockRequest.class, this, "keysCnt", retVals.length, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java index c9f2fb14ebc17..db26cf3901027 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java @@ -166,15 +166,7 @@ protected int valuesSize() { prepareCacheObjectsDeployment(vals, ctx.cacheContext(cacheId)); } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - finishUnmarshalCacheObjects(vals, ctx.cacheContext(cacheId), ldr); - } - - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDistributedLockResponse.class, this, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 958da951dc386..5e6a4242e95ba 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -383,35 +383,6 @@ public void applicationAttributes(Map appAttrs) { prepareTxDeployment(reads, ctx); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - if (writes != null) - unmarshalTx(writes, ctx, ldr); - - if (reads != null) - unmarshalTx(reads, ctx, ldr); - - if (dhtVerKeys != null && dhtVers == null) { - assert dhtVerVals != null; - assert dhtVerKeys.size() == dhtVerVals.size(); - - Iterator keyIt = dhtVerKeys.iterator(); - Iterator verIt = dhtVerVals.iterator(); - - dhtVers = U.newHashMap(dhtVerKeys.size()); - - while (keyIt.hasNext()) { - IgniteTxKey key = keyIt.next(); - - key.finishUnmarshal(ctx.cacheContext(key.cacheId()), ldr); - - dhtVers.put(key, verIt.next()); - } - } - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo || forceAddDepInfo; @@ -452,7 +423,21 @@ private boolean isFlag(int mask) { /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + if (dhtVerKeys != null && dhtVers == null) { + assert dhtVerVals != null; + assert dhtVerKeys.size() == dhtVerVals.size(); + Iterator keyIt = dhtVerKeys.iterator(); + Iterator verIt = dhtVerVals.iterator(); + + dhtVers = U.newHashMap(dhtVerKeys.size()); + + while (keyIt.hasNext()) { + IgniteTxKey key = keyIt.next(); + + dhtVers.put(key, verIt.next()); + } + } } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java index 78086afad7bc9..3d93d9368e3f3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java @@ -101,19 +101,11 @@ public void addKey(KeyCacheObject key) { prepareCacheObjectsDeployment(keys, ctx.cacheContext(cacheId)); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - finishUnmarshalCacheObjects(keys, ctx.cacheContext(cacheId), ldr); - } - /** {@inheritDoc} */ @Override public IgniteLogger messageLogger(GridCacheSharedContext ctx) { return ctx.txLockMessageLogger(); } - - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearUnlockRequest.class, this, "super", super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index f771d635dedb7..70afa43649dda 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -24,7 +24,6 @@ import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockRequest; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -258,23 +257,6 @@ public long accessTtl() { return txLbl; } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - if (ownedKeys != null) { - owned = new GridLeanMap<>(ownedKeys.length); - - for (int i = 0; i < ownedKeys.length; i++) { - ownedKeys[i].finishUnmarshal(ctx.cacheContext(cacheId).cacheObjectContext(), ldr); - owned.put(ownedKeys[i], ownedValues[i]); - } - - ownedKeys = null; - ownedValues = null; - } - } - /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { if (owned != null && ownedKeys == null) { @@ -293,7 +275,15 @@ public long accessTtl() { /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + if (ownedKeys != null) { + owned = new GridLeanMap<>(ownedKeys.length); + for (int i = 0; i < ownedKeys.length; i++) + owned.put(ownedKeys[i], ownedValues[i]); + + ownedKeys = null; + ownedValues = null; + } } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index 1a2690b843cc2..c6528afb1092a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -132,16 +132,7 @@ public Collection preloadEntries() { if (preloadEntries != null) prepareInfosDeployment(preloadEntries, cctx.shared(), cctx.cacheObjectContext()); } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - if (preloadEntries != null) - unmarshalInfos(preloadEntries, ctx.cacheContext(cacheId), ldr); - } - - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtLockResponse.class, this, super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java index 4225fffcfb22b..62c327c8d7ce5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java @@ -17,12 +17,9 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheReturn; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxFinishResponse; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.typedef.internal.S; @@ -118,20 +115,6 @@ public boolean checkCommitted() { return checkCommitted; } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) - throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - if (retVal != null && retVal.cacheId() != 0) { - GridCacheContext cctx = ctx.cacheContext(retVal.cacheId()); - - assert cctx != null : retVal.cacheId(); - - retVal.finishUnmarshal(cctx, ldr); - } - } - /** * @param retVal Return value. */ @@ -145,8 +128,7 @@ public void returnValue(GridCacheReturn retVal) { public GridCacheReturn returnValue() { return retVal; } - - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtTxFinishResponse.class, this, "super", super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java index af3655f3b2ffb..45ab9b9cfd746 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java @@ -496,7 +496,7 @@ private void addMapping( assert state == PREPARING : "Invalid tx state for " + "adding entry [msgId=" + msgId + ", e=" + e + ", tx=" + this + ']'; - e.unmarshal(cctx, false, cctx.deploy().globalLoader()); + e.initializeContext(cctx, false); checkInternal(e.txKey()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 76a81ea00f0ee..2486903e85f77 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -17,7 +17,6 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; -import java.util.ArrayList; import java.util.BitSet; import java.util.Collection; import java.util.Collections; @@ -339,9 +338,16 @@ public boolean skipCompletedVersion() { } /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (owned != null && ownedKeys == null) { + ownedKeys = owned.keySet(); + ownedVals = owned.values(); + } + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (ownedKeys != null) { assert ownedKeys.size() == ownedVals.size(); @@ -354,51 +360,9 @@ public boolean skipCompletedVersion() { while (keyIter.hasNext()) { IgniteTxKey key = keyIter.next(); - GridCacheContext cacheCtx = ctx.cacheContext(key.cacheId()); - - if (cacheCtx != null) { - key.finishUnmarshal(cacheCtx, ldr); - - owned.put(key, valIter.next()); - } + owned.put(key, valIter.next()); } } - - if (nearWrites != null) { - for (Iterator it = nearWrites.iterator(); it.hasNext();) { - IgniteTxEntry e = it.next(); - - GridCacheContext cacheCtx = ctx.cacheContext(e.cacheId()); - - if (cacheCtx == null) { - it.remove(); - - if (nearWritesCacheMissed == null) - nearWritesCacheMissed = new ArrayList<>(); - - nearWritesCacheMissed.add(e.txKey()); - } - else { - e.context(cacheCtx); - - e.unmarshal(ctx, true, ldr); - } - } - } - } - - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (owned != null && ownedKeys == null) { - ownedKeys = owned.keySet(); - - ownedVals = owned.values(); - } - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java index af5577fb03881..f4ad3faa6bd50 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java @@ -21,11 +21,8 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareResponse; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -169,28 +166,6 @@ public void addPreloadEntry(GridCacheEntryInfo info) { preloadEntries.add(info); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - if (nearEvicted != null) { - for (IgniteTxKey key : nearEvicted) { - GridCacheContext cctx = ctx.cacheContext(key.cacheId()); - - key.finishUnmarshal(cctx, ldr); - } - } - - if (preloadEntries != null) { - for (GridCacheEntryInfo info : preloadEntries) { - GridCacheContext cctx = ctx.cacheContext(info.cacheId()); - - info.unmarshal(cctx, ldr); - } - } - } - - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtTxPrepareResponse.class, this, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java index e60041e34ed06..3c5ff043e389d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java @@ -276,7 +276,7 @@ public UUID nearNodeId() { * @throws IgniteCheckedException If failed. */ public void addWrite(IgniteTxEntry entry, ClassLoader ldr) throws IgniteCheckedException { - entry.unmarshal(cctx, false, ldr); + entry.initializeContext(cctx, false); GridCacheContext cacheCtx = entry.context(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index c8677d3e2720c..168731d40b353 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -77,13 +77,6 @@ public void addNearKey(KeyCacheObject key) prepareCacheObjectsDeployment(nearKeys, ctx.cacheContext(cacheId)); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - finishUnmarshalCacheObjects(nearKeys, ctx.cacheContext(cacheId), ldr); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtUnlockRequest.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/TransactionAttributesAwareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/TransactionAttributesAwareRequest.java index 36b7a66ea4f7e..84d9c76410f9b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/TransactionAttributesAwareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/TransactionAttributesAwareRequest.java @@ -62,11 +62,6 @@ public Map applicationAttributes() { payload.prepareDeployment(ctx); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - payload.finishUnmarshal(ctx, ldr); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicApplicationAttributesAwareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicApplicationAttributesAwareRequest.java index 238a65b7ff3dd..fc6cec6affe0e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicApplicationAttributesAwareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicApplicationAttributesAwareRequest.java @@ -62,11 +62,6 @@ public Map applicationAttributes() { payload.prepareDeployment(ctx); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - payload.finishUnmarshal(ctx, ldr); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java index bdb7717e85bf8..f7944ca52288c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java @@ -18,11 +18,9 @@ package org.apache.ignite.internal.processors.cache.distributed.dht.atomic; import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; import org.apache.ignite.internal.processors.cache.GridCacheReturn; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -171,14 +169,6 @@ public long futureId() { return false; } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - if (errs != null) - errs.finishUnmarshal(this, ctx.cacheContext(cacheId), ldr); - } - /** {@inheritDoc} */ @Override public String toString() { StringBuilder flags = new StringBuilder(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java index 907934555ade5..3dbf9d0a58c02 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java @@ -19,13 +19,10 @@ import java.util.UUID; import javax.cache.processor.EntryProcessor; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheOperation; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -311,31 +308,6 @@ private void near(boolean near) { return null; } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - finishUnmarshalObject(key, cctx, ldr); - - finishUnmarshalObject(val, cctx, ldr); - - finishUnmarshalObject(prevVal, cctx, ldr); - } - - /** - * @param obj CacheObject un to marshal - * @param ctx context - * @param ldr class loader - * @throws IgniteCheckedException if error - */ - private void finishUnmarshalObject(@Nullable CacheObject obj, GridCacheContext ctx, - ClassLoader ldr) throws IgniteCheckedException { - if (obj != null) - obj.finishUnmarshal(ctx.cacheObjectContext(), ldr); - } - /** * Cleanup values not needed after message was sent. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index d589c46f90dd3..b71d3b83367a0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -495,34 +495,6 @@ else if (conflictVers != null) } } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - finishUnmarshalCacheObjects(keys, cctx, ldr); - - finishUnmarshalCacheObjects(vals, cctx, ldr); - - finishUnmarshalCacheObjects(nearKeys, cctx, ldr); - - finishUnmarshalCacheObjects(nearVals, cctx, ldr); - - finishUnmarshalCacheObjects(prevVals, cctx, ldr); - - if (forceTransformBackups) { - if (entryProcessors == null) - entryProcessors = unmarshalCollection(entryProcessorsBytes, ctx, ldr); - - if (invokeArgsBytes != null && invokeArgs == null) - invokeArgs = unmarshalInvokeArguments(invokeArgsBytes.toArray(new byte[invokeArgsBytes.size()][]), ctx, ldr); - - if (nearEntryProcessors == null) - nearEntryProcessors = unmarshalCollection(nearEntryProcessorsBytes, ctx, ldr); - } - } - /** {@inheritDoc} */ @Override protected void cleanup() { nearVals = null; @@ -545,7 +517,16 @@ else if (conflictVers != null) /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + if (forceTransformBackups) { + if (entryProcessors == null) + entryProcessors = unmarshalCollection(entryProcessorsBytes, marsh, clsLdr); + + if (invokeArgsBytes != null && invokeArgs == null) + invokeArgs = unmarshalInvokeArguments(invokeArgsBytes.toArray(new byte[invokeArgsBytes.size()][]), marsh, clsLdr); + if (nearEntryProcessors == null) + nearEntryProcessors = unmarshalCollection(nearEntryProcessorsBytes, marsh, clsLdr); + } } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index 9bab174411736..861717cb9147e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -129,18 +129,6 @@ public void nearEvicted(List nearEvicted) { prepareCacheObjectsDeployment(nearEvicted, cctx); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - finishUnmarshalCacheObjects(nearEvicted, cctx, ldr); - - if (errs != null) - errs.finishUnmarshal(this, cctx, ldr); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index 5082d1c25160d..567c4e328ef6b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -335,9 +335,6 @@ else if (conflictVers != null) GridCacheContext cctx = ctx.cacheContext(cacheId); - if (expiryPlc != null && expiryPlcBytes == null) - expiryPlcBytes = CU.marshal(cctx, new IgniteExternalizableExpiryPolicy(expiryPlc)); - prepareCacheObjectsDeployment(keys, cctx); if (filter != null && filter.length == 0) @@ -358,35 +355,6 @@ else if (conflictVers != null) prepareCacheObjectsDeployment(vals, cctx); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (expiryPlcBytes != null && expiryPlc == null) - expiryPlc = U.unmarshal(ctx, expiryPlcBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - - finishUnmarshalCacheObjects(keys, cctx, ldr); - - if (filter != null) { - for (CacheEntryPredicate p : filter) { - if (p != null) - p.finishUnmarshal(cctx, ldr); - } - } - - if (operation() == TRANSFORM) { - if (entryProcessors == null) - entryProcessors = unmarshalCollection(entryProcessorsBytes, ctx, ldr); - - if (invokeArgsBytes != null && invokeArgs == null) - invokeArgs = unmarshalInvokeArguments(invokeArgsBytes.toArray(new byte[invokeArgsBytes.size()][]), ctx, ldr); - } - else - finishUnmarshalCacheObjects(vals, cctx, ldr); - } - /** {@inheritDoc} */ @Override public int partition() { assert !F.isEmpty(keys); @@ -408,6 +376,9 @@ else if (conflictVers != null) /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (expiryPlc != null && expiryPlcBytes == null) + expiryPlcBytes = U.marshal(marsh, new IgniteExternalizableExpiryPolicy(expiryPlc)); + if (operation() == TRANSFORM) { if (entryProcessorsBytes == null) entryProcessorsBytes = marshallCollection(entryProcessors, marsh); @@ -419,7 +390,16 @@ else if (conflictVers != null) /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + if (expiryPlcBytes != null && expiryPlc == null) + expiryPlc = U.unmarshal(marsh, expiryPlcBytes, clsLdr); + + if (operation() == TRANSFORM) { + if (entryProcessors == null) + entryProcessors = unmarshalCollection(entryProcessorsBytes, marsh, clsLdr); + if (invokeArgsBytes != null && invokeArgs == null) + invokeArgs = unmarshalInvokeArguments(invokeArgsBytes.toArray(new byte[invokeArgsBytes.size()][]), marsh, clsLdr); + } } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java index 9555f9a475ff5..ef55deb9f50c3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java @@ -25,9 +25,7 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheOperation; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; import org.jetbrains.annotations.NotNull; @@ -93,20 +91,6 @@ public GridNearAtomicSingleUpdateFilterRequest() { return filter; } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - if (filter != null) { - GridCacheContext cctx = ctx.cacheContext(cacheId); - - for (CacheEntryPredicate p : filter) { - if (p != null) - p.finishUnmarshal(cctx, ldr); - } - } - } - /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { if (filter != null && filter.length == 0) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index afe5ed3d0ecb1..59f825a30359d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -179,17 +179,6 @@ public GridNearAtomicSingleUpdateInvokeRequest() { prepareInvokeArgumentsDeployment(invokeArgs, cctx); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - if (entryProcBytes != null && entryProc == null) - entryProc = U.unmarshal(ctx, entryProcBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - - if (invokeArgsBytes != null && invokeArgs == null) - invokeArgs = unmarshalInvokeArguments(invokeArgsBytes.toArray(new byte[invokeArgsBytes.size()][]), ctx, ldr); - } - /** {@inheritDoc} */ @Override public void cleanup(boolean clearKey) { super.cleanup(clearKey); @@ -208,7 +197,11 @@ public GridNearAtomicSingleUpdateInvokeRequest() { /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + if (entryProcBytes != null && entryProc == null) + entryProc = U.unmarshal(marsh, entryProcBytes, clsLdr); + if (invokeArgsBytes != null && invokeArgs == null) + invokeArgs = unmarshalInvokeArguments(invokeArgsBytes.toArray(new byte[invokeArgsBytes.size()][]), marsh, clsLdr); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java index f9428a4497770..ca62244d75d8c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java @@ -228,18 +228,6 @@ public GridNearAtomicSingleUpdateRequest() { prepareCacheObjectDeployment(val, cctx); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - key.finishUnmarshal(cctx.cacheObjectContext(), ldr); - - if (val != null) - val.finishUnmarshal(cctx.cacheObjectContext(), ldr); - } - /** {@inheritDoc} */ @Override public void cleanup(boolean clearKey) { val = null; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index d42596aedb39e..270acaceacf77 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -348,22 +348,6 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { prepareCacheObjectsDeployment(nearUpdates.nearValues(), cctx); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (errs != null) - errs.finishUnmarshal(this, cctx, ldr); - - if (nearUpdates != null) - finishUnmarshalCacheObjects(nearUpdates.nearValues(), cctx, ldr); - - if (ret != null) - ret.finishUnmarshal(cctx, ldr); - } - /** * @return Data for near cache update. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java index 105292b3798d3..820b5d7b4d17a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/UpdateErrors.java @@ -23,8 +23,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; -import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; @@ -115,17 +113,6 @@ void addFailedKeys(Collection keys, Throwable e) { errMsg.error().addSuppressed(e); } - /** */ - void prepareMarshal(GridCacheMessage msg, GridCacheContext cctx) throws IgniteCheckedException { - msg.prepareCacheObjectsDeployment(failedKeys, cctx); - } - - /** */ - void finishUnmarshal(GridCacheMessage msg, GridCacheContext cctx, ClassLoader ldr) throws IgniteCheckedException { - msg.finishUnmarshalCacheObjects(failedKeys, cctx, ldr); - } - - /** {@inheritDoc} */ @Override public String toString() { return S.toString(UpdateErrors.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 8038375f1e9d0..37d0c42732970 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -122,15 +122,6 @@ public Collection keys() { prepareCacheObjectsDeployment(keys, cctx); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - finishUnmarshalCacheObjects(keys, cctx, ldr); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index 45e9f1e2f0965..519dbd680a9b6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -141,27 +141,11 @@ public void addInfo(GridCacheEntryInfo info) { prepareCacheObjectsDeployment(missedKeys, cctx); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (missedKeys != null) - finishUnmarshalCacheObjects(missedKeys, cctx, ldr); - - if (infos != null) { - for (GridCacheEntryInfo info : infos) - info.unmarshal(cctx.cacheObjectContext(), ldr); - } - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; } - - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtForceKeysResponse.class, this, super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index 4c90b909c9efb..212474a532247 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -27,7 +27,6 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; @@ -230,21 +229,6 @@ void addEntry0(int p, boolean historical, GridCacheEntryInfo info, GridCacheShar infoCol.add(info); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - CacheGroupContext grp = ctx.cache().cacheGroup(grpId); - - if (grp == null) - return; - - for (List entries : getInfosSafe().values()) { - for (int i = 0; i < entries.size(); i++) - entries.get(i).unmarshal(grp.cacheObjectContext(), ldr); - } - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; @@ -256,8 +240,7 @@ void addEntry0(int p, boolean historical, GridCacheEntryInfo info, GridCacheShar public int size() { return getInfosSafe().size(); } - - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtPartitionSupplyMessage.class, this, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index a4a28d2eed3c1..c2685d3e2bb04 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -21,12 +21,9 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Compress; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.F; @@ -289,33 +286,7 @@ public long exchangeStartTime() { public void exchangeStartTime(long exchangeStartTime) { this.exchangeStartTime = exchangeStartTime; } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - if (dupPartsData != null) { - assert parts != null; - - for (Map.Entry e : dupPartsData.entrySet()) { - GridDhtPartitionMap map1 = parts.get(e.getKey()); - - assert map1 != null : e.getKey(); - assert F.isEmpty(map1.map()); - assert !map1.hasMovingPartitions(); - - GridDhtPartitionMap map2 = parts.get(e.getValue()); - - assert map2 != null : e.getValue(); - assert map2.map() != null; - - for (Map.Entry e0 : map2.map().entrySet()) - map1.put(e0.getKey(), e0.getValue()); - } - } - } - - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtPartitionsSingleMessage.class, this, super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java index 21d11e1d45393..d35ddede36761 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java @@ -17,10 +17,8 @@ package org.apache.ignite.internal.processors.cache.distributed.near; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; @@ -73,19 +71,6 @@ public CacheObject value() { return val; } - /** - * This method is called after the whole message is received - * and is responsible for unmarshalling state. - * - * @param ctx Context. - * @param ldr Class loader. - * @throws IgniteCheckedException If failed. - */ - public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException { - if (val != null) - val.finishUnmarshal(ctx.cacheObjectContext(), ldr); - } - /** {@inheritDoc} */ @Override public String toString() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java index a8df9c74253c6..75ef1509bc4af 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java @@ -628,8 +628,6 @@ private Map loadEntries( for (GridCacheEntryInfo info : infos) { try { - info.unmarshalValue(cctx, cctx.deploy().globalLoader()); - // Entries available locally in DHT should not be loaded into near cache for reading. if (!cctx.affinity().keyLocalNode(info.key(), cctx.affinity().affinityTopologyVersion())) { GridNearCacheEntry entry = savedEntries.get(info.key()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index c92b4639f5b02..30278a6227412 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; @@ -37,14 +38,14 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.marshaller.Marshaller; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Get request. Responsible for obtaining entry from primary node. 'Near' means 'Initiating node' here, not 'Near Cache'. */ -public class GridNearGetRequest extends GridCacheIdMessage implements GridCacheDeployable, - GridCacheVersionable { +public class GridNearGetRequest extends GridCacheIdMessage implements GridCacheDeployable, GridCacheVersionable, MarshallableMessage { /** */ private static final int READ_THROUGH_FLAG_MASK = 0x01; @@ -296,18 +297,18 @@ public long accessTtl() { prepareCacheObjectsDeployment(keys, cctx); } - /** - * @param ctx Context. - * @param ldr Loader. - * @throws IgniteCheckedException If failed. - */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - GridCacheContext cctx = ctx.cacheContext(cacheId); + /** {@inheritDoc} */ + @Override public boolean addDeploymentInfo() { + return addDepInfo; + } - finishUnmarshalCacheObjects(keys, cctx, ldr); + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + // No-op. + } + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { assert !F.isEmpty(keys); assert readersFlags == null || keys.size() == readersFlags.size(); @@ -324,12 +325,6 @@ public long accessTtl() { } } - /** {@inheritDoc} */ - @Override public boolean addDeploymentInfo() { - return addDepInfo; - } - - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearGetRequest.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java index 61da734a27bec..c8a8c84b6b148 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java @@ -19,15 +19,12 @@ import java.util.Collection; import java.util.Collections; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionable; import org.apache.ignite.internal.util.GridLeanSet; @@ -173,18 +170,6 @@ public void error(@Nullable Throwable err) { errMsg = new ErrorMessage(err); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - GridCacheContext cctx = ctx.cacheContext(cacheId()); - - if (entries != null) { - for (GridCacheEntryInfo info : entries) - info.unmarshal(cctx, ldr); - } - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java index ded6016b3a5c9..8350d8b61819d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java @@ -260,17 +260,6 @@ public boolean recovery() { prepareCacheObjectDeployment(key, cctx); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - assert key != null; - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - key.finishUnmarshal(cctx.cacheObjectContext(), ldr); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java index 28c80f2dc963c..9225b42c07138 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java @@ -24,7 +24,6 @@ import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; -import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.typedef.internal.S; @@ -156,22 +155,6 @@ public long futureId() { } } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - if (res != null) { - GridCacheContext cctx = ctx.cacheContext(cacheId()); - - if (res instanceof CacheObject) - ((CacheObject)res).finishUnmarshal(cctx.cacheObjectContext(), ldr); - else if (res instanceof CacheVersionedValue) - ((CacheVersionedValue)res).finishUnmarshal(cctx, ldr); - else if (res instanceof GridCacheEntryInfo) - ((GridCacheEntryInfo)res).unmarshal(cctx, ldr); - } - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index 5dffe6ad9d47c..ea06d7b0e24d9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -27,9 +27,7 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheReturn; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareResponse; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -238,14 +236,16 @@ public boolean hasOwnedValue(IgniteTxKey key) { } /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - // There are separate collections for keys and values of the 'ownedVals' map, because IgniteTxKey - // can not be inserted directly in a map as a key during invocation of MessageReader#read. - // The IgniteTxKey's hash code calculation will fail due to delegation of calculation - // to KeyCacheObjectImpl#hashCode, which in turn fails with assertion error if KeyCacheObjectImpl#val - // has not initialized yet in KeyCacheObjectImpl#finishUnmarshal. + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + if (ownedVals != null && ownedValKeys == null) { + ownedValKeys = ownedVals.keySet(); + + ownedValVals = ownedVals.values(); + } + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (ownedValKeys != null && ownedVals == null) { ownedVals = U.newHashMap(ownedValKeys.size()); @@ -258,47 +258,11 @@ public boolean hasOwnedValue(IgniteTxKey key) { while (keyIter.hasNext()) { IgniteTxKey key = keyIter.next(); - GridCacheContext cctx = ctx.cacheContext(key.cacheId()); - CacheVersionedValue val = valIter.next(); - key.finishUnmarshal(cctx, ldr); - - val.finishUnmarshal(cctx, ldr); - ownedVals.put(key, val); } } - - if (retVal != null && retVal.cacheId() != 0) { - GridCacheContext cctx = ctx.cacheContext(retVal.cacheId()); - - assert cctx != null : retVal.cacheId(); - - retVal.finishUnmarshal(cctx, ldr); - } - - if (filterFailedKeys != null) { - for (IgniteTxKey key : filterFailedKeys) { - GridCacheContext cctx = ctx.cacheContext(key.cacheId()); - - key.finishUnmarshal(cctx, ldr); - } - } - } - - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (ownedVals != null && ownedValKeys == null) { - ownedValKeys = ownedVals.keySet(); - - ownedValVals = ownedVals.values(); - } - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java index 936033d8b3838..6186de9446623 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java @@ -126,7 +126,7 @@ public GridNearTxRemote( if (writeEntries != null) { for (IgniteTxEntry entry : writeEntries) { - entry.unmarshal(ctx, true, ldr); + entry.initializeContext(ctx, true); addEntry(entry); } @@ -203,7 +203,7 @@ public Collection evicted() { */ public void addEntries(ClassLoader ldr, Iterable entries) throws IgniteCheckedException { for (IgniteTxEntry entry : entries) { - entry.unmarshal(cctx, true, ldr); + entry.initializeContext(cctx, true); addEntry(entry); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotAwareMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotAwareMessage.java index 1032504d60ad5..abac24c67ceaf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotAwareMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotAwareMessage.java @@ -85,13 +85,7 @@ public long snapshotTopologyVersion() { @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { payload.prepareDeployment(ctx); } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - payload.finishUnmarshal(ctx, ldr); - } - - + /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 5e1fba2884fbe..8a892468f786b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -22,7 +22,6 @@ import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; @@ -440,37 +439,6 @@ private static byte setDataPageScanEnabled(int flags, Boolean enabled) { } } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - Marshaller mrsh = ctx.marshaller(); - - ClassLoader clsLdr = U.resolveClassLoader(ldr, ctx.gridConfig()); - - if (keyValFilterBytes != null && keyValFilter == null) - keyValFilter = U.unmarshal(mrsh, keyValFilterBytes, clsLdr); - - if (rdcBytes != null && rdc == null) - rdc = U.unmarshal(mrsh, rdcBytes, ldr); - - if (transBytes != null && trans == null) - trans = U.unmarshal(mrsh, transBytes, clsLdr); - - if (argsBytes != null && args == null) - args = U.unmarshal(mrsh, argsBytes, clsLdr); - - if (idxQryDescBytes != null && idxQryDesc == null) - idxQryDesc = U.unmarshal(mrsh, idxQryDescBytes, clsLdr); - - if (!F.isEmpty(skipKeys)) { - CacheObjectContext objCtx = ctx.cacheObjectContext(cacheId); - - for (KeyCacheObject k : skipKeys) - k.finishUnmarshal(objCtx, ldr); - } - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; @@ -664,7 +632,20 @@ public Collection skipKeys() { /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + if (keyValFilterBytes != null && keyValFilter == null) + keyValFilter = U.unmarshal(marsh, keyValFilterBytes, clsLdr); + if (rdcBytes != null && rdc == null) + rdc = U.unmarshal(marsh, rdcBytes, clsLdr); + + if (transBytes != null && trans == null) + trans = U.unmarshal(marsh, transBytes, clsLdr); + + if (argsBytes != null && args == null) + args = U.unmarshal(marsh, argsBytes, clsLdr); + + if (idxQryDescBytes != null && idxQryDesc == null) + idxQryDesc = U.unmarshal(marsh, idxQryDescBytes, clsLdr); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index 78dcd963c55f7..ee030ce661855 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -17,24 +17,19 @@ package org.apache.ignite.internal.processors.cache.query; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; import java.util.Map; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.cache.query.index.IndexQueryResultMeta; import org.apache.ignite.internal.managers.communication.ErrorMessage; -import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.jetbrains.annotations.Nullable; @@ -126,57 +121,6 @@ public GridCacheQueryResponse(int cacheId, long reqId, Throwable err, boolean ad } } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - if (data == null) - data = unmarshalCollection0(dataBytes, ctx, ldr); - } - - /** - * @param byteCol Collection to unmarshal. - * @param ctx Context. - * @param ldr Loader. - * @return Unmarshalled collection. - * @throws IgniteCheckedException If failed. - */ - @Nullable protected List unmarshalCollection0(@Nullable Collection byteCol, - GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - assert ldr != null; - assert ctx != null; - - if (byteCol == null) - return null; - - List col = new ArrayList<>(byteCol.size()); - - Marshaller marsh = ctx.marshaller(); - - ClassLoader ldr0 = U.resolveClassLoader(ldr, ctx.gridConfig()); - - CacheObjectContext cacheObjCtx = null; - - for (byte[] bytes : byteCol) { - Object obj = bytes == null ? null : marsh.unmarshal(bytes, ldr0); - - if (obj instanceof Map.Entry) { - Object key = ((Map.Entry)obj).getKey(); - - if (key instanceof KeyCacheObject) { - if (cacheObjCtx == null) - cacheObjCtx = ctx.cacheContext(cacheId).cacheObjectContext(); - - ((KeyCacheObject)key).finishUnmarshal(cacheObjCtx, ldr0); - } - } - - col.add((T)obj); - } - - return col; - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; @@ -236,13 +180,14 @@ public boolean fields() { /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (dataBytes == null && data != null) + if (data != null) dataBytes = marshallCollection(data, marsh); } /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - + if (dataBytes != null) + data = unmarshalCollection(dataBytes, marsh, clsLdr); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java index 9acf37ef7a23d..2cd35df578da5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java @@ -18,12 +18,10 @@ package org.apache.ignite.internal.processors.cache.query.continuous; import javax.cache.event.EventType; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.deployment.GridDeploymentInfo; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.tostring.GridToStringExclude; @@ -287,24 +285,6 @@ boolean isKeepBinary() { return (flags & KEEP_BINARY) != 0; } - /** - * @param cctx Cache context. - * @param ldr Class loader. - * @throws IgniteCheckedException In case of error. - */ - void unmarshal(GridCacheContext cctx, @Nullable ClassLoader ldr) throws IgniteCheckedException { - if (!isFiltered()) { - if (key != null) - key.finishUnmarshal(cctx.cacheObjectContext(), ldr); - - if (newVal != null) - newVal.finishUnmarshal(cctx.cacheObjectContext(), ldr); - - if (oldVal != null) - oldVal.finishUnmarshal(cctx.cacheObjectContext(), ldr); - } - } - /** * @return Key. */ @@ -335,8 +315,7 @@ CacheObject oldValue() { @Override public GridDeploymentInfo deployInfo() { return depInfo; } - - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(CacheContinuousQueryEntry.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java index 902b418f64fe3..68f05b1dea04c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java @@ -1067,8 +1067,6 @@ private void notifyCallback0(UUID nodeId, } } - e.unmarshal(cctx, ldr); - Collection> evts = handleEvent(ctx, e); if (evts != null && !evts.isEmpty()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index c6949c52e249c..ea82c36dcab4c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -27,12 +27,10 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; import org.apache.ignite.internal.processors.cache.CacheInvalidStateException; import org.apache.ignite.internal.processors.cache.CacheInvokeEntry; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException; @@ -1041,26 +1039,27 @@ public void filtersSet(boolean filtersSet) { /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + // Unmarshal transform closure anyway if it exists. + if (transformClosBytes != null && entryProcessorsCol == null) + entryProcessorsCol = U.unmarshal(marsh, transformClosBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig())); + + if (filters == null) + filters = CU.empty0(); + + if (expiryPlcBytes != null && expiryPlc == null) + expiryPlc = U.unmarshal(marsh, expiryPlcBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig())); } /** - * Prepares this entry to unmarshall. In particular, this method initialize a cache context. - * * @param ctx Cache context. - * @param topVer Topology version that is used to validate a cache context. - * If this parameter is {@code null} then validation will be skipped. * @param near Near flag. * @throws IgniteCheckedException If un-marshalling failed. */ - public void prepareUnmarshal( - GridCacheSharedContext ctx, - AffinityTopologyVersion topVer, - boolean near - ) throws IgniteCheckedException { + public void initializeContext(GridCacheSharedContext ctx, boolean near) throws IgniteCheckedException { if (this.ctx == null) { GridCacheContext cacheCtx = ctx.cacheContext(cacheId); - if (cacheCtx == null || (topVer != null && topVer.before(cacheCtx.startTopologyVersion()))) + if (cacheCtx == null) throw new CacheInvalidStateException( "Failed to perform cache operation (cache is stopped), cacheId=" + cacheId); @@ -1073,53 +1072,6 @@ else if (!cacheCtx.isNear() && near) } } - /** - * Unmarshalls entry. - * - * @param ctx Cache context. - * @param near Near flag. - * @param clsLdr Class loader. - * @throws IgniteCheckedException If un-marshalling failed. - */ - public void unmarshal( - GridCacheSharedContext ctx, - boolean near, - ClassLoader clsLdr - ) throws IgniteCheckedException { - - if (this.ctx == null) - prepareUnmarshal(ctx, null, near); - - CacheObjectValueContext coctx = this.ctx.cacheObjectContext(); - - if (coctx == null) - throw new CacheInvalidStateException( - "Failed to perform cache operation (cache is stopped), cacheId=" + cacheId); - - // Unmarshal transform closure anyway if it exists. - if (transformClosBytes != null && entryProcessorsCol == null) - entryProcessorsCol = U.unmarshal(ctx, transformClosBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig())); - - if (filters == null) - filters = CU.empty0(); - else { - for (CacheEntryPredicate p : filters) { - if (p != null) - p.finishUnmarshal(this.ctx, clsLdr); - } - } - - key.finishUnmarshal(coctx, clsLdr); - - val.unmarshal(coctx, clsLdr); - - if (expiryPlcBytes != null && expiryPlc == null) - expiryPlc = U.unmarshal(ctx, expiryPlcBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig())); - - if (hasOldValue()) - oldVal.unmarshal(coctx, clsLdr); - } - /** * @param expiryPlc Expiry policy. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java index 392f37d32b060..e3efffb6191c7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.UUID; @@ -377,7 +378,7 @@ private IgniteTxEntry unmarshal(@Nullable Collection entries) thr IgniteTxEntry firstEntry = null; for (IgniteTxEntry e : entries) { - e.unmarshal(ctx, false, ctx.deploy().globalLoader()); + e.initializeContext(ctx, false); if (firstEntry == null) firstEntry = e; @@ -1211,7 +1212,26 @@ private void processDhtTxPrepareRequest(final UUID nodeId, final GridDhtTxPrepar if (nearTx != null) res.nearEvicted(nearTx.evicted()); - List writesCacheMissed = req.nearWritesCacheMissed(); + List writesCacheMissed = new ArrayList<>(); + + Collection writes = req.nearWrites(); + + for (Iterator it = writes.iterator(); it.hasNext();) { + IgniteTxEntry e = it.next(); + + GridCacheContext cacheCtx = ctx.cacheContext(e.cacheId()); + + if (cacheCtx == null) { + it.remove(); + + writesCacheMissed.add(e.txKey()); + } + else { + e.context(cacheCtx); + + e.initializeContext(ctx, true); + } + } if (writesCacheMissed != null) { Collection evicted0 = res.nearEvicted(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java index b90e3a4805f05..4ca6c017bf40e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java @@ -17,9 +17,7 @@ package org.apache.ignite.internal.processors.cache.transactions; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; @@ -70,17 +68,6 @@ public KeyCacheObject key() { return cacheId; } - /** - * @param ctx Context. - * @param ldr Class loader. - * @throws IgniteCheckedException If failed. - */ - public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException { - assert key != null; - - key.finishUnmarshal(ctx.cacheObjectContext(), ldr); - } - /** {@inheritDoc} */ @Override public boolean equals(Object o) { if (this == o) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 9a925d1a4a449..92d8b80a27acd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -114,6 +114,7 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteOutClosure; import org.apache.ignite.lang.IgniteReducer; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.spi.systemview.view.TransactionView; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; @@ -3446,7 +3447,9 @@ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) { return; try { - cacheMsg.finishUnmarshal(cctx, cctx.deploy().globalLoader()); + MessageSerializer ser = cctx.kernalContext().messageFactory().serializer(cacheMsg.directType()); + + ser.finishUnmarshal(cacheMsg, cctx.kernalContext(), null); } catch (IgniteCheckedException e) { cacheMsg.onClassError(e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java index 1050b7fa22373..425e4d88cdfeb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java @@ -17,10 +17,8 @@ package org.apache.ignite.internal.processors.cache.transactions; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -118,16 +116,6 @@ public boolean hasReadValue() { return hasReadVal; } - /** - * @param ctx Cache context. - * @param ldr Class loader. - * @throws IgniteCheckedException If unmarshalling failed. - */ - public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { - if (hasWriteVal && val != null) - val.finishUnmarshal(ctx, ldr); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(TxEntryValueHolder.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java index dab495aeb2698..588219de8bef6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java @@ -23,7 +23,6 @@ import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheMessage; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.A; @@ -90,21 +89,6 @@ public Collection txKeys() { return addDepInfo; } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - super.finishUnmarshal(ctx, ldr); - - txKeys = U.newHashSet(txKeysArr.length); - - for (IgniteTxKey key : txKeysArr) { - key.finishUnmarshal(ctx.cacheContext(key.cacheId()), ldr); - - txKeys.add(key); - } - - txKeysArr = null; - } - /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { txKeysArr = new IgniteTxKey[txKeys.size()]; @@ -117,6 +101,9 @@ public Collection txKeys() { /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + txKeys = U.newHashSet(txKeysArr.length); + for (IgniteTxKey key : txKeysArr) + txKeys.add(key); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index fe01c2f31967d..e517c7c5c522a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -27,7 +27,6 @@ import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheMessage; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; @@ -138,41 +137,6 @@ public void addKey(IgniteTxKey key) { return S.toString(TxLocksResponse.class, this); } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - try { - super.finishUnmarshal(ctx, ldr); - - if (nearTxKeysArr != null) { - for (int i = 0; i < nearTxKeysArr.length; i++) { - IgniteTxKey txKey = nearTxKeysArr[i]; - - txKey.key().finishUnmarshal(ctx.cacheObjectContext(txKey.cacheId()), ldr); - - txLocks().put(txKey, locksArr[i]); - } - - nearTxKeysArr = null; - locksArr = null; - } - - if (txKeysArr != null) { - txKeys = U.newHashSet(txKeysArr.length); - - for (IgniteTxKey txKey : txKeysArr) { - txKey.key().finishUnmarshal(ctx.cacheObjectContext(txKey.cacheId()), ldr); - - txKeys.add(txKey); - } - - txKeysArr = null; - } - } - catch (Exception e) { - throw new IgniteCheckedException(e); - } - } - /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { if (nearTxKeyLocks != null && !nearTxKeyLocks.isEmpty()) { @@ -205,6 +169,24 @@ public void addKey(IgniteTxKey key) { /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + if (nearTxKeysArr != null) { + for (int i = 0; i < nearTxKeysArr.length; i++) { + IgniteTxKey txKey = nearTxKeysArr[i]; + + txLocks().put(txKey, locksArr[i]); + } + nearTxKeysArr = null; + locksArr = null; + } + + if (txKeysArr != null) { + txKeys = U.newHashSet(txKeysArr.length); + + for (IgniteTxKey txKey : txKeysArr) + txKeys.add(txKey); + + txKeysArr = null; + } } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java index 39ca06b06ec70..e6f32de834b40 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java @@ -65,7 +65,7 @@ public void testMessageUnmarshallWithoutCacheContext() throws Exception { @Override public void onMessage(UUID nodeId, Object msg, byte plc) { if (msg instanceof TxLocksResponse) { try { - ((TxLocksResponse)msg).finishUnmarshal(clientCtx, clientCtx.deploy().globalLoader()); + ((TxLocksResponse)msg).finishUnmarshal(clientCtx.marshaller(), clientCtx.deploy().globalLoader()); res.set(true); } From 788527e83e98bb3450e5eead7310c4ecec4ee048 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 28 May 2026 19:18:59 +0300 Subject: [PATCH 064/215] WIP --- .../managers/communication/CompressedMessageSerializer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageSerializer.java index 594aab336e02d..992b798a3bb0c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageSerializer.java @@ -27,6 +27,10 @@ /** Message serializer for compressed message. */ public class CompressedMessageSerializer implements MessageSerializer { + /** */ + public CompressedMessageSerializer(ClassLoader clsLdr) { + } + /** {@inheritDoc} */ @Override public boolean writeTo(CompressedMessage msg, MessageWriter writer) { if (!writer.isHeaderWritten()) { From 20e3f84521f131e3b58661c9bfadcfb117685d53 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 28 May 2026 19:34:31 +0300 Subject: [PATCH 065/215] WIP --- .../spi/discovery/tcp/TcpDiscoveryIoSession.java | 2 +- .../ignite/spi/discovery/tcp/TcpDiscoverySpi.java | 12 ++++++++++-- .../tcp/TcpCommunicationSpiSkipMessageSendTest.java | 2 +- .../TcpClientDiscoverySpiFailureTimeoutSelfTest.java | 3 ++- .../tcp/TcpDiscoverySslSecuredUnsecuredTest.java | 3 ++- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java index 15e99228b5194..42cc017ea4772 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java @@ -146,7 +146,7 @@ void writeMessage(TcpDiscoveryAbstractMessage msg) throws IgniteCheckedException * @return Deserialized message instance. * @throws IgniteCheckedException If deserialization fails. */ - T readMessage() throws IgniteCheckedException, IOException { + T readMessage() throws IgniteCheckedException, IOException { try { byte b0 = (byte)in.read(); byte b1 = (byte)in.read(); diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java index 6e14dfa8f272f..a27201a64a46f 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java @@ -72,7 +72,9 @@ import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.spi.IgniteSpiAdapter; @@ -1815,7 +1817,7 @@ protected void writeToSocket( * @throws IOException If IO failed or read timed out. * @throws IgniteCheckedException If unmarshalling failed. */ - protected T readMessage(TcpDiscoveryIoSession ses, long timeout) throws IOException, IgniteCheckedException { + protected T readMessage(TcpDiscoveryIoSession ses, long timeout) throws IOException, IgniteCheckedException { Socket sock = ses.socket(); assert sock != null; @@ -1825,7 +1827,13 @@ protected T readMessage(TcpDiscoveryIoSession ses, long timeout) throws IOEx try { sock.setSoTimeout((int)timeout); - return ses.readMessage(); + T msg = ses.readMessage(); + + MessageSerializer ser = messageFactory().serializer(msg.directType()); + + ser.finishUnmarshal(msg, ((IgniteEx)ignite()).context(), null); + + return msg; } catch (IOException | IgniteCheckedException e) { if (X.hasCause(e, SocketTimeoutException.class)) diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiSkipMessageSendTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiSkipMessageSendTest.java index aeba1e4d7c136..a9ea6d824db20 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiSkipMessageSendTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiSkipMessageSendTest.java @@ -278,7 +278,7 @@ class CustomDiscoverySpi extends TcpDiscoverySpi { private final CountDownLatch netDisabledLatch = new CountDownLatch(1); /** {@inheritDoc} */ - @Override protected T readMessage(TcpDiscoveryIoSession ses, + @Override protected T readMessage(TcpDiscoveryIoSession ses, long timeout) throws IOException, IgniteCheckedException { if (netDisabled) { U.sleep(timeout); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java index 10645f5fc25d6..49ba4f269821d 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java @@ -36,6 +36,7 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; @@ -516,7 +517,7 @@ private static class TestTcpDiscoverySpi2 extends TcpDiscoverySpi { } /** {@inheritDoc} */ - @Override protected T readMessage(TcpDiscoveryIoSession ses, long timeout) + @Override protected T readMessage(TcpDiscoveryIoSession ses, long timeout) throws IOException, IgniteCheckedException { long currTimeout = getLocalNode().isClient() ? clientFailureDetectionTimeout() : failureDetectionTimeout(); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java index dcf9931ef9236..79b6962db51e6 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java @@ -23,6 +23,7 @@ import javax.net.ssl.SSLException; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; @@ -174,7 +175,7 @@ private FailDiscoverySpi(final boolean plain) { } /** {@inheritDoc} */ - @Override protected T readMessage(final TcpDiscoveryIoSession ses, + @Override protected T readMessage(final TcpDiscoveryIoSession ses, final long timeout) throws IOException, IgniteCheckedException { if (cnt-- > 0) { if (plain) From d5bfdee163cfdc7c111905c0ba7a3d4afa729bd2 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 28 May 2026 19:35:14 +0300 Subject: [PATCH 066/215] WIP --- .../apache/ignite/internal/MessageSerializerGenerator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 975cc1e630430..73b92cf256feb 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -263,7 +263,7 @@ private void generateMethods(List fields) throws Exception { } /** */ - private void generateMarshallMethods(List orderedFields){ + private void generateMarshallMethods(List orderedFields) { imports.add("org.apache.ignite.IgniteCheckedException"); imports.add("org.apache.ignite.internal.processors.cache.CacheObjectValueContext"); imports.add("org.apache.ignite.internal.GridKernalContext"); @@ -308,7 +308,7 @@ private void generateMarshallMethods(List orderedFields){ } /** */ - private void generateUnmarshallMethods(List orderedFields){ + private void generateUnmarshallMethods(List orderedFields) { marshall.add(EMPTY); indent = 1; From 83e19fc98b09e2f5961e7aa7ddd218c1e2bdbac0 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 28 May 2026 21:07:12 +0300 Subject: [PATCH 067/215] WIP --- .../ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java | 2 ++ .../org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java index 42cc017ea4772..9389b0b991bfc 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java @@ -198,6 +198,8 @@ T readMessage() throws IgniteCheckedException, IOException { } while (!finished); + msgSer.finishUnmarshal(msg, ((IgniteEx)spi.ignite()).context(), null); + return (T)msg; } catch (Exception e) { diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java index a27201a64a46f..db7eeb89c509c 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java @@ -74,7 +74,6 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.spi.IgniteSpiAdapter; @@ -1828,10 +1827,6 @@ protected T readMessage(TcpDiscoveryIoSession ses, long time sock.setSoTimeout((int)timeout); T msg = ses.readMessage(); - - MessageSerializer ser = messageFactory().serializer(msg.directType()); - - ser.finishUnmarshal(msg, ((IgniteEx)ignite()).context(), null); return msg; } From e5e77f57abbf6daed8b0f8d5f338f97245c67c5f Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 28 May 2026 21:39:51 +0300 Subject: [PATCH 068/215] WIP --- .../communication/GridCommunicationSendMessageSelfTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java index 4a65f5c912d04..2b325359e90c6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java @@ -153,7 +153,8 @@ public static class TestPluginProvider extends AbstractTestPluginProvider { registry.registerExtension(MessageFactoryProvider.class, new MessageFactoryProvider() { @Override public void registerAll(MessageFactory factory) { factory.register(DIRECT_TYPE, TestValidByteIdMessage::new, new TestValidByteIdMessageSerializer(U.gridClassLoader())); - factory.register(DIRECT_TYPE_OVER_BYTE, TestOverByteIdMessage::new, new TestOverByteIdMessageSerializer(U.gridClassLoader())); + factory.register(DIRECT_TYPE_OVER_BYTE, + TestOverByteIdMessage::new, new TestOverByteIdMessageSerializer(U.gridClassLoader())); } }); } From 679cbc763ba4b65dbbb4417bce9ddeabffc1655a Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 29 May 2026 16:30:31 +0300 Subject: [PATCH 069/215] WIP --- .../internal/managers/communication/GridIoManager.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 2b8c027f15d82..491203ec6e6a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -466,6 +466,9 @@ public void resetMetrics() { msg.getClass().getName() + ". Most likely GridCommunicationSpi is being used directly, " + "which is illegal - make sure to send messages only via GridProjection API."); } + catch (IgniteCheckedException e) { + throw new IgniteException(e); + } } @Override public void onDisconnected(UUID nodeId) { @@ -1194,10 +1197,14 @@ private void onChannelOpened0(UUID rmtNodeId, GridIoMessage initMsg, Channel cha * @param msg Message bytes. * @param msgC Closure to call when message processing finished. */ - private void onMessage0(UUID nodeId, GridIoMessage msg, IgniteRunnable msgC) { + private void onMessage0(UUID nodeId, GridIoMessage msg, IgniteRunnable msgC) throws IgniteCheckedException { assert nodeId != null; assert msg != null; + MessageSerializer ser = ctx.messageFactory().serializer(msg.directType()); + + ser.finishUnmarshal(msg, ctx, null); + Lock busyLock0 = busyLock.readLock(); busyLock0.lock(); From 4a0ab1d682ff51181df06d1e0bca8d265979b13e Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 29 May 2026 16:57:14 +0300 Subject: [PATCH 070/215] WIP --- .../internal/processors/cache/GridCacheIoManager.java | 9 +++++++++ .../cache/distributed/near/CacheVersionedValue.java | 3 ++- .../processors/cache/transactions/IgniteTxEntry.java | 4 ++-- .../processors/cache/transactions/IgniteTxHandler.java | 2 ++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index 354db9d1010df..f6fb1ab0d42ef 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -317,6 +317,15 @@ else if (desc.receivedFromStartVersion() != null) private void handleMessage(UUID nodeId, GridCacheMessage cacheMsg, byte plc) { MessageHandlers msgHandlers = cacheMsg instanceof GridCacheGroupIdMessage ? grpHandlers : cacheHandlers; + MessageSerializer ser = cctx.kernalContext().messageFactory().serializer(cacheMsg.directType()); + + try { + ser.finishUnmarshal(cacheMsg, cctx.kernalContext(), null); + } + catch (IgniteCheckedException e) { + throw new IgniteException("Failed to unmarshall entry", e); + } + Lock lock = rw.readLock(); lock.lock(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java index d35ddede36761..1cd8b6456b037 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java @@ -40,7 +40,8 @@ public class CacheVersionedValue implements Message, CacheIdAware { GridCacheVersion ver; /** */ - private int cacheId; + @Order(2) + int cacheId; /** */ public CacheVersionedValue() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index ea82c36dcab4c..9ed05e2484dba 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -1041,13 +1041,13 @@ public void filtersSet(boolean filtersSet) { @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { // Unmarshal transform closure anyway if it exists. if (transformClosBytes != null && entryProcessorsCol == null) - entryProcessorsCol = U.unmarshal(marsh, transformClosBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig())); + entryProcessorsCol = U.unmarshal(marsh, transformClosBytes, clsLdr); if (filters == null) filters = CU.empty0(); if (expiryPlcBytes != null && expiryPlc == null) - expiryPlc = U.unmarshal(marsh, expiryPlcBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig())); + expiryPlc = U.unmarshal(marsh, expiryPlcBytes, clsLdr); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java index e3efffb6191c7..df2a4467a97ee 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java @@ -1765,6 +1765,8 @@ private void sendReply(UUID nodeId, GridDhtTxFinishRequest req, boolean committe int idx = 0; for (IgniteTxEntry entry : req.writes()) { + entry.initializeContext(ctx, false); + GridCacheContext cacheCtx = entry.context(); int part = cacheCtx.affinity().partition(entry.key()); From 5a80f0b8406bc3788d5ec0f12ff67a875978005a Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 1 Jun 2026 18:13:38 +0300 Subject: [PATCH 071/215] WIP --- .../processors/cache/GridCacheAdapter.java | 48 ++++++++-------- .../processors/cache/GridCacheReturn.java | 56 ++++++++++--------- .../GridNearAtomicAbstractUpdateFuture.java | 2 +- .../GridNearAtomicSingleUpdateFuture.java | 4 +- .../atomic/GridNearAtomicUpdateFuture.java | 4 +- .../distributed/near/GridNearTxLocal.java | 4 +- .../transactions/IgniteTxLocalAdapter.java | 2 +- 7 files changed, 61 insertions(+), 59 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 410bac3545fc2..d325fcc25af1f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -210,19 +210,6 @@ public abstract class GridCacheAdapter implements IgniteInternalCache, Object>() { - @Nullable @Override public Object applyx(IgniteInternalFuture fut) - throws IgniteCheckedException { - return fut.get().value(); - } - - @Override public String toString() { - return "Cache return value to value converter."; - } - }; - /** {@link GridCacheReturn}-to-null conversion. */ protected static final IgniteClosure RET2NULL = new CX1, Object>() { @@ -250,6 +237,19 @@ public abstract class GridCacheAdapter implements IgniteInternalCache, Object>() { + @Nullable @Override public Object applyx(IgniteInternalFuture fut) + throws IgniteCheckedException { + return fut.get().value(ctx); + } + + @Override public String toString() { + return "Cache return value to value converter."; + } + }; + /** Last asynchronous future. */ protected ThreadLocal lastFut = new ThreadLocal() { @Override protected FutureHolder initialValue() { @@ -1872,7 +1872,7 @@ protected V getAndPut0(final K key, final V val, @Nullable final CacheEntryPredi throws IgniteCheckedException { return syncOp(new SyncOp(true) { @Override public V op(GridNearTxLocal tx) throws IgniteCheckedException { - return (V)tx.putAsync(ctx, null, key, val, true, filter).get().value(); + return (V)tx.putAsync(ctx, null, key, val, true, filter).get().value(ctx); } @Override public String toString() { @@ -1925,7 +1925,7 @@ public IgniteInternalFuture getAndPutAsync0(final K key, @Nullable final CacheEntryPredicate filter) { return asyncOp(new AsyncOp() { @Override public IgniteInternalFuture op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) { - return tx.putAsync(ctx, readyTopVer, key, val, true, filter).chain(RET2VAL); + return tx.putAsync(ctx, readyTopVer, key, val, true, filter).chain(ret2val); } @Override public String toString() { @@ -2112,7 +2112,7 @@ private EntryProcessorResult invoke0( (EntryProcessor)entryProcessor, args); - Map> resMap = fut.get().value(); + Map> resMap = fut.get().value(ctx); if (statsEnabled) metrics0().addInvokeTimeNanos(System.nanoTime() - start); @@ -2155,7 +2155,7 @@ private EntryProcessorResult invoke0( IgniteInternalFuture fut = tx.invokeAsync(ctx, null, keys, invokeVals, args); - Map> res = fut.get().value(); + Map> res = fut.get().value(ctx); if (statsEnabled) metrics0().addInvokeTimeNanos(System.nanoTime() - start); @@ -2206,7 +2206,7 @@ private EntryProcessorResult invoke0( if (performanceStatsEnabled) writeStatistics(OperationType.CACHE_INVOKE, start); - Map> resMap = ret.value(); + Map> resMap = ret.value(ctx); if (resMap != null) { assert resMap.isEmpty() || resMap.size() == 1 : resMap.size(); @@ -2265,7 +2265,7 @@ private EntryProcessorResult invoke0( assert ret != null; - return ret.value() != null ? ret.value() : Collections.emptyMap(); + return ret.value(ctx) != null ? ret.value(ctx) : Collections.emptyMap(); } }); } @@ -2316,8 +2316,8 @@ private EntryProcessorResult invoke0( assert ret != null; - return ret.value() != null - ? ret.>>value() + return ret.value(ctx) != null + ? ret.>>value(ctx) : Collections.>emptyMap(); } }); @@ -2348,7 +2348,7 @@ private EntryProcessorResult invoke0( args ); - Map> val = fut.get().value(); + Map> val = fut.get().value(ctx); if (statsEnabled) metrics0().addInvokeTimeNanos(System.nanoTime() - start); @@ -2594,7 +2594,7 @@ protected V getAndRemove0(final K key) throws IgniteCheckedException { null, /*singleRmv*/false); - V ret = fut.get().value(); + V ret = fut.get().value(ctx); if (ctx.config().getInterceptor() != null) { K key = keepBinary ? (K)ctx.unwrapBinaryIfNeeded(key0, true, false, null) : key0; @@ -2645,7 +2645,7 @@ protected IgniteInternalFuture getAndRemoveAsync0(final K key) { Collections.singletonList(key), /*retval*/true, null, - /*singleRmv*/false).chain(RET2VAL); + /*singleRmv*/false).chain(ret2val); } @Override public String toString() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index bffb81619672c..63fbb5c1eea24 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -24,6 +24,7 @@ import javax.cache.processor.EntryProcessorResult; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.binary.BinaryObject; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.UnregisteredBinaryTypeException; import org.apache.ignite.internal.UnregisteredClassException; @@ -31,14 +32,14 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; /** * Return value for cases where both, value and success flag need to be returned. */ -public class GridCacheReturn implements Message, CacheIdAware { +public class GridCacheReturn implements MarshallableMessage, CacheIdAware { /** Value. */ @GridToStringInclude(sensitive = true) private volatile Object v; @@ -122,7 +123,27 @@ public GridCacheReturn( /** * @return Value. */ - @Nullable public V value() { + @Nullable public V value(GridCacheContext ctx) { + if (v == null) { + if (cacheObj != null) + v = ctx.cacheObjectContext().unwrapBinaryIfNeeded(cacheObj, true, false, U.gridClassLoader()); + + if (invokeRes && invokeResCol != null) { + Map map0 = U.newHashMap(invokeResCol.size()); + + for (CacheInvokeDirectResult res : invokeResCol) { + CacheInvokeResult res0 = res.error() == null ? + CacheInvokeResult.fromResult(ctx.cacheObjectContext().unwrapBinaryIfNeeded(res.result(), true, false, null)) : + CacheInvokeResult.fromError(res.error()); + + map0.put(ctx.cacheObjectContext().unwrapBinaryIfNeeded(res.key(), true, false, null), res0); + } + + v = map0; + } + } + + return (V)v; } @@ -327,32 +348,13 @@ public void marshalResult(GridCacheContext ctx) { } } - /** - * @param ctx Cache context. - * @param ldr Class loader. - * @throws IgniteCheckedException If failed. - */ - public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException { - loc = true; - - if (cacheObj != null) - v = ctx.cacheObjectContext().unwrapBinaryIfNeeded(cacheObj, true, false, ldr); - - if (invokeRes && invokeResCol != null) { - Map map0 = U.newHashMap(invokeResCol.size()); - - for (CacheInvokeDirectResult res : invokeResCol) { - CacheInvokeResult res0 = res.error() == null ? - CacheInvokeResult.fromResult(ctx.cacheObjectContext().unwrapBinaryIfNeeded(res.result(), true, false, null)) : - CacheInvokeResult.fromError(res.error()); - - map0.put(ctx.cacheObjectContext().unwrapBinaryIfNeeded(res.key(), true, false, null), res0); - } - - v = map0; - } + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + // No-op. } + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + loc = true; + } /** {@inheritDoc} */ @Override public String toString() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java index a9b194b10e0ac..edf857ca4822e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java @@ -359,7 +359,7 @@ final void completeFuture(@Nullable GridCacheReturn ret, Throwable err, @Nullabl ? null : (this.retval || op == TRANSFORM) ? cctx.unwrapBinaryIfNeeded( - ret.value(), + ret.value(cctx), keepBinary, U.deploymentClassLoader(cctx.kernalContext(), deploymentLdrId)) : ret.success(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java index e4ea94e5c80eb..beb506097160a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java @@ -250,9 +250,9 @@ else if (res.error() != null) if (op == TRANSFORM) { if (ret != null) { - assert ret.value() == null || ret.value() instanceof Map : ret.value(); + assert ret.value(cctx) == null || ret.value(cctx) instanceof Map : ret.value(cctx); - if (ret.value() != null) { + if (ret.value(cctx) != null) { if (opRes != null) opRes.mergeEntryProcessResults(ret); else diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java index 9a062e60fc748..91eae3a3e7cbd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java @@ -414,9 +414,9 @@ else if (res.error() != null) if (op == TRANSFORM) { if (ret != null) { - assert ret.value() == null || ret.value() instanceof Map : ret.value(); + assert ret.value(cctx) == null || ret.value(cctx) instanceof Map : ret.value(cctx); - if (ret.value() != null) { + if (ret.value(cctx) != null) { if (opRes != null) opRes.mergeEntryProcessResults(ret); else diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java index 04183f5c45431..491289ce66973 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java @@ -1791,7 +1791,7 @@ private IgniteInternalFuture removeAllAsync0( true, keepBinary, U.deploymentClassLoader(cctx.kernalContext(), deploymentLdrId), - implicitRes.value(), + implicitRes.value(cacheCtx), implicitRes.success() ); } @@ -2646,7 +2646,7 @@ private IgniteInternalFuture optimisticPutFuture( try { txFut.get(); - Object res = implicitRes.value(); + Object res = implicitRes.value(cacheCtx); if (implicitRes.invokeResult()) { assert res == null || res instanceof Map : implicitRes; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java index bf2ea8938c245..6af50e12b4c71 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java @@ -1187,7 +1187,7 @@ protected final void postLockWrite( } else { // Revert operation to previous. (if no - NOOP, so entry will be unlocked). - txEntry.setAndMarkValid(txEntry.previousOperation(), cacheCtx.toCacheObject(ret.value())); + txEntry.setAndMarkValid(txEntry.previousOperation(), cacheCtx.toCacheObject(ret.value(cacheCtx))); txEntry.filters(CU.empty0()); txEntry.filtersSet(false); From c18d43bc4475a93db478df8e202d1b98d5c03ea2 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 1 Jun 2026 18:24:20 +0300 Subject: [PATCH 072/215] WIP --- .../ignite/internal/MessageSerializerGenerator.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 73b92cf256feb..f57c4e7fd2071 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -282,7 +282,10 @@ private void generateMarshallMethods(List orderedFields) { if (isCacheIdAwareMessage(type)) marshall.add( indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.cacheId()) : nested;")); - else + else if (isCacheGroupIdMessage(type)) + marshall.add( + indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.groupId()) : nested;")); + else marshall.add(indentedLine("GridCacheContext ctx = nested;")); if (marshallableMessage()) { @@ -324,6 +327,9 @@ private void generateUnmarshallMethods(List orderedFields) { if (isCacheIdAwareMessage(type)) marshall.add( indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.cacheId()) : nested;")); + else if (isCacheGroupIdMessage(type)) + marshall.add( + indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.groupId()) : nested;")); else marshall.add(indentedLine("GridCacheContext ctx = nested;")); @@ -555,6 +561,11 @@ private boolean isCacheIdAwareMessage(TypeElement te) { return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.CacheIdAware")); } + /** True if {@code te} extends {@code CacheGroupIdMessage} and therefore carries its own per-group {@code groupId()}. */ + private boolean isCacheGroupIdMessage(TypeElement te) { + return assignableFrom(te.asType(), type("org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage")); + } + /** */ private String fieldAccessor(VariableElement field) { String name = field.getSimpleName().toString(); From d1e889aa73346ae2028ad2222da1415fc71eee44 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 1 Jun 2026 18:25:28 +0300 Subject: [PATCH 073/215] WIP --- .../ignite/internal/processors/cache/GridCacheReturn.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index 63fbb5c1eea24..4a7c701fb8b47 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -142,7 +142,6 @@ public GridCacheReturn( v = map0; } } - return (V)v; } @@ -348,10 +347,12 @@ public void marshalResult(GridCacheContext ctx) { } } + /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { // No-op. } + /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { loc = true; } From a3c81ff7e5d3976a0ec958c6b589231ab73ac56a Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 2 Jun 2026 00:29:18 +0300 Subject: [PATCH 074/215] WIP --- .../GridDhtPartitionsSingleMessage.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index c2685d3e2bb04..bf9e9967b1cd6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -21,13 +21,17 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Compress; +import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.marshaller.Marshaller; import org.jetbrains.annotations.Nullable; /** @@ -35,7 +39,7 @@ * * Sent in response to {@link GridDhtPartitionsSingleRequest} and during processing partitions exchange future. */ -public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage { +public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { /** Local partitions. */ @Order(0) @Compress @@ -286,6 +290,34 @@ public long exchangeStartTime() { public void exchangeStartTime(long exchangeStartTime) { this.exchangeStartTime = exchangeStartTime; } + + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + if (dupPartsData != null) { + assert parts != null; + + for (Map.Entry e : dupPartsData.entrySet()) { + GridDhtPartitionMap map1 = parts.get(e.getKey()); + + assert map1 != null : e.getKey(); + assert F.isEmpty(map1.map()); + assert !map1.hasMovingPartitions(); + + GridDhtPartitionMap map2 = parts.get(e.getValue()); + + assert map2 != null : e.getValue(); + assert map2.map() != null; + + for (Map.Entry e0 : map2.map().entrySet()) + map1.put(e0.getKey(), e0.getValue()); + } + } + } /** {@inheritDoc} */ @Override public String toString() { From 96998488d5dc7e3be6e78e55973879e90d620511 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 2 Jun 2026 14:48:52 +0300 Subject: [PATCH 075/215] WIP --- .../cache/distributed/dht/GridDhtTxPrepareRequest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 2486903e85f77..517c8f4fc0902 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -25,7 +25,6 @@ import java.util.Map; import java.util.UUID; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; @@ -45,7 +44,7 @@ /** * DHT prepare request. */ -public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest implements MarshallableMessage { +public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest { /** Max order. */ @Order(0) UUID nearNodeId; From df98f64c3825169a39b4ebde439df5780e916b1c Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 2 Jun 2026 16:53:16 +0300 Subject: [PATCH 076/215] WIP --- .../processors/cache/GridCacheIoManager.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index f6fb1ab0d42ef..86e1cb1c55465 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -92,7 +92,6 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; @@ -317,15 +316,6 @@ else if (desc.receivedFromStartVersion() != null) private void handleMessage(UUID nodeId, GridCacheMessage cacheMsg, byte plc) { MessageHandlers msgHandlers = cacheMsg instanceof GridCacheGroupIdMessage ? grpHandlers : cacheHandlers; - MessageSerializer ser = cctx.kernalContext().messageFactory().serializer(cacheMsg.directType()); - - try { - ser.finishUnmarshal(cacheMsg, cctx.kernalContext(), null); - } - catch (IgniteCheckedException e) { - throw new IgniteException("Failed to unmarshall entry", e); - } - Lock lock = rw.readLock(); lock.lock(); @@ -1560,10 +1550,6 @@ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) { if (log.isDebugEnabled()) log.debug("Set P2P context [senderId=" + nodeId + ", msg=" + cacheMsg + ']'); } - - MessageSerializer ser = cctx.kernalContext().messageFactory().serializer(cacheMsg.directType()); - - ser.finishUnmarshal(cacheMsg, cctx.kernalContext(), null); } catch (IgniteCheckedException e) { cacheMsg.onClassError(e); From 7e89c3f9cf48d1144de697d8357f9b449230403d Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 2 Jun 2026 17:27:46 +0300 Subject: [PATCH 077/215] WIP --- .../internal/MessageSerializerGenerator.java | 11 ++++++++-- .../communication/NonMarshallableMessage.java | 22 +++++++++++++++++++ .../h2/twostep/msg/GridH2ValueMessage.java | 4 ++-- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/NonMarshallableMessage.java diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index f57c4e7fd2071..c13f5bda396d3 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -258,8 +258,10 @@ private void generateMethods(List fields) throws Exception { finish(write); finish(read); - generateMarshallMethods(fields); - generateUnmarshallMethods(fields); + if (!isNonMarshallableMessage(type)) { + generateMarshallMethods(fields); + generateUnmarshallMethods(fields); + } } /** */ @@ -556,6 +558,11 @@ private boolean isMessage(TypeMirror type) { return assignableFrom(type, type(MESSAGE_INTERFACE)); } + /** */ + private boolean isNonMarshallableMessage(TypeElement te) { + return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage")); + } + /** True if {@code te} extends {@code CacheIdAware} and therefore carries its own per-cache {@code cacheId()}. */ private boolean isCacheIdAwareMessage(TypeElement te) { return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.CacheIdAware")); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/NonMarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/NonMarshallableMessage.java new file mode 100644 index 0000000000000..d2699d2f915a7 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/NonMarshallableMessage.java @@ -0,0 +1,22 @@ +/* + * 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; + +/** */ +public interface NonMarshallableMessage extends Message { +} diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java index c24857ef13a17..6ebbfab981f9b 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java @@ -19,13 +19,13 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage; import org.h2.value.Value; /** * Abstract message wrapper for H2 values. */ -public abstract class GridH2ValueMessage implements Message { +public abstract class GridH2ValueMessage implements NonMarshallableMessage { /** * Gets H2 value. * From b93b94040fdc1904708c0e23cabb2878c5914e9c Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 2 Jun 2026 17:56:38 +0300 Subject: [PATCH 078/215] WIP --- .../processors/datastreamer/DataStreamerRequest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java index 04af061465913..a16b6e4e63556 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java @@ -24,9 +24,11 @@ import org.apache.ignite.internal.GridTopicMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.cache.GridCacheUtils; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.plugin.extensions.communication.CacheIdAware; import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,7 +36,7 @@ /** * */ -public class DataStreamerRequest implements Message { +public class DataStreamerRequest implements Message, CacheIdAware { /** */ @Order(0) long reqId; @@ -280,4 +282,9 @@ public int partition() { @Override public String toString() { return S.toString(DataStreamerRequest.class, this); } + + /** {@inheritDoc} */ + @Override public int cacheId() { + return GridCacheUtils.cacheId(cacheName); + } } From c2de1458adbc6af83a316374c28bf06e1268a353 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 2 Jun 2026 20:24:59 +0300 Subject: [PATCH 079/215] WIP --- .../ignite/internal/processors/cache/GridCacheReturn.java | 4 ++-- .../dht/atomic/GridNearAtomicSingleUpdateFuture.java | 2 +- .../distributed/dht/atomic/GridNearAtomicUpdateFuture.java | 2 +- .../processors/cache/transactions/IgniteTxLocalAdapter.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index 4a7c701fb8b47..47921a5988213 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -314,12 +314,12 @@ else if (err instanceof UnregisteredBinaryTypeException) /** * @param other Other result to merge with. */ - public synchronized void mergeEntryProcessResults(GridCacheReturn other) { + public synchronized void mergeEntryProcessResults(GridCacheContext ctx, GridCacheReturn other) { assert invokeRes || v == null : "Invalid state to merge: " + this; assert other.invokeRes; assert loc == other.loc : loc; - if (other.v == null) + if (other.value(ctx) == null) return; invokeRes = true; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java index beb506097160a..81da4bd9ab14d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java @@ -254,7 +254,7 @@ else if (res.error() != null) if (ret.value(cctx) != null) { if (opRes != null) - opRes.mergeEntryProcessResults(ret); + opRes.mergeEntryProcessResults(cctx, ret); else opRes = ret; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java index 91eae3a3e7cbd..ab5f74316bca6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java @@ -418,7 +418,7 @@ else if (res.error() != null) if (ret.value(cctx) != null) { if (opRes != null) - opRes.mergeEntryProcessResults(ret); + opRes.mergeEntryProcessResults(cctx, ret); else opRes = ret; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java index 6af50e12b4c71..f40622de14108 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java @@ -326,7 +326,7 @@ public void implicitSingleResult(GridCacheReturn ret) { assert ret != null; if (ret.invokeResult()) - implicitRes.mergeEntryProcessResults(ret); + implicitRes.mergeEntryProcessResults(cctx.cacheContext(ret.cacheId()), ret); else implicitRes = ret; } From cf1f904921898e3fbf637b95808df85cb0ce4401 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 2 Jun 2026 21:37:47 +0300 Subject: [PATCH 080/215] WIP --- .../internal/MessageSerializerGenerator.java | 6 +++--- .../internal/processors/cache/tree/DataRow.java | 15 +++------------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index c13f5bda396d3..62d63be9c1831 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -421,14 +421,14 @@ else if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { else if (isCacheObject(t)) { List code = new ArrayList<>(); - code.add(indentedLine("if (%s != null)", accessor)); + code.add(indentedLine("if (%s != null && ctx != null)", accessor)); indent++; if (!unmarshall) - code.add(indentedLine("%s.prepareMarshal(ctx != null ? ctx.cacheObjectContext() : null);", accessor)); + code.add(indentedLine("%s.prepareMarshal(ctx.cacheObjectContext());", accessor)); else - code.add(indentedLine("%s.finishUnmarshal(ctx != null ? ctx.cacheObjectContext() : null, clsLdr);", accessor)); + code.add(indentedLine("%s.finishUnmarshal(ctx.cacheObjectContext(), clsLdr);", accessor)); indent--; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java index 362a0d9e15aac..4f91f8e8de829 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java @@ -45,8 +45,7 @@ public class DataRow extends CacheDataRowAdapter { */ protected DataRow(CacheGroupContext grp, int hash, long link, int part, RowData rowData, boolean skipVer) { super(link); - - this.hash = hash; + this.part = part; try { @@ -71,8 +70,7 @@ protected DataRow(CacheGroupContext grp, int hash, long link, int part, RowData */ public DataRow(KeyCacheObject key, CacheObject val, GridCacheVersion ver, int part, long expireTime, int cacheId) { super(0); - - this.hash = key.hashCode(); + this.key = key; this.val = val; this.ver = ver; @@ -90,13 +88,6 @@ public DataRow() { super(0); } - /** {@inheritDoc} */ - @Override public void key(KeyCacheObject key) { - super.key(key); - - hash = key.hashCode(); - } - /** {@inheritDoc} */ @Override public int partition() { return part; @@ -111,7 +102,7 @@ public void partition(int partId) { /** {@inheritDoc} */ @Override public int hash() { - return hash; + return hash = key.hashCode(); } /** {@inheritDoc} */ From a121eec8b3129315101077ca49ec3fb3844db0ee Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 2 Jun 2026 21:42:03 +0300 Subject: [PATCH 081/215] WIP --- .../codegen/MessageProcessorTest.java | 30 ----- .../codegen/KeyCacheObjectEntryMsg.java | 35 ------ .../KeyCacheObjectEntryMsgSerializer.java | 95 --------------- .../TestKeyCacheObjectCollectionMessage.java | 34 ------ ...acheObjectCollectionMessageSerializer.java | 112 ------------------ .../codegen/TestMapKeyCacheObjectMessage.java | 33 ------ ...estMapKeyCacheObjectMessageSerializer.java | 94 --------------- 7 files changed, 433 deletions(-) delete mode 100644 modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsg.java delete mode 100644 modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsgSerializer.java delete mode 100644 modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessage.java delete mode 100644 modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessageSerializer.java delete mode 100644 modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessage.java delete mode 100644 modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessageSerializer.java diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java index 89fd3aae12c15..e1e2e38dbbf5c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java @@ -340,36 +340,6 @@ public void testCompressedMessageExplicitUsageFails() { assertThat(compilation).hadErrorContaining(errMsg); } - /** Collection-of-entries encoding of a {@code Map}: generator recurses into each entry's KCO. */ - @Test - public void testKeyCacheObjectInCollectionOfEntries() { - Compilation compilation = compile("KeyCacheObjectEntryMsg.java", "TestKeyCacheObjectCollectionMessage.java"); - - assertThat(compilation).succeeded(); - - assertEquals(2, compilation.generatedSourceFiles().size()); - - assertThat(compilation) - .generatedSourceFile("org.apache.ignite.internal.KeyCacheObjectEntryMsgSerializer") - .hasSourceEquivalentTo(javaFile("KeyCacheObjectEntryMsgSerializer.java")); - - assertThat(compilation) - .generatedSourceFile("org.apache.ignite.internal.TestKeyCacheObjectCollectionMessageSerializer") - .hasSourceEquivalentTo(javaFile("TestKeyCacheObjectCollectionMessageSerializer.java")); - } - -/** {@code @Order Map}: generator walks keys/values via {@code keySet()/values()}. */ - @Test - public void testMapWithKeyCacheObjectAndMessageValue() { - Compilation compilation = compile("TestMapKeyCacheObjectMessage.java"); - - assertThat(compilation).succeeded(); - - assertThat(compilation) - .generatedSourceFile("org.apache.ignite.internal.TestMapKeyCacheObjectMessageSerializer") - .hasSourceEquivalentTo(javaFile("TestMapKeyCacheObjectMessageSerializer.java")); - } - /** * Negative test that verifies the compilation failed if the Compress annotation is used for unsupported types. */ diff --git a/modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsg.java b/modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsg.java deleted file mode 100644 index 80d23d2e6ad09..0000000000000 --- a/modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsg.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal; - -import org.apache.ignite.internal.processors.cache.KeyCacheObject; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.plugin.extensions.communication.Message; - -/** APT fixture: entry Message for {@link TestKeyCacheObjectCollectionMessage}. */ -public class KeyCacheObjectEntryMsg implements Message { - @Order(0) - KeyCacheObject key; - - @Order(1) - GridCacheVersion val; - - public short directType() { - return 0; - } -} diff --git a/modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsgSerializer.java b/modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsgSerializer.java deleted file mode 100644 index 59e90a33c9ade..0000000000000 --- a/modules/core/src/test/resources/codegen/KeyCacheObjectEntryMsgSerializer.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal; - -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.KeyCacheObjectEntryMsg; -import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersionSerializer; -import org.apache.ignite.plugin.extensions.communication.MessageReader; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; -import org.apache.ignite.plugin.extensions.communication.MessageWriter; - -/** - * This class is generated automatically. - * - * @see org.apache.ignite.internal.MessageProcessor - */ -public class KeyCacheObjectEntryMsgSerializer implements MessageSerializer { - /** */ - private final static GridCacheVersionSerializer GRID_CACHE_VERSION_SER = new GridCacheVersionSerializer(); - - /** */ - @Override public boolean writeTo(KeyCacheObjectEntryMsg msg, MessageWriter writer) { - if (!writer.isHeaderWritten()) { - if (!writer.writeHeader(msg.directType())) - return false; - - writer.onHeaderWritten(); - } - - switch (writer.state()) { - case 0: - if (!writer.writeKeyCacheObject(msg.key)) - return false; - - writer.incrementState(); - - case 1: - if (!writer.writeMessage(msg.val)) - return false; - - writer.incrementState(); - } - - return true; - } - - /** */ - @Override public boolean readFrom(KeyCacheObjectEntryMsg msg, MessageReader reader) { - switch (reader.state()) { - case 0: - msg.key = reader.readKeyCacheObject(); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - - case 1: - msg.val = reader.readMessage(); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - } - - return true; - } - - /** */ - @Override public void prepareMarshalCacheObjects(KeyCacheObjectEntryMsg msg, CacheObjectValueContext ctx, GridCacheSharedContext sharedCtx) throws IgniteCheckedException { - if (msg.key != null) - msg.key.prepareMarshal(ctx); - - if (msg.val != null) - GRID_CACHE_VERSION_SER.prepareMarshalCacheObjects(msg.val, ctx, sharedCtx); - } -} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessage.java b/modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessage.java deleted file mode 100644 index b2a42705003a2..0000000000000 --- a/modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessage.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal; - -import java.util.Collection; -import org.apache.ignite.plugin.extensions.communication.Message; - -/** APT fixture: collection-of-entries replacement for an {@code @Order Map} field. */ -public class TestKeyCacheObjectCollectionMessage implements Message { - @Order(0) - Collection entries; - - @Order(1) - KeyCacheObjectEntryMsg[] entriesArr; - - public short directType() { - return 1; - } -} diff --git a/modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessageSerializer.java b/modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessageSerializer.java deleted file mode 100644 index 70510b79eee0c..0000000000000 --- a/modules/core/src/test/resources/codegen/TestKeyCacheObjectCollectionMessageSerializer.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal; - -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.KeyCacheObjectEntryMsg; -import org.apache.ignite.internal.KeyCacheObjectEntryMsgSerializer; -import org.apache.ignite.internal.TestKeyCacheObjectCollectionMessage; -import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.plugin.extensions.communication.MessageArrayType; -import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; -import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; -import org.apache.ignite.plugin.extensions.communication.MessageItemType; -import org.apache.ignite.plugin.extensions.communication.MessageReader; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; -import org.apache.ignite.plugin.extensions.communication.MessageWriter; - -/** - * This class is generated automatically. - * - * @see org.apache.ignite.internal.MessageProcessor - */ -public class TestKeyCacheObjectCollectionMessageSerializer implements MessageSerializer { - /** */ - private final static KeyCacheObjectEntryMsgSerializer KEY_CACHE_OBJECT_ENTRY_MSG_SER = new KeyCacheObjectEntryMsgSerializer(); - /** */ - private static final MessageArrayType entriesArrCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.MSG), KeyCacheObjectEntryMsg.class); - /** */ - private static final MessageCollectionType entriesCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.MSG), false); - - /** */ - @Override public boolean writeTo(TestKeyCacheObjectCollectionMessage msg, MessageWriter writer) { - if (!writer.isHeaderWritten()) { - if (!writer.writeHeader(msg.directType())) - return false; - - writer.onHeaderWritten(); - } - - switch (writer.state()) { - case 0: - if (!writer.writeCollection(msg.entries, entriesCollDesc)) - return false; - - writer.incrementState(); - - case 1: - if (!writer.writeObjectArray(msg.entriesArr, entriesArrCollDesc)) - return false; - - writer.incrementState(); - } - - return true; - } - - /** */ - @Override public boolean readFrom(TestKeyCacheObjectCollectionMessage msg, MessageReader reader) { - switch (reader.state()) { - case 0: - msg.entries = reader.readCollection(entriesCollDesc); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - - case 1: - msg.entriesArr = reader.readObjectArray(entriesArrCollDesc); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - } - - return true; - } - - /** */ - @Override public void prepareMarshalCacheObjects(TestKeyCacheObjectCollectionMessage msg, CacheObjectValueContext ctx, GridCacheSharedContext sharedCtx) throws IgniteCheckedException { - if (msg.entries != null) { - for (KeyCacheObjectEntryMsg e : msg.entries) { - if (e != null) - KEY_CACHE_OBJECT_ENTRY_MSG_SER.prepareMarshalCacheObjects(e, ctx, sharedCtx); - } - } - - if (msg.entriesArr != null) { - for (KeyCacheObjectEntryMsg e : msg.entriesArr) { - if (e != null) - KEY_CACHE_OBJECT_ENTRY_MSG_SER.prepareMarshalCacheObjects(e, ctx, sharedCtx); - } - } - } -} diff --git a/modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessage.java b/modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessage.java deleted file mode 100644 index 1956319cef672..0000000000000 --- a/modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessage.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal; - -import java.util.Map; -import org.apache.ignite.internal.processors.cache.KeyCacheObject; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.plugin.extensions.communication.Message; - -/** APT fixture: {@code @Order Map} is safe — deferred {@code HashMap} assembly. */ -public class TestMapKeyCacheObjectMessage implements Message { - @Order(0) - Map entries; - - public short directType() { - return 0; - } -} diff --git a/modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessageSerializer.java deleted file mode 100644 index c7217c0dba9e3..0000000000000 --- a/modules/core/src/test/resources/codegen/TestMapKeyCacheObjectMessageSerializer.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal; - -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.TestMapKeyCacheObjectMessage; -import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.KeyCacheObject; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersionSerializer; -import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; -import org.apache.ignite.plugin.extensions.communication.MessageItemType; -import org.apache.ignite.plugin.extensions.communication.MessageMapType; -import org.apache.ignite.plugin.extensions.communication.MessageReader; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; -import org.apache.ignite.plugin.extensions.communication.MessageWriter; - -/** - * This class is generated automatically. - * - * @see org.apache.ignite.internal.MessageProcessor - */ -public class TestMapKeyCacheObjectMessageSerializer implements MessageSerializer { - /** */ - private final static GridCacheVersionSerializer GRID_CACHE_VERSION_SER = new GridCacheVersionSerializer(); - /** */ - private static final MessageMapType entriesCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.KEY_CACHE_OBJECT), new MessageItemType(MessageCollectionItemType.MSG), false); - - /** */ - @Override public boolean writeTo(TestMapKeyCacheObjectMessage msg, MessageWriter writer) { - if (!writer.isHeaderWritten()) { - if (!writer.writeHeader(msg.directType())) - return false; - - writer.onHeaderWritten(); - } - - switch (writer.state()) { - case 0: - if (!writer.writeMap(msg.entries, entriesCollDesc)) - return false; - - writer.incrementState(); - } - - return true; - } - - /** */ - @Override public boolean readFrom(TestMapKeyCacheObjectMessage msg, MessageReader reader) { - switch (reader.state()) { - case 0: - msg.entries = reader.readMap(entriesCollDesc); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - } - - return true; - } - - /** */ - @Override public void prepareMarshalCacheObjects(TestMapKeyCacheObjectMessage msg, CacheObjectValueContext ctx, GridCacheSharedContext sharedCtx) throws IgniteCheckedException { - if (msg.entries != null) { - for (KeyCacheObject k : msg.entries.keySet()) { - if (k != null) - k.prepareMarshal(ctx); - } - - for (GridCacheVersion v : msg.entries.values()) { - if (v != null) - GRID_CACHE_VERSION_SER.prepareMarshalCacheObjects(v, ctx, sharedCtx); - } - } - } -} \ No newline at end of file From 761fa74116a2a6489c14454eb546f9fd30b28742 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 2 Jun 2026 21:45:29 +0300 Subject: [PATCH 082/215] WIP --- .../src/test/resources/codegen/TestCollectionsMessage.java | 4 ++++ modules/core/src/test/resources/codegen/TestMapMessage.java | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/modules/core/src/test/resources/codegen/TestCollectionsMessage.java b/modules/core/src/test/resources/codegen/TestCollectionsMessage.java index 312d5e91f8122..16d384b8e6a22 100644 --- a/modules/core/src/test/resources/codegen/TestCollectionsMessage.java +++ b/modules/core/src/test/resources/codegen/TestCollectionsMessage.java @@ -22,6 +22,7 @@ import java.util.Set; import java.util.UUID; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.GridLongList; import org.apache.ignite.lang.IgniteUuid; @@ -103,6 +104,9 @@ public class TestCollectionsMessage implements Message { @Order(24) Set bitSetSet; + @Order(25) + Set cacheObjectSet; + public short directType() { return 0; } diff --git a/modules/core/src/test/resources/codegen/TestMapMessage.java b/modules/core/src/test/resources/codegen/TestMapMessage.java index 71a20da923709..f33fd2cc0a679 100644 --- a/modules/core/src/test/resources/codegen/TestMapMessage.java +++ b/modules/core/src/test/resources/codegen/TestMapMessage.java @@ -22,6 +22,8 @@ import java.util.Map; import java.util.UUID; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.GridLongList; import org.apache.ignite.lang.IgniteUuid; @@ -103,6 +105,9 @@ public class TestMapMessage implements Message { @Order(24) Map>> gridlistDoubleMapUuidMap; + @Order(25) + Map>> gridCacheObjectMap; + public short directType() { return 0; } From 95301d198d9d4d1c97996d8515aebdf89f8c6b34 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 2 Jun 2026 22:00:38 +0300 Subject: [PATCH 083/215] WIP --- .../internal/MessageSerializerGenerator.java | 1 + .../codegen/ChildMessageSerializer.java | 22 +++++ ...stomMapperEnumFieldsMessageSerializer.java | 23 ++++- ...aultMapperEnumFieldsMessageSerializer.java | 21 +++++ .../TestCollectionsMessageSerializer.java | 79 ++++++++++++++-- .../codegen/TestMapMessageSerializer.java | 93 +++++++++++++++++-- ...hallableMessageMarshallableSerializer.java | 35 +++---- .../codegen/TestMessageSerializer.java | 53 ++++++++--- 8 files changed, 284 insertions(+), 43 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 62d63be9c1831..a063591ae4dbc 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -237,6 +237,7 @@ private void writeConstructor(Writer writer, String serClsName) throws IOExcepti writer.write(indentedLine("}")); writer.write(NL); + writer.write(NL); --indent; } diff --git a/modules/core/src/test/resources/codegen/ChildMessageSerializer.java b/modules/core/src/test/resources/codegen/ChildMessageSerializer.java index 9ca035db40488..b6240fb7950c0 100644 --- a/modules/core/src/test/resources/codegen/ChildMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/ChildMessageSerializer.java @@ -17,8 +17,12 @@ package org.apache.ignite.internal; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.AbstractMessage; import org.apache.ignite.internal.ChildMessage; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageWriter; @@ -29,6 +33,14 @@ * @see org.apache.ignite.internal.MessageProcessor */ public class ChildMessageSerializer implements MessageSerializer { + /** */ + private final ClassLoader clsLdr; + + /** */ + public ChildMessageSerializer(ClassLoader clsLdr) { + this.clsLdr = clsLdr; + } + /** */ @Override public boolean writeTo(ChildMessage msg, MessageWriter writer) { if (!writer.isHeaderWritten()) { @@ -105,4 +117,14 @@ public class ChildMessageSerializer implements MessageSerializer { return true; } + + /** */ + @Override public void prepareMarshal(ChildMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } + + /** */ + @Override public void finishUnmarshal(ChildMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageSerializer.java b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageSerializer.java index db939d0825792..d872ab9f912e3 100644 --- a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageSerializer.java @@ -17,8 +17,12 @@ package org.apache.ignite.internal; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.CustomMapperEnumFieldsMessage; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TransactionIsolationEnumMapper; +import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageWriter; @@ -31,9 +35,16 @@ * @see org.apache.ignite.internal.MessageProcessor */ public class CustomMapperEnumFieldsMessageSerializer implements MessageSerializer { + /** */ + private final ClassLoader clsLdr; /** */ private final EnumMapper transactionIsolationMapper = new TransactionIsolationEnumMapper(); + /** */ + public CustomMapperEnumFieldsMessageSerializer(ClassLoader clsLdr) { + this.clsLdr = clsLdr; + } + /** */ @Override public boolean writeTo(CustomMapperEnumFieldsMessage msg, MessageWriter writer) { if (!writer.isHeaderWritten()) { @@ -68,4 +79,14 @@ public class CustomMapperEnumFieldsMessageSerializer implements MessageSerialize return true; } -} \ No newline at end of file + + /** */ + @Override public void prepareMarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } + + /** */ + @Override public void finishUnmarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } +} diff --git a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageSerializer.java b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageSerializer.java index 245f1f29ae8e5..2373889c522a9 100644 --- a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageSerializer.java @@ -17,7 +17,11 @@ package org.apache.ignite.internal; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.DefaultMapperEnumFieldsMessage; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; @@ -31,11 +35,18 @@ * @see org.apache.ignite.internal.MessageProcessor */ public class DefaultMapperEnumFieldsMessageSerializer implements MessageSerializer { + /** */ + private final ClassLoader clsLdr; /** */ private final GridCacheOperation[] gridCacheOperationVals = GridCacheOperation.values(); /** */ private final TransactionIsolation[] transactionIsolationVals = TransactionIsolation.values(); + /** */ + public DefaultMapperEnumFieldsMessageSerializer(ClassLoader clsLdr) { + this.clsLdr = clsLdr; + } + /** */ @Override public boolean writeTo(DefaultMapperEnumFieldsMessage msg, MessageWriter writer) { if (!writer.isHeaderWritten()) { @@ -84,4 +95,14 @@ public class DefaultMapperEnumFieldsMessageSerializer implements MessageSerializ return true; } + + /** */ + @Override public void prepareMarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } + + /** */ + @Override public void finishUnmarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java b/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java index 496d5c889d7e1..af2a9ba623bd5 100644 --- a/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java @@ -17,12 +17,28 @@ package org.apache.ignite.internal; +import java.lang.Boolean; +import java.lang.Byte; +import java.lang.Character; +import java.lang.Double; +import java.lang.Float; +import java.lang.Integer; +import java.lang.Long; +import java.lang.Short; +import java.lang.String; +import java.util.BitSet; +import java.util.Collection; +import java.util.UUID; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestCollectionsMessage; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersionSerializer; +import org.apache.ignite.internal.util.GridLongList; +import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; import org.apache.ignite.plugin.extensions.communication.MessageItemType; @@ -37,7 +53,7 @@ */ public class TestCollectionsMessageSerializer implements MessageSerializer { /** */ - private final static GridCacheVersionSerializer GRID_CACHE_VERSION_SER = new GridCacheVersionSerializer(); + private final ClassLoader clsLdr; /** */ private static final MessageCollectionType affTopVersionListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.AFFINITY_TOPOLOGY_VERSION), false); /** */ @@ -67,6 +83,8 @@ public class TestCollectionsMessageSerializer implements MessageSerializer nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + if (msg.messageList != null) { - for (GridCacheVersion e : msg.messageList) { - if (e != null) - GRID_CACHE_VERSION_SER.prepareMarshalCacheObjects(e, ctx, sharedCtx); + for (GridCacheVersion e2 : (Collection)msg.messageList) { + if (e2 != null) + kctx.messageFactory().serializer(e2.directType()).prepareMarshal(e2, kctx, ctx); + } + } + + if (msg.cacheObjectSet != null) { + for (CacheObject e2 : (Collection)msg.cacheObjectSet) { + if (e2 != null && ctx != null) + e2.prepareMarshal(ctx.cacheObjectContext()); + } + } + } + + /** */ + @Override public void finishUnmarshal(TestCollectionsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.messageList != null) { + for (GridCacheVersion e2 : (Collection)msg.messageList) { + if (e2 != null) + kctx.messageFactory().serializer(e2.directType()).finishUnmarshal(e2, kctx, ctx); + } + } + + if (msg.cacheObjectSet != null) { + for (CacheObject e2 : (Collection)msg.cacheObjectSet) { + if (e2 != null && ctx != null) + e2.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); } } } diff --git a/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java index d210abbc82ba8..9eb4912e0098c 100644 --- a/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java @@ -17,12 +17,18 @@ package org.apache.ignite.internal; +import java.lang.Double; +import java.util.Collection; +import java.util.List; +import java.util.Map; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMapMessage; +import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersionSerializer; import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; import org.apache.ignite.plugin.extensions.communication.MessageItemType; @@ -38,7 +44,7 @@ */ public class TestMapMessageSerializer implements MessageSerializer { /** */ - private final static GridCacheVersionSerializer GRID_CACHE_VERSION_SER = new GridCacheVersionSerializer(); + private final ClassLoader clsLdr; /** */ private static final MessageMapType affTopVersionIgniteUuidMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.AFFINITY_TOPOLOGY_VERSION), new MessageItemType(MessageCollectionItemType.IGNITE_UUID), false); /** */ @@ -70,6 +76,8 @@ public class TestMapMessageSerializer implements MessageSerializer nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + if (msg.messageBoxedDoubleMap != null) { - for (GridCacheVersion k : msg.messageBoxedDoubleMap.keySet()) { - if (k != null) - GRID_CACHE_VERSION_SER.prepareMarshalCacheObjects(k, ctx, sharedCtx); + for (GridCacheVersion e3 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { + if (e3 != null) + kctx.messageFactory().serializer(e3.directType()).prepareMarshal(e3, kctx, ctx); + } + } + + if (msg.gridCacheObjectMap != null) { + for (KeyCacheObject e3 : ((Collection)msg.gridCacheObjectMap.keySet())) { + if (e3 != null && ctx != null) + e3.prepareMarshal(ctx.cacheObjectContext()); + } + for (Map e3 : ((Collection)msg.gridCacheObjectMap.values())) { + if (e3 != null) { + for (List e5 : ((Collection)e3.values())) { + if (e5 != null) { + for (CacheObject e6 : (Collection)e5) { + if (e6 != null && ctx != null) + e6.prepareMarshal(ctx.cacheObjectContext()); + } + } + } + } + } + } + } + + /** */ + @Override public void finishUnmarshal(TestMapMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.messageBoxedDoubleMap != null) { + for (GridCacheVersion e3 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { + if (e3 != null) + kctx.messageFactory().serializer(e3.directType()).finishUnmarshal(e3, kctx, ctx); + } + } + + if (msg.gridCacheObjectMap != null) { + for (KeyCacheObject e3 : ((Collection)msg.gridCacheObjectMap.keySet())) { + if (e3 != null && ctx != null) + e3.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + } + for (Map e3 : ((Collection)msg.gridCacheObjectMap.values())) { + if (e3 != null) { + for (List e5 : ((Collection)e3.values())) { + if (e5 != null) { + for (CacheObject e6 : (Collection)e5) { + if (e6 != null && ctx != null) + e6.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + } + } + } + } } } } diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java index 011985a05f0dd..5e914a3d6e52c 100644 --- a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java @@ -18,8 +18,10 @@ package org.apache.ignite.internal; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMarshallableMessage; +import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; @@ -41,19 +43,13 @@ public TestMarshallableMessageMarshallableSerializer(Marshaller marshaller, Clas this.marshaller = marshaller; this.clsLdr = clsLdr; } + /** */ @Override public boolean writeTo(TestMarshallableMessage msg, MessageWriter writer) { if (!writer.isHeaderWritten()) { if (!writer.writeHeader(msg.directType())) return false; - try { - msg.prepareMarshal(marshaller); - } - catch (IgniteCheckedException e) { - throw new IgniteException("Failed to marshal object " + msg.getClass().getSimpleName(), e); - } - writer.onHeaderWritten(); } @@ -108,13 +104,20 @@ public TestMarshallableMessageMarshallableSerializer(Marshaller marshaller, Clas reader.incrementState(); } - try { - msg.finishUnmarshal(marshaller, clsLdr); - } - catch (IgniteCheckedException e) { - throw new IgniteException("Failed to unmarshal object " + msg.getClass().getSimpleName(), e); - } - return true; } -} + + /** */ + @Override public void prepareMarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + msg.prepareMarshal(marshaller); + } + + /** */ + @Override public void finishUnmarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + msg.finishUnmarshal(marshaller, clsLdr); + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMessageSerializer.java index 78a12508dae5c..8ab43ab776765 100644 --- a/modules/core/src/test/resources/codegen/TestMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestMessageSerializer.java @@ -17,12 +17,13 @@ package org.apache.ignite.internal; +import java.lang.String; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMessage; import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersionSerializer; import org.apache.ignite.plugin.extensions.communication.MessageArrayType; import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; import org.apache.ignite.plugin.extensions.communication.MessageItemType; @@ -37,7 +38,7 @@ */ public class TestMessageSerializer implements MessageSerializer { /** */ - private final static GridCacheVersionSerializer GRID_CACHE_VERSION_SER = new GridCacheVersionSerializer(); + private final ClassLoader clsLdr; /** */ private static final MessageArrayType intMatrixCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.INT_ARR), int[].class); /** */ @@ -45,6 +46,11 @@ public class TestMessageSerializer implements MessageSerializer { /** */ private static final MessageArrayType verArrCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.MSG), GridCacheVersion.class); + /** */ + public TestMessageSerializer(ClassLoader clsLdr) { + this.clsLdr = clsLdr; + } + /** */ @Override public boolean writeTo(TestMessage msg, MessageWriter writer) { if (!writer.isHeaderWritten()) { @@ -277,21 +283,44 @@ public class TestMessageSerializer implements MessageSerializer { } /** */ - @Override public void prepareMarshalCacheObjects(TestMessage msg, CacheObjectValueContext ctx, GridCacheSharedContext sharedCtx) throws IgniteCheckedException { + @Override public void prepareMarshal(TestMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.ver != null) + kctx.messageFactory().serializer(msg.ver.directType()).prepareMarshal(msg.ver, kctx, ctx); + + if (msg.verArr != null) { + for (GridCacheVersion e3 : msg.verArr) { + if (e3 != null) + kctx.messageFactory().serializer(e3.directType()).prepareMarshal(e3, kctx, ctx); + } + } + + if (msg.keyCacheObject != null && ctx != null) + msg.keyCacheObject.prepareMarshal(ctx.cacheObjectContext()); + + if (msg.cacheObject != null && ctx != null) + msg.cacheObject.prepareMarshal(ctx.cacheObjectContext()); + } + + /** */ + @Override public void finishUnmarshal(TestMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + if (msg.ver != null) - GRID_CACHE_VERSION_SER.prepareMarshalCacheObjects(msg.ver, ctx, sharedCtx); + kctx.messageFactory().serializer(msg.ver.directType()).finishUnmarshal(msg.ver, kctx, ctx); if (msg.verArr != null) { - for (GridCacheVersion e : msg.verArr) { - if (e != null) - GRID_CACHE_VERSION_SER.prepareMarshalCacheObjects(e, ctx, sharedCtx); + for (GridCacheVersion e3 : msg.verArr) { + if (e3 != null) + kctx.messageFactory().serializer(e3.directType()).finishUnmarshal(e3, kctx, ctx); } } - if (msg.keyCacheObject != null) - msg.keyCacheObject.prepareMarshal(ctx); + if (msg.keyCacheObject != null && ctx != null) + msg.keyCacheObject.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); - if (msg.cacheObject != null) - msg.cacheObject.prepareMarshal(ctx); + if (msg.cacheObject != null && ctx != null) + msg.cacheObject.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); } } \ No newline at end of file From 4a5a25b5bc835cc62c5b8a0ba526996d039f89ca Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 2 Jun 2026 22:33:37 +0300 Subject: [PATCH 084/215] WIP --- .../spi/discovery/zk/internal/DiscoveryMessageParser.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index efba2098bddb9..501791cdacb7a 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -140,6 +140,13 @@ private T deserializeMessage(InputStream in) throws IOExcept } while (!finished); + try { + msgSer.finishUnmarshal(msg, ((IgniteEx)spi.ignite()).context(), null); + } + catch (IgniteCheckedException e) { + throw new IgniteSpiException("Failed to unmarshal joining node data", e); + } + return (T)msg; } } From 4b32a93ad6ffbbea99a62e452f65b5c90f753d63 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 3 Jun 2026 14:34:17 +0300 Subject: [PATCH 085/215] WIP --- .../ignite/internal/managers/communication/GridIoManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 491203ec6e6a1..64c6d518fee1a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1176,6 +1176,10 @@ private void onChannelOpened0(UUID rmtNodeId, GridIoMessage initMsg, Channel cha byte plc = initMsg.policy(); + MessageSerializer ser = ctx.messageFactory().serializer(initMsg.directType()); + + ser.finishUnmarshal(initMsg, ctx, null); + pools.poolForPolicy(plc).execute(new Runnable() { @Override public void run() { processOpenedChannel(initMsg.topic(), rmtNodeId, (SessionChannelMessage)initMsg.message(), From acc45d9cfd1f3bcfb0af5a1cd1282324d7608237 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 3 Jun 2026 18:40:01 +0300 Subject: [PATCH 086/215] WIP --- .../org/apache/ignite/internal/MessageSerializerGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index a063591ae4dbc..0a25a8aaad19b 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -350,7 +350,7 @@ else if (isCacheGroupIdMessage(type)) if (marshallableMessage()) { marshall.add(EMPTY); - marshall.add(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);")); + marshall.add(indentedLine("msg.finishUnmarshal(marshaller, ctx != null ? ctx.deploy().globalLoader() : clsLdr);")); } indent--; From 9426f97103b1dcdb472bfb36770aef0e10a6e004 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 4 Jun 2026 17:04:02 +0300 Subject: [PATCH 087/215] WIP --- .../message/CalciteMessageFactory.java | 24 ++--- .../calcite/message/GenericValueMessage.java | 2 +- .../calcite/message/QueryStartRequest.java | 2 +- .../calcite/metadata/ColocationGroup.java | 2 +- .../ignite/internal/MessageProcessor.java | 2 +- .../internal/MessageSerializerGenerator.java | 90 ++++++++++++++----- .../ignite/internal/CoreMessagesProvider.java | 33 +++---- .../internal/GridJobSiblingsResponse.java | 1 + .../ignite/internal/GridTopicMessage.java | 1 + .../CompressedMessageSerializer.java | 4 - .../managers/communication/ErrorMessage.java | 2 +- .../managers/communication/GridIoManager.java | 4 +- .../communication/IgniteIoTestMessage.java | 2 +- .../eventstorage/GridEventStorageMessage.java | 2 +- ...actMarshallableMessageFactoryProvider.java | 17 +--- .../cache/DynamicCacheChangeRequest.java | 2 +- .../processors/cache/GridCacheEntryInfo.java | 2 +- .../processors/cache/GridCacheIoManager.java | 5 ++ .../processors/cache/GridCacheReturn.java | 2 +- .../processors/cache/StoredCacheData.java | 2 +- .../binary/BinaryMetadataVersionInfo.java | 2 +- .../binary/MetadataUpdateProposedMessage.java | 2 +- .../GridDistributedTxPrepareRequest.java | 4 +- .../distributed/dht/GridDhtLockRequest.java | 2 +- .../atomic/GridDhtAtomicUpdateRequest.java | 2 +- .../GridNearAtomicFullUpdateRequest.java | 4 +- ...idNearAtomicSingleUpdateFilterRequest.java | 2 +- ...idNearAtomicSingleUpdateInvokeRequest.java | 4 +- .../GridNearAtomicSingleUpdateRequest.java | 3 +- .../GridDhtPartitionsFullMessage.java | 2 +- .../GridDhtPartitionsSingleMessage.java | 2 +- .../distributed/near/GridNearGetRequest.java | 4 +- .../near/GridNearTxPrepareResponse.java | 4 +- .../cache/query/GridCacheQueryRequest.java | 2 +- .../cache/query/GridCacheQueryResponse.java | 2 +- .../cache/transactions/IgniteTxEntry.java | 2 +- .../cache/transactions/IgniteTxManager.java | 3 +- .../cache/transactions/TxLocksRequest.java | 4 +- .../cache/transactions/TxLocksResponse.java | 4 +- .../cache/verify/PartitionHashRecord.java | 2 +- .../cache/verify/TransactionsHashRecord.java | 2 +- .../cluster/ChangeGlobalStateMessage.java | 2 +- .../SchemaAddQueryEntityOperation.java | 2 +- .../handlers/task/GridTaskResultResponse.java | 2 +- .../service/ServiceDeploymentRequest.java | 2 +- .../CacheMarshallableMessage.java | 22 +++++ .../communication}/MarshallableMessage.java | 3 +- .../communication/MessageSerializer.java | 13 ++- .../tcp/internal/GridNioServerWrapper.java | 2 +- .../ignite/spi/discovery/ObjectData.java | 2 +- .../discovery/tcp/TcpDiscoveryIoSession.java | 2 +- .../tcp/internal/TcpDiscoveryNode.java | 2 +- .../TcpDiscoveryAbstractTraceableMessage.java | 2 +- .../direct/DirectMarshallingMessagesTest.java | 2 +- .../GridCommunicationSendMessageSelfTest.java | 6 +- .../IgniteMessageFactoryImplTest.java | 9 +- .../MessageDirectTypeIdConflictTest.java | 3 +- ...ommunicationSpiSslVolatilePayloadTest.java | 2 +- .../GridCacheMessageSelfTest.java | 11 ++- .../spi/communication/GridTestMessage.java | 3 +- .../communication/tcp/TestDelayMessage.java | 2 +- ...DiscoveryDeserializationExceptionTest.java | 3 +- .../spi/discovery/tcp/ExploitMessage.java | 2 +- .../ignite/testframework/GridTestUtils.java | 2 +- .../codegen/TestMarshallableMessage.java | 1 + .../msg/GridH2ValueMessageFactory.java | 57 ++++++------ .../zk/internal/DiscoveryMessageParser.java | 2 +- .../zk/internal/ZkMessageFactory.java | 9 +- 68 files changed, 243 insertions(+), 186 deletions(-) create mode 100644 modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java rename modules/core/src/main/java/org/apache/ignite/{internal => plugin/extensions/communication}/MarshallableMessage.java (93%) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteMessageFactory.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteMessageFactory.java index d15b5821e0597..cec70d15ee4fd 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteMessageFactory.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteMessageFactory.java @@ -36,18 +36,18 @@ public class CalciteMessageFactory extends AbstractMarshallableMessageFactoryPro /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - register(factory, QueryStartRequest.class, (short)300, schemaAwareMarsh, resolvedClsLdr); - register(factory, QueryStartResponse.class, (short)301, dfltMarsh, dftlClsLdr); - register(factory, CalciteErrorMessage.class, (short)302, dfltMarsh, resolvedClsLdr); - register(factory, QueryBatchMessage.class, (short)303, dfltMarsh, dftlClsLdr); - register(factory, QueryBatchAcknowledgeMessage.class, (short)304, dfltMarsh, dftlClsLdr); - register(factory, QueryInboxCloseMessage.class, (short)305, dfltMarsh, dftlClsLdr); - register(factory, QueryCloseMessage.class, (short)306, dfltMarsh, dftlClsLdr); - register(factory, GenericValueMessage.class, (short)307, schemaAwareMarsh, resolvedClsLdr); - register(factory, FragmentMapping.class, (short)308, dfltMarsh, dftlClsLdr); - register(factory, ColocationGroup.class, (short)309, dfltMarsh, dftlClsLdr); - register(factory, FragmentDescription.class, (short)310, dfltMarsh, dftlClsLdr); - register(factory, QueryTxEntry.class, (short)311, dfltMarsh, dftlClsLdr); + register(factory, QueryStartRequest.class, (short)300, schemaAwareMarsh); + register(factory, QueryStartResponse.class, (short)301, dfltMarsh); + register(factory, CalciteErrorMessage.class, (short)302, dfltMarsh); + register(factory, QueryBatchMessage.class, (short)303, dfltMarsh); + register(factory, QueryBatchAcknowledgeMessage.class, (short)304, dfltMarsh); + register(factory, QueryInboxCloseMessage.class, (short)305, dfltMarsh); + register(factory, QueryCloseMessage.class, (short)306, dfltMarsh); + register(factory, GenericValueMessage.class, (short)307, schemaAwareMarsh); + register(factory, FragmentMapping.class, (short)308, dfltMarsh); + register(factory, ColocationGroup.class, (short)309, dfltMarsh); + register(factory, FragmentDescription.class, (short)310, dfltMarsh); + register(factory, QueryTxEntry.class, (short)311, dfltMarsh); } /** */ diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java index 40849bab6a73a..8a2ceea7f1965 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java @@ -18,10 +18,10 @@ package org.apache.ignite.internal.processors.query.calcite.message; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** */ public final class GenericValueMessage implements MarshallableMessage { diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java index 15d34e00fbbfe..aab115e78de0f 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java @@ -21,13 +21,13 @@ import java.util.Map; import java.util.UUID; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.query.calcite.metadata.FragmentDescription; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java index 7981d736953e2..cee6beefb7012 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java @@ -30,7 +30,6 @@ import java.util.stream.Collectors; import java.util.stream.LongStream; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; import org.apache.ignite.internal.processors.query.calcite.util.Commons; @@ -39,6 +38,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** */ public class ColocationGroup implements MarshallableMessage { diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java index 0a9c0fd58ab8b..38e0e4adb3203 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java @@ -73,7 +73,7 @@ public class MessageProcessor extends AbstractProcessor { static final String COMPRESSED_MESSAGE_CLASS = "org.apache.ignite.internal.managers.communication.CompressedMessage"; /** Externalizable message. */ - static final String MARSHALLABLE_MESSAGE_INTERFACE = "org.apache.ignite.internal.MarshallableMessage"; + static final String MARSHALLABLE_MESSAGE_INTERFACE = "org.apache.ignite.plugin.extensions.communication.MarshallableMessage"; /** Messages with no fields. A serializer must be generated due to restrictions in our communication process. */ static final String[] EMPTY_MESSAGES = { diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 0a25a8aaad19b..e9c29a03915bf 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -174,8 +174,6 @@ private String generateSerializerCode(String serClsName) throws IOException { if (marshallableMessage()) fields.add("private final Marshaller marshaller;"); - fields.add("private final ClassLoader clsLdr;"); - try (Writer writer = new StringWriter()) { writeClassHeader(writer, env.getElementUtils().getPackageOf(type).toString(), serClsName); @@ -216,9 +214,9 @@ private void writeConstructor(Writer writer, String serClsName) throws IOExcepti writer.write(NL); if (marshallableMessage()) - writer.write(indentedLine("public " + serClsName + "(Marshaller marshaller, ClassLoader clsLdr) {")); + writer.write(indentedLine("public " + serClsName + "(Marshaller marshaller) {")); else - writer.write(indentedLine("public " + serClsName + "(ClassLoader clsLdr) {")); + writer.write(indentedLine("public " + serClsName + "() {")); writer.write(NL); @@ -228,8 +226,6 @@ private void writeConstructor(Writer writer, String serClsName) throws IOExcepti writer.write(indentedLine("this.marshaller = marshaller;")); writer.write(NL); } - - writer.write(indentedLine("this.clsLdr = clsLdr;")); --indent; @@ -298,7 +294,7 @@ else if (isCacheGroupIdMessage(type)) } for (VariableElement field : orderedFields) { - List marshalled = marshall(field.asType(), fieldAccessor(field), false); + List marshalled = marshall(field.asType(), fieldAccessor(field), false, false); if (!marshalled.isEmpty()) { if (!marshall.get(marshall.size() - 1).equals(EMPTY)) @@ -323,7 +319,7 @@ private void generateUnmarshallMethods(List orderedFields) { marshall.add(indentedLine( "@Override public void finishUnmarshal(" + simpleNameWithGeneric(type) + - " msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException {")); + " msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException {")); indent++; @@ -337,7 +333,7 @@ else if (isCacheGroupIdMessage(type)) marshall.add(indentedLine("GridCacheContext ctx = nested;")); for (VariableElement field : orderedFields) { - List unmarshalled = marshall(field.asType(), fieldAccessor(field), true); + List unmarshalled = marshall(field.asType(), fieldAccessor(field), true, false); if (!unmarshalled.isEmpty()) { if (!marshall.get(marshall.size() - 1).equals(EMPTY)) @@ -347,10 +343,47 @@ else if (isCacheGroupIdMessage(type)) } } - if (marshallableMessage()) { + if (isCacheMarshallableMessage(type)) { marshall.add(EMPTY); - marshall.add(indentedLine("msg.finishUnmarshal(marshaller, ctx != null ? ctx.deploy().globalLoader() : clsLdr);")); + marshall.add(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);")); + } + + indent--; + + marshall.add(indentedLine("}")); + + imports.add("org.apache.ignite.internal.util.typedef.internal.U"); + + marshall.add(EMPTY); + + marshall.add(indentedLine(METHOD_JAVADOC)); + + marshall.add(indentedLine( + "@Override public void finishUnmarshal(" + simpleNameWithGeneric(type) + + " msg, GridKernalContext kctx) throws IgniteCheckedException {")); + + indent++; + + boolean first = true; + + for (VariableElement field : orderedFields) { + List unmarshalled = marshall(field.asType(), fieldAccessor(field), true, true); + + if (!unmarshalled.isEmpty()) { + if (!first) + marshall.add(EMPTY); + + first = false; + + marshall.addAll(unmarshalled); + } + } + + if (marshallableMessage() && !isCacheMarshallableMessage(type)) { + marshall.add(EMPTY); + + marshall.add(indentedLine("msg.finishUnmarshal(marshaller, U.gridClassLoader());")); } indent--; @@ -359,7 +392,7 @@ else if (isCacheGroupIdMessage(type)) } /** */ - private List marshall(TypeMirror t, String accessor, boolean unmarshall) { + private List marshall(TypeMirror t, String accessor, boolean unmarshall, boolean cache) { if (t.getKind() == TypeKind.ARRAY) { TypeMirror comp = ((ArrayType)t).getComponentType(); @@ -378,7 +411,7 @@ private List marshall(TypeMirror t, String accessor, boolean unmarshall) indent++; - List res = marshall(comp, el, unmarshall); + List res = marshall(comp, el, unmarshall, cache); code.addAll(res); @@ -409,17 +442,27 @@ else if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { "kctx.messageFactory().serializer(%s.directType()).prepareMarshal(%s, kctx, ctx);", accessor, accessor)); - else - code.add(indentedLine( - "kctx.messageFactory().serializer(%s.directType()).finishUnmarshal(%s, kctx, ctx);", - accessor, - accessor)); + else { + if (cache) + code.add(indentedLine( + "kctx.messageFactory().serializer(%s.directType()).finishUnmarshal(%s, kctx);", + accessor, + accessor)); + else + code.add(indentedLine( + "kctx.messageFactory().serializer(%s.directType()).finishUnmarshal(%s, kctx, ctx, clsLdr);", + accessor, + accessor)); + } indent--; return code; } else if (isCacheObject(t)) { + if (cache && unmarshall) + return Collections.emptyList(); + List code = new ArrayList<>(); code.add(indentedLine("if (%s != null && ctx != null)", accessor)); @@ -450,8 +493,8 @@ else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { String el = "e" + indent; indent++; // Emulating subsequent indent. - List keyRes = marshall(keyType, el, unmarshall); - List valRes = marshall(valType, el, unmarshall); + List keyRes = marshall(keyType, el, unmarshall, cache); + List valRes = marshall(valType, el, unmarshall, cache); indent--; if (!keyRes.isEmpty() && (keyType.getKind() == TypeKind.DECLARED || keyType.getKind() == TypeKind.TYPEVAR)) { @@ -526,7 +569,7 @@ else if (assignableFrom(erasedType(t), type(Collection.class.getName()))) { indent++; - List res = marshall(arg, el, unmarshall); + List res = marshall(arg, el, unmarshall, cache); code.addAll(res); @@ -564,6 +607,11 @@ private boolean isNonMarshallableMessage(TypeElement te) { return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage")); } + /** */ + private boolean isCacheMarshallableMessage(TypeElement te) { + return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage")); + } + /** True if {@code te} extends {@code CacheIdAware} and therefore carries its own per-cache {@code cacheId()}. */ private boolean isCacheIdAwareMessage(TypeElement te) { return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.CacheIdAware")); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java b/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java index 9da592635d229..f4b7c2e255796 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java @@ -343,7 +343,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C // [5000 - 5500]: Utility messages. Most of them originally come from Discovery. msgIdx = 5000; withNoSchema(CompressedMessage.class); - withNoSchemaResolvedClassLoader(ErrorMessage.class); + withNoSchema(ErrorMessage.class); withNoSchema(InetSocketAddressMessage.class); withNoSchema(InetAddressMessage.class); withNoSchema(TcpDiscoveryNode.class); @@ -353,8 +353,8 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C withNoSchema(GridCacheVersion.class); withNoSchema(GridCacheVersionEx.class); withNoSchema(WALPointer.class); - withNoSchemaResolvedClassLoader(ObjectData.class); - withSchemaResolvedClassLoader(GridTopicMessage.class); + withNoSchema(ObjectData.class); + withSchema(GridTopicMessage.class); // [5700 - 5900]: Discovery originated messages. msgIdx = 5700; @@ -639,7 +639,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C withNoSchema(MetadataRequestMessage.class); withNoSchema(MetadataResponseMessage.class); withNoSchema(MarshallerMappingItem.class); - withSchemaResolvedClassLoader(BinaryMetadataVersionInfo.class); + withSchema(BinaryMetadataVersionInfo.class); withNoSchema(BinaryMetadataVersionsData.class); withNoSchema(MappedName.class); withNoSchema(MarshallerMappingsData.class); @@ -662,35 +662,26 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C withNoSchema(IgniteDiagnosticResponse.class); withNoSchema(WalStateAckMessage.class); withNoSchema(CacheConfigurationEnrichment.class); - withNoSchemaResolvedClassLoader(DynamicCacheChangeRequest.class); + withNoSchema(DynamicCacheChangeRequest.class); withNoSchema(PartitionHashRecord.class); withNoSchema(TransactionsHashRecord.class); assert msgIdx <= MAX_MESSAGE_ID; } - /** Registers message using {@link #dfltMarsh} and {@link #dftlClsLdr}. */ + /** Registers message using {@link #dfltMarsh}. */ private void withNoSchema(Class cls) { - register(cls, dfltMarsh, dftlClsLdr); + register(cls, dfltMarsh); } - /** Registers message using {@link #schemaAwareMarsh} and {@link #dftlClsLdr}. */ + /** Registers message using {@link #schemaAwareMarsh}. */ private void withSchema(Class cls) { - register(cls, schemaAwareMarsh, dftlClsLdr); - } - - /** Registers message using {@link #dfltMarsh} and {@link #resolvedClsLdr}. */ - private void withNoSchemaResolvedClassLoader(Class cls) { - register(cls, dfltMarsh, resolvedClsLdr); - } - - /** Registers message using {@link #schemaAwareMarsh} and {@link #resolvedClsLdr}. */ - private void withSchemaResolvedClassLoader(Class cls) { - register(cls, schemaAwareMarsh, resolvedClsLdr); + register(cls, schemaAwareMarsh); } + /** Registers message using incrementing {@link #msgIdx} as the message id/type. */ - private void register(Class cls, Marshaller marsh, ClassLoader clsLrd) { - register(factory, cls, msgIdx++, marsh, clsLrd); + private void register(Class cls, Marshaller marsh) { + register(factory, cls, msgIdx++, marsh); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java index 99f537e9ab325..c78508b03a5cc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java @@ -23,6 +23,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridTopicMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/GridTopicMessage.java index 2f34b53f27360..5ec7fed797186 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridTopicMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTopicMessage.java @@ -21,6 +21,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** Message wrapper for grid topic. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageSerializer.java index 992b798a3bb0c..594aab336e02d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageSerializer.java @@ -27,10 +27,6 @@ /** Message serializer for compressed message. */ public class CompressedMessageSerializer implements MessageSerializer { - /** */ - public CompressedMessageSerializer(ClassLoader clsLdr) { - } - /** {@inheritDoc} */ @Override public boolean writeTo(CompressedMessage msg, MessageWriter writer) { if (!writer.isHeaderWritten()) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java index 02bb9ec0af99a..b497e76ae845c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java @@ -18,12 +18,12 @@ package org.apache.ignite.internal.managers.communication; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 64c6d518fee1a..39e7c981b9a2f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1178,7 +1178,7 @@ private void onChannelOpened0(UUID rmtNodeId, GridIoMessage initMsg, Channel cha MessageSerializer ser = ctx.messageFactory().serializer(initMsg.directType()); - ser.finishUnmarshal(initMsg, ctx, null); + ser.finishUnmarshal(initMsg, ctx); pools.poolForPolicy(plc).execute(new Runnable() { @Override public void run() { @@ -1207,7 +1207,7 @@ private void onMessage0(UUID nodeId, GridIoMessage msg, IgniteRunnable msgC) thr MessageSerializer ser = ctx.messageFactory().serializer(msg.directType()); - ser.finishUnmarshal(msg, ctx, null); + ser.finishUnmarshal(msg, ctx); Lock busyLock0 = busyLock.readLock(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java index d95ead4f902de..7c1c242642811 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java @@ -19,10 +19,10 @@ import java.util.UUID; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java index 688145e87b971..183062ac72c7e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java @@ -25,7 +25,6 @@ import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.events.Event; import org.apache.ignite.internal.GridTopicMessage; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -34,6 +33,7 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java index 39e3dffedc3e3..ffab1fad8df6e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java @@ -20,11 +20,10 @@ import java.lang.reflect.Constructor; import org.apache.ignite.IgniteException; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; @@ -38,15 +37,9 @@ public abstract class AbstractMarshallableMessageFactoryProvider implements Mess /** Default schema-less marshaller. */ protected Marshaller dfltMarsh; - /** Default class loader. */ - protected final ClassLoader dftlClsLdr = U.gridClassLoader(); - /** Schema-aware marshaller like {@link BinaryMarshaller}. */ protected Marshaller schemaAwareMarsh; - /** Resolved (configured) class loader like {@link IgniteConfiguration#setClassLoader(ClassLoader)}. */ - protected ClassLoader resolvedClsLdr; - /** * @param dfltMarsh Default schema-less marshaller like {@link JdkMarshaller}. * @param schemaAwareMarsh Schema-aware marshaller like {@link BinaryMarshaller}. @@ -55,12 +48,10 @@ public abstract class AbstractMarshallableMessageFactoryProvider implements Mess public void init(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, ClassLoader resolvedClsLdr) { this.dfltMarsh = dfltMarsh; this.schemaAwareMarsh = schemaAwareMarsh; - this.resolvedClsLdr = resolvedClsLdr; } /** Registers message automatically generating message supplier and serializer. */ - protected static void register(MessageFactory factory, Class cls, short id, Marshaller marsh, - ClassLoader clsLrd) { + protected static void register(MessageFactory factory, Class cls, short id, Marshaller marsh) { Constructor ctor; MessageSerializer serializer; @@ -72,8 +63,8 @@ protected static void register(MessageFactory factory, Class Class serCls = Class.forName(cls.getName() + (marshallable ? "MarshallableSerializer" : "Serializer")); serializer = marshallable - ? (MessageSerializer)serCls.getConstructor(Marshaller.class, ClassLoader.class).newInstance(marsh, clsLrd) - : (MessageSerializer)serCls.getConstructor(ClassLoader.class).newInstance(clsLrd); + ? (MessageSerializer)serCls.getConstructor(Marshaller.class).newInstance(marsh) + : (MessageSerializer)serCls.getConstructor().newInstance(); } catch (Exception e) { throw new IgniteException("Failed to register message of type " + cls.getSimpleName(), e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java index 79c2f7d90bf42..68d0c8f07fd0a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java @@ -24,7 +24,6 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.CoreMessagesProvider; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.query.QuerySchema; import org.apache.ignite.internal.util.tostring.GridToStringExclude; @@ -32,6 +31,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java index 86917aeb48573..293db4c0241b8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -26,6 +25,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * Entry information that gets passed over wire. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index 86e1cb1c55465..40fef83d2caf3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -92,6 +92,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; @@ -1550,6 +1551,10 @@ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) { if (log.isDebugEnabled()) log.debug("Set P2P context [senderId=" + nodeId + ", msg=" + cacheMsg + ']'); } + + MessageSerializer ser = cctx.kernalContext().messageFactory().serializer(cacheMsg.directType()); + + ser.finishUnmarshal(cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); } catch (IgniteCheckedException e) { cacheMsg.onClassError(e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index 47921a5988213..4404afed46503 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -24,7 +24,6 @@ import javax.cache.processor.EntryProcessorResult; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.binary.BinaryObject; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.UnregisteredBinaryTypeException; import org.apache.ignite.internal.UnregisteredClassException; @@ -34,6 +33,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java index dc94809a9446c..0f2e83c1fbbe7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java @@ -23,7 +23,6 @@ import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cdc.CdcCacheEvent; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.encryption.GroupKeyEncrypted; import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager; @@ -35,6 +34,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.plugin.extensions.communication.MessageFactory; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java index 9fe6d19da4421..6fc0c20042832 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java @@ -18,11 +18,11 @@ import java.io.Serializable; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.binary.BinaryMetadata; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * Wrapper for {@link BinaryMetadata} which is stored in metadata local cache on each node. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java index 90820675c6252..b11b45b5ac96a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java @@ -19,7 +19,6 @@ import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.binary.BinaryObjectException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.binary.BinaryMetadata; import org.apache.ignite.internal.binary.BinaryMetadataHandler; @@ -29,6 +28,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 5e6a4242e95ba..1a1f803a4d262 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -25,7 +25,6 @@ import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; @@ -39,6 +38,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; @@ -47,7 +47,7 @@ * Transaction prepare request for optimistic and eventually consistent * transactions. */ -public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage implements IgniteTxStateAware, MarshallableMessage { +public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage implements IgniteTxStateAware, CacheMarshallableMessage { /** */ private static final int NEED_RETURN_VALUE_FLAG_MASK = 0x01; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 70afa43649dda..fe7d4bad8b260 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -21,7 +21,6 @@ import java.util.Map; import java.util.UUID; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.KeyCacheObject; @@ -33,6 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index b71d3b83367a0..3c69ee2d1f18a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -23,7 +23,6 @@ import java.util.UUID; import javax.cache.processor.EntryProcessor; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; @@ -38,6 +37,7 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index 567c4e328ef6b..af9e873d61660 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -25,7 +25,6 @@ import javax.cache.processor.EntryProcessor; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; @@ -43,6 +42,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,7 +53,7 @@ /** * Lite DHT cache update request sent from near node to primary node. */ -public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements MarshallableMessage { +public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements CacheMarshallableMessage { /** Keys to update. */ @Order(0) @GridToStringInclude diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java index ef55deb9f50c3..523b3341c4f6d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java @@ -21,13 +21,13 @@ import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index 59f825a30359d..7f99ec4b04f98 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -24,7 +24,6 @@ import javax.cache.processor.EntryProcessor; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; @@ -37,6 +36,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -45,7 +45,7 @@ /** * */ -public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest implements MarshallableMessage { +public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest implements CacheMarshallableMessage { /** Optional arguments for entry processor. */ private @Nullable Object[] invokeArgs; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java index ca62244d75d8c..01152618b6917 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java @@ -235,8 +235,7 @@ public GridNearAtomicSingleUpdateRequest() { if (clearKey) key = null; } - - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearAtomicSingleUpdateRequest.class, this, "parent", super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index d2f183c739f12..6cce1a2ac30ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -28,7 +28,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.Compress; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; @@ -41,6 +40,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index bf9e9967b1cd6..89a0d7f22d0db 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -23,7 +23,6 @@ import java.util.Map; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Compress; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; @@ -32,6 +31,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index 30278a6227412..4ffada383bb94 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; @@ -39,13 +38,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Get request. Responsible for obtaining entry from primary node. 'Near' means 'Initiating node' here, not 'Near Cache'. */ -public class GridNearGetRequest extends GridCacheIdMessage implements GridCacheDeployable, GridCacheVersionable, MarshallableMessage { +public class GridNearGetRequest extends GridCacheIdMessage implements GridCacheDeployable, GridCacheVersionable, CacheMarshallableMessage { /** */ private static final int READ_THROUGH_FLAG_MASK = 0x01; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index ea06d7b0e24d9..b914ea44dcdfe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -23,7 +23,6 @@ import java.util.Iterator; import java.util.Map; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; @@ -37,12 +36,13 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Near cache prepare response. */ -public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse implements MarshallableMessage { +public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse implements CacheMarshallableMessage { /** Versions that are less than lock version ({@link #version()}). */ @GridToStringInclude @Order(0) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 8a892468f786b..ad1117edeb1a8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -19,7 +19,6 @@ import java.util.Collection; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; @@ -35,6 +34,7 @@ import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgniteReducer; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.INDEX; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index ee030ce661855..fa65280fc6e26 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.Map; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.cache.query.index.IndexQueryResultMeta; import org.apache.ignite.internal.managers.communication.ErrorMessage; @@ -31,6 +30,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index 9ed05e2484dba..d0e04f080458a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -25,7 +25,6 @@ import javax.cache.processor.EntryProcessor; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; import org.apache.ignite.internal.processors.cache.CacheInvalidStateException; @@ -48,6 +47,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 92d8b80a27acd..6329f84db99b7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -3449,7 +3449,8 @@ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) { try { MessageSerializer ser = cctx.kernalContext().messageFactory().serializer(cacheMsg.directType()); - ser.finishUnmarshal(cacheMsg, cctx.kernalContext(), null); + ser.finishUnmarshal(cacheMsg, cctx.kernalContext()); + ser.finishUnmarshal(cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); } catch (IgniteCheckedException e) { cacheMsg.onClassError(e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java index 588219de8bef6..499d9557e90d2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.Set; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.util.tostring.GridToStringExclude; @@ -29,11 +28,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; /** * Transactions lock list request. */ -public class TxLocksRequest extends GridCacheMessage implements MarshallableMessage { +public class TxLocksRequest extends GridCacheMessage implements CacheMarshallableMessage { /** Future ID. */ @Order(0) long futId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index e517c7c5c522a..c008463dfe4ef 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -24,7 +24,6 @@ import java.util.Map; import java.util.Set; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.util.tostring.GridToStringExclude; @@ -32,11 +31,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; /** * Transactions lock list response. */ -public class TxLocksResponse extends GridCacheMessage implements MarshallableMessage { +public class TxLocksResponse extends GridCacheMessage implements CacheMarshallableMessage { /** Future ID. */ @Order(0) long futId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java index 06ce5642fe874..766ab1752e55c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java @@ -20,7 +20,6 @@ import java.util.Objects; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.BinaryConfiguration; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.binary.GridBinaryMarshaller; import org.apache.ignite.internal.management.cache.PartitionKey; @@ -30,6 +29,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.jetbrains.annotations.Nullable; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java index 38bd085377824..3b22bdf1862fa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java @@ -19,12 +19,12 @@ import java.io.Serializable; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** Represents committed transactions hash for a pair of nodes. */ public class TransactionsHashRecord implements MarshallableMessage, Serializable { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java index 461d36f8bdb17..9d0f56da5a5fe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java @@ -21,7 +21,6 @@ import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cluster.ClusterState; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.discovery.DiscoCache; import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; @@ -35,6 +34,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java index ebb23aff57ea9..3066afad53449 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java @@ -21,10 +21,10 @@ import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.QueryEntity; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * Enabling indexing on cache operation. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java index ff0f3af4ffce8..3661cae983735 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -18,10 +18,10 @@ package org.apache.ignite.internal.processors.rest.handlers.task; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java index 7d67164f10be0..4d1813477ad91 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java @@ -18,12 +18,12 @@ package org.apache.ignite.internal.processors.service; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.jetbrains.annotations.NotNull; diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java new file mode 100644 index 0000000000000..d5bd508f03b91 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java @@ -0,0 +1,22 @@ +/* + * 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; + +/** Unmarshalls when CacheObjects are already unmarshalled. */ +public interface CacheMarshallableMessage extends MarshallableMessage { +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java similarity index 93% rename from modules/core/src/main/java/org/apache/ignite/internal/MarshallableMessage.java rename to modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java index 72b67ab2c4afd..5f2f8c4196608 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java @@ -15,11 +15,10 @@ * limitations under the License. */ -package org.apache.ignite.internal; +package org.apache.ignite.plugin.extensions.communication; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.Message; /** A {@link Message} which still requires external custom pre-marshalling and post-unmarshalling. */ public interface MarshallableMessage extends Message { diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index 47202e3b13b25..f3c4c709c7801 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -59,9 +59,20 @@ public default void prepareMarshal(M msg, GridKernalContext kctx, GridCacheConte * @param msg Message instance. * @param kctx Kernal context. * @param nested Nested context. + * @param clsLdr Classloader. * @throws IgniteCheckedException If unmarshalling fails. */ - public default void finishUnmarshal(M msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + public default void finishUnmarshal(M msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + // No-op by default. + } + + /** + * Unmarshalls message fields. + * @param msg Message instance. + * @param kctx Kernal context. + * @throws IgniteCheckedException If unmarshalling fails. + */ + public default void finishUnmarshal(M msg, GridKernalContext kctx) throws IgniteCheckedException { // No-op by default. } } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java index beba50cc4695f..df7935c6c2f41 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java @@ -826,7 +826,7 @@ public GridNioServer resetNioServer() throws IgniteCheckedException { @Override public MessageSerializer serializer(short type) { // Enable sending wait message for a communication peer while context isn't initialized. if (impl == null && type == CoreMessagesProvider.HANDSHAKE_WAIT_MSG_TYPE) - return new HandshakeWaitMessageSerializer(U.gridClassLoader()); + return new HandshakeWaitMessageSerializer(); return get().serializer(type); } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java index f9da59bffe415..e153290d3afe8 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java @@ -19,13 +19,13 @@ import java.io.Serializable; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java index 9389b0b991bfc..0768e74187ca2 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java @@ -198,7 +198,7 @@ T readMessage() throws IgniteCheckedException, IOException { } while (!finished); - msgSer.finishUnmarshal(msg, ((IgniteEx)spi.ignite()).context(), null); + msgSer.finishUnmarshal(msg, ((IgniteEx)spi.ignite()).context()); return (T)msg; } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java index 2cfc4781230b8..5d21dade1d772 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java @@ -36,7 +36,6 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.ClusterMetricsSnapshot; import org.apache.ignite.internal.IgniteNodeAttributes; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.discovery.IgniteClusterNode; import org.apache.ignite.internal.processors.cluster.NodeMetricsMessage; @@ -49,6 +48,7 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.spi.discovery.DiscoveryMetricsProvider; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.jetbrains.annotations.Nullable; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractTraceableMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractTraceableMessage.java index c36601a399567..2df35f55ce64a 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractTraceableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractTraceableMessage.java @@ -19,11 +19,11 @@ import java.util.UUID; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.tracing.messages.SpanContainer; import org.apache.ignite.internal.processors.tracing.messages.TraceableMessage; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.jetbrains.annotations.Nullable; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/direct/DirectMarshallingMessagesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/direct/DirectMarshallingMessagesTest.java index 77cf4814eaea8..ea37b6abe4545 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/direct/DirectMarshallingMessagesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/direct/DirectMarshallingMessagesTest.java @@ -50,7 +50,7 @@ public class DirectMarshallingMessagesTest extends GridCommonAbstractTest { factory -> factory.register( TestNestedContainersMessage.TYPE, TestNestedContainersMessage::new, - new TestNestedContainersMessageSerializer(U.gridClassLoader()) + new TestNestedContainersMessageSerializer() ) }); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java index 2b325359e90c6..90d9027ad7b67 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java @@ -20,7 +20,6 @@ import java.util.UUID; import java.util.concurrent.CountDownLatch; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.AbstractTestPluginProvider; import org.apache.ignite.plugin.ExtensionRegistry; import org.apache.ignite.plugin.PluginContext; @@ -152,9 +151,8 @@ public static class TestPluginProvider extends AbstractTestPluginProvider { @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) { registry.registerExtension(MessageFactoryProvider.class, new MessageFactoryProvider() { @Override public void registerAll(MessageFactory factory) { - factory.register(DIRECT_TYPE, TestValidByteIdMessage::new, new TestValidByteIdMessageSerializer(U.gridClassLoader())); - factory.register(DIRECT_TYPE_OVER_BYTE, - TestOverByteIdMessage::new, new TestOverByteIdMessageSerializer(U.gridClassLoader())); + factory.register(DIRECT_TYPE, TestValidByteIdMessage::new, new TestValidByteIdMessageSerializer()); + factory.register(DIRECT_TYPE_OVER_BYTE, TestOverByteIdMessage::new, new TestOverByteIdMessageSerializer()); } }); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImplTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImplTest.java index b89beeec8b82c..838474c82c7d1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImplTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImplTest.java @@ -19,7 +19,6 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.internal.CoreMessagesProvider; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; @@ -108,8 +107,8 @@ public void testRegisterTheSameType() { private static class TestMessageFactoryPovider implements MessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - factory.register(TEST_MSG_1_TYPE, TestMessage1::new, new TestMessage1Serializer(U.gridClassLoader())); - factory.register(TEST_MSG_42_TYPE, TestMessage42::new, new TestMessage42Serializer(U.gridClassLoader())); + factory.register(TEST_MSG_1_TYPE, TestMessage1::new, new TestMessage1Serializer()); + factory.register(TEST_MSG_42_TYPE, TestMessage42::new, new TestMessage42Serializer()); } } @@ -119,7 +118,7 @@ private static class TestMessageFactoryPovider implements MessageFactoryProvider private static class TestMessageFactoryPoviderWithTheSameDirectType implements MessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - factory.register(TEST_MSG_1_TYPE, TestMessage1::new, new TestMessage1Serializer(U.gridClassLoader())); + factory.register(TEST_MSG_1_TYPE, TestMessage1::new, new TestMessage1Serializer()); } } @@ -129,7 +128,7 @@ private static class TestMessageFactoryPoviderWithTheSameDirectType implements M private static class TestMessageFactory implements MessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - factory.register(TEST_MSG_2_TYPE, TestMessage2::new, new TestMessage2Serializer(U.gridClassLoader())); + factory.register(TEST_MSG_2_TYPE, TestMessage2::new, new TestMessage2Serializer()); } } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java index 744f5dc2e9a5a..124f30ae5daae 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java @@ -20,7 +20,6 @@ import java.util.concurrent.Callable; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.AbstractTestPluginProvider; import org.apache.ignite.plugin.ExtensionRegistry; import org.apache.ignite.plugin.PluginContext; @@ -83,7 +82,7 @@ public static class TestPluginProvider extends AbstractTestPluginProvider { registry.registerExtension(MessageFactoryProvider.class, new MessageFactoryProvider() { @Override public void registerAll(MessageFactory factory) { factory.register(DIRECT_TYPE, - DuplicateDirectTypeIdMessage::new, new DuplicateDirectTypeIdMessageSerializer(U.gridClassLoader())); + DuplicateDirectTypeIdMessage::new, new DuplicateDirectTypeIdMessageSerializer()); } }); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/TcpCommunicationSpiSslVolatilePayloadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/TcpCommunicationSpiSslVolatilePayloadTest.java index e0259a5ee4040..45c0d0ea029d6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/TcpCommunicationSpiSslVolatilePayloadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/TcpCommunicationSpiSslVolatilePayloadTest.java @@ -97,7 +97,7 @@ public class TcpCommunicationSpiSslVolatilePayloadTest extends GridAbstractCommu @Override protected MessageFactoryProvider customMessageFactory() { return f -> f.register( TestVolatilePayloadMessage.DIRECT_TYPE, - TestVolatilePayloadMessage::new, new TestVolatilePayloadMessageSerializer(U.gridClassLoader()) + TestVolatilePayloadMessage::new, new TestVolatilePayloadMessageSerializer() ); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java index ecb8a67eb653e..5357052713835 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java @@ -34,7 +34,6 @@ import org.apache.ignite.internal.managers.communication.GridMessageListener; import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.util.typedef.CI2; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.AbstractTestPluginProvider; import org.apache.ignite.plugin.ExtensionRegistry; import org.apache.ignite.plugin.PluginContext; @@ -232,11 +231,11 @@ public static class TestPluginProvider extends AbstractTestPluginProvider { /** {@inheritDoc} */ @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) { registry.registerExtension(MessageFactoryProvider.class, factory -> { - factory.register(TestMessage.DIRECT_TYPE, TestMessage::new, new TestMessageSerializer(U.gridClassLoader())); - factory.register(GridTestMessage.DIRECT_TYPE, GridTestMessage::new, new GridTestMessageSerializer(U.gridClassLoader())); - factory.register(TestMessage1.DIRECT_TYPE, TestMessage1::new, new TestMessage1Serializer(U.gridClassLoader())); - factory.register(TestMessage2.DIRECT_TYPE, TestMessage2::new, new TestMessage2Serializer(U.gridClassLoader())); - factory.register(TestBadMessage.DIRECT_TYPE, TestBadMessage::new, new TestBadMessageSerializer(U.gridClassLoader())); + factory.register(TestMessage.DIRECT_TYPE, TestMessage::new, new TestMessageSerializer()); + factory.register(GridTestMessage.DIRECT_TYPE, GridTestMessage::new, new GridTestMessageSerializer()); + factory.register(TestMessage1.DIRECT_TYPE, TestMessage1::new, new TestMessage1Serializer()); + factory.register(TestMessage2.DIRECT_TYPE, TestMessage2::new, new TestMessage2Serializer()); + factory.register(TestBadMessage.DIRECT_TYPE, TestBadMessage::new, new TestBadMessageSerializer()); }); } } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java index 21c115a4e019d..83a6ea91775b7 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java @@ -20,7 +20,6 @@ import java.util.Objects; import java.util.UUID; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; @@ -33,7 +32,7 @@ public class GridTestMessage implements Message { /** */ public static final MessageFactoryProvider GRID_TEST_MESSAGE_FACTORY = f -> f.register( - GridTestMessage.DIRECT_TYPE, GridTestMessage::new, new GridTestMessageSerializer(U.gridClassLoader())); + GridTestMessage.DIRECT_TYPE, GridTestMessage::new, new GridTestMessageSerializer()); /** */ @Order(0) diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessage.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessage.java index 4ed72c9905f40..af49c5f9c96c4 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessage.java @@ -19,10 +19,10 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.IgniteInterruptedCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** Test message. */ public class TestDelayMessage implements MarshallableMessage { diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryDeserializationExceptionTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryDeserializationExceptionTest.java index 10aeab8dab0d4..cfe047d58e75d 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryDeserializationExceptionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryDeserializationExceptionTest.java @@ -25,7 +25,6 @@ import org.apache.ignite.failure.FailureContext; import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.AbstractTestPluginProvider; import org.apache.ignite.plugin.ExtensionRegistry; import org.apache.ignite.plugin.PluginContext; @@ -139,7 +138,7 @@ public static class NotRegisteredMessageProvider extends AbstractTestPluginProvi /** {@inheritDoc} */ @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) { registry.registerExtension(MessageFactoryProvider.class, (factory) -> - factory.register(MSG_DIRECT_TYPE, NotRegisteredMessage::new, new NotRegisteredMessageSerializer(U.gridClassLoader())) + factory.register(MSG_DIRECT_TYPE, NotRegisteredMessage::new, new NotRegisteredMessageSerializer()) ); } } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ExploitMessage.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ExploitMessage.java index 182f91f826289..d4074b58fdb45 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ExploitMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ExploitMessage.java @@ -18,9 +18,9 @@ package org.apache.ignite.spi.discovery.tcp; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.Order; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.spi.discovery.tcp.DiscoveryUnmarshalVulnerabilityTest.Exploit; /** */ diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java index cd6b30d84de49..6e8180ee87431 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java @@ -99,7 +99,6 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.internal.MarshallableMessage; import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; @@ -127,6 +126,7 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessage.java b/modules/core/src/test/resources/codegen/TestMarshallableMessage.java index 95980c4266f68..12b5ef75ee04d 100644 --- a/modules/core/src/test/resources/codegen/TestMarshallableMessage.java +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessage.java @@ -20,6 +20,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; public class TestMarshallableMessage implements MarshallableMessage { @Order(0) diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java index c22e32703714f..b26089afd70fe 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java @@ -26,7 +26,6 @@ import org.apache.ignite.internal.processors.query.h2.QueryTable; import org.apache.ignite.internal.processors.query.h2.QueryTableSerializer; import org.apache.ignite.internal.processors.query.h2.opt.GridH2ValueCacheObject; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; @@ -38,34 +37,34 @@ public class GridH2ValueMessageFactory implements MessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - factory.register(-4, () -> GridH2Null.INSTANCE, new GridH2NullSerializer(U.gridClassLoader())); - factory.register(-5, GridH2Boolean::new, new GridH2BooleanSerializer(U.gridClassLoader())); - factory.register(-6, GridH2Byte::new, new GridH2ByteSerializer(U.gridClassLoader())); - factory.register(-7, GridH2Short::new, new GridH2ShortSerializer(U.gridClassLoader())); - factory.register(-8, GridH2Integer::new, new GridH2IntegerSerializer(U.gridClassLoader())); - factory.register(-9, GridH2Long::new, new GridH2LongSerializer(U.gridClassLoader())); - factory.register(-10, GridH2Decimal::new, new GridH2DecimalSerializer(U.gridClassLoader())); - factory.register(-11, GridH2Double::new, new GridH2DoubleSerializer(U.gridClassLoader())); - factory.register(-12, GridH2Float::new, new GridH2FloatSerializer(U.gridClassLoader())); - factory.register(-13, GridH2Time::new, new GridH2TimeSerializer(U.gridClassLoader())); - factory.register(-14, GridH2Date::new, new GridH2DateSerializer(U.gridClassLoader())); - factory.register(-15, GridH2Timestamp::new, new GridH2TimestampSerializer(U.gridClassLoader())); - factory.register(-16, GridH2Bytes::new, new GridH2BytesSerializer(U.gridClassLoader())); - factory.register(-17, GridH2String::new, new GridH2StringSerializer(U.gridClassLoader())); - factory.register(-18, GridH2Array::new, new GridH2ArraySerializer(U.gridClassLoader())); - factory.register(-19, GridH2JavaObject::new, new GridH2JavaObjectSerializer(U.gridClassLoader())); - factory.register(-20, GridH2Uuid::new, new GridH2UuidSerializer(U.gridClassLoader())); - factory.register(-21, GridH2Geometry::new, new GridH2GeometrySerializer(U.gridClassLoader())); - factory.register(-22, GridH2CacheObject::new, new GridH2CacheObjectSerializer(U.gridClassLoader())); - factory.register(-30, GridH2IndexRangeRequest::new, new GridH2IndexRangeRequestSerializer(U.gridClassLoader())); - factory.register(-31, GridH2IndexRangeResponse::new, new GridH2IndexRangeResponseSerializer(U.gridClassLoader())); - factory.register(-32, GridH2RowMessage::new, new GridH2RowMessageSerializer(U.gridClassLoader())); - factory.register(-33, GridH2QueryRequest::new, new GridH2QueryRequestSerializer(U.gridClassLoader())); - factory.register(-34, GridH2RowRange::new, new GridH2RowRangeSerializer(U.gridClassLoader())); - factory.register(-35, GridH2RowRangeBounds::new, new GridH2RowRangeBoundsSerializer(U.gridClassLoader())); - factory.register(-54, QueryTable::new, new QueryTableSerializer(U.gridClassLoader())); - factory.register(-55, GridH2DmlRequest::new, new GridH2DmlRequestSerializer(U.gridClassLoader())); - factory.register(-56, GridH2DmlResponse::new, new GridH2DmlResponseSerializer(U.gridClassLoader())); + factory.register(-4, () -> GridH2Null.INSTANCE, new GridH2NullSerializer()); + factory.register(-5, GridH2Boolean::new, new GridH2BooleanSerializer()); + factory.register(-6, GridH2Byte::new, new GridH2ByteSerializer()); + factory.register(-7, GridH2Short::new, new GridH2ShortSerializer()); + factory.register(-8, GridH2Integer::new, new GridH2IntegerSerializer()); + factory.register(-9, GridH2Long::new, new GridH2LongSerializer()); + factory.register(-10, GridH2Decimal::new, new GridH2DecimalSerializer()); + factory.register(-11, GridH2Double::new, new GridH2DoubleSerializer()); + factory.register(-12, GridH2Float::new, new GridH2FloatSerializer()); + factory.register(-13, GridH2Time::new, new GridH2TimeSerializer()); + factory.register(-14, GridH2Date::new, new GridH2DateSerializer()); + factory.register(-15, GridH2Timestamp::new, new GridH2TimestampSerializer()); + factory.register(-16, GridH2Bytes::new, new GridH2BytesSerializer()); + factory.register(-17, GridH2String::new, new GridH2StringSerializer()); + factory.register(-18, GridH2Array::new, new GridH2ArraySerializer()); + factory.register(-19, GridH2JavaObject::new, new GridH2JavaObjectSerializer()); + factory.register(-20, GridH2Uuid::new, new GridH2UuidSerializer()); + factory.register(-21, GridH2Geometry::new, new GridH2GeometrySerializer()); + factory.register(-22, GridH2CacheObject::new, new GridH2CacheObjectSerializer()); + factory.register(-30, GridH2IndexRangeRequest::new, new GridH2IndexRangeRequestSerializer()); + factory.register(-31, GridH2IndexRangeResponse::new, new GridH2IndexRangeResponseSerializer()); + factory.register(-32, GridH2RowMessage::new, new GridH2RowMessageSerializer()); + factory.register(-33, GridH2QueryRequest::new, new GridH2QueryRequestSerializer()); + factory.register(-34, GridH2RowRange::new, new GridH2RowRangeSerializer()); + factory.register(-35, GridH2RowRangeBounds::new, new GridH2RowRangeBoundsSerializer()); + factory.register(-54, QueryTable::new, new QueryTableSerializer()); + factory.register(-55, GridH2DmlRequest::new, new GridH2DmlRequestSerializer()); + factory.register(-56, GridH2DmlResponse::new, new GridH2DmlResponseSerializer()); } /** diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index 501791cdacb7a..a16cfca9fadca 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -141,7 +141,7 @@ private T deserializeMessage(InputStream in) throws IOExcept while (!finished); try { - msgSer.finishUnmarshal(msg, ((IgniteEx)spi.ignite()).context(), null); + msgSer.finishUnmarshal(msg, ((IgniteEx)spi.ignite()).context()); } catch (IgniteCheckedException e) { throw new IgniteSpiException("Failed to unmarshal joining node data", e); diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java index 393ea9f8e5a89..df2274248fc81 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java @@ -17,7 +17,6 @@ package org.apache.ignite.spi.discovery.zk.internal; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; @@ -26,10 +25,10 @@ public class ZkMessageFactory implements MessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { factory.register(400, - ZkCommunicationErrorResolveFinishMessage::new, new ZkCommunicationErrorResolveFinishMessageSerializer(U.gridClassLoader())); + ZkCommunicationErrorResolveFinishMessage::new, new ZkCommunicationErrorResolveFinishMessageSerializer()); factory.register(401, - ZkCommunicationErrorResolveStartMessage::new, new ZkCommunicationErrorResolveStartMessageSerializer(U.gridClassLoader())); - factory.register(402, ZkForceNodeFailMessage::new, new ZkForceNodeFailMessageSerializer(U.gridClassLoader())); - factory.register(403, ZkNoServersMessage::new, new ZkNoServersMessageSerializer(U.gridClassLoader())); + ZkCommunicationErrorResolveStartMessage::new, new ZkCommunicationErrorResolveStartMessageSerializer()); + factory.register(402, ZkForceNodeFailMessage::new, new ZkForceNodeFailMessageSerializer()); + factory.register(403, ZkNoServersMessage::new, new ZkNoServersMessageSerializer()); } } From b13b16b39991b3856e2609caea637bb2d3c27f94 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 4 Jun 2026 17:08:28 +0300 Subject: [PATCH 088/215] WIP --- .../java/org/apache/ignite/internal/CoreMessagesProvider.java | 1 - .../plugin/extensions/communication/MessageSerializer.java | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java b/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java index f4b7c2e255796..355314ce30adf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java @@ -679,7 +679,6 @@ private void withSchema(Class cls) { register(cls, schemaAwareMarsh); } - /** Registers message using incrementing {@link #msgIdx} as the message id/type. */ private void register(Class cls, Marshaller marsh) { register(factory, cls, msgIdx++, marsh); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index f3c4c709c7801..385143fa512f8 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -62,7 +62,8 @@ public default void prepareMarshal(M msg, GridKernalContext kctx, GridCacheConte * @param clsLdr Classloader. * @throws IgniteCheckedException If unmarshalling fails. */ - public default void finishUnmarshal(M msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + public default void finishUnmarshal(M msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) + throws IgniteCheckedException { // No-op by default. } From 442c531ab102fc2ad6928263ab75b794e8b22654 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 4 Jun 2026 17:13:48 +0300 Subject: [PATCH 089/215] WIP --- .../java/org/apache/ignite/spi/MessagesPluginProvider.java | 2 +- .../discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java | 3 +-- .../java/org/apache/ignite/testframework/GridTestUtils.java | 6 ++---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/spi/MessagesPluginProvider.java b/modules/core/src/test/java/org/apache/ignite/spi/MessagesPluginProvider.java index 865d9ba164444..6983e7e17aad6 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/MessagesPluginProvider.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/MessagesPluginProvider.java @@ -53,7 +53,7 @@ public MessagesPluginProvider(Class... msgs) { } }; - f.register(directType, msgSupp, loadSerializer(msg, null, null)); + f.register(directType, msgSupp, loadSerializer(msg, null)); directType++; } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index 9cf44281893f3..5947cb094f94b 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -290,8 +290,7 @@ private MessageSerializerWrapper(AbstractMarshallableMessageFactoryProvider prov private void initIfNecessary() { if (init.get() && init.compareAndSet(true, false)) serde = loadSerializer(ExploitMessage.class, - U.field(provider, "dfltMarsh"), - U.field(provider, "resolvedClsLdr")); + U.field(provider, "dfltMarsh")); } } } diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java index 6e8180ee87431..ca6ab9769a25b 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java @@ -2638,7 +2638,7 @@ public static void skipCommNioServerRead(IgniteEx ignite, boolean skip) { /** */ public static MessageSerializer loadSerializer(Class msgCls, - @Nullable Marshaller dfltMarsh, @Nullable ClassLoader dfltClsLdr) { + @Nullable Marshaller dfltMarsh) { try { boolean isMarshallable = MarshallableMessage.class.isAssignableFrom(msgCls); @@ -2648,11 +2648,9 @@ public static MessageSerializer loadSerializer(Class)msgSer; From 3f81a4627c31ad668369c4f59689a28ea2489a3b Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 4 Jun 2026 17:21:12 +0300 Subject: [PATCH 090/215] WIP --- .../spi/discovery/zk/internal/DiscoveryMessageParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index a16cfca9fadca..4cc146b7e0ab3 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -141,7 +141,7 @@ private T deserializeMessage(InputStream in) throws IOExcept while (!finished); try { - msgSer.finishUnmarshal(msg, ((IgniteEx)spi.ignite()).context()); + msgSer.finishUnmarshal(msg, ((IgniteEx)spi.ignite()).context()); } catch (IgniteCheckedException e) { throw new IgniteSpiException("Failed to unmarshal joining node data", e); From cca847f8643739cb63946043e3525b00d039de98 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 4 Jun 2026 17:22:32 +0300 Subject: [PATCH 091/215] WIP --- .../discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index 5947cb094f94b..d207750d31fa1 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -281,8 +281,8 @@ private MessageSerializerWrapper(AbstractMarshallableMessageFactoryProvider prov } /** {@inheritDoc} */ - @Override public void prepareMarshal(ExploitMessage msg, GridKernalContext kctx, - GridCacheContext nested) throws IgniteCheckedException { + @Override public void prepareMarshal(ExploitMessage msg, GridKernalContext kctx, GridCacheContext nested) + throws IgniteCheckedException { msg.prepareMarshal(jdk()); } From aa5c0a6c7aacaba28f2db22d69a1e6e4de4054dc Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 4 Jun 2026 22:28:10 +0300 Subject: [PATCH 092/215] WIP --- .../org/apache/ignite/internal/MessageSerializerGenerator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index e9c29a03915bf..42569cce28730 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -381,7 +381,8 @@ else if (isCacheGroupIdMessage(type)) } if (marshallableMessage() && !isCacheMarshallableMessage(type)) { - marshall.add(EMPTY); + if (!first) + marshall.add(EMPTY); marshall.add(indentedLine("msg.finishUnmarshal(marshaller, U.gridClassLoader());")); } From 86acbcbfa3492b1eee7b5e865c6a67eb14501412 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 4 Jun 2026 22:41:53 +0300 Subject: [PATCH 093/215] WIP --- .../query/calcite/message/QueryTxEntry.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java index cad5e8afb75f1..0d6dfd38d9172 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java @@ -20,9 +20,12 @@ import java.util.Collection; import java.util.Comparator; import java.util.function.Function; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext; @@ -92,4 +95,24 @@ public CacheObject value() { public GridCacheVersion version() { return ver; } + + /** {@inheritDoc} */ + @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { + CacheObjectContext coctx = ctx.cacheContext(cacheId).cacheObjectContext(); + + key.prepareMarshal(coctx); + + if (val != null) + val.prepareMarshal(coctx); + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { + CacheObjectContext coctx = ctx.cacheContext(cacheId).cacheObjectContext(); + + key.finishUnmarshal(coctx, ldr); + + if (val != null) + val.finishUnmarshal(coctx, ldr); + } } From bf148ab4e0bc272916d63580ac9ae34bda23f0a1 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 4 Jun 2026 22:49:21 +0300 Subject: [PATCH 094/215] WIP --- .../cache/query/continuous/CacheContinuousQueryHandler.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java index 68f05b1dea04c..1a7f57ec49fb9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java @@ -82,6 +82,7 @@ import org.apache.ignite.lang.IgniteAsyncCallback; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteClosure; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -1067,6 +1068,10 @@ private void notifyCallback0(UUID nodeId, } } + MessageSerializer ser = cctx.kernalContext().messageFactory().serializer(e.directType()); + + ser.finishUnmarshal(e, cctx.kernalContext(), null, cctx.deploy().globalLoader()); + Collection> evts = handleEvent(ctx, e); if (evts != null && !evts.isEmpty()) From 4bf1468e20ec3b9edb9219843430872537f764d6 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 4 Jun 2026 23:06:50 +0300 Subject: [PATCH 095/215] WIP --- .../processors/cache/query/GridCacheQueryRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index ad1117edeb1a8..9c980e4b23587 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -34,7 +34,7 @@ import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgniteReducer; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.INDEX; @@ -44,7 +44,7 @@ /** * Query request. */ -public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, MarshallableMessage { +public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, CacheMarshallableMessage { /** */ private static final int FLAG_DATA_PAGE_SCAN_DFLT = 0b00; From 30b3e6ff8af0c94e436f9ea8874c9d513a3fdc7f Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 4 Jun 2026 23:28:13 +0300 Subject: [PATCH 096/215] WIP --- .../processors/cache/distributed/dht/GridDhtLockRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index fe7d4bad8b260..edbc2319b7ded 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -32,7 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,7 +40,7 @@ /** * DHT lock request. */ -public class GridDhtLockRequest extends GridDistributedLockRequest implements MarshallableMessage { +public class GridDhtLockRequest extends GridDistributedLockRequest implements CacheMarshallableMessage { /** Invalidate reader flags. */ @Order(0) BitSet invalidateEntries; From 104da1a660b0f87fa0b9356165ab1cd974324b1c Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 5 Jun 2026 00:06:54 +0300 Subject: [PATCH 097/215] WIP --- .../internal/processors/cache/tree/DataRow.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java index 4f91f8e8de829..362a0d9e15aac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java @@ -45,7 +45,8 @@ public class DataRow extends CacheDataRowAdapter { */ protected DataRow(CacheGroupContext grp, int hash, long link, int part, RowData rowData, boolean skipVer) { super(link); - + + this.hash = hash; this.part = part; try { @@ -70,7 +71,8 @@ protected DataRow(CacheGroupContext grp, int hash, long link, int part, RowData */ public DataRow(KeyCacheObject key, CacheObject val, GridCacheVersion ver, int part, long expireTime, int cacheId) { super(0); - + + this.hash = key.hashCode(); this.key = key; this.val = val; this.ver = ver; @@ -88,6 +90,13 @@ public DataRow() { super(0); } + /** {@inheritDoc} */ + @Override public void key(KeyCacheObject key) { + super.key(key); + + hash = key.hashCode(); + } + /** {@inheritDoc} */ @Override public int partition() { return part; @@ -102,7 +111,7 @@ public void partition(int partId) { /** {@inheritDoc} */ @Override public int hash() { - return hash = key.hashCode(); + return hash; } /** {@inheritDoc} */ From 39a6d0b95c9a70aff87dc2c3be54e7eb296c2b55 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 5 Jun 2026 00:54:30 +0300 Subject: [PATCH 098/215] WIP --- .../internal/processors/cache/transactions/IgniteTxEntry.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index d0e04f080458a..144668b2493c6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -47,7 +47,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; @@ -59,7 +59,7 @@ * {@link #equals(Object)} method, as transaction entries should use referential * equality. */ -public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, CacheIdAware { +public class IgniteTxEntry implements GridPeerDeployAware, CacheMarshallableMessage, CacheIdAware { /** */ private static final long serialVersionUID = 0L; From dc66ed7eb4763312136e62ba8082cbbcdeac8396 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 5 Jun 2026 01:55:29 +0300 Subject: [PATCH 099/215] WIP --- .../plugin/extensions/communication/MessageSerializer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index 385143fa512f8..1c0730b52f2e6 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -69,6 +69,7 @@ public default void finishUnmarshal(M msg, GridKernalContext kctx, GridCacheCont /** * Unmarshalls message fields. + * * @param msg Message instance. * @param kctx Kernal context. * @throws IgniteCheckedException If unmarshalling fails. From fc25e5e2dc5281421e992451cf7c3754431b6c38 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 5 Jun 2026 01:58:25 +0300 Subject: [PATCH 100/215] WIP --- .../ignite/internal/managers/communication/GridIoManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 39e7c981b9a2f..66b1aaf4d0b65 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1999,7 +1999,6 @@ private void send( ser.prepareMarshal(ioMsg, ctx, null); if (locNodeId.equals(node.id())) { - assert plc != P2P_POOL; CommunicationListener commLsnr = this.commLsnr; From 108f662b8cd04e8efed282cd13e50bb0b7b17008 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 5 Jun 2026 15:32:31 +0300 Subject: [PATCH 101/215] WIP --- .../query/calcite/message/GenericValueMessage.java | 4 ++-- .../processors/query/calcite/message/MessageServiceImpl.java | 5 +++++ .../processors/query/calcite/message/QueryStartRequest.java | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java index 8a2ceea7f1965..7587aa6be062b 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java @@ -21,10 +21,10 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; /** */ -public final class GenericValueMessage implements MarshallableMessage { +public final class GenericValueMessage implements CacheMarshallableMessage { /** */ private Object val; diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java index 4c8a699ca9c68..f24a32a0110ad 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java @@ -39,6 +39,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; /** * @@ -197,6 +198,10 @@ protected void prepareMarshal(Message msg) throws IgniteCheckedException { /** */ protected void prepareUnmarshal(Message msg) throws IgniteCheckedException { try { + MessageSerializer ser = ctx.kernalContext().messageFactory().serializer(msg.directType()); + + ser.finishUnmarshal(msg, ctx.kernalContext(), null, ctx.deploy().globalLoader()); + if (msg instanceof CalciteContextMarshallableMessage) ((CalciteContextMarshallableMessage)msg).finishUnmarshal(ctx, clsLdr); } diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java index aab115e78de0f..67fa6697f9590 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java @@ -27,13 +27,13 @@ import org.apache.ignite.internal.processors.query.calcite.metadata.FragmentDescription; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** * */ -public class QueryStartRequest implements MarshallableMessage, CalciteContextMarshallableMessage, ExecutionContextAware { +public class QueryStartRequest implements CacheMarshallableMessage, CalciteContextMarshallableMessage, ExecutionContextAware { /** */ @Order(0) String schema; From 21c959ce3b7bf3c8b8966179f4f530ab66ca169d Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 15 Jun 2026 17:06:14 +0300 Subject: [PATCH 102/215] WIP --- .../org/apache/ignite/internal/MessageSerializerGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 42569cce28730..9ad1e80bfee99 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -384,7 +384,7 @@ else if (isCacheGroupIdMessage(type)) if (!first) marshall.add(EMPTY); - marshall.add(indentedLine("msg.finishUnmarshal(marshaller, U.gridClassLoader());")); + marshall.add(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));")); } indent--; From 579c37029da1299cedcd321599ff22609cae95af Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 15 Jun 2026 17:47:30 +0300 Subject: [PATCH 103/215] WIP --- .../processors/cache/GridCacheEntryInfo.java | 4 ++-- .../cache/IgniteCacheOffheapManagerImpl.java | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java index 293db4c0241b8..e63ec515d3b9a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java @@ -25,12 +25,12 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; /** * Entry information that gets passed over wire. */ -public class GridCacheEntryInfo implements MarshallableMessage, CacheIdAware { +public class GridCacheEntryInfo implements CacheMarshallableMessage, CacheIdAware { /** */ private static final int SIZE_OVERHEAD = 3 * 8 /* reference */ + 4 /* int */ + 2 * 8 /* long */ + 32 /* version */; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java index 48a3328d0469b..4e709b0879ce1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java @@ -995,13 +995,18 @@ private long allocateForTree() throws IgniteCheckedException { assert info.ttl() == TTL_ETERNAL : info.ttl(); - batch.add(new DataRowCacheAware(info.key(), - info.value(), - info.version(), - part.id(), - info.expireTime(), - info.cacheId(), - grp.storeCacheIdInDataPage())); + try { + batch.add(new DataRowCacheAware(info.key(), + info.value(), + info.version(), + part.id(), + info.expireTime(), + info.cacheId(), + grp.storeCacheIdInDataPage())); + } + catch (Throwable th) { + assert ctx.cacheContext(grp.groupId()) == null; // Ignorring removed cache entries. + } if (batch.size() == PRELOAD_SIZE_UNDER_CHECKPOINT_LOCK || !infos.hasNext()) { ctx.database().checkpointReadLock(); From 84db8ab3db81f06a2725fd39ce8e3f6277e8320e Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 15 Jun 2026 22:12:54 +0300 Subject: [PATCH 104/215] WIP --- .../ignite/internal/processors/cache/GridCacheReturn.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index 4404afed46503..ed00c8bde33ac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -33,13 +33,13 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Return value for cases where both, value and success flag need to be returned. */ -public class GridCacheReturn implements MarshallableMessage, CacheIdAware { +public class GridCacheReturn implements CacheMarshallableMessage, CacheIdAware { /** Value. */ @GridToStringInclude(sensitive = true) private volatile Object v; From bc766d03323edf1b8f2c12b5cc1214f2511095dd Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 15 Jun 2026 23:17:54 +0300 Subject: [PATCH 105/215] WIP --- .../org/apache/ignite/internal/TxEntriesInfo.java | 8 +++++++- .../internal/processors/cluster/ClusterProcessor.java | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java index 25f04b06f2bbb..4b13bc58c965e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java @@ -24,9 +24,10 @@ import org.apache.ignite.internal.processors.cache.GridCacheMapEntry; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.plugin.extensions.communication.CacheIdAware; /** */ -public final class TxEntriesInfo extends IgniteDiagnosticRequest.DiagnosticBaseInfo { +public final class TxEntriesInfo extends IgniteDiagnosticRequest.DiagnosticBaseInfo implements CacheIdAware { /** */ @Order(0) int cacheId; @@ -100,4 +101,9 @@ public TxEntriesInfo() { @Override public int hashCode() { return Objects.hash(getClass(), cacheId); } + + /** {@inheritDoc} */ + @Override public int cacheId() { + return cacheId; + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java index b7d78a906a5b7..f9a73ea8763e5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java @@ -76,6 +76,7 @@ import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.metric.MetricRegistry; import org.apache.ignite.mxbean.IgniteClusterMXBean; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.spi.discovery.DiscoveryDataBag; import org.apache.ignite.spi.discovery.DiscoveryDataBag.GridDiscoveryData; import org.apache.ignite.spi.discovery.DiscoveryMetricsProvider; @@ -382,6 +383,16 @@ public void initDiagnosticListeners() throws IgniteCheckedException { if (msg instanceof IgniteDiagnosticRequest) { IgniteDiagnosticRequest infoReq = (IgniteDiagnosticRequest)msg; + MessageSerializer ser = ctx.messageFactory().serializer(infoReq.directType()); + + try { + ser.finishUnmarshal(infoReq, ctx); + ser.finishUnmarshal(infoReq, ctx, null, U.gridClassLoader()); + } + catch (IgniteCheckedException e) { + U.error(diagnosticLog, "Failed to ummarshall diagnostic request [msg=" + infoReq + "]", e); + } + ClusterNode node = ctx.discovery().node(nodeId); if (node == null) { From 6607ab7860e3a01934121957ce0841e1d88f3031 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 15 Jun 2026 23:58:51 +0300 Subject: [PATCH 106/215] WIP --- .../cache/IgniteCacheOffheapManagerImpl.java | 4 ++-- .../processors/cache/KeyCacheObjectImpl.java | 3 ++- .../dht/GridDhtTxPrepareRequest.java | 18 ++++++------------ .../distributed/near/GridNearTxRemote.java | 10 ++++++++-- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java index 4e709b0879ce1..6419b1d49ce94 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java @@ -1004,8 +1004,8 @@ private long allocateForTree() throws IgniteCheckedException { info.cacheId(), grp.storeCacheIdInDataPage())); } - catch (Throwable th) { - assert ctx.cacheContext(grp.groupId()) == null; // Ignorring removed cache entries. + catch (IllegalStateException th) { + assert ctx.cacheContext(grp.groupId()) == null; // Ignoring removed cache entries. } if (batch.size() == PRELOAD_SIZE_UNDER_CHECKPOINT_LOCK || !infos.hasNext()) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java index f781fb3218b42..f4e6c60333838 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java @@ -108,7 +108,8 @@ public KeyCacheObjectImpl(Object val, byte[] valBytes, int part) { /** {@inheritDoc} */ @Override public int hashCode() { - assert val != null; + if (val == null) + throw new IllegalStateException("Value is null"); return IgniteUtils.hashCode(val); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 517c8f4fc0902..96698d7cf204b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -21,7 +21,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.UUID; import org.apache.ignite.IgniteCheckedException; @@ -98,9 +97,6 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest { @Order(11) BitSet preloadKeys; - /** */ - private List nearWritesCacheMissed; - /** {@code True} if remote tx should skip adding itself to completed versions map on finish. */ @Order(12) boolean skipCompletedVers; @@ -187,13 +183,6 @@ public Collection updateCounters() { return updCntrs; } - /** - * @return Near cache writes for which cache was not found (possible if client near cache was closed). - */ - @Nullable public List nearWritesCacheMissed() { - return nearWritesCacheMissed; - } - /** * @return Near transaction ID. */ @@ -359,7 +348,12 @@ public boolean skipCompletedVersion() { while (keyIter.hasNext()) { IgniteTxKey key = keyIter.next(); - owned.put(key, valIter.next()); + try { + owned.put(key, valIter.next()); + } + catch (IllegalStateException th) { + // Skipping entries for removed cache. + } } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java index 6186de9446623..e8350b4a4f0f3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java @@ -25,6 +25,7 @@ import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.cache.CacheInvalidStateException; import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException; @@ -126,9 +127,14 @@ public GridNearTxRemote( if (writeEntries != null) { for (IgniteTxEntry entry : writeEntries) { - entry.initializeContext(ctx, true); + try { + entry.initializeContext(ctx, true); - addEntry(entry); + addEntry(entry); + } + catch (IgniteCheckedException e) { + assert e instanceof CacheInvalidStateException; // Cache was destroyed. + } } } From f820df2cbed101a35653d306530adc797c07890a Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 16 Jun 2026 00:03:05 +0300 Subject: [PATCH 107/215] WIP --- .../processors/cache/transactions/TxLocksResponse.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index c008463dfe4ef..a35e5a67ab1eb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -183,8 +183,14 @@ public void addKey(IgniteTxKey key) { if (txKeysArr != null) { txKeys = U.newHashSet(txKeysArr.length); - for (IgniteTxKey txKey : txKeysArr) - txKeys.add(txKey); + for (IgniteTxKey txKey : txKeysArr) { + try { + txKeys.add(txKey); + } + catch (IllegalStateException th) { + // Skipping entries for removed cache. + } + } txKeysArr = null; } From 19d8e7a0675888b977572604c42240159e83fdd2 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 16 Jun 2026 01:33:21 +0300 Subject: [PATCH 108/215] WIP --- .../calcite/message/MessageServiceImpl.java | 2 +- .../exec/rel/AbstractExecutionTest.java | 13 ++++++++++++ .../exec/rel/ContinuousExecutionTest.java | 20 +++++++++++++++++-- .../junits/GridTestKernalContext.java | 9 +++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java index f24a32a0110ad..69f282bb9e969 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java @@ -200,7 +200,7 @@ protected void prepareUnmarshal(Message msg) throws IgniteCheckedException { try { MessageSerializer ser = ctx.kernalContext().messageFactory().serializer(msg.directType()); - ser.finishUnmarshal(msg, ctx.kernalContext(), null, ctx.deploy().globalLoader()); + ser.finishUnmarshal(msg, ctx.kernalContext(), null, clsLdr); if (msg instanceof CalciteContextMarshallableMessage) ((CalciteContextMarshallableMessage)msg).finishUnmarshal(ctx, clsLdr); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java index b7f5880259be2..af02b591a1573 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.query.calcite.exec.rel; +import java.lang.reflect.Field; import java.util.ArrayDeque; import java.util.Deque; import java.util.HashMap; @@ -40,6 +41,7 @@ import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheProcessor; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.pool.PoolProcessor; import org.apache.ignite.internal.processors.query.calcite.QueryRegistryImpl; import org.apache.ignite.internal.processors.query.calcite.exec.ArrayRowHandler; @@ -72,6 +74,7 @@ import org.junit.Before; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.mockito.Mockito; import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_THREAD_KEEP_ALIVE_TIME; @@ -196,6 +199,16 @@ public void setup() throws Exception { kernal.add(new GridCacheProcessor(kernal)); kernal.add(new PoolProcessor(kernal)); + Field ctx = kernal.cache().getClass().getDeclaredField("sharedCtx"); + + ctx.setAccessible(true); + + GridCacheSharedContext sharedCtx = Mockito.mock(GridCacheSharedContext.class); + + Mockito.when(sharedCtx.kernalContext()).thenReturn(kernal); + + ctx.set(kernal.cache(), sharedCtx); + AbstractQueryTaskExecutor taskExecutor; if (taskExecutorType == TaskExecutorType.STRIPED) { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ContinuousExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ContinuousExecutionTest.java index af835b4f0adf6..0c126ce569c2e 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ContinuousExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ContinuousExecutionTest.java @@ -27,6 +27,7 @@ import java.util.stream.Stream; import com.google.common.collect.ImmutableList; import org.apache.calcite.rel.type.RelDataType; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImpl; import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext; import org.apache.ignite.internal.processors.query.calcite.exec.MailboxRegistry; @@ -34,7 +35,9 @@ import org.apache.ignite.internal.processors.query.calcite.trait.AllNodes; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; +import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; +import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.junit.Before; import org.junit.Test; import org.junit.runners.Parameterized; @@ -58,6 +61,9 @@ public class ContinuousExecutionTest extends AbstractExecutionTest { /** */ @Parameter(REMOTE_FRAGMENTS_PARAM_NUM) public int remoteFragmentsCnt; + + /** */ + private MessageFactory messageFactory; /** */ @Parameterized.Parameters(name = PARAMS_STRING + ", " + @@ -96,10 +102,20 @@ public static List data() { @Before @Override public void setup() throws Exception { nodesCnt = remoteFragmentsCnt + 1; - super.setup(); // Register messages in Message#REGISTRATIONS and avoids failure in Message#directType(). - new IgniteMessageFactoryImpl(new MessageFactoryProvider[]{new CalciteMessageFactory()}); + messageFactory = new IgniteMessageFactoryImpl(new MessageFactoryProvider[]{new CalciteMessageFactory()}); + + super.setup(); + } + + /** {@inheritDoc} */ + @Override protected GridTestKernalContext newContext() throws IgniteCheckedException { + GridTestKernalContext kctx = super.newContext(); + + kctx.messageFactory = messageFactory; + + return kctx; } /** */ diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java index 337dd99ed4f95..3b5bf716479d8 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java @@ -37,6 +37,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.PluginProvider; +import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi; import org.apache.ignite.testframework.GridTestUtils; @@ -46,6 +47,9 @@ * Test context. */ public class GridTestKernalContext extends GridKernalContextImpl { + /** */ + public MessageFactory messageFactory; + /** * @param log Logger to use in context config. */ @@ -115,6 +119,11 @@ public void stop(boolean cancel) throws IgniteCheckedException { } } + /** {@inheritDoc} */ + @Override public MessageFactory messageFactory() { + return messageFactory != null ? messageFactory : super.messageFactory(); + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridTestKernalContext.class, this, super.toString()); From b1170c5791636bf7aa43c01aa9cf3af7496d4243 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 16 Jun 2026 15:23:57 +0300 Subject: [PATCH 109/215] WIP --- .../cache/distributed/dht/GridDhtTxPrepareRequest.java | 2 +- .../internal/processors/cache/transactions/TxLocksResponse.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 96698d7cf204b..394de19760234 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -351,7 +351,7 @@ public boolean skipCompletedVersion() { try { owned.put(key, valIter.next()); } - catch (IllegalStateException th) { + catch (IllegalStateException ignored) { // Skipping entries for removed cache. } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index a35e5a67ab1eb..b36775c47e001 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -187,7 +187,7 @@ public void addKey(IgniteTxKey key) { try { txKeys.add(txKey); } - catch (IllegalStateException th) { + catch (IllegalStateException ignored) { // Skipping entries for removed cache. } } From 428232cead9031f82f0a30eb222d5dba3bab3cf1 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 16 Jun 2026 15:34:37 +0300 Subject: [PATCH 110/215] WIP --- .../processors/cache/transactions/TxLocksResponse.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index b36775c47e001..fde78bec7bbe2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -173,7 +173,12 @@ public void addKey(IgniteTxKey key) { for (int i = 0; i < nearTxKeysArr.length; i++) { IgniteTxKey txKey = nearTxKeysArr[i]; - txLocks().put(txKey, locksArr[i]); + try { + txLocks().put(txKey, locksArr[i]); + } + catch (IllegalStateException ignored) { + // Skipping entries for missed cache. + } } nearTxKeysArr = null; From fb119f7f6f3b7b25f6bea7c7d1bd146fa6493eb1 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 16 Jun 2026 15:43:12 +0300 Subject: [PATCH 111/215] WIP --- .../processors/cache/distributed/near/GridNearTxRemote.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java index e8350b4a4f0f3..6bf95b410259d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java @@ -132,8 +132,8 @@ public GridNearTxRemote( addEntry(entry); } - catch (IgniteCheckedException e) { - assert e instanceof CacheInvalidStateException; // Cache was destroyed. + catch (CacheInvalidStateException e) { + // Cache was destroyed. } } } From bef3f8754d2a6688ff86b2127edc9360d9d73141 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 16 Jun 2026 19:51:00 +0300 Subject: [PATCH 112/215] WIP --- .../processors/cache/GridCacheIoManager.java | 2 +- .../dht/GridDhtTxLocalAdapter.java | 2 +- .../distributed/dht/GridDhtTxRemote.java | 2 +- .../distributed/near/GridNearTxRemote.java | 4 ++-- .../cache/transactions/IgniteTxEntry.java | 10 ++++++-- .../cache/transactions/IgniteTxHandler.java | 23 ++++++++++++++----- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index 40fef83d2caf3..e1d7b25d482e9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -742,7 +742,7 @@ else if (cacheMsg instanceof GridNearAtomicCheckUpdateRequest) * @param plc Message policy. * @throws IgniteCheckedException If failed. */ - private void processFailedMessage(UUID nodeId, + public void processFailedMessage(UUID nodeId, GridCacheMessage msg, IgniteBiInClosure c, byte plc) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java index 45ab9b9cfd746..746f5a90bb9ae 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java @@ -496,7 +496,7 @@ private void addMapping( assert state == PREPARING : "Invalid tx state for " + "adding entry [msgId=" + msgId + ", e=" + e + ", tx=" + this + ']'; - e.initializeContext(cctx, false); + e.initializeContext(cctx, topVer, false); checkInternal(e.txKey()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java index 3c5ff043e389d..693583230fa6a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java @@ -276,7 +276,7 @@ public UUID nearNodeId() { * @throws IgniteCheckedException If failed. */ public void addWrite(IgniteTxEntry entry, ClassLoader ldr) throws IgniteCheckedException { - entry.initializeContext(cctx, false); + entry.initializeContext(cctx, topVer, false); GridCacheContext cacheCtx = entry.context(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java index 6bf95b410259d..d67accfd6bedc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java @@ -128,7 +128,7 @@ public GridNearTxRemote( if (writeEntries != null) { for (IgniteTxEntry entry : writeEntries) { try { - entry.initializeContext(ctx, true); + entry.initializeContext(ctx, topVer, true); addEntry(entry); } @@ -209,7 +209,7 @@ public Collection evicted() { */ public void addEntries(ClassLoader ldr, Iterable entries) throws IgniteCheckedException { for (IgniteTxEntry entry : entries) { - entry.initializeContext(cctx, true); + entry.initializeContext(cctx, topVer, true); addEntry(entry); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index 144668b2493c6..abcdbf2916e0a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -26,6 +26,7 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; import org.apache.ignite.internal.processors.cache.CacheInvalidStateException; import org.apache.ignite.internal.processors.cache.CacheInvokeEntry; @@ -1052,14 +1053,19 @@ public void filtersSet(boolean filtersSet) { /** * @param ctx Cache context. + * @param topVer Topology version that is used to validate a cache context. + * If this parameter is {@code null} then validation will be skipped. * @param near Near flag. * @throws IgniteCheckedException If un-marshalling failed. */ - public void initializeContext(GridCacheSharedContext ctx, boolean near) throws IgniteCheckedException { + public void initializeContext(GridCacheSharedContext ctx, + AffinityTopologyVersion topVer, + boolean near + ) throws IgniteCheckedException { if (this.ctx == null) { GridCacheContext cacheCtx = ctx.cacheContext(cacheId); - if (cacheCtx == null) + if (cacheCtx == null || (topVer != null && topVer.before(cacheCtx.startTopologyVersion()))) throw new CacheInvalidStateException( "Failed to perform cache operation (cache is stopped), cacheId=" + cacheId); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java index df2a4467a97ee..d7023ca336edc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java @@ -371,14 +371,16 @@ public IgniteInternalFuture prepareColocatedTx( * @return First entry. * @throws IgniteCheckedException If failed. */ - private IgniteTxEntry unmarshal(@Nullable Collection entries) throws IgniteCheckedException { + private IgniteTxEntry initialize( + @Nullable Collection entries, + AffinityTopologyVersion topVer) throws IgniteCheckedException { if (entries == null) return null; IgniteTxEntry firstEntry = null; for (IgniteTxEntry e : entries) { - e.initializeContext(ctx, false); + e.initializeContext(ctx, topVer, false); if (firstEntry == null) firstEntry = e; @@ -427,12 +429,21 @@ public IgniteInternalFuture prepareNearTxLocal( IgniteTxEntry firstEntry; try { - IgniteTxEntry firstWrite = unmarshal(req.writes()); - IgniteTxEntry firstRead = unmarshal(req.reads()); + IgniteTxEntry firstWrite = initialize(req.writes(), req.topologyVersion()); + IgniteTxEntry firstRead = initialize(req.reads(), req.topologyVersion()); firstEntry = firstWrite != null ? firstWrite : firstRead; } catch (IgniteCheckedException e) { + try { + req.onClassError(e); + + ctx.io().processFailedMessage(nearNode.id(), req, null, req.policy()); + } + catch (IgniteCheckedException ex) { + throw new IgniteException(ex); + } + return new GridFinishedFuture<>(e); } @@ -1229,7 +1240,7 @@ private void processDhtTxPrepareRequest(final UUID nodeId, final GridDhtTxPrepar else { e.context(cacheCtx); - e.initializeContext(ctx, true); + e.initializeContext(ctx, req.topologyVersion(), true); } } @@ -1765,7 +1776,7 @@ private void sendReply(UUID nodeId, GridDhtTxFinishRequest req, boolean committe int idx = 0; for (IgniteTxEntry entry : req.writes()) { - entry.initializeContext(ctx, false); + entry.initializeContext(ctx, req.topologyVersion(), false); GridCacheContext cacheCtx = entry.context(); From a34f972996a0660c174f657fe419caeaf3edc835 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 16 Jun 2026 22:02:27 +0300 Subject: [PATCH 113/215] WIP --- .../ignite/internal/MessageProcessor.java | 3 +- .../communication/tcp/TestDelayMessage.java | 32 ++--------- .../tcp/TestDelayMessageSerializer.java | 53 +++++++++++++++++++ 3 files changed, 58 insertions(+), 30 deletions(-) create mode 100644 modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessageSerializer.java diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java index 38e0e4adb3203..2beb70f328c10 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java @@ -86,7 +86,8 @@ public class MessageProcessor extends AbstractProcessor { static final String[] SKIP_MESSAGES = { "org.apache.ignite.internal.processors.odbc.ClientMessage", COMPRESSED_MESSAGE_CLASS, - "org.apache.ignite.loadtests.communication.GridTestMessage" + "org.apache.ignite.loadtests.communication.GridTestMessage", + "org.apache.ignite.spi.communication.tcp.TestDelayMessage" }; /** */ diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessage.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessage.java index af49c5f9c96c4..70c8f724b60a7 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessage.java @@ -17,21 +17,12 @@ package org.apache.ignite.spi.communication.tcp; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.IgniteInterruptedCheckedException; -import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; /** Test message. */ -public class TestDelayMessage implements MarshallableMessage { +public class TestDelayMessage implements Message { /** */ - @Order(0) - int val; - - /** */ - private final int writeDelay; + final int writeDelay; /** */ public TestDelayMessage(int writeDelay) { @@ -42,21 +33,4 @@ public TestDelayMessage(int writeDelay) { public TestDelayMessage() { this(0); } - - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (writeDelay > 0) { - try { - U.sleep(writeDelay); - } - catch (IgniteInterruptedCheckedException ignored) { - // No-op. - } - } - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - // No-op. - } } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessageSerializer.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessageSerializer.java new file mode 100644 index 0000000000000..28de0ed417ddb --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessageSerializer.java @@ -0,0 +1,53 @@ +/* + * 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.spi.communication.tcp; + +import org.apache.ignite.internal.IgniteInterruptedCheckedException; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageWriter; + +/** */ +public class TestDelayMessageSerializer implements MessageSerializer { + /** */ + @Override public boolean writeTo(TestDelayMessage msg, MessageWriter writer) { + if (!writer.isHeaderWritten()) { + if (!writer.writeHeader(msg.directType())) + return false; + + writer.onHeaderWritten(); + } + + if (msg.writeDelay > 0) { + try { + U.sleep(msg.writeDelay); + } + catch (IgniteInterruptedCheckedException ignored) { + // No-op. + } + } + + return true; + } + + /** */ + @Override public boolean readFrom(TestDelayMessage msg, MessageReader reader) { + return true; + } +} \ No newline at end of file From d6d5651ad9b74eb2e73fc40b9e55753687e1e044 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 16 Jun 2026 22:13:18 +0300 Subject: [PATCH 114/215] WIP --- .../spi/communication/tcp/TestDelayMessageSerializer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessageSerializer.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessageSerializer.java index 28de0ed417ddb..98222023c81dd 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessageSerializer.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TestDelayMessageSerializer.java @@ -50,4 +50,4 @@ public class TestDelayMessageSerializer implements MessageSerializer Date: Wed, 17 Jun 2026 15:32:45 +0300 Subject: [PATCH 115/215] WIP --- .../processors/query/calcite/metadata/ColocationGroup.java | 4 ++-- .../org/apache/ignite/internal/GridJobSiblingsResponse.java | 4 ++-- .../ignite/internal/managers/communication/ErrorMessage.java | 4 ++-- .../managers/eventstorage/GridEventStorageMessage.java | 4 ++-- .../distributed/dht/atomic/GridDhtAtomicUpdateRequest.java | 4 ++-- .../dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java | 4 ++-- .../dht/preloader/GridDhtPartitionsFullMessage.java | 4 ++-- .../dht/preloader/GridDhtPartitionsSingleMessage.java | 4 ++-- .../internal/processors/cache/verify/PartitionHashRecord.java | 4 ++-- .../processors/cache/verify/TransactionsHashRecord.java | 4 ++-- .../query/schema/operation/SchemaAddQueryEntityOperation.java | 4 ++-- .../processors/rest/handlers/task/GridTaskResultResponse.java | 4 ++-- .../internal/processors/service/ServiceDeploymentRequest.java | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java index cee6beefb7012..377591c837d03 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java @@ -38,10 +38,10 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; /** */ -public class ColocationGroup implements MarshallableMessage { +public class ColocationGroup implements CacheMarshallableMessage { /** */ @Order(0) long[] srcIds; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java index c78508b03a5cc..68ded7abbf503 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java @@ -23,13 +23,13 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Job siblings response. */ -public class GridJobSiblingsResponse implements MarshallableMessage { +public class GridJobSiblingsResponse implements CacheMarshallableMessage { /** */ private @Nullable Collection siblings; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java index b497e76ae845c..8087a47fbe324 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java @@ -23,14 +23,14 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Message used to transfer {@link Throwable} objects. */ @SuppressWarnings({"NullableProblems", "unused"}) -public class ErrorMessage implements MarshallableMessage { +public class ErrorMessage implements CacheMarshallableMessage { /** Error bytes. */ @Order(0) @GridToStringExclude diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java index 183062ac72c7e..c2998ba2c68c8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java @@ -33,13 +33,13 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Event storage message. */ -public class GridEventStorageMessage implements MarshallableMessage { +public class GridEventStorageMessage implements CacheMarshallableMessage { /** */ @Order(0) GridTopicMessage resTopicMsg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 3c69ee2d1f18a..3cb91d026a627 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -37,14 +37,14 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Lite dht cache backup update request. */ -public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements MarshallableMessage { +public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements CacheMarshallableMessage { /** Keys to update. */ @GridToStringInclude @Order(0) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java index 523b3341c4f6d..f9ef62894fdd8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java @@ -27,14 +27,14 @@ import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * */ -public class GridNearAtomicSingleUpdateFilterRequest extends GridNearAtomicSingleUpdateRequest implements MarshallableMessage { +public class GridNearAtomicSingleUpdateFilterRequest extends GridNearAtomicSingleUpdateRequest implements CacheMarshallableMessage { /** Filter. */ @Order(0) CacheEntryPredicate[] filter; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index 6cce1a2ac30ea..00473e4898074 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -40,7 +40,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -49,7 +49,7 @@ * GridDhtPartitionsSingleMessage}s were received.
May be also compacted as part of {@link * CacheAffinityChangeMessage} for node left or failed case.
*/ -public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { +public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessage implements CacheMarshallableMessage { /** */ private static final byte REBALANCED_FLAG_MASK = 0x01; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index 89a0d7f22d0db..50dbf868f20fc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -31,7 +31,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** @@ -39,7 +39,7 @@ * * Sent in response to {@link GridDhtPartitionsSingleRequest} and during processing partitions exchange future. */ -public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { +public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements CacheMarshallableMessage { /** Local partitions. */ @Order(0) @Compress diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java index 766ab1752e55c..61ac480634620 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java @@ -29,14 +29,14 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.jetbrains.annotations.Nullable; /** * Record containing partition checksum, primary flag and consistent ID of owner. */ -public class PartitionHashRecord implements MarshallableMessage, Serializable { +public class PartitionHashRecord implements CacheMarshallableMessage, Serializable { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java index 3b22bdf1862fa..7094c0e580cec 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java @@ -24,10 +24,10 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; /** Represents committed transactions hash for a pair of nodes. */ -public class TransactionsHashRecord implements MarshallableMessage, Serializable { +public class TransactionsHashRecord implements CacheMarshallableMessage, Serializable { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java index 3066afad53449..2768ee19c77e4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java @@ -24,12 +24,12 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; /** * Enabling indexing on cache operation. */ -public class SchemaAddQueryEntityOperation extends SchemaAbstractOperation implements MarshallableMessage { +public class SchemaAddQueryEntityOperation extends SchemaAbstractOperation implements CacheMarshallableMessage { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java index 3661cae983735..11a5182de4301 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -21,13 +21,13 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Task result response. */ -public class GridTaskResultResponse implements MarshallableMessage { +public class GridTaskResultResponse implements CacheMarshallableMessage { /** Result. */ public @Nullable Object res; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java index 4d1813477ad91..a524da43be9c1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java @@ -23,14 +23,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.jetbrains.annotations.NotNull; /** * Service deployment request. */ -public class ServiceDeploymentRequest extends ServiceChangeAbstractRequest implements MarshallableMessage { +public class ServiceDeploymentRequest extends ServiceChangeAbstractRequest implements CacheMarshallableMessage { /** Service configuration. */ private LazyServiceConfiguration cfg; From b9579804a253f874e71ebe16a9810456525aa672 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 17 Jun 2026 19:13:20 +0300 Subject: [PATCH 116/215] WIP --- .../ignite/internal/managers/communication/ErrorMessage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java index 8087a47fbe324..b497e76ae845c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java @@ -23,14 +23,14 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Message used to transfer {@link Throwable} objects. */ @SuppressWarnings({"NullableProblems", "unused"}) -public class ErrorMessage implements CacheMarshallableMessage { +public class ErrorMessage implements MarshallableMessage { /** Error bytes. */ @Order(0) @GridToStringExclude From 212f4655881ef4e4530040174d171f67c7847dd2 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 17 Jun 2026 19:15:57 +0300 Subject: [PATCH 117/215] WIP --- .../internal/processors/service/ServiceDeploymentRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java index a524da43be9c1..4d1813477ad91 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java @@ -23,14 +23,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.jetbrains.annotations.NotNull; /** * Service deployment request. */ -public class ServiceDeploymentRequest extends ServiceChangeAbstractRequest implements CacheMarshallableMessage { +public class ServiceDeploymentRequest extends ServiceChangeAbstractRequest implements MarshallableMessage { /** Service configuration. */ private LazyServiceConfiguration cfg; From 43d212483b32b2a72c543032eb43b02c48e3541d Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 17 Jun 2026 19:18:00 +0300 Subject: [PATCH 118/215] WIP --- .../query/schema/operation/SchemaAddQueryEntityOperation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java index 2768ee19c77e4..3066afad53449 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java @@ -24,12 +24,12 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * Enabling indexing on cache operation. */ -public class SchemaAddQueryEntityOperation extends SchemaAbstractOperation implements CacheMarshallableMessage { +public class SchemaAddQueryEntityOperation extends SchemaAbstractOperation implements MarshallableMessage { /** */ private static final long serialVersionUID = 0L; From bf8c45f1d249b4da5601fc0ce0e5415e6dd8a59c Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 17 Jun 2026 19:27:24 +0300 Subject: [PATCH 119/215] WIP --- .../internal/processors/cache/verify/PartitionHashRecord.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java index 61ac480634620..766ab1752e55c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java @@ -29,14 +29,14 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.jetbrains.annotations.Nullable; /** * Record containing partition checksum, primary flag and consistent ID of owner. */ -public class PartitionHashRecord implements CacheMarshallableMessage, Serializable { +public class PartitionHashRecord implements MarshallableMessage, Serializable { /** */ private static final long serialVersionUID = 0L; From 90878029fbc8d91ef55e40364324e8231e0dd999 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 17 Jun 2026 19:40:52 +0300 Subject: [PATCH 120/215] WIP --- .../internal/managers/communication/GridIoManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 66b1aaf4d0b65..8509d98d2ef19 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1994,10 +1994,6 @@ private void send( GridIoMessage ioMsg = createGridIoMessage(topic, msg, plc, ordered, timeout, skipOnTimeout); - MessageSerializer ser = ctx.messageFactory().serializer(ioMsg.directType()); - - ser.prepareMarshal(ioMsg, ctx, null); - if (locNodeId.equals(node.id())) { assert plc != P2P_POOL; @@ -2017,6 +2013,10 @@ else if (async) ackC.apply(null); } else { + MessageSerializer ser = ctx.messageFactory().serializer(ioMsg.directType()); + + ser.prepareMarshal(ioMsg, ctx, null); + try { if ((CommunicationSpi)getSpi() instanceof TcpCommunicationSpi) getTcpCommunicationSpi().sendMessage(node, ioMsg, ackC); From a770f39b2df683553ebde1efc94de0422fd3ee02 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 17 Jun 2026 19:46:09 +0300 Subject: [PATCH 121/215] WIP --- .../ignite/internal/processors/cache/GridCacheMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index 52f7b0a8f2c09..61834dd58fc26 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -383,7 +383,7 @@ else if (p2pEnabled && e.entryProcessors() != null) { * @param ctx Context. * @throws IgniteCheckedException If failed. */ - @Nullable protected final void prepareInvokeArgumentsDeployment(@Nullable Object[] args, GridCacheContext ctx) + protected final void prepareInvokeArgumentsDeployment(@Nullable Object[] args, GridCacheContext ctx) throws IgniteCheckedException { assert ctx != null; From 5cb3bcc1da8ea005b7c9e87678c7b02317464480 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 18 Jun 2026 14:19:56 +0300 Subject: [PATCH 122/215] WIP --- .../processors/cache/verify/TransactionsHashRecord.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java index 7094c0e580cec..3b22bdf1862fa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java @@ -24,10 +24,10 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** Represents committed transactions hash for a pair of nodes. */ -public class TransactionsHashRecord implements CacheMarshallableMessage, Serializable { +public class TransactionsHashRecord implements MarshallableMessage, Serializable { /** */ private static final long serialVersionUID = 0L; From d2e169c764fb3a37e01928718ebfeabd802459d6 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 18 Jun 2026 14:37:22 +0300 Subject: [PATCH 123/215] WIP --- .../org/apache/ignite/internal/GridJobSiblingsResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java index 68ded7abbf503..c78508b03a5cc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java @@ -23,13 +23,13 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Job siblings response. */ -public class GridJobSiblingsResponse implements CacheMarshallableMessage { +public class GridJobSiblingsResponse implements MarshallableMessage { /** */ private @Nullable Collection siblings; From 3b781e7815774576b8fc1843911cdc1c9a58f359 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 18 Jun 2026 14:38:17 +0300 Subject: [PATCH 124/215] WIP --- .../managers/eventstorage/GridEventStorageMessage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java index c2998ba2c68c8..183062ac72c7e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java @@ -33,13 +33,13 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Event storage message. */ -public class GridEventStorageMessage implements CacheMarshallableMessage { +public class GridEventStorageMessage implements MarshallableMessage { /** */ @Order(0) GridTopicMessage resTopicMsg; From 82a93affd54f7213f3114111bcaa723ee6f828e1 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 18 Jun 2026 14:58:02 +0300 Subject: [PATCH 125/215] WIP --- .../CalciteContextMarshallableMessage.java | 44 ------------------- .../calcite/message/MessageServiceImpl.java | 21 +-------- .../calcite/message/QueryStartRequest.java | 19 +------- .../query/calcite/message/QueryTxEntry.java | 26 +---------- 4 files changed, 4 insertions(+), 106 deletions(-) delete mode 100644 modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteContextMarshallableMessage.java diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteContextMarshallableMessage.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteContextMarshallableMessage.java deleted file mode 100644 index f81fd1709c088..0000000000000 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteContextMarshallableMessage.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.query.calcite.message; - -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.plugin.extensions.communication.Message; - -/** A Calcite engine related message which requires marshalling with context. */ -public interface CalciteContextMarshallableMessage extends Message { - /** - * Prepares the message before sending. - * - * @param ctx Cache shared context. - */ - default void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - // No-op. - } - - /** - * Prepares the message before processing. - * - * @param ctx Cache shared context. - * @param clsLdr Class loader. - */ - default void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader clsLdr) throws IgniteCheckedException { - // No-op. - } -} diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java index 69f282bb9e969..1dc621952612e 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java @@ -155,11 +155,8 @@ public FailureProcessor failureProcessor() { @Override public void send(UUID nodeId, Message msg) throws IgniteCheckedException { if (localNodeId().equals(nodeId)) onMessage(nodeId, msg); - else { - prepareMarshal(msg); - + else ioManager().sendToGridTopic(nodeId, GridTopic.TOPIC_QUERY, msg, GridIoPolicy.CALLER_THREAD); - } } /** {@inheritDoc} */ @@ -182,28 +179,12 @@ public FailureProcessor failureProcessor() { } } - /** */ - protected void prepareMarshal(Message msg) throws IgniteCheckedException { - try { - if (msg instanceof CalciteContextMarshallableMessage) - ((CalciteContextMarshallableMessage)msg).prepareMarshal(ctx); - } - catch (Exception e) { - failureProcessor().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); - - throw e; - } - } - /** */ protected void prepareUnmarshal(Message msg) throws IgniteCheckedException { try { MessageSerializer ser = ctx.kernalContext().messageFactory().serializer(msg.directType()); ser.finishUnmarshal(msg, ctx.kernalContext(), null, clsLdr); - - if (msg instanceof CalciteContextMarshallableMessage) - ((CalciteContextMarshallableMessage)msg).finishUnmarshal(ctx, clsLdr); } catch (Exception e) { failureProcessor().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java index 67fa6697f9590..61289af51d0c1 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java @@ -23,7 +23,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.query.calcite.metadata.FragmentDescription; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; @@ -33,7 +32,7 @@ /** * */ -public class QueryStartRequest implements CacheMarshallableMessage, CalciteContextMarshallableMessage, ExecutionContextAware { +public class QueryStartRequest implements CacheMarshallableMessage, ExecutionContextAware { /** */ @Order(0) String schema; @@ -220,14 +219,6 @@ public boolean keepBinaryMode() { paramsBytes = U.marshal(marsh, params); } - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - if (qryTxEntries != null) { - for (QueryTxEntry e : qryTxEntries) - e.prepareMarshal(ctx); - } - } - /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (params == null && paramsBytes != null) @@ -235,12 +226,4 @@ public boolean keepBinaryMode() { paramsBytes = null; } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader clsLdr) throws IgniteCheckedException { - if (qryTxEntries != null) { - for (QueryTxEntry e : qryTxEntries) - e.finishUnmarshal(ctx, clsLdr); - } - } } diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java index 0d6dfd38d9172..5b5640f094825 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java @@ -20,16 +20,14 @@ import java.util.Collection; import java.util.Comparator; import java.util.function.Function; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.CacheObjectContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; +import org.apache.ignite.plugin.extensions.communication.Message; /** * Class to pass to remote nodes transaction changes. @@ -39,7 +37,7 @@ * @see ExecutionContext#transactionChanges(int, int[], Function, Comparator) * @see QueryStartRequest#queryTransactionEntries() */ -public class QueryTxEntry implements CalciteContextMarshallableMessage, CacheIdAware { +public class QueryTxEntry implements Message, CacheIdAware { /** Cache id. */ @Order(0) int cacheId; @@ -95,24 +93,4 @@ public CacheObject value() { public GridCacheVersion version() { return ver; } - - /** {@inheritDoc} */ - @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { - CacheObjectContext coctx = ctx.cacheContext(cacheId).cacheObjectContext(); - - key.prepareMarshal(coctx); - - if (val != null) - val.prepareMarshal(coctx); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { - CacheObjectContext coctx = ctx.cacheContext(cacheId).cacheObjectContext(); - - key.finishUnmarshal(coctx, ldr); - - if (val != null) - val.finishUnmarshal(coctx, ldr); - } } From 3efaf5fb14be63684f61fce05b9ff88230d7c756 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 18 Jun 2026 16:36:14 +0300 Subject: [PATCH 126/215] WIP --- .../ignite/internal/processors/cache/GridCacheReturn.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index ed00c8bde33ac..8946f2c38f6f0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -126,7 +126,7 @@ public GridCacheReturn( @Nullable public V value(GridCacheContext ctx) { if (v == null) { if (cacheObj != null) - v = ctx.cacheObjectContext().unwrapBinaryIfNeeded(cacheObj, true, false, U.gridClassLoader()); + v = ctx.cacheObjectContext().unwrapBinaryIfNeeded(cacheObj, true, false, ctx.deploy().globalLoader()); if (invokeRes && invokeResCol != null) { Map map0 = U.newHashMap(invokeResCol.size()); From ef766e7227bf22f43a7cccdbdfb95aca5d901bac Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 18 Jun 2026 16:40:20 +0300 Subject: [PATCH 127/215] WIP --- .../processors/cache/IgniteCacheOffheapManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java index 6419b1d49ce94..000752998796b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java @@ -1005,7 +1005,7 @@ private long allocateForTree() throws IgniteCheckedException { grp.storeCacheIdInDataPage())); } catch (IllegalStateException th) { - assert ctx.cacheContext(grp.groupId()) == null; // Ignoring removed cache entries. + assert ctx.cacheContext(info.cacheId()) == null; // Ignoring removed cache entries. } if (batch.size() == PRELOAD_SIZE_UNDER_CHECKPOINT_LOCK || !infos.hasNext()) { From b011b3d3502283260a639507670ca662290ac140 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 18 Jun 2026 16:43:08 +0300 Subject: [PATCH 128/215] WIP --- .../spi/discovery/zk/internal/DiscoveryMessageParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index 4cc146b7e0ab3..39498c824ddcf 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -96,7 +96,7 @@ private void serializeMessage(Message m, OutputStream out) throws IOException { msgSer.prepareMarshal(m, ((IgniteEx)spi.ignite()).context(), null); } catch (IgniteCheckedException e) { - throw new IgniteSpiException("Failed to marshal joining node data", e); + throw new IgniteSpiException("Failed to marshal discovery message", e); } boolean finished; From 4f6d5810db1ca675eba5c99010b10f9a9794ff94 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 18 Jun 2026 16:44:49 +0300 Subject: [PATCH 129/215] WIP --- .../spi/discovery/zk/internal/DiscoveryMessageParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index 39498c824ddcf..6f2896001128f 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -144,7 +144,7 @@ private T deserializeMessage(InputStream in) throws IOExcept msgSer.finishUnmarshal(msg, ((IgniteEx)spi.ignite()).context()); } catch (IgniteCheckedException e) { - throw new IgniteSpiException("Failed to unmarshal joining node data", e); + throw new IgniteSpiException("Failed to unmarshal discovery message", e); } return (T)msg; From f8e95eccfa37f4df9c43d33ee2cabd25e0b491dd Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 18 Jun 2026 17:42:08 +0300 Subject: [PATCH 130/215] WIP --- .../tcp/DiscoveryUnmarshalVulnerabilityTest.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index d207750d31fa1..ccaf13eb56be9 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -51,7 +51,6 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_ENABLE_OBJECT_INPUT_FILTER_AUTOCONFIGURATION; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHALLER_BLACKLIST; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHALLER_WHITELIST; -import static org.apache.ignite.marshaller.Marshallers.jdk; import static org.apache.ignite.testframework.GridTestUtils.loadSerializer; /** @@ -283,7 +282,16 @@ private MessageSerializerWrapper(AbstractMarshallableMessageFactoryProvider prov /** {@inheritDoc} */ @Override public void prepareMarshal(ExploitMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - msg.prepareMarshal(jdk()); + initIfNecessary(); + + serde.prepareMarshal(msg, kctx, nested); + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(ExploitMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + initIfNecessary(); + + serde.finishUnmarshal(msg, kctx); } /** */ From 9b96c569f97a8f18c77f37871e3c76929a5998cd Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 18 Jun 2026 23:32:02 +0300 Subject: [PATCH 131/215] WIP --- .../query/calcite/planner/AbstractPlannerTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java index b49af08b5c700..82ee3fab07fdd 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java @@ -786,6 +786,11 @@ static class TestMessageServiceImpl extends MessageServiceImpl { @Override public boolean alive(UUID nodeId) { return true; } + + /** {@inheritDoc} */ + @Override protected void prepareUnmarshal(Message msg) { + // No-op: TestIoManager delivers messages in-memory, no deserialization needed. + } } /** */ From 9f1fda4f52bea099f39d40d96732213161da6b54 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 18 Jun 2026 23:45:40 +0300 Subject: [PATCH 132/215] WIP --- .../exec/rel/AbstractExecutionTest.java | 18 +++++------------ .../exec/rel/ContinuousExecutionTest.java | 20 ++----------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java index af02b591a1573..5dd910a20c7e9 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java @@ -17,7 +17,6 @@ package org.apache.ignite.internal.processors.query.calcite.exec.rel; -import java.lang.reflect.Field; import java.util.ArrayDeque; import java.util.Deque; import java.util.HashMap; @@ -41,7 +40,6 @@ import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheProcessor; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.pool.PoolProcessor; import org.apache.ignite.internal.processors.query.calcite.QueryRegistryImpl; import org.apache.ignite.internal.processors.query.calcite.exec.ArrayRowHandler; @@ -74,7 +72,6 @@ import org.junit.Before; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import org.mockito.Mockito; import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_THREAD_KEEP_ALIVE_TIME; @@ -199,16 +196,6 @@ public void setup() throws Exception { kernal.add(new GridCacheProcessor(kernal)); kernal.add(new PoolProcessor(kernal)); - Field ctx = kernal.cache().getClass().getDeclaredField("sharedCtx"); - - ctx.setAccessible(true); - - GridCacheSharedContext sharedCtx = Mockito.mock(GridCacheSharedContext.class); - - Mockito.when(sharedCtx.kernalContext()).thenReturn(kernal); - - ctx.set(kernal.cache(), sharedCtx); - AbstractQueryTaskExecutor taskExecutor; if (taskExecutorType == TaskExecutorType.STRIPED) { @@ -412,6 +399,11 @@ private TestMessageServiceImpl(GridKernalContext kernal, TestIoManager mgr) { @Override public boolean alive(UUID nodeId) { return true; } + + /** {@inheritDoc} */ + @Override protected void prepareUnmarshal(Message msg) { + // No-op: TestIoManager delivers messages in-memory, no deserialization needed. + } } /** diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ContinuousExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ContinuousExecutionTest.java index 0c126ce569c2e..af835b4f0adf6 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ContinuousExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ContinuousExecutionTest.java @@ -27,7 +27,6 @@ import java.util.stream.Stream; import com.google.common.collect.ImmutableList; import org.apache.calcite.rel.type.RelDataType; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImpl; import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext; import org.apache.ignite.internal.processors.query.calcite.exec.MailboxRegistry; @@ -35,9 +34,7 @@ import org.apache.ignite.internal.processors.query.calcite.trait.AllNodes; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; -import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; -import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.junit.Before; import org.junit.Test; import org.junit.runners.Parameterized; @@ -61,9 +58,6 @@ public class ContinuousExecutionTest extends AbstractExecutionTest { /** */ @Parameter(REMOTE_FRAGMENTS_PARAM_NUM) public int remoteFragmentsCnt; - - /** */ - private MessageFactory messageFactory; /** */ @Parameterized.Parameters(name = PARAMS_STRING + ", " + @@ -102,20 +96,10 @@ public static List data() { @Before @Override public void setup() throws Exception { nodesCnt = remoteFragmentsCnt + 1; - - // Register messages in Message#REGISTRATIONS and avoids failure in Message#directType(). - messageFactory = new IgniteMessageFactoryImpl(new MessageFactoryProvider[]{new CalciteMessageFactory()}); - super.setup(); - } - /** {@inheritDoc} */ - @Override protected GridTestKernalContext newContext() throws IgniteCheckedException { - GridTestKernalContext kctx = super.newContext(); - - kctx.messageFactory = messageFactory; - - return kctx; + // Register messages in Message#REGISTRATIONS and avoids failure in Message#directType(). + new IgniteMessageFactoryImpl(new MessageFactoryProvider[]{new CalciteMessageFactory()}); } /** */ From 31b4912bfe58eef530a2e4cd50f8f620e0700b80 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 00:18:09 +0300 Subject: [PATCH 133/215] WIP --- .../internal/MessageSerializerGenerator.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 9ad1e80bfee99..574bd00ff9877 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -278,14 +278,7 @@ private void generateMarshallMethods(List orderedFields) { indent++; - if (isCacheIdAwareMessage(type)) - marshall.add( - indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.cacheId()) : nested;")); - else if (isCacheGroupIdMessage(type)) - marshall.add( - indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.groupId()) : nested;")); - else - marshall.add(indentedLine("GridCacheContext ctx = nested;")); + addCtxResolution(); if (marshallableMessage()) { marshall.add(EMPTY); @@ -323,14 +316,7 @@ private void generateUnmarshallMethods(List orderedFields) { indent++; - if (isCacheIdAwareMessage(type)) - marshall.add( - indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.cacheId()) : nested;")); - else if (isCacheGroupIdMessage(type)) - marshall.add( - indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.groupId()) : nested;")); - else - marshall.add(indentedLine("GridCacheContext ctx = nested;")); + addCtxResolution(); for (VariableElement field : orderedFields) { List unmarshalled = marshall(field.asType(), fieldAccessor(field), true, false); @@ -392,6 +378,18 @@ else if (isCacheGroupIdMessage(type)) marshall.add(indentedLine("}")); } + /** Adds a {@code GridCacheContext ctx} resolution line for the current message type. */ + private void addCtxResolution() { + if (isCacheIdAwareMessage(type)) + marshall.add( + indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.cacheId()) : nested;")); + else if (isCacheGroupIdMessage(type)) + marshall.add( + indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.groupId()) : nested;")); + else + marshall.add(indentedLine("GridCacheContext ctx = nested;")); + } + /** */ private List marshall(TypeMirror t, String accessor, boolean unmarshall, boolean cache) { if (t.getKind() == TypeKind.ARRAY) { From ae0d761b29aeaec1358f20a8ad9d37c420dd6346 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 14:40:11 +0300 Subject: [PATCH 134/215] WIP --- .../calcite/message/MessageServiceImpl.java | 8 +- .../ignite/internal/MessageGenerator.java | 261 +++++++ .../internal/MessageMarshallerGenerator.java | 505 ++++++++++++++ .../ignite/internal/MessageProcessor.java | 10 + .../internal/MessageSerializerGenerator.java | 642 +----------------- .../idto/IDTOSerializerGenerator.java | 25 +- .../IgniteDataTransferObjectProcessor.java | 6 +- .../CompressedMessageMarshaller.java | 41 ++ .../managers/communication/GridIoManager.java | 18 +- .../IgniteMessageFactoryImpl.java | 29 +- ...actMarshallableMessageFactoryProvider.java | 24 +- .../processors/cache/GridCacheIoManager.java | 7 +- .../CacheContinuousQueryHandler.java | 7 +- .../cache/transactions/IgniteTxManager.java | 9 +- .../processors/cluster/ClusterProcessor.java | 8 +- .../communication/MessageFactory.java | 27 +- .../communication/MessageMarshaller.java | 85 +++ .../communication/MessageSerializer.java | 41 -- .../apache/ignite/spi/IgniteSpiAdapter.java | 5 + .../tcp/internal/GridNioServerWrapper.java | 5 + .../discovery/tcp/TcpDiscoveryIoSession.java | 5 +- .../codegen/MessageProcessorTest.java | 56 +- ...ByteBufferStreamImplByteOrderSelfTest.java | 5 + .../DataStreamerImplSelfTest.java | 7 +- .../ignite/spi/MessagesPluginProvider.java | 2 +- .../DiscoveryUnmarshalVulnerabilityTest.java | 57 +- .../ignite/testframework/GridTestUtils.java | 35 +- .../codegen/ChildMessageMarshaller.java | 49 ++ .../codegen/ChildMessageSerializer.java | 20 +- ...stomMapperEnumFieldsMessageMarshaller.java | 49 ++ ...stomMapperEnumFieldsMessageSerializer.java | 19 +- ...aultMapperEnumFieldsMessageMarshaller.java | 49 ++ ...aultMapperEnumFieldsMessageSerializer.java | 19 +- .../TestCollectionsMessageMarshaller.java | 86 +++ .../TestCollectionsMessageSerializer.java | 64 +- .../codegen/TestMapMessageMarshaller.java | 113 +++ .../codegen/TestMapMessageSerializer.java | 78 +-- .../TestMarshallableMessageMarshaller.java | 57 ++ .../TestMarshallableMessageSerializer.java | 99 +++ .../codegen/TestMessageMarshaller.java | 91 +++ .../codegen/TestMessageSerializer.java | 57 +- .../zk/internal/DiscoveryMessageParser.java | 7 +- 42 files changed, 1789 insertions(+), 998 deletions(-) create mode 100644 modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java create mode 100644 modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java create mode 100644 modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageMarshaller.java create mode 100644 modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java create mode 100644 modules/core/src/test/resources/codegen/ChildMessageMarshaller.java create mode 100644 modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java create mode 100644 modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java create mode 100644 modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java create mode 100644 modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java create mode 100644 modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java create mode 100644 modules/core/src/test/resources/codegen/TestMarshallableMessageSerializer.java create mode 100644 modules/core/src/test/resources/codegen/TestMessageMarshaller.java diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java index 1dc621952612e..742d7c2f7eec9 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java @@ -39,7 +39,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; /** * @@ -180,11 +180,13 @@ public FailureProcessor failureProcessor() { } /** */ + @SuppressWarnings("unchecked") protected void prepareUnmarshal(Message msg) throws IgniteCheckedException { try { - MessageSerializer ser = ctx.kernalContext().messageFactory().serializer(msg.directType()); + MessageMarshaller marshaller = ctx.kernalContext().messageFactory().marshaller(msg.directType()); - ser.finishUnmarshal(msg, ctx.kernalContext(), null, clsLdr); + if (marshaller != null) + marshaller.finishUnmarshal(msg, ctx.kernalContext(), null, clsLdr); } catch (Exception e) { failureProcessor().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java new file mode 100644 index 0000000000000..bf98bbec1df68 --- /dev/null +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java @@ -0,0 +1,261 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.Writer; +import java.util.List; +import java.util.TreeSet; +import javax.annotation.processing.FilerException; +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.Elements; +import javax.tools.Diagnostic; +import javax.tools.FileObject; +import javax.tools.JavaFileObject; +import javax.tools.StandardLocation; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.SB; + +/** Base class for message code generators ({@link MessageSerializerGenerator}, {@link MessageMarshallerGenerator}). */ +public abstract class MessageGenerator { + /** */ + public static final String EMPTY = ""; + + /** */ + public static final String NL = System.lineSeparator(); + + /** */ + public static final String TAB = " "; + + /** */ + public static final String METHOD_JAVADOC = "/** */"; + + /** */ + public static final String CLS_JAVADOC = "/**" + NL + + " * This class is generated automatically." + NL + + " *" + NL + + " * @see org.apache.ignite.internal.MessageProcessor" + NL + + " */"; + + /** */ + final ProcessingEnvironment env; + + /** Collection of message-specific imports. */ + final java.util.Set imports = new TreeSet<>(); + + /** Stored type of the message being processed. */ + TypeElement type; + + /** */ + int indent; + + /** */ + MessageGenerator(ProcessingEnvironment env) { + this.env = env; + } + + /** + * Generates and writes the source file for the given message type. + * Template method: subclasses implement {@link #generateBody} and {@link #buildClassCode}. + */ + final void generate(TypeElement type, List fields) throws Exception { + assert this.type == null : "Message" + typeSuffix() + " generator isn't stateless and is supposed to be single-use."; + + if (shouldSkip(type)) + return; + + this.type = type; + + generateBody(fields); + + String clsName = type.getSimpleName() + typeSuffix(); + String fqnClsName = env.getElementUtils().getPackageOf(type) + "." + clsName; + String code = buildClassCode(clsName); + + try { + JavaFileObject file = env.getFiler().createSourceFile(fqnClsName); + + try (Writer writer = file.openWriter()) { + writer.append(code); + writer.flush(); + } + } + catch (FilerException e) { + if (!identicalFileIsAlreadyGenerated(env, code, fqnClsName)) { + env.getMessager().printMessage( + Diagnostic.Kind.ERROR, + "Message" + typeSuffix() + " " + clsName + " is already generated. Try 'mvn clean install' to fix the issue."); + + throw e; + } + } + } + + /** @return Class name suffix: {@code "Serializer"} or {@code "Marshaller"}. */ + abstract String typeSuffix(); + + /** + * @return {@code true} if no source file should be generated for the given message type. + * Default: {@code false} (generate for all types). + */ + boolean shouldSkip(TypeElement type) { + return false; + } + + /** + * Generates the body of the class by populating internal state (e.g. write/read or marshal/unmarshal lists). + * Called before {@link #buildClassCode}. + */ + abstract void generateBody(List fields) throws Exception; + + /** Generates and returns the complete source code for the generated class. */ + abstract String buildClassCode(String clsName) throws IOException; + + /** Writes the Apache license header to the given writer. */ + void writeLicense(Writer writer) throws IOException { + try (InputStream in = getClass().getClassLoader().getResourceAsStream("license.txt"); + BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { + + PrintWriter out = new PrintWriter(writer); + String line; + + while ((line = reader.readLine()) != null) + out.println(line); + } + } + + /** + * Writes the common class header: license, package declaration, imports, Javadoc, and class declaration line. + * Callers must have already populated {@link #imports} with all required imports before calling this method. + * + * @param writer Target writer. + * @param interfaceName Simple name of the implemented interface (e.g. {@code "MessageSerializer"}). + * @param clsName Generated class name (e.g. {@code "FooSerializer"}). + */ + void writeClassHeader(Writer writer, String interfaceName, String clsName) throws IOException { + writeLicense(writer); + + writer.write(NL); + writer.write("package " + env.getElementUtils().getPackageOf(type) + ";" + NL + NL); + + for (String imp : imports) + writer.write("import " + imp + ";" + NL); + + writer.write(NL); + writer.write(CLS_JAVADOC); + writer.write(NL); + writer.write("public class " + clsName + " implements " + interfaceName + "<" + simpleNameWithGeneric(type) + "> {" + NL); + } + + /** */ + String indentedLine(String format, Object... args) { + SB sb = new SB(); + + for (int i = 0; i < indent; i++) + sb.a(TAB); + + sb.a(String.format(format, args)); + + return sb.toString(); + } + + /** */ + String simpleNameWithGeneric(TypeElement te) { + if (F.size(te.getTypeParameters()) == 0) + return te.getSimpleName().toString(); + + StringBuilder generic = new StringBuilder(te.getSimpleName() + "<"); + + for (int i = 0; i < F.size(te.getTypeParameters()); i++) { + if (i > 0) + generic.append(", "); + + generic.append("?"); + } + + generic.append(">"); + + return generic.toString(); + } + + /** */ + boolean assignableFrom(TypeMirror type, TypeMirror superType) { + return env.getTypeUtils().isAssignable(type, superType); + } + + /** */ + TypeMirror type(String clazz) { + Elements elementUtils = env.getElementUtils(); + TypeElement typeElement = elementUtils.getTypeElement(clazz); + return typeElement != null ? typeElement.asType() : null; + } + + /** */ + TypeMirror erasedType(TypeMirror type) { + return env.getTypeUtils().erasure(type); + } + + /** */ + String fieldAccessor(VariableElement field) { + return "msg." + field.getSimpleName().toString(); + } + + /** @return {@code true} if a file with identical content is already generated (e.g. during IDE incremental build). */ + public static boolean identicalFileIsAlreadyGenerated(ProcessingEnvironment env, String srcCode, String fqnClsName) { + try { + String fileName = fqnClsName.replace('.', '/') + ".java"; + FileObject prevFile = env.getFiler().getResource(StandardLocation.SOURCE_OUTPUT, "", fileName); + + String prevFileContent; + try (Reader r = prevFile.openReader(true)) { + prevFileContent = content(r); + } + + if (prevFileContent.contentEquals(srcCode)) + return true; + } + catch (Exception ignoredAttemptToGetExistingFile) { + // We have some other problem, not an existing file. + } + + return false; + } + + /** */ + static String content(Reader reader) throws IOException { + BufferedReader br = new BufferedReader(reader); + StringBuilder sb = new StringBuilder(); + String line; + + while ((line = br.readLine()) != null) + sb.append(line).append(NL); + + // Delete last line separator. + sb.deleteCharAt(sb.length() - 1); + + return sb.toString(); + } +} diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java new file mode 100644 index 0000000000000..49cd495f078a4 --- /dev/null +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -0,0 +1,505 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.Element; +import javax.lang.model.element.QualifiedNameable; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.ArrayType; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.type.TypeVariable; + +import static org.apache.ignite.internal.MessageProcessor.MARSHALLABLE_MESSAGE_INTERFACE; +import static org.apache.ignite.internal.MessageProcessor.MESSAGE_INTERFACE; + +/** + * Generates marshaller class for a given {@code Message} class. The generated marshaller follows the naming convention: + * {@code org.apache.ignite.internal.codegen.[MessageClassName]Marshaller}. + *

+ * No marshaller is generated for {@code NonMarshallableMessage} types. + */ +public class MessageMarshallerGenerator extends MessageGenerator { + /** Collection of lines for {@code prepareMarshal} / {@code finishUnmarshal} methods. */ + private final List marshall = new ArrayList<>(); + + /** The marshallable message type. */ + private final TypeMirror marshallableMsgType; + + /** The cache-marshallable message type. */ + private final TypeMirror cacheMarshallableMsgType; + + /** */ + MessageMarshallerGenerator(ProcessingEnvironment env) { + super(env); + + TypeElement marshallableMsgElem = env.getElementUtils().getTypeElement(MARSHALLABLE_MESSAGE_INTERFACE); + marshallableMsgType = marshallableMsgElem != null ? marshallableMsgElem.asType() : null; + + TypeElement cacheMarshallableMsgElem = env.getElementUtils() + .getTypeElement("org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage"); + cacheMarshallableMsgType = cacheMarshallableMsgElem != null ? cacheMarshallableMsgElem.asType() : null; + } + + /** {@inheritDoc} */ + @Override String typeSuffix() { + return "Marshaller"; + } + + /** {@inheritDoc} */ + @Override boolean shouldSkip(TypeElement type) { + return isNonMarshallableMessage(type); + } + + /** {@inheritDoc} */ + @Override void generateBody(List fields) throws Exception { + generateMarshallMethods(fields); + generateUnmarshallMethods(fields); + } + + /** {@inheritDoc} */ + @Override String buildClassCode(String marshallerClsName) throws IOException { + try (Writer writer = new StringWriter()) { + imports.add(type.toString()); + imports.add("org.apache.ignite.plugin.extensions.communication.MessageMarshaller"); + + if (marshallableMessage()) + imports.add("org.apache.ignite.marshaller.Marshaller"); + + writeClassHeader(writer, "MessageMarshaller", marshallerClsName); + + writeConstructor(writer, marshallerClsName); + + for (String line : marshall) + writer.write(line + NL); + + writer.write("}"); + + return writer.toString(); + } + } + + /** */ + private void writeConstructor(Writer writer, String marshallerClsName) throws IOException { + indent = 1; + + writer.write(indentedLine(METHOD_JAVADOC)); + writer.write(NL); + + if (marshallableMessage()) { + writer.write(indentedLine("private final Marshaller marshaller;")); + writer.write(NL + NL); + + writer.write(indentedLine(METHOD_JAVADOC)); + writer.write(NL); + writer.write(indentedLine("public " + marshallerClsName + "(Marshaller marshaller) {")); + writer.write(NL); + + indent++; + writer.write(indentedLine("this.marshaller = marshaller;")); + writer.write(NL); + indent--; + } + else { + writer.write(indentedLine("public " + marshallerClsName + "() {")); + writer.write(NL); + } + + writer.write(NL); + writer.write(indentedLine("}")); + writer.write(NL + NL); + } + + /** */ + private void generateMarshallMethods(List orderedFields) { + imports.add("org.apache.ignite.IgniteCheckedException"); + imports.add("org.apache.ignite.internal.GridKernalContext"); + imports.add("org.apache.ignite.internal.processors.cache.GridCacheContext"); + + indent = 1; + + marshall.add(indentedLine(METHOD_JAVADOC)); + + marshall.add(indentedLine( + "@Override public void prepareMarshal(" + simpleNameWithGeneric(type) + + " msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException {")); + + indent++; + + addCtxResolution(); + + if (marshallableMessage()) { + marshall.add(EMPTY); + marshall.add(indentedLine("msg.prepareMarshal(marshaller);")); + } + + for (VariableElement field : orderedFields) { + List marshalled = marshall(field.asType(), fieldAccessor(field), false, false); + + if (!marshalled.isEmpty()) { + if (!marshall.get(marshall.size() - 1).equals(EMPTY)) + marshall.add(EMPTY); + + marshall.addAll(marshalled); + } + } + + indent--; + + marshall.add(indentedLine("}")); + } + + /** */ + private void generateUnmarshallMethods(List orderedFields) { + marshall.add(EMPTY); + + indent = 1; + + marshall.add(indentedLine(METHOD_JAVADOC)); + + marshall.add(indentedLine( + "@Override public void finishUnmarshal(" + simpleNameWithGeneric(type) + + " msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException {")); + + indent++; + + addCtxResolution(); + + for (VariableElement field : orderedFields) { + List unmarshalled = marshall(field.asType(), fieldAccessor(field), true, false); + + if (!unmarshalled.isEmpty()) { + if (!marshall.get(marshall.size() - 1).equals(EMPTY)) + marshall.add(EMPTY); + + marshall.addAll(unmarshalled); + } + } + + if (isCacheMarshallableMessage(type)) { + marshall.add(EMPTY); + marshall.add(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);")); + } + + indent--; + + marshall.add(indentedLine("}")); + + imports.add("org.apache.ignite.internal.util.typedef.internal.U"); + + marshall.add(EMPTY); + + marshall.add(indentedLine(METHOD_JAVADOC)); + + marshall.add(indentedLine( + "@Override public void finishUnmarshal(" + simpleNameWithGeneric(type) + + " msg, GridKernalContext kctx) throws IgniteCheckedException {")); + + indent++; + + boolean first = true; + + for (VariableElement field : orderedFields) { + List unmarshalled = marshall(field.asType(), fieldAccessor(field), true, true); + + if (!unmarshalled.isEmpty()) { + if (!first) + marshall.add(EMPTY); + + first = false; + + marshall.addAll(unmarshalled); + } + } + + if (marshallableMessage() && !isCacheMarshallableMessage(type)) { + if (!first) + marshall.add(EMPTY); + + marshall.add(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));")); + } + + indent--; + + marshall.add(indentedLine("}")); + } + + /** Adds a {@code GridCacheContext ctx} resolution line for the current message type. */ + private void addCtxResolution() { + if (isCacheIdAwareMessage(type)) + marshall.add( + indentedLine("GridCacheContext ctx = nested == null ? " + + "kctx.cache().context().cacheContext(msg.cacheId()) : nested;")); + else if (isCacheGroupIdMessage(type)) + marshall.add( + indentedLine("GridCacheContext ctx = nested == null ? " + + "kctx.cache().context().cacheContext(msg.groupId()) : nested;")); + else + marshall.add(indentedLine("GridCacheContext ctx = nested;")); + } + + /** */ + private List marshall(TypeMirror t, String accessor, boolean unmarshall, boolean cache) { + if (t.getKind() == TypeKind.ARRAY) { + TypeMirror comp = ((ArrayType)t).getComponentType(); + + if (comp.getKind() == TypeKind.DECLARED) { + List code = new ArrayList<>(); + + imports.add(((QualifiedNameable)((DeclaredType)comp).asElement()).getQualifiedName().toString()); + + code.add(indentedLine("if (%s != null) {", accessor)); + + indent++; + + String el = "e" + indent; + + code.add(indentedLine("for (%s %s : %s) {", ((DeclaredType)comp).asElement().getSimpleName().toString(), el, accessor)); + + indent++; + + List res = marshall(comp, el, unmarshall, cache); + + code.addAll(res); + + indent--; + + code.add(indentedLine("}")); + + indent--; + + code.add(indentedLine("}")); + + if (res.isEmpty()) + return java.util.Collections.emptyList(); + else + return code; + } + } + else if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { + if (isMessage(t)) { + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null)", accessor)); + + indent++; + + if (!unmarshall) + code.add(indentedLine( + "MessageMarshaller.prepareMarshal(kctx.messageFactory(), %s, kctx, ctx);", + accessor)); + else { + if (cache) + code.add(indentedLine( + "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx);", + accessor)); + else + code.add(indentedLine( + "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx, ctx, clsLdr);", + accessor)); + } + + indent--; + + return code; + } + else if (isCacheObject(t)) { + if (cache && unmarshall) + return java.util.Collections.emptyList(); + + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null && ctx != null)", accessor)); + + indent++; + + if (!unmarshall) + code.add(indentedLine("%s.prepareMarshal(ctx.cacheObjectContext());", accessor)); + else + code.add(indentedLine("%s.finishUnmarshal(ctx.cacheObjectContext(), clsLdr);", accessor)); + + indent--; + + return code; + } + else if (assignableFrom(erasedType(t), type(java.util.Map.class.getName()))) { + List args = ((DeclaredType)t).getTypeArguments(); + + TypeMirror keyType = args.get(0); + TypeMirror valType = args.get(1); + + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null) {", accessor)); + + indent++; + + String el = "e" + indent; + + indent++; + List keyRes = marshall(keyType, el, unmarshall, cache); + List valRes = marshall(valType, el, unmarshall, cache); + indent--; + + if (!keyRes.isEmpty() && (keyType.getKind() == TypeKind.DECLARED || keyType.getKind() == TypeKind.TYPEVAR)) { + Element elem = element(keyType); + + imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); + imports.add("java.util.Collection"); + + String typeName = elem.getSimpleName().toString(); + + code.add(indentedLine("for (%s %s : ((Collection)%s.keySet())) {", typeName, el, typeName, accessor)); + + indent++; + code.addAll(keyRes); + indent--; + + code.add(indentedLine("}")); + } + + if (!valRes.isEmpty() && (valType.getKind() == TypeKind.DECLARED || valType.getKind() == TypeKind.TYPEVAR)) { + Element elem = element(valType); + + imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); + imports.add("java.util.Collection"); + + String typeName = elem.getSimpleName().toString(); + + code.add(indentedLine("for (%s %s : ((Collection)%s.values())) {", typeName, el, typeName, accessor)); + + indent++; + code.addAll(valRes); + indent--; + + code.add(indentedLine("}")); + } + + indent--; + + code.add(indentedLine("}")); + + if (keyRes.isEmpty() && valRes.isEmpty()) + return java.util.Collections.emptyList(); + else + return code; + } + else if (assignableFrom(erasedType(t), type(java.util.Collection.class.getName()))) { + List args = ((DeclaredType)t).getTypeArguments(); + + TypeMirror arg = args.get(0); + + if ((arg.getKind() == TypeKind.DECLARED || arg.getKind() == TypeKind.TYPEVAR)) { + List code = new ArrayList<>(); + + Element elem = element(arg); + + imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); + imports.add("java.util.Collection"); + + String el = "e" + indent; + + code.add(indentedLine("if (%s != null) {", accessor)); + + indent++; + + String typeName = elem.getSimpleName().toString(); + + code.add(indentedLine("for (%s %s : (Collection)%s) {", typeName, el, typeName, accessor)); + + indent++; + + List res = marshall(arg, el, unmarshall, cache); + + code.addAll(res); + + indent--; + + code.add(indentedLine("}")); + + indent--; + + code.add(indentedLine("}")); + + if (res.isEmpty()) + return java.util.Collections.emptyList(); + else + return code; + } + } + } + + return java.util.Collections.emptyList(); + } + + /** */ + private boolean isCacheObject(TypeMirror type) { + TypeMirror cacheObject = type("org.apache.ignite.internal.processors.cache.CacheObject"); + return cacheObject != null && assignableFrom(type, cacheObject); + } + + /** */ + private boolean isMessage(TypeMirror type) { + TypeMirror message = type(MESSAGE_INTERFACE); + return message != null && assignableFrom(type, message); + } + + /** */ + private boolean isNonMarshallableMessage(TypeElement te) { + TypeMirror nonMarshallable = type("org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage"); + return nonMarshallable != null && assignableFrom(te.asType(), nonMarshallable); + } + + /** */ + private boolean isCacheMarshallableMessage(TypeElement te) { + return cacheMarshallableMsgType != null && env.getTypeUtils().isAssignable(te.asType(), cacheMarshallableMsgType); + } + + /** True if {@code te} extends {@code CacheIdAware}. */ + private boolean isCacheIdAwareMessage(TypeElement te) { + TypeMirror cacheIdAware = type("org.apache.ignite.plugin.extensions.communication.CacheIdAware"); + return cacheIdAware != null && assignableFrom(te.asType(), cacheIdAware); + } + + /** True if {@code te} extends {@code GridCacheGroupIdMessage}. */ + private boolean isCacheGroupIdMessage(TypeElement te) { + TypeMirror grpIdMsg = type("org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage"); + return grpIdMsg != null && assignableFrom(te.asType(), grpIdMsg); + } + + /** */ + private boolean marshallableMessage() { + return marshallableMsgType != null && env.getTypeUtils().isAssignable(type.asType(), marshallableMsgType); + } + + /** */ + /** */ + private Element element(TypeMirror t) { + return t.getKind() == TypeKind.DECLARED ? + ((DeclaredType)t).asElement() : + ((DeclaredType)((TypeVariable)t).getUpperBound()).asElement(); + } +} diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java index 1c5c330a52fd3..369db73b59e0b 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java @@ -142,6 +142,16 @@ public class MessageProcessor extends AbstractProcessor { "Failed to generate a message serializer:" + e.getMessage(), type.getKey()); } + + try { + new MessageMarshallerGenerator(processingEnv).generate(type.getKey(), type.getValue()); + } + catch (Exception e) { + processingEnv.getMessager().printMessage( + Diagnostic.Kind.ERROR, + "Failed to generate a message marshaller:" + e.getMessage(), + type.getKey()); + } } return true; diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 574bd00ff9877..b8885e71a68ea 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -17,75 +17,39 @@ package org.apache.ignite.internal; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.io.Reader; import java.io.StringWriter; import java.io.Writer; import java.util.ArrayList; import java.util.BitSet; import java.util.Collection; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TreeSet; import java.util.UUID; -import javax.annotation.processing.FilerException; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.QualifiedNameable; -import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.PrimitiveType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; -import javax.lang.model.type.TypeVariable; -import javax.lang.model.util.Elements; -import javax.tools.Diagnostic; -import javax.tools.FileObject; -import javax.tools.JavaFileObject; -import javax.tools.StandardLocation; import org.apache.ignite.internal.systemview.SystemViewRowAttributeWalkerProcessor; -import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.SB; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.MessageProcessor.COMPRESSED_MESSAGE_CLASS; -import static org.apache.ignite.internal.MessageProcessor.MARSHALLABLE_MESSAGE_INTERFACE; import static org.apache.ignite.internal.MessageProcessor.MESSAGE_INTERFACE; /** * Generates serializer class for given {@code Message} class. The generated serializer follows the naming convention: * {@code org.apache.ignite.internal.codegen.[MessageClassName]Serializer}. */ -public class MessageSerializerGenerator { - /** */ - private static final String EMPTY = ""; - - /** */ - public static final String TAB = " "; - - /** */ - public static final String NL = System.lineSeparator(); - - /** */ - private static final String CLS_JAVADOC = "/**" + NL + - " * This class is generated automatically." + NL + - " *" + NL + - " * @see org.apache.ignite.internal.MessageProcessor" + NL + - " */"; - - /** */ - public static final String METHOD_JAVADOC = "/** */"; - +public class MessageSerializerGenerator extends MessageGenerator { /** */ private static final String RETURN_FALSE_STMT = "return false;"; @@ -102,80 +66,31 @@ public class MessageSerializerGenerator { /** Collection of lines for {@code readFrom} method. */ private final List read = new ArrayList<>(); - /** */ - private final List marshall = new ArrayList<>(); - - /** Collection of message-specific imports. */ - private final Set imports = new TreeSet<>(); - /** Collection of Serializer class fields containing mappers for message enum fields. */ - private final Set fields = new TreeSet<>(); - - /** */ - private final ProcessingEnvironment env; - - /** Stored type of the message being processed. */ - private TypeElement type; - - /** The marshallable message type. */ - private final TypeMirror marshallableMsgType; - - /** */ - private int indent; + private final Set fields = new java.util.TreeSet<>(); /** */ MessageSerializerGenerator(ProcessingEnvironment env) { - this.env = env; - - marshallableMsgType = env.getElementUtils().getTypeElement(MARSHALLABLE_MESSAGE_INTERFACE).asType(); + super(env); } - /** */ - void generate(TypeElement type, List fields) throws Exception { - assert this.type == null : "Message serializer generator isn't stateless and is supposed to be single-use."; - - this.type = type; + /** {@inheritDoc} */ + @Override String typeSuffix() { + return "Serializer"; + } + /** {@inheritDoc} */ + @Override void generateBody(List fields) throws Exception { generateMethods(fields); + // Include superclass types in imports so generated code can cast to them for inherited fields. SystemViewRowAttributeWalkerProcessor.superclasses(env, type).forEach(el -> imports.add(el.toString())); - - String serClsName = type.getSimpleName() + (marshallableMessage() ? "Marshallable" : "") + "Serializer"; - String serFqnClsName = env.getElementUtils().getPackageOf(type) + "." + serClsName; - String serCode = generateSerializerCode(serClsName); - - try { - JavaFileObject file = env.getFiler().createSourceFile(serFqnClsName); - - try (Writer writer = file.openWriter()) { - writer.append(serCode); - writer.flush(); - } - } - catch (FilerException e) { - // IntelliJ IDEA parses Ignite's pom.xml and configures itself to use this annotation processor on each Run. - // During a Run, it invokes the processor and may fail when attempting to generate sources that already exist. - // There is no a setting to disable this invocation. The IntelliJ community suggests a workaround — delegating - // all Run commands to Maven. However, this significantly slows down test startup time. - // This hack checks whether the content of a generating file is identical to already existed file, and skips - // handling this class if it is. - if (!identicalFileIsAlreadyGenerated(env, serCode, serFqnClsName)) { - env.getMessager().printMessage( - Diagnostic.Kind.ERROR, - "MessageSerializer " + serClsName + " is already generated. Try 'mvn clean install' to fix the issue."); - - throw e; - } - } } - /** Generates full code for a serializer class. */ - private String generateSerializerCode(String serClsName) throws IOException { - if (marshallableMessage()) - fields.add("private final Marshaller marshaller;"); - + /** {@inheritDoc} */ + @Override String buildClassCode(String serClsName) throws IOException { try (Writer writer = new StringWriter()) { - writeClassHeader(writer, env.getElementUtils().getPackageOf(type).toString(), serClsName); + writeSerializerHeader(writer, env.getElementUtils().getPackageOf(type).toString(), serClsName); writeClassFields(writer); @@ -193,13 +108,6 @@ private String generateSerializerCode(String serClsName) throws IOException { writer.write(TAB + "}" + NL); - if (!marshall.isEmpty()) { - writer.write(NL); - - for (String p: marshall) - writer.write(p + NL); - } - writer.write("}"); return writer.toString(); @@ -212,25 +120,8 @@ private void writeConstructor(Writer writer, String serClsName) throws IOExcepti writer.write(indentedLine(METHOD_JAVADOC)); writer.write(NL); - - if (marshallableMessage()) - writer.write(indentedLine("public " + serClsName + "(Marshaller marshaller) {")); - else - writer.write(indentedLine("public " + serClsName + "() {")); - - writer.write(NL); - - ++indent; - - if (marshallableMessage()) { - writer.write(indentedLine("this.marshaller = marshaller;")); - writer.write(NL); - } - - --indent; - - writer.write(NL); - + writer.write(indentedLine("public " + serClsName + "() {")); + writer.write(NL + NL); writer.write(indentedLine("}")); writer.write(NL); writer.write(NL); @@ -254,385 +145,6 @@ private void generateMethods(List fields) throws Exception { finish(write); finish(read); - - if (!isNonMarshallableMessage(type)) { - generateMarshallMethods(fields); - generateUnmarshallMethods(fields); - } - } - - /** */ - private void generateMarshallMethods(List orderedFields) { - imports.add("org.apache.ignite.IgniteCheckedException"); - imports.add("org.apache.ignite.internal.processors.cache.CacheObjectValueContext"); - imports.add("org.apache.ignite.internal.GridKernalContext"); - imports.add("org.apache.ignite.internal.processors.cache.GridCacheContext"); - - indent = 1; - - marshall.add(indentedLine(METHOD_JAVADOC)); - - marshall.add(indentedLine( - "@Override public void prepareMarshal(" + simpleNameWithGeneric(type) + - " msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException {")); - - indent++; - - addCtxResolution(); - - if (marshallableMessage()) { - marshall.add(EMPTY); - - marshall.add(indentedLine("msg.prepareMarshal(marshaller);")); - } - - for (VariableElement field : orderedFields) { - List marshalled = marshall(field.asType(), fieldAccessor(field), false, false); - - if (!marshalled.isEmpty()) { - if (!marshall.get(marshall.size() - 1).equals(EMPTY)) - marshall.add(EMPTY); - - marshall.addAll(marshalled); - } - } - - indent--; - - marshall.add(indentedLine("}")); - } - - /** */ - private void generateUnmarshallMethods(List orderedFields) { - marshall.add(EMPTY); - - indent = 1; - - marshall.add(indentedLine(METHOD_JAVADOC)); - - marshall.add(indentedLine( - "@Override public void finishUnmarshal(" + simpleNameWithGeneric(type) + - " msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException {")); - - indent++; - - addCtxResolution(); - - for (VariableElement field : orderedFields) { - List unmarshalled = marshall(field.asType(), fieldAccessor(field), true, false); - - if (!unmarshalled.isEmpty()) { - if (!marshall.get(marshall.size() - 1).equals(EMPTY)) - marshall.add(EMPTY); - - marshall.addAll(unmarshalled); - } - } - - if (isCacheMarshallableMessage(type)) { - marshall.add(EMPTY); - - marshall.add(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);")); - } - - indent--; - - marshall.add(indentedLine("}")); - - imports.add("org.apache.ignite.internal.util.typedef.internal.U"); - - marshall.add(EMPTY); - - marshall.add(indentedLine(METHOD_JAVADOC)); - - marshall.add(indentedLine( - "@Override public void finishUnmarshal(" + simpleNameWithGeneric(type) + - " msg, GridKernalContext kctx) throws IgniteCheckedException {")); - - indent++; - - boolean first = true; - - for (VariableElement field : orderedFields) { - List unmarshalled = marshall(field.asType(), fieldAccessor(field), true, true); - - if (!unmarshalled.isEmpty()) { - if (!first) - marshall.add(EMPTY); - - first = false; - - marshall.addAll(unmarshalled); - } - } - - if (marshallableMessage() && !isCacheMarshallableMessage(type)) { - if (!first) - marshall.add(EMPTY); - - marshall.add(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));")); - } - - indent--; - - marshall.add(indentedLine("}")); - } - - /** Adds a {@code GridCacheContext ctx} resolution line for the current message type. */ - private void addCtxResolution() { - if (isCacheIdAwareMessage(type)) - marshall.add( - indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.cacheId()) : nested;")); - else if (isCacheGroupIdMessage(type)) - marshall.add( - indentedLine("GridCacheContext ctx = nested == null ? kctx.cache().context().cacheContext(msg.groupId()) : nested;")); - else - marshall.add(indentedLine("GridCacheContext ctx = nested;")); - } - - /** */ - private List marshall(TypeMirror t, String accessor, boolean unmarshall, boolean cache) { - if (t.getKind() == TypeKind.ARRAY) { - TypeMirror comp = ((ArrayType)t).getComponentType(); - - if (comp.getKind() == TypeKind.DECLARED) { - List code = new ArrayList<>(); - - imports.add(((QualifiedNameable)((DeclaredType)comp).asElement()).getQualifiedName().toString()); - - code.add(indentedLine("if (%s != null) {", accessor)); - - indent++; - - String el = "e" + indent; - - code.add(indentedLine("for (%s %s : %s) {", ((DeclaredType)comp).asElement().getSimpleName().toString(), el, accessor)); - - indent++; - - List res = marshall(comp, el, unmarshall, cache); - - code.addAll(res); - - indent--; - - code.add(indentedLine("}")); - - indent--; - - code.add(indentedLine("}")); - - if (res.isEmpty()) - return Collections.emptyList(); - else - return code; - } - } - else if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { - if (isMessage(t)) { - List code = new ArrayList<>(); - - code.add(indentedLine("if (%s != null)", accessor)); - - indent++; - - if (!unmarshall) - code.add(indentedLine( - "kctx.messageFactory().serializer(%s.directType()).prepareMarshal(%s, kctx, ctx);", - accessor, - accessor)); - else { - if (cache) - code.add(indentedLine( - "kctx.messageFactory().serializer(%s.directType()).finishUnmarshal(%s, kctx);", - accessor, - accessor)); - else - code.add(indentedLine( - "kctx.messageFactory().serializer(%s.directType()).finishUnmarshal(%s, kctx, ctx, clsLdr);", - accessor, - accessor)); - } - - indent--; - - return code; - } - else if (isCacheObject(t)) { - if (cache && unmarshall) - return Collections.emptyList(); - - List code = new ArrayList<>(); - - code.add(indentedLine("if (%s != null && ctx != null)", accessor)); - - indent++; - - if (!unmarshall) - code.add(indentedLine("%s.prepareMarshal(ctx.cacheObjectContext());", accessor)); - else - code.add(indentedLine("%s.finishUnmarshal(ctx.cacheObjectContext(), clsLdr);", accessor)); - - indent--; - - return code; - } - else if (assignableFrom(erasedType(t), type(Map.class.getName()))) { - List args = ((DeclaredType)t).getTypeArguments(); - - TypeMirror keyType = args.get(0); - TypeMirror valType = args.get(1); - - List code = new ArrayList<>(); - - code.add(indentedLine("if (%s != null) {", accessor)); - - indent++; - - String el = "e" + indent; - - indent++; // Emulating subsequent indent. - List keyRes = marshall(keyType, el, unmarshall, cache); - List valRes = marshall(valType, el, unmarshall, cache); - indent--; - - if (!keyRes.isEmpty() && (keyType.getKind() == TypeKind.DECLARED || keyType.getKind() == TypeKind.TYPEVAR)) { - Element elem = element(keyType); - - imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); - imports.add("java.util.Collection"); - - String type = elem.getSimpleName().toString(); - - code.add(indentedLine("for (%s %s : ((Collection)%s.keySet())) {", type, el, type, accessor)); - - indent++; - - code.addAll(keyRes); - - indent--; - - code.add(indentedLine("}")); - } - - if (!valRes.isEmpty() && (valType.getKind() == TypeKind.DECLARED || valType.getKind() == TypeKind.TYPEVAR)) { - Element elem = element(valType); - - imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); - imports.add("java.util.Collection"); - - String type = elem.getSimpleName().toString(); - - code.add(indentedLine("for (%s %s : ((Collection)%s.values())) {", type, el, type, accessor)); - - indent++; - - code.addAll(valRes); - - indent--; - - code.add(indentedLine("}")); - } - - indent--; - - code.add(indentedLine("}")); - - if (keyRes.isEmpty() && valRes.isEmpty()) - return Collections.emptyList(); - else - return code; - } - else if (assignableFrom(erasedType(t), type(Collection.class.getName()))) { - List args = ((DeclaredType)t).getTypeArguments(); - - TypeMirror arg = args.get(0); - - if ((arg.getKind() == TypeKind.DECLARED || arg.getKind() == TypeKind.TYPEVAR)) { - List code = new ArrayList<>(); - - Element elem = element(arg); - - imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); - imports.add("java.util.Collection"); - - String el = "e" + indent; - - code.add(indentedLine("if (%s != null) {", accessor)); - - indent++; - - String type = elem.getSimpleName().toString(); - - code.add(indentedLine("for (%s %s : (Collection)%s) {", type, el, type, accessor)); - - indent++; - - List res = marshall(arg, el, unmarshall, cache); - - code.addAll(res); - - indent--; - - code.add(indentedLine("}")); - - indent--; - - code.add(indentedLine("}")); - - if (res.isEmpty()) - return Collections.emptyList(); - else - return code; - } - } - } - - return Collections.emptyList(); - } - - /** */ - private boolean isCacheObject(TypeMirror type) { - return assignableFrom(type, type("org.apache.ignite.internal.processors.cache.CacheObject")); - } - - /** */ - private boolean isMessage(TypeMirror type) { - return assignableFrom(type, type(MESSAGE_INTERFACE)); - } - - /** */ - private boolean isNonMarshallableMessage(TypeElement te) { - return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage")); - } - - /** */ - private boolean isCacheMarshallableMessage(TypeElement te) { - return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage")); - } - - /** True if {@code te} extends {@code CacheIdAware} and therefore carries its own per-cache {@code cacheId()}. */ - private boolean isCacheIdAwareMessage(TypeElement te) { - return assignableFrom(te.asType(), type("org.apache.ignite.plugin.extensions.communication.CacheIdAware")); - } - - /** True if {@code te} extends {@code CacheGroupIdMessage} and therefore carries its own per-group {@code groupId()}. */ - private boolean isCacheGroupIdMessage(TypeElement te) { - return assignableFrom(te.asType(), type("org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage")); - } - - /** */ - private String fieldAccessor(VariableElement field) { - String name = field.getSimpleName().toString(); - - return "msg." + name; - } - - /** */ - private Element element(TypeMirror type) { - return type.getKind() == TypeKind.DECLARED ? - ((DeclaredType)type).asElement() : - ((DeclaredType)((TypeVariable)type).getUpperBound()).asElement(); } /** @@ -1314,22 +826,6 @@ private void finish(List code) { code.add(indentedLine("return true;")); } - /** - * Creates line with current indent from given arguments. - * - * @return Line with current indent. - */ - private String indentedLine(String format, Object... args) { - SB sb = new SB(); - - for (int i = 0; i < indent; i++) - sb.a(TAB); - - sb.a(String.format(format, args)); - - return sb.toString(); - } - /** * Creates line from given arguments. * @@ -1362,43 +858,13 @@ private void writeClassFields(Writer writer) throws IOException { } /** Write header of serializer class: license, imports, class declaration. */ - private void writeClassHeader(Writer writer, String pkgName, String serClsName) throws IOException { - try (InputStream in = getClass().getClassLoader().getResourceAsStream("license.txt"); - BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { - - PrintWriter out = new PrintWriter(writer); - - String line; - - while ((line = reader.readLine()) != null) - out.println(line); - } - - writer.write(NL); - writer.write("package " + pkgName + ";" + NL + NL); - + private void writeSerializerHeader(Writer writer, String pkgName, String serClsName) throws IOException { imports.add(type.toString()); - - if (marshallableMessage()) - imports.add("org.apache.ignite.marshaller.Marshaller"); - imports.add("org.apache.ignite.plugin.extensions.communication.MessageSerializer"); imports.add("org.apache.ignite.plugin.extensions.communication.MessageWriter"); imports.add("org.apache.ignite.plugin.extensions.communication.MessageReader"); - for (String regularImport : imports) - writer.write("import " + regularImport + ";" + NL); - - writer.write(NL); - writer.write(CLS_JAVADOC); - writer.write(NL); - - writer.write("public class " + serClsName + " implements MessageSerializer<" + simpleNameWithGeneric(type) + "> {" + NL); - } - - /** */ - private boolean marshallableMessage() { - return env.getTypeUtils().isAssignable(type.asType(), marshallableMsgType); + writeClassHeader(writer, "MessageSerializer", serClsName); } /** */ @@ -1411,11 +877,6 @@ private boolean sameType(TypeMirror type, Class cls) { return env.getTypeUtils().isSameType(type, type(cls.getCanonicalName())); } - /** */ - private boolean assignableFrom(TypeMirror type, TypeMirror superType) { - return env.getTypeUtils().isAssignable(type, superType); - } - /** */ public static boolean enumType(ProcessingEnvironment env, TypeMirror type) { Element element = env.getTypeUtils().asElement(type); @@ -1423,62 +884,11 @@ public static boolean enumType(ProcessingEnvironment env, TypeMirror type) { return element != null && element.getKind() == ElementKind.ENUM; } - /** */ - private TypeMirror type(String clazz) { - Elements elementUtils = env.getElementUtils(); - - TypeElement typeElement = elementUtils.getTypeElement(clazz); - - return typeElement != null ? typeElement.asType() : null; - } - - /** */ - private TypeMirror erasedType(TypeMirror type) { - return env.getTypeUtils().erasure(type); - } - /** Converts string "BYTE" to string "Byte", with first capital latter. */ private String capitalizeOnlyFirst(String input) { return input.substring(0, 1).toUpperCase() + input.substring(1).toLowerCase(); } - /** @return {@code true} if trying to generate file with the same content. */ - public static boolean identicalFileIsAlreadyGenerated(ProcessingEnvironment env, String srcCode, String fqnClsName) { - try { - String fileName = fqnClsName.replace('.', '/') + ".java"; - FileObject prevFile = env.getFiler().getResource(StandardLocation.SOURCE_OUTPUT, "", fileName); - - String prevFileContent; - try (Reader r = prevFile.openReader(true)) { - prevFileContent = content(r); - } - - // We are ok, for some reason the same file is already generated (Intellij IDEA might do it). - if (prevFileContent.contentEquals(srcCode)) - return true; - } - catch (Exception ignoredAttemptToGetExistingFile) { - // We have some other problem, not an existing file. - } - - return false; - } - - /** */ - private static String content(Reader reader) throws IOException { - BufferedReader br = new BufferedReader(reader); - StringBuilder sb = new StringBuilder(); - String line; - - while ((line = br.readLine()) != null) - sb.append(line).append(NL); - - // Delete last line separator. - sb.deleteCharAt(sb.length() - 1); - - return sb.toString(); - } - /** Checks that the Compress annotation is used only for supported types: Map and Message. */ private void checkTypeForCompress(TypeMirror type) { if (type.getKind() == TypeKind.DECLARED) { @@ -1490,22 +900,4 @@ private void checkTypeForCompress(TypeMirror type) { throw new IllegalArgumentException("Compress annotation is used for an unsupported type: " + type); } - /** @return Simple class name. */ - private String simpleNameWithGeneric(TypeElement te) { - if (F.size(te.getTypeParameters()) == 0) - return te.getSimpleName().toString(); - - StringBuilder generic = new StringBuilder(te.getSimpleName() + "<"); - - for (int i = 0; i < F.size(te.getTypeParameters()); i++) { - if (i > 0) - generic.append(", "); - - generic.append("?"); - } - - generic.append(">"); - - return generic.toString(); - } } diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/idto/IDTOSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/idto/IDTOSerializerGenerator.java index acbd9ecd35b60..d20399a197e11 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/idto/IDTOSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/idto/IDTOSerializerGenerator.java @@ -61,10 +61,10 @@ import org.apache.ignite.lang.IgniteBiTuple; import org.jetbrains.annotations.NotNull; -import static org.apache.ignite.internal.MessageSerializerGenerator.NL; -import static org.apache.ignite.internal.MessageSerializerGenerator.TAB; +import static org.apache.ignite.internal.MessageGenerator.NL; +import static org.apache.ignite.internal.MessageGenerator.TAB; +import static org.apache.ignite.internal.MessageGenerator.identicalFileIsAlreadyGenerated; import static org.apache.ignite.internal.MessageSerializerGenerator.enumType; -import static org.apache.ignite.internal.MessageSerializerGenerator.identicalFileIsAlreadyGenerated; import static org.apache.ignite.internal.idto.IgniteDataTransferObjectProcessor.DTO_CLASS; /** @@ -740,7 +740,7 @@ private Collection fields(TypeElement type) { } /** @return FQN of {@code comp}. */ - private static String className(TypeMirror comp) { + private String className(TypeMirror comp) { String n = comp.toString(); int spaceIdx = n.indexOf(' '); @@ -750,7 +750,22 @@ private static String className(TypeMirror comp) { int genIdx = n.indexOf('<'); - return genIdx == -1 ? n : n.substring(0, genIdx); + n = genIdx == -1 ? n : n.substring(0, genIdx); + + // In some JDK versions, annotated types may yield simple names (no package). + // Resolve to FQN via the TypeElement to ensure COLL_IMPL / TYPE_SERDES lookups work. + if (!n.contains(".") && comp instanceof DeclaredType) { + TypeElement elem = (TypeElement)((DeclaredType)comp).asElement(); + + if (elem != null) { + String fqn = elem.getQualifiedName().toString(); + + if (!fqn.isEmpty()) + n = fqn; + } + } + + return n; } /** @return Serializer class name. */ diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/idto/IgniteDataTransferObjectProcessor.java b/modules/codegen/src/main/java/org/apache/ignite/internal/idto/IgniteDataTransferObjectProcessor.java index ae119f63c3ae3..6be4b9f7fd10a 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/idto/IgniteDataTransferObjectProcessor.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/idto/IgniteDataTransferObjectProcessor.java @@ -42,9 +42,9 @@ import javax.tools.Diagnostic; import javax.tools.JavaFileObject; -import static org.apache.ignite.internal.MessageSerializerGenerator.NL; -import static org.apache.ignite.internal.MessageSerializerGenerator.TAB; -import static org.apache.ignite.internal.MessageSerializerGenerator.identicalFileIsAlreadyGenerated; +import static org.apache.ignite.internal.MessageGenerator.NL; +import static org.apache.ignite.internal.MessageGenerator.TAB; +import static org.apache.ignite.internal.MessageGenerator.identicalFileIsAlreadyGenerated; import static org.apache.ignite.internal.idto.IDTOSerializerGenerator.CLS_JAVADOC; import static org.apache.ignite.internal.idto.IDTOSerializerGenerator.DTO_SERDES_INTERFACE; import static org.apache.ignite.internal.idto.IDTOSerializerGenerator.simpleName; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageMarshaller.java new file mode 100644 index 0000000000000..2691179aa6b49 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageMarshaller.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.managers.communication; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; + +/** Message marshaller for compressed message. CompressedMessage has no marshallable fields. */ +public class CompressedMessageMarshaller implements MessageMarshaller { + /** {@inheritDoc} */ + @Override public void prepareMarshal(CompressedMessage msg, GridKernalContext kctx, + GridCacheContext nested) throws IgniteCheckedException { + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(CompressedMessage msg, GridKernalContext kctx, + GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(CompressedMessage msg, GridKernalContext kctx) + throws IgniteCheckedException { + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 8509d98d2ef19..f7222c0653f5d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -127,8 +127,8 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFormatter; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.plugin.extensions.communication.MessageReader; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageWriter; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.CommunicationListener; @@ -1176,9 +1176,7 @@ private void onChannelOpened0(UUID rmtNodeId, GridIoMessage initMsg, Channel cha byte plc = initMsg.policy(); - MessageSerializer ser = ctx.messageFactory().serializer(initMsg.directType()); - - ser.finishUnmarshal(initMsg, ctx); + MessageMarshaller.finishUnmarshal(ctx.messageFactory(), initMsg, ctx); pools.poolForPolicy(plc).execute(new Runnable() { @Override public void run() { @@ -1205,9 +1203,7 @@ private void onMessage0(UUID nodeId, GridIoMessage msg, IgniteRunnable msgC) thr assert nodeId != null; assert msg != null; - MessageSerializer ser = ctx.messageFactory().serializer(msg.directType()); - - ser.finishUnmarshal(msg, ctx); + MessageMarshaller.finishUnmarshal(ctx.messageFactory(), msg, ctx); Lock busyLock0 = busyLock.readLock(); @@ -1941,9 +1937,7 @@ private IgniteInternalFuture openChannel( false ); - MessageSerializer ser = ctx.messageFactory().serializer(ioMsg.directType()); - - ser.prepareMarshal(ioMsg, ctx, null); + MessageMarshaller.prepareMarshal(ctx.messageFactory(), ioMsg, ctx, null); try { return ((TcpCommunicationSpi)(CommunicationSpi)getSpi()).openChannel(node, ioMsg); @@ -2013,9 +2007,7 @@ else if (async) ackC.apply(null); } else { - MessageSerializer ser = ctx.messageFactory().serializer(ioMsg.directType()); - - ser.prepareMarshal(ioMsg, ctx, null); + MessageMarshaller.prepareMarshal(ctx.messageFactory(), ioMsg, ctx, null); try { if ((CommunicationSpi)getSpi() instanceof TcpCommunicationSpi) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java index 6c1d45ef16438..62b32658efe9d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java @@ -23,6 +23,7 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.jetbrains.annotations.Nullable; @@ -42,6 +43,9 @@ public class IgniteMessageFactoryImpl implements MessageFactory { /** Message serializers. */ private final MessageSerializer[] msgSerializers = (MessageSerializer[])Array.newInstance(MessageSerializer.class, ARR_SIZE); + /** Message marshallers (null entry = no marshaller registered for that type). */ + private final MessageMarshaller[] msgMarshallers = (MessageMarshaller[])Array.newInstance(MessageMarshaller.class, ARR_SIZE); + /** Initialized flag. If {@code true} then new message type couldn't be registered. */ private boolean initialized; @@ -71,6 +75,23 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] factories) { /** {@inheritDoc} */ @Override public void register(short directType, Supplier supplier, MessageSerializer serializer) throws IgniteException { + register(directType, supplier, serializer, null); + } + + /** + * Registers a message type with both a serializer and an optional marshaller. + * + * @param directType Direct type. + * @param supplier Message factory. + * @param serializer Message serializer. + * @param marshaller Message marshaller, or {@code null} for NonMarshallableMessage types. + */ + @Override public void register( + short directType, + Supplier supplier, + MessageSerializer serializer, + @Nullable MessageMarshaller marshaller + ) throws IgniteException { if (initialized) { throw new IllegalStateException("Message factory is already initialized. " + "Registration of new message types is forbidden."); @@ -91,6 +112,7 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] factories) { if (curr == null) { msgSuppliers[idx] = supplier; msgSerializers[idx] = serializer; + msgMarshallers[idx] = marshaller; minIdx = Math.min(idx, minIdx); @@ -120,7 +142,7 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] factories) { /** * @param directType Message direct type. - * @return Message instance. + * @return Message serializer. * @throws IgniteException If there are no any message factory for given {@code directType}. */ @Override public MessageSerializer serializer(short directType) { @@ -132,6 +154,11 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] factories) { return serializer; } + /** {@inheritDoc} */ + @Override public @Nullable MessageMarshaller marshaller(short directType) { + return msgMarshallers[directTypeToIndex(directType)]; + } + /** * Returns direct types of all registered messages. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java index ffab1fad8df6e..5916292ceef82 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java @@ -27,7 +27,9 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage; /** * An extension of {@link MessageFactoryProvider} allowing to use provided schema-aware marshaller @@ -50,26 +52,33 @@ public void init(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, ClassLoader this.schemaAwareMarsh = schemaAwareMarsh; } - /** Registers message automatically generating message supplier and serializer. */ + /** Registers message automatically generating message supplier, serializer, and marshaller (if applicable). */ protected static void register(MessageFactory factory, Class cls, short id, Marshaller marsh) { Constructor ctor; MessageSerializer serializer; + MessageMarshaller marshaller = null; try { ctor = cls.getConstructor(); - boolean marshallable = MarshallableMessage.class.isAssignableFrom(cls); + Class serCls = Class.forName(cls.getName() + "Serializer"); + serializer = (MessageSerializer)serCls.getConstructor().newInstance(); - Class serCls = Class.forName(cls.getName() + (marshallable ? "MarshallableSerializer" : "Serializer")); + if (!NonMarshallableMessage.class.isAssignableFrom(cls)) { + Class marshallerCls = Class.forName(cls.getName() + "Marshaller"); + boolean marshallable = MarshallableMessage.class.isAssignableFrom(cls); - serializer = marshallable - ? (MessageSerializer)serCls.getConstructor(Marshaller.class).newInstance(marsh) - : (MessageSerializer)serCls.getConstructor().newInstance(); + marshaller = marshallable + ? (MessageMarshaller)marshallerCls.getConstructor(Marshaller.class).newInstance(marsh) + : (MessageMarshaller)marshallerCls.getConstructor().newInstance(); + } } catch (Exception e) { throw new IgniteException("Failed to register message of type " + cls.getSimpleName(), e); } + MessageMarshaller marshallerFinal = marshaller; + factory.register( id, () -> { @@ -80,7 +89,8 @@ protected static void register(MessageFactory factory, Class throw new IgniteException("Failed to create message of type " + cls.getSimpleName(), e); } }, - serializer + serializer, + marshallerFinal ); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index e1d7b25d482e9..8138ade11bdc7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -92,7 +92,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; @@ -1552,9 +1552,8 @@ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) { log.debug("Set P2P context [senderId=" + nodeId + ", msg=" + cacheMsg + ']'); } - MessageSerializer ser = cctx.kernalContext().messageFactory().serializer(cacheMsg.directType()); - - ser.finishUnmarshal(cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); + MessageMarshaller.finishUnmarshal( + cctx.kernalContext().messageFactory(), cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); } catch (IgniteCheckedException e) { cacheMsg.onClassError(e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java index deef16a4e5bb1..131381d3ec1bf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java @@ -82,7 +82,7 @@ import org.apache.ignite.lang.IgniteAsyncCallback; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteClosure; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -1072,9 +1072,8 @@ private void notifyCallback0(UUID nodeId, } } - MessageSerializer ser = cctx.kernalContext().messageFactory().serializer(e.directType()); - - ser.finishUnmarshal(e, cctx.kernalContext(), null, cctx.deploy().globalLoader()); + MessageMarshaller.finishUnmarshal( + cctx.kernalContext().messageFactory(), e, cctx.kernalContext(), null, cctx.deploy().globalLoader()); Collection> evts = handleEvent(ctx, e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 6329f84db99b7..6da323fb77593 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -114,7 +114,7 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteOutClosure; import org.apache.ignite.lang.IgniteReducer; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.spi.systemview.view.TransactionView; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; @@ -3447,10 +3447,9 @@ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) { return; try { - MessageSerializer ser = cctx.kernalContext().messageFactory().serializer(cacheMsg.directType()); - - ser.finishUnmarshal(cacheMsg, cctx.kernalContext()); - ser.finishUnmarshal(cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); + MessageMarshaller.finishUnmarshal(cctx.kernalContext().messageFactory(), cacheMsg, cctx.kernalContext()); + MessageMarshaller.finishUnmarshal( + cctx.kernalContext().messageFactory(), cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); } catch (IgniteCheckedException e) { cacheMsg.onClassError(e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java index f9a73ea8763e5..4595ee5fdeb9c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java @@ -76,7 +76,7 @@ import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.metric.MetricRegistry; import org.apache.ignite.mxbean.IgniteClusterMXBean; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.spi.discovery.DiscoveryDataBag; import org.apache.ignite.spi.discovery.DiscoveryDataBag.GridDiscoveryData; import org.apache.ignite.spi.discovery.DiscoveryMetricsProvider; @@ -383,11 +383,9 @@ public void initDiagnosticListeners() throws IgniteCheckedException { if (msg instanceof IgniteDiagnosticRequest) { IgniteDiagnosticRequest infoReq = (IgniteDiagnosticRequest)msg; - MessageSerializer ser = ctx.messageFactory().serializer(infoReq.directType()); - try { - ser.finishUnmarshal(infoReq, ctx); - ser.finishUnmarshal(infoReq, ctx, null, U.gridClassLoader()); + MessageMarshaller.finishUnmarshal(ctx.messageFactory(), infoReq, ctx); + MessageMarshaller.finishUnmarshal(ctx.messageFactory(), infoReq, ctx, null, U.gridClassLoader()); } catch (IgniteCheckedException e) { U.error(diagnosticLog, "Failed to ummarshall diagnostic request [msg=" + infoReq + "]", e); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java index 53366108bfca0..8a0e5b16707a3 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java @@ -19,6 +19,7 @@ import java.util.function.Supplier; import org.apache.ignite.IgniteException; +import org.jetbrains.annotations.Nullable; /** * Message factory for all communication messages registered using {@link #register(short, Supplier, MessageSerializer)} method call. @@ -100,11 +101,35 @@ default void register(int directType, Supplier supplier, MessageSeriali */ public Message create(short type); + /** + * Register message factory with given direct type, serializer, and marshaller. All messages must be registered + * during construction of class which implements this interface. + * + * @param directType Direct type. + * @param supplier Message factory. + * @param serializer Message serializer. + * @param marshaller Message marshaller, or {@code null} for non-marshallable messages. + * @throws IgniteException In case of attempt to register message with direct type which is already registered. + */ + default void register(short directType, Supplier supplier, MessageSerializer serializer, + @Nullable MessageMarshaller marshaller) throws IgniteException { + register(directType, supplier, serializer); + } + /** * Returns {@code MessageSerializer} for provided type. * * @param type Message type. - * @return Message instance. + * @return Message serializer. */ public MessageSerializer serializer(short type); + + /** + * Returns {@code MessageMarshaller} for provided type, or {@code null} if none is registered + * (e.g. for {@code NonMarshallableMessage} types). + * + * @param type Message type. + * @return Message marshaller, or {@code null}. + */ + public @Nullable MessageMarshaller marshaller(short type); } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java new file mode 100644 index 0000000000000..d5e2647ddf1ab --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -0,0 +1,85 @@ +/* + * 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.processors.cache.GridCacheContext; +import org.jetbrains.annotations.Nullable; + +/** Marshalling logic for cache-object fields in a {@link Message}. */ +public interface MessageMarshaller { + /** + * Marshals cache-object fields on the user thread. + * + * @param msg Message instance. + * @param kctx Kernal context. + * @param nested Nested cache context, or {@code null}. + */ + public void prepareMarshal(M msg, GridKernalContext kctx, @Nullable GridCacheContext nested) + throws IgniteCheckedException; + + /** + * Unmarshals cache-object fields including nested-context resolution. + * + * @param msg Message instance. + * @param kctx Kernal context. + * @param nested Nested cache context, or {@code null}. + * @param clsLdr Class loader. + */ + public void finishUnmarshal(M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) + throws IgniteCheckedException; + + /** + * Unmarshals message fields without a nested cache context (cache-free path). + * + * @param msg Message instance. + * @param kctx Kernal context. + */ + public void finishUnmarshal(M msg, GridKernalContext kctx) throws IgniteCheckedException; + + /** Null-safe {@code prepareMarshal} — skips when no marshaller is registered (e.g. NonMarshallableMessage). */ + static void prepareMarshal( + MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested) + throws IgniteCheckedException { + MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); + + if (m != null) + m.prepareMarshal(msg, kctx, nested); + } + + /** Null-safe {@code finishUnmarshal} (with nested context) — skips when no marshaller is registered. */ + static void finishUnmarshal( + MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) + throws IgniteCheckedException { + MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); + + if (m != null) + m.finishUnmarshal(msg, kctx, nested, clsLdr); + } + + /** Null-safe {@code finishUnmarshal} (cache-free) — skips when no marshaller is registered. */ + static void finishUnmarshal( + MessageFactory factory, M msg, GridKernalContext kctx) + throws IgniteCheckedException { + MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); + + if (m != null) + m.finishUnmarshal(msg, kctx); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index 1c0730b52f2e6..dfd3efe491c5a 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -17,10 +17,6 @@ package org.apache.ignite.plugin.extensions.communication; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; - /** Message serialization logic. */ public interface MessageSerializer { /** @@ -40,41 +36,4 @@ public interface MessageSerializer { * @return Whether message was fully read. */ public boolean readFrom(M msg, MessageReader reader); - - /** - * Marshalls cache-object fields on the user thread. - * - * @param msg Message instance. - * @param kctx Kernal context. - * @param nested Nested context. - * @throws IgniteCheckedException If marshalling fails. - */ - public default void prepareMarshal(M msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - // No-op by default. - } - - /** - * Unmarshalls cache-object fields on the user thread. - * - * @param msg Message instance. - * @param kctx Kernal context. - * @param nested Nested context. - * @param clsLdr Classloader. - * @throws IgniteCheckedException If unmarshalling fails. - */ - public default void finishUnmarshal(M msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) - throws IgniteCheckedException { - // No-op by default. - } - - /** - * Unmarshalls message fields. - * - * @param msg Message instance. - * @param kctx Kernal context. - * @throws IgniteCheckedException If unmarshalling fails. - */ - public default void finishUnmarshal(M msg, GridKernalContext kctx) throws IgniteCheckedException { - // No-op by default. - } } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java index bbf821e17d799..1d51119aa6fb3 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java @@ -49,6 +49,7 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFormatter; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageWriter; @@ -771,6 +772,10 @@ private class GridDummySpiContext implements IgniteSpiContext { @Override public MessageSerializer serializer(short type) { throw new IgniteException("Failed to register message, node is not started."); } + + @Nullable @Override public MessageMarshaller marshaller(short type) { + throw new IgniteException("Failed to register message, node is not started."); + } }; } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java index df7935c6c2f41..765bd01b85308 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java @@ -87,6 +87,7 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFormatter; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageWriter; @@ -831,6 +832,10 @@ public GridNioServer resetNioServer() throws IgniteCheckedException { return get().serializer(type); } + @Nullable @Override public MessageMarshaller marshaller(short type) { + return get().marshaller(type); + } + private MessageFactory get() { if (impl == null) { impl = stateProvider.getSpiContext().messageFactory(); diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java index 0768e74187ca2..40c85da736d19 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java @@ -40,6 +40,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; import org.jetbrains.annotations.NotNull; @@ -198,7 +199,7 @@ T readMessage() throws IgniteCheckedException, IOException { } while (!finished); - msgSer.finishUnmarshal(msg, ((IgniteEx)spi.ignite()).context()); + MessageMarshaller.finishUnmarshal(spi.messageFactory(), msg, ((IgniteEx)spi.ignite()).context()); return (T)msg; } @@ -244,7 +245,7 @@ public Socket socket() { void serializeMessage(Message m, OutputStream out) throws IOException, IgniteCheckedException { MessageSerializer msgSer = spi.messageFactory().serializer(m.directType()); - msgSer.prepareMarshal(m, ((IgniteEx)spi.ignite()).context(), null); + MessageMarshaller.prepareMarshal(spi.messageFactory(), m, ((IgniteEx)spi.ignite()).context(), null); msgWriter.reset(); msgWriter.setBuffer(msgBuf); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java index e1e2e38dbbf5c..15da7cf0349d5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java @@ -56,11 +56,15 @@ public void testProcessorGeneratesSerializer() { assertThat(compilation).succeeded(); - assertEquals(1, compilation.generatedSourceFiles().size()); + assertEquals(2, compilation.generatedSourceFiles().size()); assertThat(compilation) .generatedSourceFile("org.apache.ignite.internal.TestMessageSerializer") .hasSourceEquivalentTo(javaFile("TestMessageSerializer.java")); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMessageMarshaller") + .hasSourceEquivalentTo(javaFile("TestMessageMarshaller.java")); } /** */ @@ -70,11 +74,15 @@ public void testCollectionsMessage() { assertThat(compilation).succeeded(); - assertEquals(1, compilation.generatedSourceFiles().size()); + assertEquals(2, compilation.generatedSourceFiles().size()); assertThat(compilation) .generatedSourceFile("org.apache.ignite.internal.TestCollectionsMessageSerializer") .hasSourceEquivalentTo(javaFile("TestCollectionsMessageSerializer.java")); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestCollectionsMessageMarshaller") + .hasSourceEquivalentTo(javaFile("TestCollectionsMessageMarshaller.java")); } /** */ @@ -84,11 +92,15 @@ public void testMapMessage() { assertThat(compilation).succeeded(); - assertEquals(1, compilation.generatedSourceFiles().size()); + assertEquals(2, compilation.generatedSourceFiles().size()); assertThat(compilation) .generatedSourceFile("org.apache.ignite.internal.TestMapMessageSerializer") .hasSourceEquivalentTo(javaFile("TestMapMessageSerializer.java")); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMapMessageMarshaller") + .hasSourceEquivalentTo(javaFile("TestMapMessageMarshaller.java")); } /** */ @@ -131,11 +143,15 @@ public void testInheritedMessages() { assertThat(compilation).succeeded(); - assertEquals(1, compilation.generatedSourceFiles().size()); + assertEquals(2, compilation.generatedSourceFiles().size()); assertThat(compilation) .generatedSourceFile("org.apache.ignite.internal.ChildMessageSerializer") .hasSourceEquivalentTo(javaFile("ChildMessageSerializer.java")); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.ChildMessageMarshaller") + .hasSourceEquivalentTo(javaFile("ChildMessageMarshaller.java")); } /** */ @@ -145,15 +161,23 @@ public void testMultipleMessages() { assertThat(compilation).succeeded(); - assertEquals(2, compilation.generatedSourceFiles().size()); + assertEquals(4, compilation.generatedSourceFiles().size()); assertThat(compilation) .generatedSourceFile("org.apache.ignite.internal.ChildMessageSerializer") .hasSourceEquivalentTo(javaFile("ChildMessageSerializer.java")); + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.ChildMessageMarshaller") + .hasSourceEquivalentTo(javaFile("ChildMessageMarshaller.java")); + assertThat(compilation) .generatedSourceFile("org.apache.ignite.internal.TestMessageSerializer") .hasSourceEquivalentTo(javaFile("TestMessageSerializer.java")); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMessageMarshaller") + .hasSourceEquivalentTo(javaFile("TestMessageMarshaller.java")); } /** */ @@ -218,9 +242,15 @@ public void testDefaultMapperEnumFields() { assertThat(compilation).succeeded(); + assertEquals(2, compilation.generatedSourceFiles().size()); + assertThat(compilation) .generatedSourceFile("org.apache.ignite.internal.DefaultMapperEnumFieldsMessageSerializer") .hasSourceEquivalentTo(javaFile("DefaultMapperEnumFieldsMessageSerializer.java")); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.DefaultMapperEnumFieldsMessageMarshaller") + .hasSourceEquivalentTo(javaFile("DefaultMapperEnumFieldsMessageMarshaller.java")); } /** @@ -258,9 +288,15 @@ public void testCustomMapperEnumFieldsMessage() { assertThat(compilation).succeeded(); + assertEquals(2, compilation.generatedSourceFiles().size()); + assertThat(compilation) .generatedSourceFile("org.apache.ignite.internal.CustomMapperEnumFieldsMessageSerializer") .hasSourceEquivalentTo(javaFile("CustomMapperEnumFieldsMessageSerializer.java")); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.CustomMapperEnumFieldsMessageMarshaller") + .hasSourceEquivalentTo(javaFile("CustomMapperEnumFieldsMessageMarshaller.java")); } /** */ @@ -270,9 +306,15 @@ public void testMarshallableMessage() { assertThat(compilation).succeeded(); + assertEquals(2, compilation.generatedSourceFiles().size()); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMarshallableMessageSerializer") + .hasSourceEquivalentTo(javaFile("TestMarshallableMessageSerializer.java")); + assertThat(compilation) - .generatedSourceFile("org.apache.ignite.internal.TestMarshallableMessageMarshallableSerializer") - .hasSourceEquivalentTo(javaFile("TestMarshallableMessageMarshallableSerializer.java")); + .generatedSourceFile("org.apache.ignite.internal.TestMarshallableMessageMarshaller") + .hasSourceEquivalentTo(javaFile("TestMarshallableMessageMarshaller.java")); } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStreamImplByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStreamImplByteOrderSelfTest.java index 4c5a786c7e862..f07d995357df8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStreamImplByteOrderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStreamImplByteOrderSelfTest.java @@ -29,6 +29,7 @@ import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.jetbrains.annotations.Nullable; import org.junit.Before; @@ -103,6 +104,10 @@ private static DirectByteBufferStream createStream(ByteBuffer buff) { @Override public MessageSerializer serializer(short type) { return null; } + + @Nullable @Override public MessageMarshaller marshaller(short type) { + return null; + } }); stream.setBuffer(buff); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java index ddb5a7f0cc985..f5f1dad89989d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java @@ -52,7 +52,7 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.stream.StreamReceiver; import org.apache.ignite.testframework.GridTestUtils; @@ -715,10 +715,11 @@ private static class StaleTopologyCommunicationSpi extends TcpCommunicationSpi { ioMsg.skipOnTimeout() ); - MessageSerializer msgSer = ((IgniteEx)ignite).context().messageFactory().serializer(msg.directType()); + MessageMarshaller msgMarshaller = ((IgniteEx)ignite).context().messageFactory().marshaller(msg.directType()); try { - msgSer.prepareMarshal(msg, ((IgniteEx)ignite).context(), null); + if (msgMarshaller != null) + msgMarshaller.prepareMarshal(msg, ((IgniteEx)ignite).context(), null); } catch (IgniteCheckedException e) { throw new RuntimeException(e); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/MessagesPluginProvider.java b/modules/core/src/test/java/org/apache/ignite/spi/MessagesPluginProvider.java index 6983e7e17aad6..d75f1c28e17c1 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/MessagesPluginProvider.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/MessagesPluginProvider.java @@ -53,7 +53,7 @@ public MessagesPluginProvider(Class... msgs) { } }; - f.register(directType, msgSupp, loadSerializer(msg, null)); + f.register(directType, msgSupp, loadSerializer(msg)); directType++; } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index ccaf13eb56be9..1d451125d4385 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -38,6 +38,7 @@ import org.apache.ignite.marshaller.Marshallers; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageWriter; @@ -51,6 +52,7 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_ENABLE_OBJECT_INPUT_FILTER_AUTOCONFIGURATION; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHALLER_BLACKLIST; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHALLER_WHITELIST; +import static org.apache.ignite.testframework.GridTestUtils.loadMarshaller; import static org.apache.ignite.testframework.GridTestUtils.loadSerializer; /** @@ -67,6 +69,9 @@ public class DiscoveryUnmarshalVulnerabilityTest extends GridCommonAbstractTest /** */ private MessageSerializer serializer; + /** */ + private MessageMarshaller marshaller; + /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -89,11 +94,13 @@ public class DiscoveryUnmarshalVulnerabilityTest extends GridCommonAbstractTest MessageFactoryProvider msgFactoryProvider = new AbstractMarshallableMessageFactoryProvider() { @Override public void registerAll(MessageFactory factory) { serializer = new MessageSerializerWrapper(this); - + marshaller = new MessageMarshallerWrapper(this); + factory.register( - CoreMessagesProvider.MAX_MESSAGE_ID + 1, + (short)(CoreMessagesProvider.MAX_MESSAGE_ID + 1), ExploitMessage::new, - serializer); + serializer, + marshaller); } }; @@ -232,7 +239,7 @@ private byte[] serializedMessage() throws IgniteCheckedException { ExploitMessage msg = new ExploitMessage(new Exploit()); - serializer.prepareMarshal(msg, grid().context(), null); + marshaller.prepareMarshal(msg, grid().context(), null); writer.writeMessage(msg); @@ -279,26 +286,56 @@ private MessageSerializerWrapper(AbstractMarshallableMessageFactoryProvider prov return serde.readFrom(msg, reader); } + /** */ + private void initIfNecessary() { + if (init.get() && init.compareAndSet(true, false)) + serde = loadSerializer(ExploitMessage.class); + } + } + + /** */ + private static class MessageMarshallerWrapper implements MessageMarshaller { + /** */ + private final AbstractMarshallableMessageFactoryProvider provider; + + /** */ + private final AtomicBoolean init = new AtomicBoolean(true); + + /** */ + private MessageMarshaller marsh; + + /** */ + private MessageMarshallerWrapper(AbstractMarshallableMessageFactoryProvider provider) { + this.provider = provider; + } + /** {@inheritDoc} */ - @Override public void prepareMarshal(ExploitMessage msg, GridKernalContext kctx, GridCacheContext nested) + @Override public void prepareMarshal(ExploitMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { initIfNecessary(); - serde.prepareMarshal(msg, kctx, nested); + marsh.prepareMarshal(msg, kctx, nested); + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(ExploitMessage msg, GridKernalContext kctx, GridCacheContext nested, + ClassLoader clsLdr) throws IgniteCheckedException { + initIfNecessary(); + + marsh.finishUnmarshal(msg, kctx, nested, clsLdr); } /** {@inheritDoc} */ @Override public void finishUnmarshal(ExploitMessage msg, GridKernalContext kctx) throws IgniteCheckedException { initIfNecessary(); - - serde.finishUnmarshal(msg, kctx); + + marsh.finishUnmarshal(msg, kctx); } /** */ private void initIfNecessary() { if (init.get() && init.compareAndSet(true, false)) - serde = loadSerializer(ExploitMessage.class, - U.field(provider, "dfltMarsh")); + marsh = loadMarshaller(ExploitMessage.class, U.field(provider, "dfltMarsh")); } } } diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java index ff8333e4efbd1..6ca8d374816c5 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java @@ -131,6 +131,7 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.communication.tcp.internal.GridNioServerWrapper; @@ -2704,26 +2705,36 @@ public static void skipCommNioServerRead(IgniteEx ignite, boolean skip) { } /** */ - public static MessageSerializer loadSerializer(Class msgCls, - @Nullable Marshaller dfltMarsh) { + public static MessageSerializer loadSerializer(Class msgCls) { try { - boolean isMarshallable = MarshallableMessage.class.isAssignableFrom(msgCls); + Class serCls = U.gridClassLoader() + .loadClass(msgCls.getPackage().getName() + "." + msgCls.getSimpleName() + "Serializer"); - String clsPref = msgCls.getSimpleName() + (isMarshallable ? "Marshallable" : ""); + return (MessageSerializer)U.newInstance(serCls); + } + catch (Exception e) { + throw new RuntimeException("Unable to find serializer for message: " + msgCls, e); + } + } - Class serCls = U.gridClassLoader() - .loadClass(msgCls.getPackage().getName() + "." + clsPref + "Serializer"); + /** */ + public static MessageMarshaller loadMarshaller(Class msgCls, + @Nullable Marshaller dfltMarsh) { + try { + Class marshallerCls = U.gridClassLoader() + .loadClass(msgCls.getPackage().getName() + "." + msgCls.getSimpleName() + "Marshaller"); - Marshaller marsh = dfltMarsh != null ? dfltMarsh : jdk(); + boolean isMarshallable = MarshallableMessage.class.isAssignableFrom(msgCls); - Object msgSer = isMarshallable ? - serCls.getConstructor(Marshaller.class).newInstance(marsh) : - U.newInstance(serCls); + if (isMarshallable) { + Marshaller marsh = dfltMarsh != null ? dfltMarsh : jdk(); + return (MessageMarshaller)marshallerCls.getConstructor(Marshaller.class).newInstance(marsh); + } - return (MessageSerializer)msgSer; + return (MessageMarshaller)U.newInstance(marshallerCls); } catch (Exception e) { - throw new RuntimeException("Unable to find serializer for message: " + msgCls, e); + throw new RuntimeException("Unable to find marshaller for message: " + msgCls, e); } } diff --git a/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java b/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java new file mode 100644 index 0000000000000..4031816e51b17 --- /dev/null +++ b/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.ChildMessage; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class ChildMessageMarshaller implements MessageMarshaller { + /** */ + public ChildMessageMarshaller() { + + } + + /** */ + @Override public void prepareMarshal(ChildMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } + + /** */ + @Override public void finishUnmarshal(ChildMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } + + /** */ + @Override public void finishUnmarshal(ChildMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + } +} diff --git a/modules/core/src/test/resources/codegen/ChildMessageSerializer.java b/modules/core/src/test/resources/codegen/ChildMessageSerializer.java index b6240fb7950c0..d4de3abe02800 100644 --- a/modules/core/src/test/resources/codegen/ChildMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/ChildMessageSerializer.java @@ -17,12 +17,8 @@ package org.apache.ignite.internal; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.AbstractMessage; import org.apache.ignite.internal.ChildMessage; -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageWriter; @@ -34,13 +30,10 @@ */ public class ChildMessageSerializer implements MessageSerializer { /** */ - private final ClassLoader clsLdr; + public ChildMessageSerializer() { - /** */ - public ChildMessageSerializer(ClassLoader clsLdr) { - this.clsLdr = clsLdr; } - + /** */ @Override public boolean writeTo(ChildMessage msg, MessageWriter writer) { if (!writer.isHeaderWritten()) { @@ -118,13 +111,4 @@ public ChildMessageSerializer(ClassLoader clsLdr) { return true; } - /** */ - @Override public void prepareMarshal(ChildMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - } - - /** */ - @Override public void finishUnmarshal(ChildMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java new file mode 100644 index 0000000000000..71007ee9faf62 --- /dev/null +++ b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.CustomMapperEnumFieldsMessage; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class CustomMapperEnumFieldsMessageMarshaller implements MessageMarshaller { + /** */ + public CustomMapperEnumFieldsMessageMarshaller() { + + } + + /** */ + @Override public void prepareMarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } + + /** */ + @Override public void finishUnmarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } + + /** */ + @Override public void finishUnmarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + } +} diff --git a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageSerializer.java b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageSerializer.java index d872ab9f912e3..7d8e53bf08d4b 100644 --- a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageSerializer.java @@ -17,12 +17,8 @@ package org.apache.ignite.internal; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.CustomMapperEnumFieldsMessage; -import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TransactionIsolationEnumMapper; -import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageWriter; @@ -35,14 +31,12 @@ * @see org.apache.ignite.internal.MessageProcessor */ public class CustomMapperEnumFieldsMessageSerializer implements MessageSerializer { - /** */ - private final ClassLoader clsLdr; /** */ private final EnumMapper transactionIsolationMapper = new TransactionIsolationEnumMapper(); /** */ - public CustomMapperEnumFieldsMessageSerializer(ClassLoader clsLdr) { - this.clsLdr = clsLdr; + public CustomMapperEnumFieldsMessageSerializer() { + } /** */ @@ -80,13 +74,4 @@ public CustomMapperEnumFieldsMessageSerializer(ClassLoader clsLdr) { return true; } - /** */ - @Override public void prepareMarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - } - - /** */ - @Override public void finishUnmarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - } } diff --git a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java new file mode 100644 index 0000000000000..2157567483074 --- /dev/null +++ b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.DefaultMapperEnumFieldsMessage; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class DefaultMapperEnumFieldsMessageMarshaller implements MessageMarshaller { + /** */ + public DefaultMapperEnumFieldsMessageMarshaller() { + + } + + /** */ + @Override public void prepareMarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } + + /** */ + @Override public void finishUnmarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } + + /** */ + @Override public void finishUnmarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + } +} diff --git a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageSerializer.java b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageSerializer.java index 2373889c522a9..000fea443fb75 100644 --- a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageSerializer.java @@ -17,11 +17,7 @@ package org.apache.ignite.internal; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.DefaultMapperEnumFieldsMessage; -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; @@ -35,16 +31,14 @@ * @see org.apache.ignite.internal.MessageProcessor */ public class DefaultMapperEnumFieldsMessageSerializer implements MessageSerializer { - /** */ - private final ClassLoader clsLdr; /** */ private final GridCacheOperation[] gridCacheOperationVals = GridCacheOperation.values(); /** */ private final TransactionIsolation[] transactionIsolationVals = TransactionIsolation.values(); /** */ - public DefaultMapperEnumFieldsMessageSerializer(ClassLoader clsLdr) { - this.clsLdr = clsLdr; + public DefaultMapperEnumFieldsMessageSerializer() { + } /** */ @@ -96,13 +90,4 @@ public DefaultMapperEnumFieldsMessageSerializer(ClassLoader clsLdr) { return true; } - /** */ - @Override public void prepareMarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - } - - /** */ - @Override public void finishUnmarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java new file mode 100644 index 0000000000000..176e9e2618833 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.util.Collection; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.TestCollectionsMessage; +import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestCollectionsMessageMarshaller implements MessageMarshaller { + /** */ + public TestCollectionsMessageMarshaller() { + + } + + /** */ + @Override public void prepareMarshal(TestCollectionsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.messageList != null) { + for (GridCacheVersion e2 : (Collection)msg.messageList) { + if (e2 != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e2, kctx, ctx); + } + } + + if (msg.cacheObjectSet != null) { + for (CacheObject e2 : (Collection)msg.cacheObjectSet) { + if (e2 != null && ctx != null) + e2.prepareMarshal(ctx.cacheObjectContext()); + } + } + } + + /** */ + @Override public void finishUnmarshal(TestCollectionsMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.messageList != null) { + for (GridCacheVersion e2 : (Collection)msg.messageList) { + if (e2 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e2, kctx, ctx, clsLdr); + } + } + + if (msg.cacheObjectSet != null) { + for (CacheObject e2 : (Collection)msg.cacheObjectSet) { + if (e2 != null && ctx != null) + e2.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + } + } + } + + /** */ + @Override public void finishUnmarshal(TestCollectionsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + if (msg.messageList != null) { + for (GridCacheVersion e2 : (Collection)msg.messageList) { + if (e2 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e2, kctx); + } + } + } +} diff --git a/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java b/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java index af2a9ba623bd5..2aff2a2e686b3 100644 --- a/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java @@ -17,28 +17,7 @@ package org.apache.ignite.internal; -import java.lang.Boolean; -import java.lang.Byte; -import java.lang.Character; -import java.lang.Double; -import java.lang.Float; -import java.lang.Integer; -import java.lang.Long; -import java.lang.Short; -import java.lang.String; -import java.util.BitSet; -import java.util.Collection; -import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestCollectionsMessage; -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.util.GridLongList; -import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; import org.apache.ignite.plugin.extensions.communication.MessageItemType; @@ -52,8 +31,6 @@ * @see org.apache.ignite.internal.MessageProcessor */ public class TestCollectionsMessageSerializer implements MessageSerializer { - /** */ - private final ClassLoader clsLdr; /** */ private static final MessageCollectionType affTopVersionListCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.AFFINITY_TOPOLOGY_VERSION), false); /** */ @@ -108,8 +85,8 @@ public class TestCollectionsMessageSerializer implements MessageSerializer nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - - if (msg.messageList != null) { - for (GridCacheVersion e2 : (Collection)msg.messageList) { - if (e2 != null) - kctx.messageFactory().serializer(e2.directType()).prepareMarshal(e2, kctx, ctx); - } - } - - if (msg.cacheObjectSet != null) { - for (CacheObject e2 : (Collection)msg.cacheObjectSet) { - if (e2 != null && ctx != null) - e2.prepareMarshal(ctx.cacheObjectContext()); - } - } - } - - /** */ - @Override public void finishUnmarshal(TestCollectionsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - - if (msg.messageList != null) { - for (GridCacheVersion e2 : (Collection)msg.messageList) { - if (e2 != null) - kctx.messageFactory().serializer(e2.directType()).finishUnmarshal(e2, kctx, ctx); - } - } - - if (msg.cacheObjectSet != null) { - for (CacheObject e2 : (Collection)msg.cacheObjectSet) { - if (e2 != null && ctx != null) - e2.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); - } - } - } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java new file mode 100644 index 0000000000000..a9faf8c49643f --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.TestMapMessage; +import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMapMessageMarshaller implements MessageMarshaller { + /** */ + public TestMapMessageMarshaller() { + + } + + /** */ + @Override public void prepareMarshal(TestMapMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.messageBoxedDoubleMap != null) { + for (GridCacheVersion e3 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { + if (e3 != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e3, kctx, ctx); + } + } + + if (msg.gridCacheObjectMap != null) { + for (KeyCacheObject e3 : ((Collection)msg.gridCacheObjectMap.keySet())) { + if (e3 != null && ctx != null) + e3.prepareMarshal(ctx.cacheObjectContext()); + } + for (Map e3 : ((Collection)msg.gridCacheObjectMap.values())) { + if (e3 != null) { + for (List e5 : ((Collection)e3.values())) { + if (e5 != null) { + for (CacheObject e6 : (Collection)e5) { + if (e6 != null && ctx != null) + e6.prepareMarshal(ctx.cacheObjectContext()); + } + } + } + } + } + } + } + + /** */ + @Override public void finishUnmarshal(TestMapMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.messageBoxedDoubleMap != null) { + for (GridCacheVersion e3 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { + if (e3 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e3, kctx, ctx, clsLdr); + } + } + + if (msg.gridCacheObjectMap != null) { + for (KeyCacheObject e3 : ((Collection)msg.gridCacheObjectMap.keySet())) { + if (e3 != null && ctx != null) + e3.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + } + for (Map e3 : ((Collection)msg.gridCacheObjectMap.values())) { + if (e3 != null) { + for (List e5 : ((Collection)e3.values())) { + if (e5 != null) { + for (CacheObject e6 : (Collection)e5) { + if (e6 != null && ctx != null) + e6.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + } + } + } + } + } + } + } + + /** */ + @Override public void finishUnmarshal(TestMapMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + if (msg.messageBoxedDoubleMap != null) { + for (GridCacheVersion e3 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { + if (e3 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e3, kctx); + } + } + } +} diff --git a/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java index 9eb4912e0098c..1e43dcb11553b 100644 --- a/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java @@ -17,18 +17,7 @@ package org.apache.ignite.internal; -import java.lang.Double; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMapMessage; -import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.KeyCacheObject; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; import org.apache.ignite.plugin.extensions.communication.MessageItemType; @@ -43,8 +32,6 @@ * @see org.apache.ignite.internal.MessageProcessor */ public class TestMapMessageSerializer implements MessageSerializer { - /** */ - private final ClassLoader clsLdr; /** */ private static final MessageMapType affTopVersionIgniteUuidMapCollDesc = new MessageMapType(new MessageItemType(MessageCollectionItemType.AFFINITY_TOPOLOGY_VERSION), new MessageItemType(MessageCollectionItemType.IGNITE_UUID), false); /** */ @@ -99,8 +86,8 @@ public class TestMapMessageSerializer implements MessageSerializer nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - - if (msg.messageBoxedDoubleMap != null) { - for (GridCacheVersion e3 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { - if (e3 != null) - kctx.messageFactory().serializer(e3.directType()).prepareMarshal(e3, kctx, ctx); - } - } - - if (msg.gridCacheObjectMap != null) { - for (KeyCacheObject e3 : ((Collection)msg.gridCacheObjectMap.keySet())) { - if (e3 != null && ctx != null) - e3.prepareMarshal(ctx.cacheObjectContext()); - } - for (Map e3 : ((Collection)msg.gridCacheObjectMap.values())) { - if (e3 != null) { - for (List e5 : ((Collection)e3.values())) { - if (e5 != null) { - for (CacheObject e6 : (Collection)e5) { - if (e6 != null && ctx != null) - e6.prepareMarshal(ctx.cacheObjectContext()); - } - } - } - } - } - } - } - - /** */ - @Override public void finishUnmarshal(TestMapMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - - if (msg.messageBoxedDoubleMap != null) { - for (GridCacheVersion e3 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { - if (e3 != null) - kctx.messageFactory().serializer(e3.directType()).finishUnmarshal(e3, kctx, ctx); - } - } - - if (msg.gridCacheObjectMap != null) { - for (KeyCacheObject e3 : ((Collection)msg.gridCacheObjectMap.keySet())) { - if (e3 != null && ctx != null) - e3.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); - } - for (Map e3 : ((Collection)msg.gridCacheObjectMap.values())) { - if (e3 != null) { - for (List e5 : ((Collection)e3.values())) { - if (e5 != null) { - for (CacheObject e6 : (Collection)e5) { - if (e6 != null && ctx != null) - e6.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); - } - } - } - } - } - } - } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java new file mode 100644 index 0000000000000..71706ecc3a1e5 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.TestMarshallableMessage; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMarshallableMessageMarshaller implements MessageMarshaller { + /** */ + private final Marshaller marshaller; + + /** */ + public TestMarshallableMessageMarshaller(Marshaller marshaller) { + this.marshaller = marshaller; + } + + /** */ + @Override public void prepareMarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + msg.prepareMarshal(marshaller); + } + + /** */ + @Override public void finishUnmarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + GridCacheContext ctx = nested; + } + + /** */ + @Override public void finishUnmarshal(TestMarshallableMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config())); + } +} diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMarshallableMessageSerializer.java new file mode 100644 index 0000000000000..b993fe6be0a30 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessageSerializer.java @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.internal.TestMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageWriter; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMarshallableMessageSerializer implements MessageSerializer { + /** */ + public TestMarshallableMessageSerializer() { + + } + + /** */ + @Override public boolean writeTo(TestMarshallableMessage msg, MessageWriter writer) { + if (!writer.isHeaderWritten()) { + if (!writer.writeHeader(msg.directType())) + return false; + + writer.onHeaderWritten(); + } + + switch (writer.state()) { + case 0: + if (!writer.writeInt(msg.iv)) + return false; + + writer.incrementState(); + + case 1: + if (!writer.writeString(msg.sv)) + return false; + + writer.incrementState(); + + case 2: + if (!writer.writeByteArray(msg.cstDataBytes)) + return false; + + writer.incrementState(); + } + + return true; + } + + /** */ + @Override public boolean readFrom(TestMarshallableMessage msg, MessageReader reader) { + switch (reader.state()) { + case 0: + msg.iv = reader.readInt(); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + + case 1: + msg.sv = reader.readString(); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + + case 2: + msg.cstDataBytes = reader.readByteArray(); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + } + + return true; + } + +} diff --git a/modules/core/src/test/resources/codegen/TestMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMessageMarshaller.java new file mode 100644 index 0000000000000..7f220cf13a8f1 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMessageMarshaller.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.TestMessage; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMessageMarshaller implements MessageMarshaller { + /** */ + public TestMessageMarshaller() { + + } + + /** */ + @Override public void prepareMarshal(TestMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.ver != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), msg.ver, kctx, ctx); + + if (msg.verArr != null) { + for (GridCacheVersion e3 : msg.verArr) { + if (e3 != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e3, kctx, ctx); + } + } + + if (msg.keyCacheObject != null && ctx != null) + msg.keyCacheObject.prepareMarshal(ctx.cacheObjectContext()); + + if (msg.cacheObject != null && ctx != null) + msg.cacheObject.prepareMarshal(ctx.cacheObjectContext()); + } + + /** */ + @Override public void finishUnmarshal(TestMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.ver != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), msg.ver, kctx, ctx, clsLdr); + + if (msg.verArr != null) { + for (GridCacheVersion e3 : msg.verArr) { + if (e3 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e3, kctx, ctx, clsLdr); + } + } + + if (msg.keyCacheObject != null && ctx != null) + msg.keyCacheObject.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + + if (msg.cacheObject != null && ctx != null) + msg.cacheObject.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + } + + /** */ + @Override public void finishUnmarshal(TestMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + if (msg.ver != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), msg.ver, kctx); + + if (msg.verArr != null) { + for (GridCacheVersion e3 : msg.verArr) { + if (e3 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e3, kctx); + } + } + } +} diff --git a/modules/core/src/test/resources/codegen/TestMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMessageSerializer.java index 8ab43ab776765..a553f049c68a6 100644 --- a/modules/core/src/test/resources/codegen/TestMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestMessageSerializer.java @@ -17,12 +17,7 @@ package org.apache.ignite.internal; -import java.lang.String; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMessage; -import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.plugin.extensions.communication.MessageArrayType; import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; @@ -37,8 +32,6 @@ * @see org.apache.ignite.internal.MessageProcessor */ public class TestMessageSerializer implements MessageSerializer { - /** */ - private final ClassLoader clsLdr; /** */ private static final MessageArrayType intMatrixCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.INT_ARR), int[].class); /** */ @@ -47,10 +40,10 @@ public class TestMessageSerializer implements MessageSerializer { private static final MessageArrayType verArrCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.MSG), GridCacheVersion.class); /** */ - public TestMessageSerializer(ClassLoader clsLdr) { - this.clsLdr = clsLdr; + public TestMessageSerializer() { + } - + /** */ @Override public boolean writeTo(TestMessage msg, MessageWriter writer) { if (!writer.isHeaderWritten()) { @@ -281,46 +274,4 @@ public TestMessageSerializer(ClassLoader clsLdr) { return true; } - - /** */ - @Override public void prepareMarshal(TestMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - - if (msg.ver != null) - kctx.messageFactory().serializer(msg.ver.directType()).prepareMarshal(msg.ver, kctx, ctx); - - if (msg.verArr != null) { - for (GridCacheVersion e3 : msg.verArr) { - if (e3 != null) - kctx.messageFactory().serializer(e3.directType()).prepareMarshal(e3, kctx, ctx); - } - } - - if (msg.keyCacheObject != null && ctx != null) - msg.keyCacheObject.prepareMarshal(ctx.cacheObjectContext()); - - if (msg.cacheObject != null && ctx != null) - msg.cacheObject.prepareMarshal(ctx.cacheObjectContext()); - } - - /** */ - @Override public void finishUnmarshal(TestMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - - if (msg.ver != null) - kctx.messageFactory().serializer(msg.ver.directType()).finishUnmarshal(msg.ver, kctx, ctx); - - if (msg.verArr != null) { - for (GridCacheVersion e3 : msg.verArr) { - if (e3 != null) - kctx.messageFactory().serializer(e3.directType()).finishUnmarshal(e3, kctx, ctx); - } - } - - if (msg.keyCacheObject != null && ctx != null) - msg.keyCacheObject.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); - - if (msg.cacheObject != null && ctx != null) - msg.cacheObject.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); - } -} \ No newline at end of file +} diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index 6f2896001128f..3f7c7a1a4575f 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -31,6 +31,7 @@ import org.apache.ignite.internal.direct.DirectMessageWriter; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi; @@ -93,11 +94,11 @@ private void serializeMessage(Message m, OutputStream out) throws IOException { MessageSerializer msgSer = msgFactory.serializer(m.directType()); try { - msgSer.prepareMarshal(m, ((IgniteEx)spi.ignite()).context(), null); + MessageMarshaller.prepareMarshal(msgFactory, m, ((IgniteEx)spi.ignite()).context(), null); } catch (IgniteCheckedException e) { throw new IgniteSpiException("Failed to marshal discovery message", e); - } + } boolean finished; @@ -141,7 +142,7 @@ private T deserializeMessage(InputStream in) throws IOExcept while (!finished); try { - msgSer.finishUnmarshal(msg, ((IgniteEx)spi.ignite()).context()); + MessageMarshaller.finishUnmarshal(msgFactory, msg, ((IgniteEx)spi.ignite()).context()); } catch (IgniteCheckedException e) { throw new IgniteSpiException("Failed to unmarshal discovery message", e); From 132abcff3197ebff8ffb8e4fb0d6dfd37b057bc5 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 14:42:35 +0300 Subject: [PATCH 135/215] WIP --- .../ignite/internal/MessageMarshallerGenerator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 49cd495f078a4..ec932767d8e88 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -457,14 +457,14 @@ else if (assignableFrom(erasedType(t), type(java.util.Collection.class.getName() /** */ private boolean isCacheObject(TypeMirror type) { - TypeMirror cacheObject = type("org.apache.ignite.internal.processors.cache.CacheObject"); - return cacheObject != null && assignableFrom(type, cacheObject); + TypeMirror obj = type("org.apache.ignite.internal.processors.cache.CacheObject"); + return obj != null && assignableFrom(type, obj); } /** */ private boolean isMessage(TypeMirror type) { - TypeMirror message = type(MESSAGE_INTERFACE); - return message != null && assignableFrom(type, message); + TypeMirror msg = type(MESSAGE_INTERFACE); + return msg != null && assignableFrom(type, msg); } /** */ From 75dea239e90583a785fde411164b02be7c667a57 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 14:56:36 +0300 Subject: [PATCH 136/215] WIP --- .../codegen/ChildMessageMarshaller.java | 4 +++- ...ustomMapperEnumFieldsMessageMarshaller.java | 4 +++- ...faultMapperEnumFieldsMessageMarshaller.java | 4 +++- .../TestCollectionsMessageMarshaller.java | 18 +++++++++++++++++- .../codegen/TestMapMessageMarshaller.java | 5 ++++- .../TestMarshallableMessageMarshaller.java | 4 +++- .../codegen/TestMessageMarshaller.java | 5 ++++- 7 files changed, 37 insertions(+), 7 deletions(-) diff --git a/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java b/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java index 4031816e51b17..93cfc03305d22 100644 --- a/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java @@ -19,7 +19,9 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.ChildMessage; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; /** @@ -46,4 +48,4 @@ public ChildMessageMarshaller() { /** */ @Override public void finishUnmarshal(ChildMessage msg, GridKernalContext kctx) throws IgniteCheckedException { } -} +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java index 71007ee9faf62..b764f07ba2ccd 100644 --- a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java @@ -19,7 +19,9 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.CustomMapperEnumFieldsMessage; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; /** @@ -46,4 +48,4 @@ public CustomMapperEnumFieldsMessageMarshaller() { /** */ @Override public void finishUnmarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { } -} +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java index 2157567483074..9f13010907448 100644 --- a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java @@ -19,7 +19,9 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.DefaultMapperEnumFieldsMessage; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; /** @@ -46,4 +48,4 @@ public DefaultMapperEnumFieldsMessageMarshaller() { /** */ @Override public void finishUnmarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { } -} +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java index 176e9e2618833..e84d844bf6ad4 100644 --- a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java @@ -17,12 +17,28 @@ package org.apache.ignite.internal; +import java.lang.Boolean; +import java.lang.Byte; +import java.lang.Character; +import java.lang.Double; +import java.lang.Float; +import java.lang.Integer; +import java.lang.Long; +import java.lang.Short; +import java.lang.String; +import java.util.BitSet; import java.util.Collection; +import java.util.UUID; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestCollectionsMessage; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.util.GridLongList; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; /** @@ -83,4 +99,4 @@ public TestCollectionsMessageMarshaller() { } } } -} +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java index a9faf8c49643f..aee7ec6230016 100644 --- a/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java @@ -17,15 +17,18 @@ package org.apache.ignite.internal; +import java.lang.Double; import java.util.Collection; import java.util.List; import java.util.Map; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMapMessage; import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; /** @@ -110,4 +113,4 @@ public TestMapMessageMarshaller() { } } } -} +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java index 71706ecc3a1e5..131a145ea3ab0 100644 --- a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMarshallableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.util.typedef.internal.U; @@ -36,6 +37,7 @@ public class TestMarshallableMessageMarshaller implements MessageMarshaller Date: Fri, 19 Jun 2026 15:01:23 +0300 Subject: [PATCH 137/215] WIP --- .../communication/MessageMarshaller.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index d5e2647ddf1ab..34dee97916a24 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -53,7 +53,13 @@ public void finishUnmarshal(M msg, GridKernalContext kctx, @Nullable GridCacheCo */ public void finishUnmarshal(M msg, GridKernalContext kctx) throws IgniteCheckedException; - /** Null-safe {@code prepareMarshal} — skips when no marshaller is registered (e.g. NonMarshallableMessage). */ + /** Null-safe {@code prepareMarshal} — skips when no marshaller is registered (e.g. NonMarshallableMessage). + * + * @param factory Message factory. + * @param msg Message. + * @param kctx Kernal context. + * @param nested Nested context. + * */ static void prepareMarshal( MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested) throws IgniteCheckedException { @@ -63,7 +69,14 @@ static void prepareMarshal( m.prepareMarshal(msg, kctx, nested); } - /** Null-safe {@code finishUnmarshal} (with nested context) — skips when no marshaller is registered. */ + /** Null-safe {@code finishUnmarshal} (with nested context) — skips when no marshaller is registered. + * + * @param factory Message Factory. + * @param msg Message. + * @param kctx Kernal context. + * @param nested Nested context. + * @param clsLdr Class loader. + * */ static void finishUnmarshal( MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { @@ -73,7 +86,11 @@ static void finishUnmarshal( m.finishUnmarshal(msg, kctx, nested, clsLdr); } - /** Null-safe {@code finishUnmarshal} (cache-free) — skips when no marshaller is registered. */ + /** Null-safe {@code finishUnmarshal} (cache-free) — skips when no marshaller is registered. + * + * @param factory Message factory. + * @param kctx Kernal context. + * */ static void finishUnmarshal( MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { From a0dbcbe9a50d3c0520b2f0e04f217afa47ce6d2f Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 15:11:57 +0300 Subject: [PATCH 138/215] WIP --- .../plugin/extensions/communication/MessageMarshaller.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index 34dee97916a24..8ab3b63ee7304 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -59,6 +59,7 @@ public void finishUnmarshal(M msg, GridKernalContext kctx, @Nullable GridCacheCo * @param msg Message. * @param kctx Kernal context. * @param nested Nested context. + * @param Message type. * */ static void prepareMarshal( MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested) @@ -76,6 +77,7 @@ static void prepareMarshal( * @param kctx Kernal context. * @param nested Nested context. * @param clsLdr Class loader. + * @param Message type. * */ static void finishUnmarshal( MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) @@ -90,6 +92,7 @@ static void finishUnmarshal( * * @param factory Message factory. * @param kctx Kernal context. + * @param Message type. * */ static void finishUnmarshal( MessageFactory factory, M msg, GridKernalContext kctx) From 187f77320fe4894068891a5de3d715c75f7f7ac0 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 16:27:41 +0300 Subject: [PATCH 139/215] WIP --- .../plugin/extensions/communication/MessageMarshaller.java | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index 8ab3b63ee7304..fdb0a2057621a 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -92,6 +92,7 @@ static void finishUnmarshal( * * @param factory Message factory. * @param kctx Kernal context. + * @param msg Message. * @param Message type. * */ static void finishUnmarshal( From f737f3df468d7823ae619bf9bd3a62d01a806217 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 18:41:09 +0300 Subject: [PATCH 140/215] WIP --- .../calcite/message/MessageServiceImpl.java | 6 +- modules/core/pom.xml | 7 + .../direct/stream/DirectByteBufferStream.java | 5 +- .../internal/util/nio/GridDirectParser.java | 4 +- .../internal/util/nio/GridNioServer.java | 8 +- .../communication/MessageSerializer.java | 26 ++++ .../tcp/internal/TcpHandshakeExecutor.java | 10 +- .../discovery/tcp/TcpDiscoveryIoSession.java | 8 +- .../MessageSerializationArchitectureTest.java | 131 ++++++++++++++++++ .../AbstractMessageSerializationTest.java | 5 +- .../cache/CacheMetricsCacheSizeTest.java | 6 +- ...acheContinuousQueryImmutableEntryTest.java | 8 +- .../DataStreamerImplSelfTest.java | 6 +- .../DiscoveryUnmarshalVulnerabilityTest.java | 4 +- .../testsuites/IgniteBasicTestSuite.java | 2 + .../zk/internal/DiscoveryMessageParser.java | 7 +- 16 files changed, 194 insertions(+), 49 deletions(-) create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java index 742d7c2f7eec9..98211b8cb8876 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java @@ -180,13 +180,9 @@ public FailureProcessor failureProcessor() { } /** */ - @SuppressWarnings("unchecked") protected void prepareUnmarshal(Message msg) throws IgniteCheckedException { try { - MessageMarshaller marshaller = ctx.kernalContext().messageFactory().marshaller(msg.directType()); - - if (marshaller != null) - marshaller.finishUnmarshal(msg, ctx.kernalContext(), null, clsLdr); + MessageMarshaller.finishUnmarshal(ctx.kernalContext().messageFactory(), msg, ctx.kernalContext(), null, clsLdr); } catch (Exception e) { failureProcessor().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); diff --git a/modules/core/pom.xml b/modules/core/pom.xml index aebc94795a5f5..1dfe5e39a8b45 100644 --- a/modules/core/pom.xml +++ b/modules/core/pom.xml @@ -231,6 +231,13 @@ test + + com.tngtech.archunit + archunit-junit4 + 1.4.1 + test + + com.google.testing.compile compile-testing diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java index 2192272747cd9..c2c29b1a09d10 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java @@ -49,6 +49,7 @@ import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageMapType; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageType; import org.apache.ignite.plugin.extensions.communication.MessageWriter; @@ -925,7 +926,7 @@ public void writeGridLongList(@Nullable GridLongList val) { public void writeMessage(Message msg, MessageWriter writer) { if (msg != null) { if (buf.hasRemaining()) - nestedWrite(writer, () -> msgFactory.serializer(msg.directType()).writeTo(msg, writer)); + nestedWrite(writer, () -> MessageSerializer.writeTo(msgFactory, msg, writer)); else lastFinished = false; } @@ -1571,7 +1572,7 @@ public T readMessage(MessageReader reader) { try { reader.beforeNestedRead(); - lastFinished = msgFactory.serializer(msg.directType()).readFrom(msg, reader); + lastFinished = MessageSerializer.readFrom(msgFactory, msg, reader); } finally { reader.afterNestedRead(lastFinished); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java index faf416dfdbee7..a8331346de417 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java @@ -85,11 +85,9 @@ public GridDirectParser(IgniteLogger log, MessageFactory msgFactory, GridNioMess boolean finished = false; if (msg != null && buf.hasRemaining()) { - MessageSerializer msgSer = msgFactory.serializer(msg.directType()); - reader.setBuffer(buf); - finished = msgSer.readFrom(msg, reader); + finished = MessageSerializer.readFrom(msgFactory, msg, reader); } if (finished) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java index 797290677db52..69b5c76f45b2c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java @@ -1648,11 +1648,9 @@ private boolean writeToBuffer( finished = ((ClientMessage)msg).writeTo(buf); } else { - MessageSerializer msgSer = messageFactory().serializer(msg.directType()); - writer.setBuffer(buf); - finished = msgSer.writeTo(msg, writer); + finished = MessageSerializer.writeTo(messageFactory(), msg, writer); } span.addTag(SOCKET_WRITE_BYTES, () -> Integer.toString(buf.position() - startPos)); @@ -1849,11 +1847,9 @@ private boolean writeToBuffer(GridSelectorNioSessionImpl ses, ByteBuffer buf, Se finished = ((ClientMessage)msg).writeTo(buf); } else { - MessageSerializer msgSer = msgFactory.serializer(msg.directType()); - writer.setBuffer(buf); - finished = msgSer.writeTo(msg, writer); + finished = MessageSerializer.writeTo(msgFactory, msg, writer); } span.addTag(SOCKET_WRITE_BYTES, () -> Integer.toString(buf.position() - startPos)); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index dfd3efe491c5a..0557ad96eb1ce 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -36,4 +36,30 @@ public interface MessageSerializer { * @return Whether message was fully read. */ public boolean readFrom(M msg, MessageReader reader); + + /** + * Writes the message using the serializer resolved from the factory. + * + * @param factory Message factory. + * @param msg Message instance. + * @param writer Writer. + * @param Message type. + * @return Whether message was fully written. + */ + static boolean writeTo(MessageFactory factory, M msg, MessageWriter writer) { + return ((MessageSerializer)factory.serializer(msg.directType())).writeTo(msg, writer); + } + + /** + * Reads the message using the serializer resolved from the factory. + * + * @param factory Message factory. + * @param msg Message instance. + * @param reader Reader. + * @param Message type. + * @return Whether message was fully read. + */ + static boolean readFrom(MessageFactory factory, M msg, MessageReader reader) { + return ((MessageSerializer)factory.serializer(msg.directType())).readFrom(msg, reader); + } } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java index 7a609d2f7ebdf..3483ab3947f58 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java @@ -30,13 +30,13 @@ import org.apache.ignite.internal.util.nio.ssl.GridSslMeta; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageFactory; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageWriter; import org.apache.ignite.spi.IgniteSpiContext; import org.apache.ignite.spi.communication.tcp.messages.HandshakeMessage; import org.apache.ignite.spi.communication.tcp.messages.NodeIdMessage; import org.apache.ignite.spi.communication.tcp.messages.RecoveryLastReceivedMessage; -import org.apache.ignite.spi.communication.tcp.messages.RecoveryLastReceivedMessageSerializer; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.plugin.extensions.communication.Message.DIRECT_TYPE_SIZE; @@ -172,7 +172,7 @@ private abstract static class BlockingTransport { NodeIdMessage nodeIdMsg = new NodeIdMessage(); reader.setBuffer(buf); - msgFactory.serializer(nodeIdMsg.directType()).readFrom(nodeIdMsg, reader); + MessageSerializer.readFrom(msgFactory, nodeIdMsg, reader); reader.reset(); return nodeIdMsg.nodeId(); @@ -191,7 +191,7 @@ void sendHandshake(HandshakeMessage msg) throws IgniteCheckedException { writer.setBuffer(buf); - msgFactory.serializer(msg.directType()).writeTo(msg, writer); + MessageSerializer.writeTo(msgFactory, msg, writer); buf.flip(); @@ -210,8 +210,6 @@ long receiveAcknowledge() throws IgniteCheckedException { boolean fininshed = false; RecoveryLastReceivedMessage msg = new RecoveryLastReceivedMessage(); - RecoveryLastReceivedMessageSerializer msgSer = - (RecoveryLastReceivedMessageSerializer)msgFactory.serializer(msg.directType()); short msgType = 0; int readPos = 0; @@ -243,7 +241,7 @@ long receiveAcknowledge() throws IgniteCheckedException { reader.setBuffer(buf); - fininshed = msgSer.readFrom(msg, reader); + fininshed = MessageSerializer.readFrom(msgFactory, msg, reader); readPos = buf.position(); } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java index 40c85da736d19..75b3886989a50 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java @@ -169,8 +169,6 @@ T readMessage() throws IgniteCheckedException, IOException { msgReader.reset(); msgReader.setBuffer(msgBuf); - MessageSerializer msgSer = spi.messageFactory().serializer(msg.directType()); - boolean finished; do { @@ -183,7 +181,7 @@ T readMessage() throws IgniteCheckedException, IOException { msgBuf.limit(read); - finished = msgSer.readFrom(msg, msgReader); + finished = MessageSerializer.readFrom(spi.messageFactory(), msg, msgReader); // Server Discovery only sends next message to next Server upon receiving a receipt for the previous one. // This behaviour guarantees that we never read a next message from the buffer right after the end of @@ -243,8 +241,6 @@ public Socket socket() { * @throws IOException If serialization fails. */ void serializeMessage(Message m, OutputStream out) throws IOException, IgniteCheckedException { - MessageSerializer msgSer = spi.messageFactory().serializer(m.directType()); - MessageMarshaller.prepareMarshal(spi.messageFactory(), m, ((IgniteEx)spi.ignite()).context(), null); msgWriter.reset(); @@ -256,7 +252,7 @@ void serializeMessage(Message m, OutputStream out) throws IOException, IgniteChe // Should be cleared before first operation. msgBuf.clear(); - finished = msgSer.writeTo(m, msgWriter); + finished = MessageSerializer.writeTo(spi.messageFactory(), m, msgWriter); out.write(msgBuf.array(), 0, msgBuf.position()); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java new file mode 100644 index 0000000000000..d8c1dc78c90a9 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.codegen; + +import com.tngtech.archunit.base.DescribedPredicate; +import com.tngtech.archunit.core.domain.JavaClasses; +import com.tngtech.archunit.core.domain.JavaMethodCall; +import com.tngtech.archunit.core.domain.JavaModifier; +import com.tngtech.archunit.core.domain.properties.HasOwner; +import com.tngtech.archunit.core.importer.ClassFileImporter; +import com.tngtech.archunit.core.importer.ImportOption; +import com.tngtech.archunit.lang.ArchRule; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.junit.BeforeClass; +import org.junit.Test; + +import static com.tngtech.archunit.core.domain.JavaCall.Predicates.target; +import static com.tngtech.archunit.core.domain.JavaClass.Predicates.assignableTo; +import static com.tngtech.archunit.core.domain.properties.HasName.Predicates.nameMatching; +import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; + +/** + * Verifies that instance methods of {@link MessageSerializer} and {@link MessageMarshaller} are only + * called from classes that implement these interfaces (i.e. generated serializers/marshallers and their + * hand-written wrappers). All other code must use the static convenience methods: + *

    + *
  • {@link MessageSerializer#writeTo(org.apache.ignite.plugin.extensions.communication.MessageFactory, + * org.apache.ignite.plugin.extensions.communication.Message, + * org.apache.ignite.plugin.extensions.communication.MessageWriter)}
  • + *
  • {@link MessageSerializer#readFrom(org.apache.ignite.plugin.extensions.communication.MessageFactory, + * org.apache.ignite.plugin.extensions.communication.Message, + * org.apache.ignite.plugin.extensions.communication.MessageReader)}
  • + *
  • {@link MessageMarshaller#prepareMarshal}
  • + *
  • {@link MessageMarshaller#finishUnmarshal}
  • + *
+ */ +public class MessageSerializationArchitectureTest { + /** Matches method calls that resolve to a non-static (instance) method. */ + private static final DescribedPredicate TO_INSTANCE_METHOD = + new DescribedPredicate<>("to instance method") { + @Override public boolean test(JavaMethodCall call) { + return call.getTarget().resolveMember() + .map(m -> !m.getModifiers().contains(JavaModifier.STATIC)) + .orElse(false); + } + }; + + /** Classes under analysis: all production + test sources on the classpath, excluding JARs. */ + private static JavaClasses classes; + + /** */ + @BeforeClass + public static void importClasses() { + classes = new ClassFileImporter() + .withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_JARS) + .importPackages("org.apache.ignite"); + } + + /** + * Instance methods of {@link MessageSerializer} ({@code writeTo}, {@code readFrom}) must only be + * called from within classes that themselves implement {@link MessageSerializer} — i.e. generated + * serializers and hand-written wrappers that delegate to the underlying serializer. + * + * Everyone else must use + * {@link MessageSerializer#writeTo(org.apache.ignite.plugin.extensions.communication.MessageFactory, + * org.apache.ignite.plugin.extensions.communication.Message, + * org.apache.ignite.plugin.extensions.communication.MessageWriter)} and + * {@link MessageSerializer#readFrom(org.apache.ignite.plugin.extensions.communication.MessageFactory, + * org.apache.ignite.plugin.extensions.communication.Message, + * org.apache.ignite.plugin.extensions.communication.MessageReader)}. + */ + @Test + public void serializerInstanceMethodsOnlyCalledFromImplementations() { + ArchRule rule = noClasses() + .that() + // Exclude MessageSerializer itself and all its implementations (generated + wrappers). + .areNotAssignableTo(MessageSerializer.class) + .should() + .callMethodWhere( + TO_INSTANCE_METHOD + .and(target(nameMatching("writeTo|readFrom"))) + .and(target(HasOwner.Predicates.With.owner(assignableTo(MessageSerializer.class)))) + ) + .because("Use static MessageSerializer.writeTo(factory, msg, writer) and " + + "MessageSerializer.readFrom(factory, msg, reader) instead of calling instance methods directly."); + + rule.check(classes); + } + + /** + * Instance methods of {@link MessageMarshaller} ({@code prepareMarshal}, {@code finishUnmarshal}) must + * only be called from within classes that themselves implement {@link MessageMarshaller} — i.e. generated + * marshallers and hand-written wrappers that delegate to the underlying marshaller. + * + * Everyone else must use the static + * {@link MessageMarshaller#prepareMarshal} and {@link MessageMarshaller#finishUnmarshal} methods. + */ + @Test + public void marshallerInstanceMethodsOnlyCalledFromImplementations() { + ArchRule rule = noClasses() + .that() + // Exclude MessageMarshaller itself and all its implementations (generated + wrappers). + .areNotAssignableTo(MessageMarshaller.class) + .should() + .callMethodWhere( + TO_INSTANCE_METHOD + .and(target(nameMatching("prepareMarshal|finishUnmarshal"))) + .and(target(HasOwner.Predicates.With.owner(assignableTo(MessageMarshaller.class)))) + ) + .because("Use static MessageMarshaller.prepareMarshal(factory, ...) and " + + "MessageMarshaller.finishUnmarshal(factory, ...) instead of calling instance methods directly."); + + rule.check(classes); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/AbstractMessageSerializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/AbstractMessageSerializationTest.java index 82d3d96ba0f16..e7b63930bd41c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/AbstractMessageSerializationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/AbstractMessageSerializationTest.java @@ -36,6 +36,7 @@ import org.apache.ignite.plugin.extensions.communication.MessageArrayType; import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; import org.apache.ignite.plugin.extensions.communication.MessageFactory; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; import org.apache.ignite.plugin.extensions.communication.MessageMapType; import org.apache.ignite.plugin.extensions.communication.MessageReader; @@ -103,13 +104,13 @@ private void checkSerializationAndDeserializationConsistency( initializeMessage(msg); - while (!msgFactory.serializer(msgType).writeTo(msg, writer)) { + while (!MessageSerializer.writeTo(msgFactory, msg, writer)) { // No-op. } msg = msgFactory.create(msgType); - while (!msgFactory.serializer(msgType).readFrom(msg, reader)) { + while (!MessageSerializer.readFrom(msgFactory, msg, reader)) { // No-op. } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsCacheSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsCacheSizeTest.java index 77616ae9e8d2b..cb91e85a346f7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsCacheSizeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsCacheSizeTest.java @@ -106,8 +106,6 @@ public void testCacheSize() throws Exception { msg.addServerCacheMetrics(srvrId, cacheMetrics); MessageFactory msgFactory = ((TcpDiscoverySpi)grid(0).context().discovery().getInjectedDiscoverySpi()).messageFactory(); - MessageSerializer msgSerializer = msgFactory.serializer(msg.directType()); - // First time we write initial message type which is not read by the reader because the message type is known. // We have to skip this header at the further message reading. AtomicInteger initHdrSize = new AtomicInteger(); @@ -123,7 +121,7 @@ public void testCacheSize() throws Exception { // 2kb should be enough for an empty message even if it is a relatively large metrics message. msgWritter.setBuffer(ByteBuffer.allocate(2048)); - assertTrue(msgSerializer.writeTo(msg, msgWritter)); + assertTrue(MessageSerializer.writeTo(msgFactory, msg, msgWritter)); assertTrue(msgWritter.getBuffer().hasRemaining()); @@ -135,7 +133,7 @@ public void testCacheSize() throws Exception { TcpDiscoveryMetricsUpdateMessage msg2 = new TcpDiscoveryMetricsUpdateMessage(); - assertTrue(msgSerializer.readFrom(msg2, msgReader)); + assertTrue(MessageSerializer.readFrom(msgFactory, msg2, msgReader)); Map cacheMetrics2 = msg2.serversFullMetricsMessages().values().iterator().next() .cachesMetricsMessages(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryImmutableEntryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryImmutableEntryTest.java index 285ddb2362bb2..141ed3a925cb3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryImmutableEntryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryImmutableEntryTest.java @@ -39,6 +39,7 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Test; @@ -155,14 +156,13 @@ public void testCacheContinuousQueryEntrySerialization() { ByteBuffer buf = ByteBuffer.allocate(4096); DirectMessageWriter writer = new DirectMessageWriter(msgFactory); - var serializer = msgFactory.serializer(e0.directType()); - assertNotNull("Serializer not found for message type " + e0.directType(), serializer); + assertNotNull("Serializer not found for message type " + e0.directType(), msgFactory.serializer(e0.directType())); writer.setBuffer(buf); // Skip write class header. writer.onHeaderWritten(); - serializer.writeTo(e0, writer); + MessageSerializer.writeTo(msgFactory, e0, writer); CacheContinuousQueryEntry e1 = new CacheContinuousQueryEntry(); @@ -170,7 +170,7 @@ public void testCacheContinuousQueryEntrySerialization() { reader.setBuffer(ByteBuffer.wrap(buf.array())); - serializer.readFrom(e1, reader); + MessageSerializer.readFrom(msgFactory, e1, reader); assertEquals(e0.cacheId(), e1.cacheId()); assertEquals(e0.eventType(), e1.eventType()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java index f5f1dad89989d..aaa36fc73f51c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java @@ -715,11 +715,9 @@ private static class StaleTopologyCommunicationSpi extends TcpCommunicationSpi { ioMsg.skipOnTimeout() ); - MessageMarshaller msgMarshaller = ((IgniteEx)ignite).context().messageFactory().marshaller(msg.directType()); - try { - if (msgMarshaller != null) - msgMarshaller.prepareMarshal(msg, ((IgniteEx)ignite).context(), null); + MessageMarshaller.prepareMarshal( + ((IgniteEx)ignite).context().messageFactory(), msg, ((IgniteEx)ignite).context(), null); } catch (IgniteCheckedException e) { throw new RuntimeException(e); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index 1d451125d4385..e96b179b5de47 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -238,8 +238,8 @@ private byte[] serializedMessage() throws IgniteCheckedException { writer.setBuffer(buf); ExploitMessage msg = new ExploitMessage(new Exploit()); - - marshaller.prepareMarshal(msg, grid().context(), null); + + MessageMarshaller.prepareMarshal(msgFactory, msg, grid().context(), null); writer.writeMessage(msg); diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java index 40140614e7bf5..aa3327e4d1c18 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java @@ -38,6 +38,7 @@ import org.apache.ignite.internal.TransactionsMXBeanImplTest; import org.apache.ignite.internal.codegen.IgniteDataTransferObjectProcessorTest; import org.apache.ignite.internal.codegen.MessageProcessorTest; +import org.apache.ignite.internal.codegen.MessageSerializationArchitectureTest; import org.apache.ignite.internal.managers.communication.CompressedMessageTest; import org.apache.ignite.internal.managers.communication.DefaultEnumMapperTest; import org.apache.ignite.internal.managers.communication.ErrorMessageSelfTest; @@ -150,6 +151,7 @@ ClientSessionOutboundQueueLimitTest.class, MessageProcessorTest.class, + MessageSerializationArchitectureTest.class, ErrorMessageSelfTest.class, DefaultEnumMapperTest.class, IgniteDataTransferObjectProcessorTest.class, diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index 3f7c7a1a4575f..c06a3480836b5 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -91,8 +91,6 @@ private void serializeMessage(Message m, OutputStream out) throws IOException { msgWriter.setBuffer(msgBuf); - MessageSerializer msgSer = msgFactory.serializer(m.directType()); - try { MessageMarshaller.prepareMarshal(msgFactory, m, ((IgniteEx)spi.ignite()).context(), null); } @@ -105,7 +103,7 @@ private void serializeMessage(Message m, OutputStream out) throws IOException { do { msgBuf.clear(); - finished = msgSer.writeTo(m, msgWriter); + finished = MessageSerializer.writeTo(msgFactory, m, msgWriter); out.write(msgBuf.array(), 0, msgBuf.position()); } @@ -120,7 +118,6 @@ private T deserializeMessage(InputStream in) throws IOExcept msgReader.setBuffer(msgBuf); Message msg = msgFactory.create(makeMessageType((byte)in.read(), (byte)in.read())); - MessageSerializer msgSer = msgFactory.serializer(msg.directType()); boolean finished; @@ -132,7 +129,7 @@ private T deserializeMessage(InputStream in) throws IOExcept msgBuf.rewind(); } - finished = msgSer.readFrom(msg, msgReader); + finished = MessageSerializer.readFrom(msgFactory, msg, msgReader); assert read != -1 || finished : "Stream closed before message was fully read."; From fbe4df71bd59229636a628e3af6fc18999e855a6 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 18:49:05 +0300 Subject: [PATCH 141/215] WIP --- .../communication/CompressedMessage.java | 4 +- .../CompressedMessageMarshaller.java | 41 ------------------- 2 files changed, 2 insertions(+), 43 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageMarshaller.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessage.java index e3e46c43ff35c..bf4b57d901893 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessage.java @@ -27,14 +27,14 @@ import java.util.zip.InflaterInputStream; import org.apache.ignite.IgniteException; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage; /** * Internal message used when transmitting fields annotated with @Compress over the network. *

* WARNING: CompressedMessage is not intended for explicit use in messages. */ -public class CompressedMessage implements Message { +public class CompressedMessage implements NonMarshallableMessage { /** Chunk size. */ static final int CHUNK_SIZE = 10 * 1024; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageMarshaller.java deleted file mode 100644 index 2691179aa6b49..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CompressedMessageMarshaller.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.managers.communication; - -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; - -/** Message marshaller for compressed message. CompressedMessage has no marshallable fields. */ -public class CompressedMessageMarshaller implements MessageMarshaller { - /** {@inheritDoc} */ - @Override public void prepareMarshal(CompressedMessage msg, GridKernalContext kctx, - GridCacheContext nested) throws IgniteCheckedException { - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(CompressedMessage msg, GridKernalContext kctx, - GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(CompressedMessage msg, GridKernalContext kctx) - throws IgniteCheckedException { - } -} From 676675559b926576a7a105c88e7ee6c3484c4ba7 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 18:53:30 +0300 Subject: [PATCH 142/215] WIP --- .../main/java/org/apache/ignite/internal/IgniteKernal.java | 4 +++- .../ignite/internal/processors/cache/GridCacheReturn.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index 8d834e96f84b5..57d7072a6d46d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -221,6 +221,7 @@ import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import static java.util.Collections.singleton; import static java.util.Optional.ofNullable; @@ -1309,7 +1310,8 @@ else if (e instanceof IgniteCheckedException) } /** */ - public void initMessageFactory() throws IgniteCheckedException { + @TestOnly + void initMessageFactory() throws IgniteCheckedException { MessageFactoryProvider[] msgs = ctx.plugins().extensions(MessageFactoryProvider.class); List compMsgs = new ArrayList<>(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index 8946f2c38f6f0..3770aacc77e2c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -354,6 +354,7 @@ public void marshalResult(GridCacheContext ctx) { /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + // Mark the message as local — it has arrived at the target node. loc = true; } From d471c0c87d4c542129e7ab8bda2f287257b8034e Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 18:58:15 +0300 Subject: [PATCH 143/215] WIP --- .../src/main/java/org/apache/ignite/internal/IgniteKernal.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index 57d7072a6d46d..f4d4bb9aba301 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -1311,7 +1311,7 @@ else if (e instanceof IgniteCheckedException) /** */ @TestOnly - void initMessageFactory() throws IgniteCheckedException { + public void initMessageFactory() throws IgniteCheckedException { MessageFactoryProvider[] msgs = ctx.plugins().extensions(MessageFactoryProvider.class); List compMsgs = new ArrayList<>(); From 12321d450624449a8cd737aea310f6f1d5a37627 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 19:20:42 +0300 Subject: [PATCH 144/215] WIP --- .../internal/processors/cache/transactions/IgniteTxManager.java | 1 - .../ignite/internal/processors/cluster/ClusterProcessor.java | 1 - 2 files changed, 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 6da323fb77593..bf891be4cc4ac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -3447,7 +3447,6 @@ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) { return; try { - MessageMarshaller.finishUnmarshal(cctx.kernalContext().messageFactory(), cacheMsg, cctx.kernalContext()); MessageMarshaller.finishUnmarshal( cctx.kernalContext().messageFactory(), cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java index 4595ee5fdeb9c..22d635c520282 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java @@ -384,7 +384,6 @@ public void initDiagnosticListeners() throws IgniteCheckedException { IgniteDiagnosticRequest infoReq = (IgniteDiagnosticRequest)msg; try { - MessageMarshaller.finishUnmarshal(ctx.messageFactory(), infoReq, ctx); MessageMarshaller.finishUnmarshal(ctx.messageFactory(), infoReq, ctx, null, U.gridClassLoader()); } catch (IgniteCheckedException e) { From 9838350494d1a32cf5b539a6601c524cfa5d2049 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 19:27:28 +0300 Subject: [PATCH 145/215] WIP --- .../spi/communication/tcp/internal/TcpHandshakeExecutor.java | 2 +- .../internal/managers/AbstractMessageSerializationTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java index 3483ab3947f58..e7c8524807e60 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java @@ -30,8 +30,8 @@ import org.apache.ignite.internal.util.nio.ssl.GridSslMeta; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageFactory; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageWriter; import org.apache.ignite.spi.IgniteSpiContext; import org.apache.ignite.spi.communication.tcp.messages.HandshakeMessage; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/AbstractMessageSerializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/AbstractMessageSerializationTest.java index e7b63930bd41c..5ffa58606d71d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/AbstractMessageSerializationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/AbstractMessageSerializationTest.java @@ -36,10 +36,10 @@ import org.apache.ignite.plugin.extensions.communication.MessageArrayType; import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; import org.apache.ignite.plugin.extensions.communication.MessageFactory; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; import org.apache.ignite.plugin.extensions.communication.MessageMapType; import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageWriter; import org.apache.ignite.spi.communication.tcp.messages.HandshakeMessage; import org.jetbrains.annotations.Nullable; From fef9f9e259c27bd03b2c3d11aff487b09be39ea0 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 19:28:12 +0300 Subject: [PATCH 146/215] WIP --- .../ignite/internal/direct/stream/DirectByteBufferStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java index c2c29b1a09d10..f5583b2244827 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java @@ -49,8 +49,8 @@ import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageMapType; -import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.MessageType; import org.apache.ignite.plugin.extensions.communication.MessageWriter; import org.jetbrains.annotations.Nullable; From 616af67ee6f6896d77b215f602b981f11bbe77b4 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 19:49:49 +0300 Subject: [PATCH 147/215] WIP --- .../internal/MessageMarshallerGenerator.java | 60 +++++++++++++++---- .../codegen/ChildMessageMarshaller.java | 2 - ...stomMapperEnumFieldsMessageMarshaller.java | 2 - ...aultMapperEnumFieldsMessageMarshaller.java | 2 - .../TestMarshallableMessageMarshaller.java | 3 - 5 files changed, 47 insertions(+), 22 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index ec932767d8e88..ae8f68881b0c9 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -149,10 +149,14 @@ private void generateMarshallMethods(List orderedFields) { indent++; - addCtxResolution(); + int prepareBodyStart = marshall.size(); + + if (needsCtx(orderedFields)) + marshall.add(ctxResolutionLine()); if (marshallableMessage()) { - marshall.add(EMPTY); + if (marshall.size() > prepareBodyStart) + marshall.add(EMPTY); marshall.add(indentedLine("msg.prepareMarshal(marshaller);")); } @@ -186,7 +190,10 @@ private void generateUnmarshallMethods(List orderedFields) { indent++; - addCtxResolution(); + int finish5BodyStart = marshall.size(); + + if (needsCtx(orderedFields)) + marshall.add(ctxResolutionLine()); for (VariableElement field : orderedFields) { List unmarshalled = marshall(field.asType(), fieldAccessor(field), true, false); @@ -200,7 +207,8 @@ private void generateUnmarshallMethods(List orderedFields) { } if (isCacheMarshallableMessage(type)) { - marshall.add(EMPTY); + if (marshall.size() > finish5BodyStart) + marshall.add(EMPTY); marshall.add(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);")); } @@ -247,18 +255,44 @@ private void generateUnmarshallMethods(List orderedFields) { marshall.add(indentedLine("}")); } - /** Adds a {@code GridCacheContext ctx} resolution line for the current message type. */ - private void addCtxResolution() { + /** Returns the {@code GridCacheContext ctx} resolution line for the current message type. */ + private String ctxResolutionLine() { if (isCacheIdAwareMessage(type)) - marshall.add( - indentedLine("GridCacheContext ctx = nested == null ? " + - "kctx.cache().context().cacheContext(msg.cacheId()) : nested;")); + return indentedLine("GridCacheContext ctx = nested == null ? " + + "kctx.cache().context().cacheContext(msg.cacheId()) : nested;"); else if (isCacheGroupIdMessage(type)) - marshall.add( - indentedLine("GridCacheContext ctx = nested == null ? " + - "kctx.cache().context().cacheContext(msg.groupId()) : nested;")); + return indentedLine("GridCacheContext ctx = nested == null ? " + + "kctx.cache().context().cacheContext(msg.groupId()) : nested;"); else - marshall.add(indentedLine("GridCacheContext ctx = nested;")); + return indentedLine("GridCacheContext ctx = nested;"); + } + + /** Returns {@code true} if any field requires {@code ctx} in generated marshal/unmarshal code. */ + private boolean needsCtx(List fields) { + return fields.stream().anyMatch(f -> needsCtxType(f.asType())); + } + + /** */ + private boolean needsCtxType(TypeMirror t) { + if (t.getKind() == TypeKind.ARRAY) + return needsCtxType(((ArrayType)t).getComponentType()); + + if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { + if (isMessage(t) || isCacheObject(t)) + return true; + + if (assignableFrom(erasedType(t), type(java.util.Map.class.getName()))) { + List args = ((DeclaredType)t).getTypeArguments(); + return needsCtxType(args.get(0)) || needsCtxType(args.get(1)); + } + + if (assignableFrom(erasedType(t), type(java.util.Collection.class.getName()))) { + List args = ((DeclaredType)t).getTypeArguments(); + return needsCtxType(args.get(0)); + } + } + + return false; } /** */ diff --git a/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java b/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java index 93cfc03305d22..b86dcbfb5c33c 100644 --- a/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java @@ -37,12 +37,10 @@ public ChildMessageMarshaller() { /** */ @Override public void prepareMarshal(ChildMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; } /** */ @Override public void finishUnmarshal(ChildMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - GridCacheContext ctx = nested; } /** */ diff --git a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java index b764f07ba2ccd..4e7b972c1c9d7 100644 --- a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java @@ -37,12 +37,10 @@ public CustomMapperEnumFieldsMessageMarshaller() { /** */ @Override public void prepareMarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; } /** */ @Override public void finishUnmarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - GridCacheContext ctx = nested; } /** */ diff --git a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java index 9f13010907448..563f88502f3a2 100644 --- a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java @@ -37,12 +37,10 @@ public DefaultMapperEnumFieldsMessageMarshaller() { /** */ @Override public void prepareMarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; } /** */ @Override public void finishUnmarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - GridCacheContext ctx = nested; } /** */ diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java index 131a145ea3ab0..52c75c2d3860e 100644 --- a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java @@ -42,14 +42,11 @@ public TestMarshallableMessageMarshaller(Marshaller marshaller) { /** */ @Override public void prepareMarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; - msg.prepareMarshal(marshaller); } /** */ @Override public void finishUnmarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - GridCacheContext ctx = nested; } /** */ From 70615f4eb1634e08de5101b3351e52e533b6c1df Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 20:07:19 +0300 Subject: [PATCH 148/215] WIP --- .../internal/MessageMarshallerGenerator.java | 58 ++++++++++++------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index ae8f68881b0c9..a703dcad49dd5 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -161,7 +161,7 @@ private void generateMarshallMethods(List orderedFields) { } for (VariableElement field : orderedFields) { - List marshalled = marshall(field.asType(), fieldAccessor(field), false, false); + List marshalled = marshall(field.asType(), fieldAccessor(field), MarshalMode.PREPARE); if (!marshalled.isEmpty()) { if (!marshall.get(marshall.size() - 1).equals(EMPTY)) @@ -196,7 +196,7 @@ private void generateUnmarshallMethods(List orderedFields) { marshall.add(ctxResolutionLine()); for (VariableElement field : orderedFields) { - List unmarshalled = marshall(field.asType(), fieldAccessor(field), true, false); + List unmarshalled = marshall(field.asType(), fieldAccessor(field), MarshalMode.FINISH_CACHE); if (!unmarshalled.isEmpty()) { if (!marshall.get(marshall.size() - 1).equals(EMPTY)) @@ -231,7 +231,7 @@ private void generateUnmarshallMethods(List orderedFields) { boolean first = true; for (VariableElement field : orderedFields) { - List unmarshalled = marshall(field.asType(), fieldAccessor(field), true, true); + List unmarshalled = marshall(field.asType(), fieldAccessor(field), MarshalMode.FINISH_BASE); if (!unmarshalled.isEmpty()) { if (!first) @@ -295,8 +295,24 @@ private boolean needsCtxType(TypeMirror t) { return false; } + /** + * Describes which marshalling operation to generate code for. + * + *

    + *
  • {@link #PREPARE} — {@code prepareMarshal}: marshal CacheObjects and recurse into nested Messages.
  • + *
  • {@link #FINISH_BASE} — {@code finishUnmarshal(3-arg)}: lightweight unmarshal; recurses into nested + * Messages only, CacheObject fields are skipped (no cache context available).
  • + *
  • {@link #FINISH_CACHE} — {@code finishUnmarshal(5-arg)}: unmarshal with full cache context and class loader.
  • + *
+ */ + private enum MarshalMode { + PREPARE, + FINISH_BASE, + FINISH_CACHE + } + /** */ - private List marshall(TypeMirror t, String accessor, boolean unmarshall, boolean cache) { + private List marshall(TypeMirror t, String accessor, MarshalMode mode) { if (t.getKind() == TypeKind.ARRAY) { TypeMirror comp = ((ArrayType)t).getComponentType(); @@ -315,7 +331,7 @@ private List marshall(TypeMirror t, String accessor, boolean unmarshall, indent++; - List res = marshall(comp, el, unmarshall, cache); + List res = marshall(comp, el, mode); code.addAll(res); @@ -341,19 +357,19 @@ else if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { indent++; - if (!unmarshall) - code.add(indentedLine( - "MessageMarshaller.prepareMarshal(kctx.messageFactory(), %s, kctx, ctx);", - accessor)); - else { - if (cache) + switch (mode) { + case PREPARE: code.add(indentedLine( - "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx);", - accessor)); - else + "MessageMarshaller.prepareMarshal(kctx.messageFactory(), %s, kctx, ctx);", accessor)); + break; + case FINISH_BASE: + code.add(indentedLine( + "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx);", accessor)); + break; + case FINISH_CACHE: code.add(indentedLine( - "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx, ctx, clsLdr);", - accessor)); + "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx, ctx, clsLdr);", accessor)); + break; } indent--; @@ -361,7 +377,7 @@ else if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { return code; } else if (isCacheObject(t)) { - if (cache && unmarshall) + if (mode == MarshalMode.FINISH_BASE) return java.util.Collections.emptyList(); List code = new ArrayList<>(); @@ -370,7 +386,7 @@ else if (isCacheObject(t)) { indent++; - if (!unmarshall) + if (mode == MarshalMode.PREPARE) code.add(indentedLine("%s.prepareMarshal(ctx.cacheObjectContext());", accessor)); else code.add(indentedLine("%s.finishUnmarshal(ctx.cacheObjectContext(), clsLdr);", accessor)); @@ -394,8 +410,8 @@ else if (assignableFrom(erasedType(t), type(java.util.Map.class.getName()))) { String el = "e" + indent; indent++; - List keyRes = marshall(keyType, el, unmarshall, cache); - List valRes = marshall(valType, el, unmarshall, cache); + List keyRes = marshall(keyType, el, mode); + List valRes = marshall(valType, el, mode); indent--; if (!keyRes.isEmpty() && (keyType.getKind() == TypeKind.DECLARED || keyType.getKind() == TypeKind.TYPEVAR)) { @@ -466,7 +482,7 @@ else if (assignableFrom(erasedType(t), type(java.util.Collection.class.getName() indent++; - List res = marshall(arg, el, unmarshall, cache); + List res = marshall(arg, el, mode); code.addAll(res); From fb2e17f6add8e4623da51fd644fb50cd8470de27 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 19 Jun 2026 20:18:18 +0300 Subject: [PATCH 149/215] WIP --- .../internal/MessageMarshallerGenerator.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index a703dcad49dd5..73595a38246a4 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -295,19 +295,15 @@ private boolean needsCtxType(TypeMirror t) { return false; } - /** - * Describes which marshalling operation to generate code for. - * - *
    - *
  • {@link #PREPARE} — {@code prepareMarshal}: marshal CacheObjects and recurse into nested Messages.
  • - *
  • {@link #FINISH_BASE} — {@code finishUnmarshal(3-arg)}: lightweight unmarshal; recurses into nested - * Messages only, CacheObject fields are skipped (no cache context available).
  • - *
  • {@link #FINISH_CACHE} — {@code finishUnmarshal(5-arg)}: unmarshal with full cache context and class loader.
  • - *
- */ + /** */ private enum MarshalMode { + /** Marshal. */ PREPARE, + + /** Lightweight unmarshal. Messages only, CacheObject fields are skipped (no cache context available). */ FINISH_BASE, + + /** Unmarshal with full cache context and class loader. */ FINISH_CACHE } From c95163d454d6f068e556624ead3a7c43a5b26202 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 23 Jun 2026 00:00:19 +0300 Subject: [PATCH 150/215] WIP --- .../internal/MessageMarshallerGenerator.java | 298 +++++++++--------- 1 file changed, 145 insertions(+), 153 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 73595a38246a4..590656c70baa9 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -299,10 +299,10 @@ private boolean needsCtxType(TypeMirror t) { private enum MarshalMode { /** Marshal. */ PREPARE, - + /** Lightweight unmarshal. Messages only, CacheObject fields are skipped (no cache context available). */ FINISH_BASE, - + /** Unmarshal with full cache context and class loader. */ FINISH_CACHE } @@ -311,194 +311,186 @@ private enum MarshalMode { private List marshall(TypeMirror t, String accessor, MarshalMode mode) { if (t.getKind() == TypeKind.ARRAY) { TypeMirror comp = ((ArrayType)t).getComponentType(); - - if (comp.getKind() == TypeKind.DECLARED) { - List code = new ArrayList<>(); - - imports.add(((QualifiedNameable)((DeclaredType)comp).asElement()).getQualifiedName().toString()); - - code.add(indentedLine("if (%s != null) {", accessor)); - - indent++; - - String el = "e" + indent; - - code.add(indentedLine("for (%s %s : %s) {", ((DeclaredType)comp).asElement().getSimpleName().toString(), el, accessor)); - - indent++; - - List res = marshall(comp, el, mode); - - code.addAll(res); - - indent--; - - code.add(indentedLine("}")); - - indent--; - - code.add(indentedLine("}")); - - if (res.isEmpty()) - return java.util.Collections.emptyList(); - else - return code; - } + + return comp.getKind() == TypeKind.DECLARED ? marshallArray(comp, accessor, mode) : java.util.Collections.emptyList(); } - else if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { - if (isMessage(t)) { - List code = new ArrayList<>(); - - code.add(indentedLine("if (%s != null)", accessor)); - - indent++; - - switch (mode) { - case PREPARE: - code.add(indentedLine( - "MessageMarshaller.prepareMarshal(kctx.messageFactory(), %s, kctx, ctx);", accessor)); - break; - case FINISH_BASE: - code.add(indentedLine( - "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx);", accessor)); - break; - case FINISH_CACHE: - code.add(indentedLine( - "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx, ctx, clsLdr);", accessor)); - break; - } - - indent--; - - return code; - } - else if (isCacheObject(t)) { - if (mode == MarshalMode.FINISH_BASE) - return java.util.Collections.emptyList(); - - List code = new ArrayList<>(); - - code.add(indentedLine("if (%s != null && ctx != null)", accessor)); - - indent++; - if (mode == MarshalMode.PREPARE) - code.add(indentedLine("%s.prepareMarshal(ctx.cacheObjectContext());", accessor)); - else - code.add(indentedLine("%s.finishUnmarshal(ctx.cacheObjectContext(), clsLdr);", accessor)); - - indent--; - - return code; - } - else if (assignableFrom(erasedType(t), type(java.util.Map.class.getName()))) { - List args = ((DeclaredType)t).getTypeArguments(); - - TypeMirror keyType = args.get(0); - TypeMirror valType = args.get(1); - - List code = new ArrayList<>(); - - code.add(indentedLine("if (%s != null) {", accessor)); - - indent++; + if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { + if (isMessage(t)) + return marshallMessage(accessor, mode); + if (isCacheObject(t)) + return marshallCacheObject(accessor, mode); + if (assignableFrom(erasedType(t), type(java.util.Map.class.getName()))) + return marshallMap((DeclaredType)t, accessor, mode); + if (assignableFrom(erasedType(t), type(java.util.Collection.class.getName()))) + return marshallCollection((DeclaredType)t, accessor, mode); + } - String el = "e" + indent; + return java.util.Collections.emptyList(); + } - indent++; - List keyRes = marshall(keyType, el, mode); - List valRes = marshall(valType, el, mode); - indent--; + /** */ + private List marshallMessage(String accessor, MarshalMode mode) { + List code = new ArrayList<>(); - if (!keyRes.isEmpty() && (keyType.getKind() == TypeKind.DECLARED || keyType.getKind() == TypeKind.TYPEVAR)) { - Element elem = element(keyType); + code.add(indentedLine("if (%s != null)", accessor)); - imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); - imports.add("java.util.Collection"); + indent++; - String typeName = elem.getSimpleName().toString(); + switch (mode) { + case PREPARE: + code.add(indentedLine( + "MessageMarshaller.prepareMarshal(kctx.messageFactory(), %s, kctx, ctx);", accessor)); + break; + case FINISH_BASE: + code.add(indentedLine( + "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx);", accessor)); + break; + case FINISH_CACHE: + code.add(indentedLine( + "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx, ctx, clsLdr);", accessor)); + break; + } - code.add(indentedLine("for (%s %s : ((Collection)%s.keySet())) {", typeName, el, typeName, accessor)); + indent--; - indent++; - code.addAll(keyRes); - indent--; + return code; + } - code.add(indentedLine("}")); - } + /** */ + private List marshallCacheObject(String accessor, MarshalMode mode) { + if (mode == MarshalMode.FINISH_BASE) + return java.util.Collections.emptyList(); - if (!valRes.isEmpty() && (valType.getKind() == TypeKind.DECLARED || valType.getKind() == TypeKind.TYPEVAR)) { - Element elem = element(valType); + List code = new ArrayList<>(); - imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); - imports.add("java.util.Collection"); + code.add(indentedLine("if (%s != null && ctx != null)", accessor)); - String typeName = elem.getSimpleName().toString(); + indent++; + + code.add(mode == MarshalMode.PREPARE + ? indentedLine("%s.prepareMarshal(ctx.cacheObjectContext());", accessor) + : indentedLine("%s.finishUnmarshal(ctx.cacheObjectContext(), clsLdr);", accessor)); + + indent--; - code.add(indentedLine("for (%s %s : ((Collection)%s.values())) {", typeName, el, typeName, accessor)); + return code; + } - indent++; - code.addAll(valRes); - indent--; + /** */ + private List marshallArray(TypeMirror comp, String accessor, MarshalMode mode) { + Element elem = ((DeclaredType)comp).asElement(); + + imports.add(((QualifiedNameable)elem).getQualifiedName().toString()); - code.add(indentedLine("}")); - } + indent++; + + List loopCode = forLoop(elem.getSimpleName().toString(), comp, accessor, mode); + + indent--; - indent--; + return wrapNullGuarded(accessor, loopCode); + } - code.add(indentedLine("}")); + /** */ + private List marshallCollection(DeclaredType t, String accessor, MarshalMode mode) { + TypeMirror arg = t.getTypeArguments().get(0); - if (keyRes.isEmpty() && valRes.isEmpty()) - return java.util.Collections.emptyList(); - else - return code; - } - else if (assignableFrom(erasedType(t), type(java.util.Collection.class.getName()))) { - List args = ((DeclaredType)t).getTypeArguments(); + if (arg.getKind() != TypeKind.DECLARED && arg.getKind() != TypeKind.TYPEVAR) + return java.util.Collections.emptyList(); - TypeMirror arg = args.get(0); + Element elem = element(arg); + + imports.add(((QualifiedNameable)elem).getQualifiedName().toString()); + imports.add("java.util.Collection"); - if ((arg.getKind() == TypeKind.DECLARED || arg.getKind() == TypeKind.TYPEVAR)) { - List code = new ArrayList<>(); + String typeName = elem.getSimpleName().toString(); - Element elem = element(arg); + indent++; + + List loopCode = forLoop(typeName, arg, "(Collection)" + accessor, mode); + + indent--; - imports.add(((QualifiedNameable)(elem)).getQualifiedName().toString()); - imports.add("java.util.Collection"); + return wrapNullGuarded(accessor, loopCode); + } - String el = "e" + indent; + /** Iterates {@code keySet()} then {@code values()}, wrapping both loops in a null-guard. */ + private List marshallMap(DeclaredType t, String accessor, MarshalMode mode) { + List args = t.getTypeArguments(); - code.add(indentedLine("if (%s != null) {", accessor)); + indent++; + + List combined = new ArrayList<>(); + for (int i = 0; i < 2; i++) { + TypeMirror elemType = args.get(i); - indent++; + if (elemType.getKind() != TypeKind.DECLARED && elemType.getKind() != TypeKind.TYPEVAR) + continue; - String typeName = elem.getSimpleName().toString(); + Element elem = element(elemType); + + imports.add(((QualifiedNameable)elem).getQualifiedName().toString()); + imports.add("java.util.Collection"); - code.add(indentedLine("for (%s %s : (Collection)%s) {", typeName, el, typeName, accessor)); + String typeName = elem.getSimpleName().toString(); + String collection = i == 0 ? "keySet" : "values"; + String iterable = "((Collection)" + accessor + "." + collection + "())"; - indent++; + combined.addAll(forLoop(typeName, elemType, iterable, mode)); + } + + indent--; - List res = marshall(arg, el, mode); + return wrapNullGuarded(accessor, combined); + } - code.addAll(res); + /** Returns empty if {@code inner} is empty. */ + private List wrapNullGuarded(String nullGuard, List inner) { + if (inner.isEmpty()) + return java.util.Collections.emptyList(); - indent--; + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null) {", nullGuard)); + + indent++; + + code.addAll(inner); + + indent--; + + code.add(indentedLine("}")); - code.add(indentedLine("}")); + return code; + } - indent--; + /** Returns empty if {@code elemType} requires no marshalling. Leaves {@code this.indent} unchanged. */ + private List forLoop(String typeName, TypeMirror elemType, String iterable, MarshalMode mode) { + String el = "e" + (indent + 1); + + indent++; + + List inner = marshall(elemType, el, mode); + + indent--; - code.add(indentedLine("}")); + if (inner.isEmpty()) + return java.util.Collections.emptyList(); - if (res.isEmpty()) - return java.util.Collections.emptyList(); - else - return code; - } - } - } + List code = new ArrayList<>(); + + code.add(indentedLine("for (%s %s : %s) {", typeName, el, iterable)); + + indent++; + + code.addAll(inner); + + indent--; + + code.add(indentedLine("}")); - return java.util.Collections.emptyList(); + return code; } /** */ From 88c3f73de582819b12a7b2ce82441a8903f18e36 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 23 Jun 2026 16:38:50 +0300 Subject: [PATCH 151/215] WIP --- .../internal/MessageMarshallerGenerator.java | 71 ++++++++----------- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 590656c70baa9..3cb25a66db9a8 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -149,28 +149,23 @@ private void generateMarshallMethods(List orderedFields) { indent++; - int prepareBodyStart = marshall.size(); + List body = new ArrayList<>(); if (needsCtx(orderedFields)) - marshall.add(ctxResolutionLine()); + appendBlock(body, List.of(ctxResolutionLine())); - if (marshallableMessage()) { - if (marshall.size() > prepareBodyStart) - marshall.add(EMPTY); - marshall.add(indentedLine("msg.prepareMarshal(marshaller);")); - } + if (marshallableMessage()) + appendBlock(body, List.of(indentedLine("msg.prepareMarshal(marshaller);"))); for (VariableElement field : orderedFields) { List marshalled = marshall(field.asType(), fieldAccessor(field), MarshalMode.PREPARE); - if (!marshalled.isEmpty()) { - if (!marshall.get(marshall.size() - 1).equals(EMPTY)) - marshall.add(EMPTY); - - marshall.addAll(marshalled); - } + if (!marshalled.isEmpty()) + appendBlock(body, marshalled); } + marshall.addAll(body); + indent--; marshall.add(indentedLine("}")); @@ -190,27 +185,22 @@ private void generateUnmarshallMethods(List orderedFields) { indent++; - int finish5BodyStart = marshall.size(); + List body = new ArrayList<>(); if (needsCtx(orderedFields)) - marshall.add(ctxResolutionLine()); + appendBlock(body, List.of(ctxResolutionLine())); for (VariableElement field : orderedFields) { List unmarshalled = marshall(field.asType(), fieldAccessor(field), MarshalMode.FINISH_CACHE); - if (!unmarshalled.isEmpty()) { - if (!marshall.get(marshall.size() - 1).equals(EMPTY)) - marshall.add(EMPTY); - - marshall.addAll(unmarshalled); - } + if (!unmarshalled.isEmpty()) + appendBlock(body, unmarshalled); } - if (isCacheMarshallableMessage(type)) { - if (marshall.size() > finish5BodyStart) - marshall.add(EMPTY); - marshall.add(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);")); - } + if (isCacheMarshallableMessage(type)) + appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);"))); + + marshall.addAll(body); indent--; @@ -228,33 +218,33 @@ private void generateUnmarshallMethods(List orderedFields) { indent++; - boolean first = true; + List baseBody = new ArrayList<>(); for (VariableElement field : orderedFields) { List unmarshalled = marshall(field.asType(), fieldAccessor(field), MarshalMode.FINISH_BASE); - if (!unmarshalled.isEmpty()) { - if (!first) - marshall.add(EMPTY); - - first = false; - - marshall.addAll(unmarshalled); - } + if (!unmarshalled.isEmpty()) + appendBlock(baseBody, unmarshalled); } - if (marshallableMessage() && !isCacheMarshallableMessage(type)) { - if (!first) - marshall.add(EMPTY); + if (marshallableMessage() && !isCacheMarshallableMessage(type)) + appendBlock(baseBody, List.of(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));"))); - marshall.add(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));")); - } + marshall.addAll(baseBody); indent--; marshall.add(indentedLine("}")); } + /** Appends {@code block} to {@code body}, inserting a blank-line separator when {@code body} is non-empty. */ + private static void appendBlock(List body, List block) { + if (!body.isEmpty()) + body.add(EMPTY); + + body.addAll(block); + } + /** Returns the {@code GridCacheContext ctx} resolution line for the current message type. */ private String ctxResolutionLine() { if (isCacheIdAwareMessage(type)) @@ -533,7 +523,6 @@ private boolean marshallableMessage() { return marshallableMsgType != null && env.getTypeUtils().isAssignable(type.asType(), marshallableMsgType); } - /** */ /** */ private Element element(TypeMirror t) { return t.getKind() == TypeKind.DECLARED ? From 63e5f51b699924590f4961336737ec81635a0391 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 01:33:39 +0300 Subject: [PATCH 152/215] WIP --- .../internal/MessageMarshallerGenerator.java | 79 +++++++++++-------- .../org/apache/ignite/internal/NioField.java | 32 ++++++++ .../managers/communication/GridIoManager.java | 31 ++++---- .../managers/communication/GridIoMessage.java | 2 + .../communication/MessageMarshaller.java | 65 +++++---------- .../codegen/MessageProcessorTest.java | 9 +++ .../codegen/NioFieldOnNonMessageMessage.java | 30 +++++++ .../TestCollectionsMessageMarshaller.java | 30 +++---- .../codegen/TestMapMessageMarshaller.java | 71 ++++++++++------- .../test/resources/codegen/TestMessage.java | 5 ++ .../codegen/TestMessageMarshaller.java | 36 +++++---- .../codegen/TestMessageSerializer.java | 16 +++- 12 files changed, 251 insertions(+), 155 deletions(-) create mode 100644 modules/codegen/src/main/java/org/apache/ignite/internal/NioField.java create mode 100644 modules/core/src/test/resources/codegen/NioFieldOnNonMessageMessage.java diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 3cb25a66db9a8..da86df4453f88 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.List; import javax.annotation.processing.ProcessingEnvironment; +import javax.tools.Diagnostic; import javax.lang.model.element.Element; import javax.lang.model.element.QualifiedNameable; import javax.lang.model.element.TypeElement; @@ -173,6 +174,37 @@ private void generateMarshallMethods(List orderedFields) { /** */ private void generateUnmarshallMethods(List orderedFields) { + List nioFields = new ArrayList<>(); + List workerFields = new ArrayList<>(); + + for (VariableElement f : orderedFields) { + if (isNioField(f) && isMessage(f.asType())) + nioFields.add(f); + else { + if (isNioField(f)) + env.getMessager().printMessage(Diagnostic.Kind.ERROR, + "@NioField has no effect on non-Message field '" + f.getSimpleName() + "' of type " + f.asType(), + f); + + workerFields.add(f); + } + } + + imports.add("org.apache.ignite.internal.util.typedef.internal.U"); + + String msgParam = simpleNameWithGeneric(type) + " msg, GridKernalContext kctx"; + + generateFinishUnmarshalMethod("finishUnmarshal", msgParam + ", GridCacheContext nested, ClassLoader clsLdr", + workerFields, MarshalMode.FINISH_CACHE); + + generateFinishUnmarshalMethod("finishUnmarshal", msgParam, workerFields, MarshalMode.FINISH_BASE); + + if (!nioFields.isEmpty()) + generateFinishUnmarshalMethod("finishUnmarshalNio", msgParam, nioFields, MarshalMode.FINISH_BASE); + } + + /** */ + private void generateFinishUnmarshalMethod(String methodName, String params, List fields, MarshalMode mode) { marshall.add(EMPTY); indent = 1; @@ -180,61 +212,38 @@ private void generateUnmarshallMethods(List orderedFields) { marshall.add(indentedLine(METHOD_JAVADOC)); marshall.add(indentedLine( - "@Override public void finishUnmarshal(" + simpleNameWithGeneric(type) + - " msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException {")); + "@Override public void " + methodName + "(" + params + ") throws IgniteCheckedException {")); indent++; List body = new ArrayList<>(); - if (needsCtx(orderedFields)) + if (mode == MarshalMode.FINISH_CACHE && needsCtx(fields)) appendBlock(body, List.of(ctxResolutionLine())); - for (VariableElement field : orderedFields) { - List unmarshalled = marshall(field.asType(), fieldAccessor(field), MarshalMode.FINISH_CACHE); + for (VariableElement field : fields) { + List unmarshalled = marshall(field.asType(), fieldAccessor(field), mode); if (!unmarshalled.isEmpty()) appendBlock(body, unmarshalled); } - if (isCacheMarshallableMessage(type)) + if (mode == MarshalMode.FINISH_CACHE && isCacheMarshallableMessage(type)) appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);"))); + if (mode == MarshalMode.FINISH_BASE && marshallableMessage() && !isCacheMarshallableMessage(type)) + appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));"))); + marshall.addAll(body); indent--; marshall.add(indentedLine("}")); + } - imports.add("org.apache.ignite.internal.util.typedef.internal.U"); - - marshall.add(EMPTY); - - marshall.add(indentedLine(METHOD_JAVADOC)); - - marshall.add(indentedLine( - "@Override public void finishUnmarshal(" + simpleNameWithGeneric(type) + - " msg, GridKernalContext kctx) throws IgniteCheckedException {")); - - indent++; - - List baseBody = new ArrayList<>(); - - for (VariableElement field : orderedFields) { - List unmarshalled = marshall(field.asType(), fieldAccessor(field), MarshalMode.FINISH_BASE); - - if (!unmarshalled.isEmpty()) - appendBlock(baseBody, unmarshalled); - } - - if (marshallableMessage() && !isCacheMarshallableMessage(type)) - appendBlock(baseBody, List.of(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));"))); - - marshall.addAll(baseBody); - - indent--; - - marshall.add(indentedLine("}")); + /** */ + private static boolean isNioField(VariableElement field) { + return field.getAnnotation(NioField.class) != null; } /** Appends {@code block} to {@code body}, inserting a blank-line separator when {@code body} is non-empty. */ diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/NioField.java b/modules/codegen/src/main/java/org/apache/ignite/internal/NioField.java new file mode 100644 index 0000000000000..23ded719e0ddf --- /dev/null +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/NioField.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marks a {@link Message}-typed {@link Order @Order} field whose {@code finishUnmarshal} runs in the NIO/IO thread. + * All other {@link Message}-typed fields have {@code finishUnmarshal} deferred to the worker thread. + */ +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface NioField { +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index f7222c0653f5d..bca951b6fb3c2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1203,7 +1203,7 @@ private void onMessage0(UUID nodeId, GridIoMessage msg, IgniteRunnable msgC) thr assert nodeId != null; assert msg != null; - MessageMarshaller.finishUnmarshal(ctx.messageFactory(), msg, ctx); + MessageMarshaller.finishUnmarshalNio(ctx.messageFactory(), msg, ctx); Lock busyLock0 = busyLock.readLock(); @@ -1312,16 +1312,7 @@ private void processP2PMessage( try { threadProcessingMessage(true, msgC); - GridMessageListener lsnr = listenerGet0(msg.topic()); - - if (lsnr == null) - return; - - Object obj = msg.message(); - - assert obj != null; - - invokeListener(msg.policy(), lsnr, nodeId, obj, secSubjId(msg)); + processRegularMessage0(msg, nodeId); } finally { threadProcessingMessage(false, null); @@ -1455,11 +1446,19 @@ private void processRegularMessage0(GridIoMessage msg, UUID nodeId) { if (lsnr == null) return; - Object obj = msg.message(); + finishUnmarshalPayload(msg); - assert obj != null; + invokeListener(msg.policy(), lsnr, nodeId, msg.message(), secSubjId(msg)); + } - invokeListener(msg.policy(), lsnr, nodeId, obj, secSubjId(msg)); + /** */ + private void finishUnmarshalPayload(GridIoMessage msg) { + try { + MessageMarshaller.finishUnmarshal(ctx.messageFactory(), msg.message(), ctx); + } + catch (IgniteCheckedException e) { + throw new IgniteException("Failed to unmarshal message payload", e); + } } /** @@ -3813,7 +3812,9 @@ void unwind(GridMessageListener lsnr) { MTC.span().addTag(SpanTags.MESSAGE, () -> traceName(fmc.message)); - invokeListener(plc, lsnr, nodeId, mc.message.message(), secSubjId(mc.message)); + finishUnmarshalPayload(mc.message); + + invokeListener(mc.message.policy(), lsnr, nodeId, mc.message.message(), secSubjId(mc.message)); } finally { if (mc.closure != null) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java index 8cc6c106cf22e..280644e6f70ac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java @@ -19,6 +19,7 @@ import org.apache.ignite.internal.ExecutorAwareMessage; import org.apache.ignite.internal.GridTopicMessage; +import org.apache.ignite.internal.NioField; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.processors.datastreamer.DataStreamerRequest; @@ -40,6 +41,7 @@ public class GridIoMessage implements Message, SpanTransport { byte plc; /** Topic message. */ + @NioField @Order(1) @GridToStringInclude GridTopicMessage topicMsg; diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index fdb0a2057621a..36f945d94274a 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -24,43 +24,32 @@ /** Marshalling logic for cache-object fields in a {@link Message}. */ public interface MessageMarshaller { - /** - * Marshals cache-object fields on the user thread. - * - * @param msg Message instance. - * @param kctx Kernal context. - * @param nested Nested cache context, or {@code null}. - */ + /** Marshals cache-object fields on the user thread. */ public void prepareMarshal(M msg, GridKernalContext kctx, @Nullable GridCacheContext nested) throws IgniteCheckedException; - /** - * Unmarshals cache-object fields including nested-context resolution. - * - * @param msg Message instance. - * @param kctx Kernal context. - * @param nested Nested cache context, or {@code null}. - * @param clsLdr Class loader. - */ + /** Unmarshals cache-object fields with full cache context and class loader. */ public void finishUnmarshal(M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException; - /** - * Unmarshals message fields without a nested cache context (cache-free path). - * - * @param msg Message instance. - * @param kctx Kernal context. - */ + /** Unmarshals message fields without a cache context. */ public void finishUnmarshal(M msg, GridKernalContext kctx) throws IgniteCheckedException; - /** Null-safe {@code prepareMarshal} — skips when no marshaller is registered (e.g. NonMarshallableMessage). - * - * @param factory Message factory. - * @param msg Message. - * @param kctx Kernal context. - * @param nested Nested context. - * @param Message type. - * */ + /** Unmarshals only {@code @NioField}-annotated fields in the NIO/IO thread. No-op by default. */ + default void finishUnmarshalNio(M msg, GridKernalContext kctx) throws IgniteCheckedException { + } + + /** Null-safe {@code finishUnmarshalNio} — skips when no marshaller is registered. */ + static void finishUnmarshalNio( + MessageFactory factory, M msg, GridKernalContext kctx) + throws IgniteCheckedException { + MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); + + if (m != null) + m.finishUnmarshalNio(msg, kctx); + } + + /** Null-safe {@code prepareMarshal} — skips when no marshaller is registered. */ static void prepareMarshal( MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested) throws IgniteCheckedException { @@ -70,15 +59,7 @@ static void prepareMarshal( m.prepareMarshal(msg, kctx, nested); } - /** Null-safe {@code finishUnmarshal} (with nested context) — skips when no marshaller is registered. - * - * @param factory Message Factory. - * @param msg Message. - * @param kctx Kernal context. - * @param nested Nested context. - * @param clsLdr Class loader. - * @param Message type. - * */ + /** Null-safe {@code finishUnmarshal} — skips when no marshaller is registered. */ static void finishUnmarshal( MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { @@ -88,13 +69,7 @@ static void finishUnmarshal( m.finishUnmarshal(msg, kctx, nested, clsLdr); } - /** Null-safe {@code finishUnmarshal} (cache-free) — skips when no marshaller is registered. - * - * @param factory Message factory. - * @param kctx Kernal context. - * @param msg Message. - * @param Message type. - * */ + /** Null-safe {@code finishUnmarshal} (cache-free) — skips when no marshaller is registered. */ static void finishUnmarshal( MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java index 15da7cf0349d5..a82cdf376f8b0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java @@ -393,6 +393,15 @@ public void testCompressAnnotationFailsForUnsupportedTypes() { assertThat(compilation).hadErrorContaining("Compress annotation is used for an unsupported type: java.util.List"); } + /** Verifies that {@code @NioField} on a non-{@link Message}-typed field is a compilation error. */ + @Test + public void testNioFieldOnNonMessageTypeFails() { + Compilation compilation = compile("NioFieldOnNonMessageMessage.java"); + + assertThat(compilation).failed(); + assertThat(compilation).hadErrorContaining("@NioField has no effect on non-Message field"); + } + /** */ private Compilation compile(String... srcFiles) { return compile(new MessageProcessor(), srcFiles); diff --git a/modules/core/src/test/resources/codegen/NioFieldOnNonMessageMessage.java b/modules/core/src/test/resources/codegen/NioFieldOnNonMessageMessage.java new file mode 100644 index 0000000000000..a8ac50154d9df --- /dev/null +++ b/modules/core/src/test/resources/codegen/NioFieldOnNonMessageMessage.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.plugin.extensions.communication.Message; + +public class NioFieldOnNonMessageMessage implements Message { + @NioField + @Order(0) + int id; + + public short directType() { + return 0; + } +} diff --git a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java index e84d844bf6ad4..d62e4b4c5aad4 100644 --- a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java @@ -57,16 +57,16 @@ public TestCollectionsMessageMarshaller() { GridCacheContext ctx = nested; if (msg.messageList != null) { - for (GridCacheVersion e2 : (Collection)msg.messageList) { - if (e2 != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e2, kctx, ctx); + for (GridCacheVersion e4 : (Collection)msg.messageList) { + if (e4 != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e4, kctx, ctx); } } if (msg.cacheObjectSet != null) { - for (CacheObject e2 : (Collection)msg.cacheObjectSet) { - if (e2 != null && ctx != null) - e2.prepareMarshal(ctx.cacheObjectContext()); + for (CacheObject e4 : (Collection)msg.cacheObjectSet) { + if (e4 != null && ctx != null) + e4.prepareMarshal(ctx.cacheObjectContext()); } } } @@ -76,16 +76,16 @@ public TestCollectionsMessageMarshaller() { GridCacheContext ctx = nested; if (msg.messageList != null) { - for (GridCacheVersion e2 : (Collection)msg.messageList) { - if (e2 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e2, kctx, ctx, clsLdr); + for (GridCacheVersion e4 : (Collection)msg.messageList) { + if (e4 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx, ctx, clsLdr); } } if (msg.cacheObjectSet != null) { - for (CacheObject e2 : (Collection)msg.cacheObjectSet) { - if (e2 != null && ctx != null) - e2.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + for (CacheObject e4 : (Collection)msg.cacheObjectSet) { + if (e4 != null && ctx != null) + e4.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); } } } @@ -93,9 +93,9 @@ public TestCollectionsMessageMarshaller() { /** */ @Override public void finishUnmarshal(TestCollectionsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.messageList != null) { - for (GridCacheVersion e2 : (Collection)msg.messageList) { - if (e2 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e2, kctx); + for (GridCacheVersion e4 : (Collection)msg.messageList) { + if (e4 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx); } } } diff --git a/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java index aee7ec6230016..5aaed6f7210d4 100644 --- a/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java @@ -17,18 +17,31 @@ package org.apache.ignite.internal; +import java.lang.Boolean; +import java.lang.Byte; +import java.lang.Character; import java.lang.Double; +import java.lang.Float; +import java.lang.Integer; +import java.lang.Long; +import java.lang.Short; +import java.lang.String; +import java.util.BitSet; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMapMessage; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.util.GridLongList; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; /** @@ -47,24 +60,24 @@ public TestMapMessageMarshaller() { GridCacheContext ctx = nested; if (msg.messageBoxedDoubleMap != null) { - for (GridCacheVersion e3 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { - if (e3 != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e3, kctx, ctx); + for (GridCacheVersion e4 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { + if (e4 != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e4, kctx, ctx); } } if (msg.gridCacheObjectMap != null) { - for (KeyCacheObject e3 : ((Collection)msg.gridCacheObjectMap.keySet())) { - if (e3 != null && ctx != null) - e3.prepareMarshal(ctx.cacheObjectContext()); + for (KeyCacheObject e4 : ((Collection)msg.gridCacheObjectMap.keySet())) { + if (e4 != null && ctx != null) + e4.prepareMarshal(ctx.cacheObjectContext()); } - for (Map e3 : ((Collection)msg.gridCacheObjectMap.values())) { - if (e3 != null) { - for (List e5 : ((Collection)e3.values())) { - if (e5 != null) { - for (CacheObject e6 : (Collection)e5) { - if (e6 != null && ctx != null) - e6.prepareMarshal(ctx.cacheObjectContext()); + for (Map e4 : ((Collection)msg.gridCacheObjectMap.values())) { + if (e4 != null) { + for (List e6 : ((Collection)e4.values())) { + if (e6 != null) { + for (CacheObject e8 : (Collection)e6) { + if (e8 != null && ctx != null) + e8.prepareMarshal(ctx.cacheObjectContext()); } } } @@ -78,24 +91,24 @@ public TestMapMessageMarshaller() { GridCacheContext ctx = nested; if (msg.messageBoxedDoubleMap != null) { - for (GridCacheVersion e3 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { - if (e3 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e3, kctx, ctx, clsLdr); + for (GridCacheVersion e4 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { + if (e4 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx, ctx, clsLdr); } } if (msg.gridCacheObjectMap != null) { - for (KeyCacheObject e3 : ((Collection)msg.gridCacheObjectMap.keySet())) { - if (e3 != null && ctx != null) - e3.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + for (KeyCacheObject e4 : ((Collection)msg.gridCacheObjectMap.keySet())) { + if (e4 != null && ctx != null) + e4.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); } - for (Map e3 : ((Collection)msg.gridCacheObjectMap.values())) { - if (e3 != null) { - for (List e5 : ((Collection)e3.values())) { - if (e5 != null) { - for (CacheObject e6 : (Collection)e5) { - if (e6 != null && ctx != null) - e6.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + for (Map e4 : ((Collection)msg.gridCacheObjectMap.values())) { + if (e4 != null) { + for (List e6 : ((Collection)e4.values())) { + if (e6 != null) { + for (CacheObject e8 : (Collection)e6) { + if (e8 != null && ctx != null) + e8.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); } } } @@ -107,9 +120,9 @@ public TestMapMessageMarshaller() { /** */ @Override public void finishUnmarshal(TestMapMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.messageBoxedDoubleMap != null) { - for (GridCacheVersion e3 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { - if (e3 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e3, kctx); + for (GridCacheVersion e4 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { + if (e4 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx); } } } diff --git a/modules/core/src/test/resources/codegen/TestMessage.java b/modules/core/src/test/resources/codegen/TestMessage.java index 6f3ef5eb1353a..82ca4788c116a 100644 --- a/modules/core/src/test/resources/codegen/TestMessage.java +++ b/modules/core/src/test/resources/codegen/TestMessage.java @@ -44,12 +44,17 @@ public class TestMessage implements Message { @Order(4) int[][] intMatrix; + @NioField // test-only: exercises multi-field finishUnmarshalNio generation @Order(5) GridCacheVersion ver; @Order(6) GridCacheVersion[] verArr; + @NioField // test-only: second NioField to verify both appear in finishUnmarshalNio + @Order(15) + GridCacheVersion ver2; + @Order(7) UUID uuid; diff --git a/modules/core/src/test/resources/codegen/TestMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMessageMarshaller.java index 6856b36a81a9a..e8084a5126a0f 100644 --- a/modules/core/src/test/resources/codegen/TestMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMessageMarshaller.java @@ -45,9 +45,9 @@ public TestMessageMarshaller() { MessageMarshaller.prepareMarshal(kctx.messageFactory(), msg.ver, kctx, ctx); if (msg.verArr != null) { - for (GridCacheVersion e3 : msg.verArr) { - if (e3 != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e3, kctx, ctx); + for (GridCacheVersion e4 : msg.verArr) { + if (e4 != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e4, kctx, ctx); } } @@ -56,19 +56,19 @@ public TestMessageMarshaller() { if (msg.cacheObject != null && ctx != null) msg.cacheObject.prepareMarshal(ctx.cacheObjectContext()); + + if (msg.ver2 != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), msg.ver2, kctx, ctx); } /** */ @Override public void finishUnmarshal(TestMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { GridCacheContext ctx = nested; - if (msg.ver != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), msg.ver, kctx, ctx, clsLdr); - if (msg.verArr != null) { - for (GridCacheVersion e3 : msg.verArr) { - if (e3 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e3, kctx, ctx, clsLdr); + for (GridCacheVersion e4 : msg.verArr) { + if (e4 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx, ctx, clsLdr); } } @@ -81,14 +81,20 @@ public TestMessageMarshaller() { /** */ @Override public void finishUnmarshal(TestMessage msg, GridKernalContext kctx) throws IgniteCheckedException { - if (msg.ver != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), msg.ver, kctx); - if (msg.verArr != null) { - for (GridCacheVersion e3 : msg.verArr) { - if (e3 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e3, kctx); + for (GridCacheVersion e4 : msg.verArr) { + if (e4 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx); } } } + + /** */ + @Override public void finishUnmarshalNio(TestMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + if (msg.ver != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), msg.ver, kctx); + + if (msg.ver2 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), msg.ver2, kctx); + } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMessageSerializer.java index a553f049c68a6..f55bcb63a1f7b 100644 --- a/modules/core/src/test/resources/codegen/TestMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestMessageSerializer.java @@ -143,6 +143,12 @@ public TestMessageSerializer() { return false; writer.incrementState(); + + case 15: + if (!writer.writeMessage(msg.ver2)) + return false; + + writer.incrementState(); } return true; @@ -266,6 +272,14 @@ public TestMessageSerializer() { case 14: msg.gridLongList = reader.readGridLongList(); + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + + case 15: + msg.ver2 = reader.readMessage(); + if (!reader.isLastRead()) return false; @@ -274,4 +288,4 @@ public TestMessageSerializer() { return true; } -} +} \ No newline at end of file From 1ace5ed026e8f7008a78f58d690c133f0049c369 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 01:48:18 +0300 Subject: [PATCH 153/215] WIP --- .../processors/query/calcite/metadata/ColocationGroup.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java index 377591c837d03..cee6beefb7012 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java @@ -38,10 +38,10 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** */ -public class ColocationGroup implements CacheMarshallableMessage { +public class ColocationGroup implements MarshallableMessage { /** */ @Order(0) long[] srcIds; From aefccbcf046acdb97a68ed2bd01b247011866711 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 02:44:45 +0300 Subject: [PATCH 154/215] WIP --- .../calcite/message/GenericValueMessage.java | 4 +- .../calcite/message/QueryStartRequest.java | 4 +- .../internal/MessageMarshallerGenerator.java | 236 +++++++++++------- .../processors/cache/GridCacheEntryInfo.java | 4 +- .../processors/cache/GridCacheReturn.java | 4 +- .../GridDistributedTxPrepareRequest.java | 4 +- .../distributed/dht/GridDhtLockRequest.java | 4 +- .../atomic/GridDhtAtomicUpdateRequest.java | 4 +- .../GridNearAtomicFullUpdateRequest.java | 4 +- ...idNearAtomicSingleUpdateFilterRequest.java | 4 +- ...idNearAtomicSingleUpdateInvokeRequest.java | 4 +- .../GridDhtPartitionsFullMessage.java | 4 +- .../GridDhtPartitionsSingleMessage.java | 4 +- .../distributed/near/GridNearGetRequest.java | 4 +- .../near/GridNearTxPrepareResponse.java | 4 +- .../cache/query/GridCacheQueryRequest.java | 4 +- .../cache/transactions/IgniteTxEntry.java | 4 +- .../cache/transactions/TxLocksRequest.java | 4 +- .../cache/transactions/TxLocksResponse.java | 4 +- .../handlers/task/GridTaskResultResponse.java | 4 +- .../TestMarshallableMessageMarshaller.java | 1 + 21 files changed, 181 insertions(+), 132 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java index 7587aa6be062b..8a2ceea7f1965 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java @@ -21,10 +21,10 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** */ -public final class GenericValueMessage implements CacheMarshallableMessage { +public final class GenericValueMessage implements MarshallableMessage { /** */ private Object val; diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java index 61289af51d0c1..0b6ca25f9dbdb 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java @@ -26,13 +26,13 @@ import org.apache.ignite.internal.processors.query.calcite.metadata.FragmentDescription; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * */ -public class QueryStartRequest implements CacheMarshallableMessage, ExecutionContextAware { +public class QueryStartRequest implements MarshallableMessage, ExecutionContextAware { /** */ @Order(0) String schema; diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index da86df4453f88..48835a78eaf87 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.List; import javax.annotation.processing.ProcessingEnvironment; -import javax.tools.Diagnostic; import javax.lang.model.element.Element; import javax.lang.model.element.QualifiedNameable; import javax.lang.model.element.TypeElement; @@ -33,6 +32,7 @@ import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVariable; +import javax.tools.Diagnostic; import static org.apache.ignite.internal.MessageProcessor.MARSHALLABLE_MESSAGE_INTERFACE; import static org.apache.ignite.internal.MessageProcessor.MESSAGE_INTERFACE; @@ -47,22 +47,52 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** Collection of lines for {@code prepareMarshal} / {@code finishUnmarshal} methods. */ private final List marshall = new ArrayList<>(); - /** The marshallable message type. */ + /** MarshallableMessage type mirror. */ private final TypeMirror marshallableMsgType; - /** The cache-marshallable message type. */ - private final TypeMirror cacheMarshallableMsgType; + /** Message type mirror. */ + private final TypeMirror messageMirror; + + /** CacheObject type mirror. */ + private final TypeMirror cacheObjectMirror; + + /** NonMarshallableMessage type mirror. */ + private final TypeMirror nonMarshallableMirror; + + /** CacheIdAware type mirror. */ + private final TypeMirror cacheIdAwareMirror; + + /** GridCacheGroupIdMessage type mirror. */ + private final TypeMirror cacheGroupIdMsgMirror; + + /** java.util.Map type mirror. */ + private final TypeMirror mapMirror; + + /** java.util.Collection type mirror. */ + private final TypeMirror collectionMirror; + + /** Whether the current message type implements {@code MarshallableMessage}. Set at the start of {@link #generateBody}. */ + private boolean marshallable; /** */ MessageMarshallerGenerator(ProcessingEnvironment env) { super(env); - TypeElement marshallableMsgElem = env.getElementUtils().getTypeElement(MARSHALLABLE_MESSAGE_INTERFACE); - marshallableMsgType = marshallableMsgElem != null ? marshallableMsgElem.asType() : null; + marshallableMsgType = mirror(env, MARSHALLABLE_MESSAGE_INTERFACE); + messageMirror = mirror(env, MESSAGE_INTERFACE); + cacheObjectMirror = mirror(env, "org.apache.ignite.internal.processors.cache.CacheObject"); + nonMarshallableMirror = mirror(env, "org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage"); + cacheIdAwareMirror = mirror(env, "org.apache.ignite.plugin.extensions.communication.CacheIdAware"); + cacheGroupIdMsgMirror = mirror(env, "org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage"); + mapMirror = mirror(env, "java.util.Map"); + collectionMirror = mirror(env, "java.util.Collection"); + } - TypeElement cacheMarshallableMsgElem = env.getElementUtils() - .getTypeElement("org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage"); - cacheMarshallableMsgType = cacheMarshallableMsgElem != null ? cacheMarshallableMsgElem.asType() : null; + /** */ + private static TypeMirror mirror(ProcessingEnvironment env, String qualifiedName) { + TypeElement elem = env.getElementUtils().getTypeElement(qualifiedName); + + return elem != null ? elem.asType() : null; } /** {@inheritDoc} */ @@ -77,6 +107,10 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** {@inheritDoc} */ @Override void generateBody(List fields) throws Exception { + marshallable = marshallableMsgType != null && env.getTypeUtils().isAssignable(type.asType(), marshallableMsgType); + + indent = 1; + generateMarshallMethods(fields); generateUnmarshallMethods(fields); } @@ -87,7 +121,7 @@ public class MessageMarshallerGenerator extends MessageGenerator { imports.add(type.toString()); imports.add("org.apache.ignite.plugin.extensions.communication.MessageMarshaller"); - if (marshallableMessage()) + if (marshallable) imports.add("org.apache.ignite.marshaller.Marshaller"); writeClassHeader(writer, "MessageMarshaller", marshallerClsName); @@ -105,12 +139,10 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** */ private void writeConstructor(Writer writer, String marshallerClsName) throws IOException { - indent = 1; - writer.write(indentedLine(METHOD_JAVADOC)); writer.write(NL); - if (marshallableMessage()) { + if (marshallable) { writer.write(indentedLine("private final Marshaller marshaller;")); writer.write(NL + NL); @@ -140,8 +172,6 @@ private void generateMarshallMethods(List orderedFields) { imports.add("org.apache.ignite.internal.GridKernalContext"); imports.add("org.apache.ignite.internal.processors.cache.GridCacheContext"); - indent = 1; - marshall.add(indentedLine(METHOD_JAVADOC)); marshall.add(indentedLine( @@ -155,15 +185,10 @@ private void generateMarshallMethods(List orderedFields) { if (needsCtx(orderedFields)) appendBlock(body, List.of(ctxResolutionLine())); - if (marshallableMessage()) + if (marshallable) appendBlock(body, List.of(indentedLine("msg.prepareMarshal(marshaller);"))); - for (VariableElement field : orderedFields) { - List marshalled = marshall(field.asType(), fieldAccessor(field), MarshalMode.PREPARE); - - if (!marshalled.isEmpty()) - appendBlock(body, marshalled); - } + appendFields(body, orderedFields, MarshalMode.PREPARE); marshall.addAll(body); @@ -178,10 +203,12 @@ private void generateUnmarshallMethods(List orderedFields) { List workerFields = new ArrayList<>(); for (VariableElement f : orderedFields) { - if (isNioField(f) && isMessage(f.asType())) + boolean nioField = isNioField(f); + + if (nioField && isMessage(f.asType())) nioFields.add(f); else { - if (isNioField(f)) + if (nioField) env.getMessager().printMessage(Diagnostic.Kind.ERROR, "@NioField has no effect on non-Message field '" + f.getSimpleName() + "' of type " + f.asType(), f); @@ -197,18 +224,16 @@ private void generateUnmarshallMethods(List orderedFields) { generateFinishUnmarshalMethod("finishUnmarshal", msgParam + ", GridCacheContext nested, ClassLoader clsLdr", workerFields, MarshalMode.FINISH_CACHE); - generateFinishUnmarshalMethod("finishUnmarshal", msgParam, workerFields, MarshalMode.FINISH_BASE); + generateFinishUnmarshalMethod("finishUnmarshal", msgParam, workerFields, MarshalMode.FINISH); if (!nioFields.isEmpty()) - generateFinishUnmarshalMethod("finishUnmarshalNio", msgParam, nioFields, MarshalMode.FINISH_BASE); + generateFinishUnmarshalNioMethod(msgParam, nioFields); } /** */ private void generateFinishUnmarshalMethod(String methodName, String params, List fields, MarshalMode mode) { marshall.add(EMPTY); - indent = 1; - marshall.add(indentedLine(METHOD_JAVADOC)); marshall.add(indentedLine( @@ -221,18 +246,36 @@ private void generateFinishUnmarshalMethod(String methodName, String params, Lis if (mode == MarshalMode.FINISH_CACHE && needsCtx(fields)) appendBlock(body, List.of(ctxResolutionLine())); - for (VariableElement field : fields) { - List unmarshalled = marshall(field.asType(), fieldAccessor(field), mode); + appendFields(body, fields, mode); - if (!unmarshalled.isEmpty()) - appendBlock(body, unmarshalled); + if (marshallable) { + if (mode == MarshalMode.FINISH_CACHE) + appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);"))); + else if (mode == MarshalMode.FINISH) + appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));"))); } - if (mode == MarshalMode.FINISH_CACHE && isCacheMarshallableMessage(type)) - appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);"))); + marshall.addAll(body); - if (mode == MarshalMode.FINISH_BASE && marshallableMessage() && !isCacheMarshallableMessage(type)) - appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));"))); + indent--; + + marshall.add(indentedLine("}")); + } + + /** */ + private void generateFinishUnmarshalNioMethod(String params, List nioFields) { + marshall.add(EMPTY); + + marshall.add(indentedLine(METHOD_JAVADOC)); + + marshall.add(indentedLine( + "@Override public void finishUnmarshalNio(" + params + ") throws IgniteCheckedException {")); + + indent++; + + List body = new ArrayList<>(); + + appendFields(body, nioFields, MarshalMode.FINISH); marshall.addAll(body); @@ -246,6 +289,16 @@ private static boolean isNioField(VariableElement field) { return field.getAnnotation(NioField.class) != null; } + /** Marshals each field and appends non-empty results to {@code body}. */ + private void appendFields(List body, List fields, MarshalMode mode) { + for (VariableElement field : fields) { + List result = marshall(field.asType(), fieldAccessor(field), mode); + + if (!result.isEmpty()) + appendBlock(body, result); + } + } + /** Appends {@code block} to {@code body}, inserting a blank-line separator when {@code body} is non-empty. */ private static void appendBlock(List body, List block) { if (!body.isEmpty()) @@ -280,12 +333,12 @@ private boolean needsCtxType(TypeMirror t) { if (isMessage(t) || isCacheObject(t)) return true; - if (assignableFrom(erasedType(t), type(java.util.Map.class.getName()))) { + if (isMap(t)) { List args = ((DeclaredType)t).getTypeArguments(); return needsCtxType(args.get(0)) || needsCtxType(args.get(1)); } - if (assignableFrom(erasedType(t), type(java.util.Collection.class.getName()))) { + if (isCollection(t)) { List args = ((DeclaredType)t).getTypeArguments(); return needsCtxType(args.get(0)); } @@ -300,7 +353,7 @@ private enum MarshalMode { PREPARE, /** Lightweight unmarshal. Messages only, CacheObject fields are skipped (no cache context available). */ - FINISH_BASE, + FINISH, /** Unmarshal with full cache context and class loader. */ FINISH_CACHE @@ -310,8 +363,8 @@ private enum MarshalMode { private List marshall(TypeMirror t, String accessor, MarshalMode mode) { if (t.getKind() == TypeKind.ARRAY) { TypeMirror comp = ((ArrayType)t).getComponentType(); - - return comp.getKind() == TypeKind.DECLARED ? marshallArray(comp, accessor, mode) : java.util.Collections.emptyList(); + + return comp.getKind() == TypeKind.DECLARED ? marshallArray(comp, accessor, mode) : List.of(); } if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { @@ -319,13 +372,13 @@ private List marshall(TypeMirror t, String accessor, MarshalMode mode) { return marshallMessage(accessor, mode); if (isCacheObject(t)) return marshallCacheObject(accessor, mode); - if (assignableFrom(erasedType(t), type(java.util.Map.class.getName()))) + if (isMap(t)) return marshallMap((DeclaredType)t, accessor, mode); - if (assignableFrom(erasedType(t), type(java.util.Collection.class.getName()))) + if (isCollection(t)) return marshallCollection((DeclaredType)t, accessor, mode); } - return java.util.Collections.emptyList(); + return List.of(); } /** */ @@ -341,7 +394,7 @@ private List marshallMessage(String accessor, MarshalMode mode) { code.add(indentedLine( "MessageMarshaller.prepareMarshal(kctx.messageFactory(), %s, kctx, ctx);", accessor)); break; - case FINISH_BASE: + case FINISH: code.add(indentedLine( "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx);", accessor)); break; @@ -358,19 +411,19 @@ private List marshallMessage(String accessor, MarshalMode mode) { /** */ private List marshallCacheObject(String accessor, MarshalMode mode) { - if (mode == MarshalMode.FINISH_BASE) - return java.util.Collections.emptyList(); + if (mode == MarshalMode.FINISH) + return List.of(); List code = new ArrayList<>(); code.add(indentedLine("if (%s != null && ctx != null)", accessor)); indent++; - + code.add(mode == MarshalMode.PREPARE ? indentedLine("%s.prepareMarshal(ctx.cacheObjectContext());", accessor) : indentedLine("%s.finishUnmarshal(ctx.cacheObjectContext(), clsLdr);", accessor)); - + indent--; return code; @@ -379,13 +432,13 @@ private List marshallCacheObject(String accessor, MarshalMode mode) { /** */ private List marshallArray(TypeMirror comp, String accessor, MarshalMode mode) { Element elem = ((DeclaredType)comp).asElement(); - + imports.add(((QualifiedNameable)elem).getQualifiedName().toString()); indent++; - + List loopCode = forLoop(elem.getSimpleName().toString(), comp, accessor, mode); - + indent--; return wrapNullGuarded(accessor, loopCode); @@ -396,19 +449,19 @@ private List marshallCollection(DeclaredType t, String accessor, Marshal TypeMirror arg = t.getTypeArguments().get(0); if (arg.getKind() != TypeKind.DECLARED && arg.getKind() != TypeKind.TYPEVAR) - return java.util.Collections.emptyList(); + return List.of(); Element elem = element(arg); - + imports.add(((QualifiedNameable)elem).getQualifiedName().toString()); imports.add("java.util.Collection"); String typeName = elem.getSimpleName().toString(); indent++; - + List loopCode = forLoop(typeName, arg, "(Collection)" + accessor, mode); - + indent--; return wrapNullGuarded(accessor, loopCode); @@ -419,7 +472,7 @@ private List marshallMap(DeclaredType t, String accessor, MarshalMode mo List args = t.getTypeArguments(); indent++; - + List combined = new ArrayList<>(); for (int i = 0; i < 2; i++) { TypeMirror elemType = args.get(i); @@ -428,7 +481,7 @@ private List marshallMap(DeclaredType t, String accessor, MarshalMode mo continue; Element elem = element(elemType); - + imports.add(((QualifiedNameable)elem).getQualifiedName().toString()); imports.add("java.util.Collection"); @@ -438,7 +491,7 @@ private List marshallMap(DeclaredType t, String accessor, MarshalMode mo combined.addAll(forLoop(typeName, elemType, iterable, mode)); } - + indent--; return wrapNullGuarded(accessor, combined); @@ -447,18 +500,18 @@ private List marshallMap(DeclaredType t, String accessor, MarshalMode mo /** Returns empty if {@code inner} is empty. */ private List wrapNullGuarded(String nullGuard, List inner) { if (inner.isEmpty()) - return java.util.Collections.emptyList(); + return List.of(); List code = new ArrayList<>(); - + code.add(indentedLine("if (%s != null) {", nullGuard)); - + indent++; - + code.addAll(inner); - + indent--; - + code.add(indentedLine("}")); return code; @@ -467,26 +520,26 @@ private List wrapNullGuarded(String nullGuard, List inner) { /** Returns empty if {@code elemType} requires no marshalling. Leaves {@code this.indent} unchanged. */ private List forLoop(String typeName, TypeMirror elemType, String iterable, MarshalMode mode) { String el = "e" + (indent + 1); - + indent++; - + List inner = marshall(elemType, el, mode); - + indent--; if (inner.isEmpty()) - return java.util.Collections.emptyList(); + return List.of(); List code = new ArrayList<>(); - + code.add(indentedLine("for (%s %s : %s) {", typeName, el, iterable)); - + indent++; - + code.addAll(inner); - + indent--; - + code.add(indentedLine("}")); return code; @@ -494,42 +547,37 @@ private List forLoop(String typeName, TypeMirror elemType, String iterab /** */ private boolean isCacheObject(TypeMirror type) { - TypeMirror obj = type("org.apache.ignite.internal.processors.cache.CacheObject"); - return obj != null && assignableFrom(type, obj); + return cacheObjectMirror != null && assignableFrom(type, cacheObjectMirror); } /** */ - private boolean isMessage(TypeMirror type) { - TypeMirror msg = type(MESSAGE_INTERFACE); - return msg != null && assignableFrom(type, msg); + private boolean isMap(TypeMirror type) { + return mapMirror != null && assignableFrom(erasedType(type), mapMirror); } /** */ - private boolean isNonMarshallableMessage(TypeElement te) { - TypeMirror nonMarshallable = type("org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage"); - return nonMarshallable != null && assignableFrom(te.asType(), nonMarshallable); + private boolean isCollection(TypeMirror type) { + return collectionMirror != null && assignableFrom(erasedType(type), collectionMirror); } /** */ - private boolean isCacheMarshallableMessage(TypeElement te) { - return cacheMarshallableMsgType != null && env.getTypeUtils().isAssignable(te.asType(), cacheMarshallableMsgType); + private boolean isMessage(TypeMirror type) { + return messageMirror != null && assignableFrom(type, messageMirror); } - /** True if {@code te} extends {@code CacheIdAware}. */ - private boolean isCacheIdAwareMessage(TypeElement te) { - TypeMirror cacheIdAware = type("org.apache.ignite.plugin.extensions.communication.CacheIdAware"); - return cacheIdAware != null && assignableFrom(te.asType(), cacheIdAware); + /** */ + private boolean isNonMarshallableMessage(TypeElement te) { + return nonMarshallableMirror != null && assignableFrom(te.asType(), nonMarshallableMirror); } - /** True if {@code te} extends {@code GridCacheGroupIdMessage}. */ - private boolean isCacheGroupIdMessage(TypeElement te) { - TypeMirror grpIdMsg = type("org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage"); - return grpIdMsg != null && assignableFrom(te.asType(), grpIdMsg); + /** */ + private boolean isCacheIdAwareMessage(TypeElement te) { + return cacheIdAwareMirror != null && assignableFrom(te.asType(), cacheIdAwareMirror); } /** */ - private boolean marshallableMessage() { - return marshallableMsgType != null && env.getTypeUtils().isAssignable(type.asType(), marshallableMsgType); + private boolean isCacheGroupIdMessage(TypeElement te) { + return cacheGroupIdMsgMirror != null && assignableFrom(te.asType(), cacheGroupIdMsgMirror); } /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java index e63ec515d3b9a..293db4c0241b8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java @@ -25,12 +25,12 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * Entry information that gets passed over wire. */ -public class GridCacheEntryInfo implements CacheMarshallableMessage, CacheIdAware { +public class GridCacheEntryInfo implements MarshallableMessage, CacheIdAware { /** */ private static final int SIZE_OVERHEAD = 3 * 8 /* reference */ + 4 /* int */ + 2 * 8 /* long */ + 32 /* version */; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index 3770aacc77e2c..dbf7758971436 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -33,13 +33,13 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Return value for cases where both, value and success flag need to be returned. */ -public class GridCacheReturn implements CacheMarshallableMessage, CacheIdAware { +public class GridCacheReturn implements MarshallableMessage, CacheIdAware { /** Value. */ @GridToStringInclude(sensitive = true) private volatile Object v; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index c65c1a43b1bae..0f227c74f8b84 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -38,7 +38,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; @@ -47,7 +47,7 @@ * Transaction prepare request for optimistic and eventually consistent * transactions. */ -public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage implements IgniteTxStateAware, CacheMarshallableMessage { +public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage implements IgniteTxStateAware, MarshallableMessage { /** */ private static final int NEED_RETURN_VALUE_FLAG_MASK = 0x01; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 68733f968e78b..b3f8b9908adc2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -32,7 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,7 +40,7 @@ /** * DHT lock request. */ -public class GridDhtLockRequest extends GridDistributedLockRequest implements CacheMarshallableMessage { +public class GridDhtLockRequest extends GridDistributedLockRequest implements MarshallableMessage { /** Invalidate reader flags. */ @Order(0) BitSet invalidateEntries; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index a18e91f4f7d73..e2a248c2c9566 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -37,14 +37,14 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Lite dht cache backup update request. */ -public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements CacheMarshallableMessage { +public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements MarshallableMessage { /** Keys to update. */ @GridToStringInclude @Order(0) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index af9e873d61660..e82be8499ef99 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -42,7 +42,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,7 +53,7 @@ /** * Lite DHT cache update request sent from near node to primary node. */ -public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements CacheMarshallableMessage { +public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements MarshallableMessage { /** Keys to update. */ @Order(0) @GridToStringInclude diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java index f9ef62894fdd8..523b3341c4f6d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java @@ -27,14 +27,14 @@ import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * */ -public class GridNearAtomicSingleUpdateFilterRequest extends GridNearAtomicSingleUpdateRequest implements CacheMarshallableMessage { +public class GridNearAtomicSingleUpdateFilterRequest extends GridNearAtomicSingleUpdateRequest implements MarshallableMessage { /** Filter. */ @Order(0) CacheEntryPredicate[] filter; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index 7f99ec4b04f98..e98035f795a3d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -36,7 +36,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -45,7 +45,7 @@ /** * */ -public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest implements CacheMarshallableMessage { +public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest implements MarshallableMessage { /** Optional arguments for entry processor. */ private @Nullable Object[] invokeArgs; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index 00473e4898074..6cce1a2ac30ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -40,7 +40,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -49,7 +49,7 @@ * GridDhtPartitionsSingleMessage}s were received.
May be also compacted as part of {@link * CacheAffinityChangeMessage} for node left or failed case.
*/ -public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessage implements CacheMarshallableMessage { +public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { /** */ private static final byte REBALANCED_FLAG_MASK = 0x01; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index 50dbf868f20fc..89a0d7f22d0db 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -31,7 +31,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** @@ -39,7 +39,7 @@ * * Sent in response to {@link GridDhtPartitionsSingleRequest} and during processing partitions exchange future. */ -public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements CacheMarshallableMessage { +public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { /** Local partitions. */ @Order(0) @Compress diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index 4ffada383bb94..ed74674741ae0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -38,14 +38,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Get request. Responsible for obtaining entry from primary node. 'Near' means 'Initiating node' here, not 'Near Cache'. */ -public class GridNearGetRequest extends GridCacheIdMessage implements GridCacheDeployable, GridCacheVersionable, CacheMarshallableMessage { +public class GridNearGetRequest extends GridCacheIdMessage implements GridCacheDeployable, GridCacheVersionable, MarshallableMessage { /** */ private static final int READ_THROUGH_FLAG_MASK = 0x01; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index b914ea44dcdfe..fefb2018598b2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -36,13 +36,13 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Near cache prepare response. */ -public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse implements CacheMarshallableMessage { +public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse implements MarshallableMessage { /** Versions that are less than lock version ({@link #version()}). */ @GridToStringInclude @Order(0) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 9c980e4b23587..ad1117edeb1a8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -34,7 +34,7 @@ import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgniteReducer; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.INDEX; @@ -44,7 +44,7 @@ /** * Query request. */ -public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, CacheMarshallableMessage { +public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, MarshallableMessage { /** */ private static final int FLAG_DATA_PAGE_SCAN_DFLT = 0b00; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index c9341ef7c547f..1883734d6883c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -48,7 +48,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; @@ -60,7 +60,7 @@ * {@link #equals(Object)} method, as transaction entries should use referential * equality. */ -public class IgniteTxEntry implements GridPeerDeployAware, CacheMarshallableMessage, CacheIdAware { +public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, CacheIdAware { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java index 499d9557e90d2..cd3e43b69189d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java @@ -28,12 +28,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * Transactions lock list request. */ -public class TxLocksRequest extends GridCacheMessage implements CacheMarshallableMessage { +public class TxLocksRequest extends GridCacheMessage implements MarshallableMessage { /** Future ID. */ @Order(0) long futId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index fde78bec7bbe2..a6ff66cc8e4b2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -31,12 +31,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * Transactions lock list response. */ -public class TxLocksResponse extends GridCacheMessage implements CacheMarshallableMessage { +public class TxLocksResponse extends GridCacheMessage implements MarshallableMessage { /** Future ID. */ @Order(0) long futId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java index 11a5182de4301..3661cae983735 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -21,13 +21,13 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Task result response. */ -public class GridTaskResultResponse implements CacheMarshallableMessage { +public class GridTaskResultResponse implements MarshallableMessage { /** Result. */ public @Nullable Object res; diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java index 52c75c2d3860e..805f382bbb672 100644 --- a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java @@ -47,6 +47,7 @@ public TestMarshallableMessageMarshaller(Marshaller marshaller) { /** */ @Override public void finishUnmarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + msg.finishUnmarshal(marshaller, clsLdr); } /** */ From c93620d4da541fdc7fea693bebe05dd0295beb7e Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 02:50:10 +0300 Subject: [PATCH 155/215] WIP --- .../internal/MessageMarshallerGenerator.java | 83 +++++++++---------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 48835a78eaf87..e628be3bfa1b6 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -88,13 +88,6 @@ public class MessageMarshallerGenerator extends MessageGenerator { collectionMirror = mirror(env, "java.util.Collection"); } - /** */ - private static TypeMirror mirror(ProcessingEnvironment env, String qualifiedName) { - TypeElement elem = env.getElementUtils().getTypeElement(qualifiedName); - - return elem != null ? elem.asType() : null; - } - /** {@inheritDoc} */ @Override String typeSuffix() { return "Marshaller"; @@ -284,29 +277,6 @@ private void generateFinishUnmarshalNioMethod(String params, List body, List fields, MarshalMode mode) { - for (VariableElement field : fields) { - List result = marshall(field.asType(), fieldAccessor(field), mode); - - if (!result.isEmpty()) - appendBlock(body, result); - } - } - - /** Appends {@code block} to {@code body}, inserting a blank-line separator when {@code body} is non-empty. */ - private static void appendBlock(List body, List block) { - if (!body.isEmpty()) - body.add(EMPTY); - - body.addAll(block); - } - /** Returns the {@code GridCacheContext ctx} resolution line for the current message type. */ private String ctxResolutionLine() { if (isCacheIdAwareMessage(type)) @@ -347,18 +317,6 @@ private boolean needsCtxType(TypeMirror t) { return false; } - /** */ - private enum MarshalMode { - /** Marshal. */ - PREPARE, - - /** Lightweight unmarshal. Messages only, CacheObject fields are skipped (no cache context available). */ - FINISH, - - /** Unmarshal with full cache context and class loader. */ - FINISH_CACHE - } - /** */ private List marshall(TypeMirror t, String accessor, MarshalMode mode) { if (t.getKind() == TypeKind.ARRAY) { @@ -586,4 +544,45 @@ private Element element(TypeMirror t) { ((DeclaredType)t).asElement() : ((DeclaredType)((TypeVariable)t).getUpperBound()).asElement(); } + + /** */ + private static boolean isNioField(VariableElement field) { + return field.getAnnotation(NioField.class) != null; + } + + /** Marshals each field and appends non-empty results to {@code body}. */ + private void appendFields(List body, List fields, MarshalMode mode) { + for (VariableElement field : fields) { + List result = marshall(field.asType(), fieldAccessor(field), mode); + + if (!result.isEmpty()) + appendBlock(body, result); + } + } + + /** Appends {@code block} to {@code body}, inserting a blank-line separator when {@code body} is non-empty. */ + private static void appendBlock(List body, List block) { + if (!body.isEmpty()) + body.add(EMPTY); + + body.addAll(block); + } + + /** */ + private static TypeMirror mirror(ProcessingEnvironment env, String qualifiedName) { + TypeElement elem = env.getElementUtils().getTypeElement(qualifiedName); + return elem != null ? elem.asType() : null; + } + + /** */ + private enum MarshalMode { + /** Marshal. */ + PREPARE, + + /** Lightweight unmarshal. Messages only, CacheObject fields are skipped (no cache context available). */ + FINISH, + + /** Unmarshal with full cache context and class loader. */ + FINISH_CACHE + } } From 0ade8bb588345ddb6fc93e162c06419ea9d43880 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 02:53:19 +0300 Subject: [PATCH 156/215] WIP --- .../ignite/internal/MessageMarshallerGenerator.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index e628be3bfa1b6..8a5b643992f18 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -44,7 +44,7 @@ * No marshaller is generated for {@code NonMarshallableMessage} types. */ public class MessageMarshallerGenerator extends MessageGenerator { - /** Collection of lines for {@code prepareMarshal} / {@code finishUnmarshal} methods. */ + /** Accumulated source lines for all generated marshal/unmarshal methods. */ private final List marshall = new ArrayList<>(); /** MarshallableMessage type mirror. */ @@ -145,8 +145,10 @@ private void writeConstructor(Writer writer, String marshallerClsName) throws IO writer.write(NL); indent++; + writer.write(indentedLine("this.marshaller = marshaller;")); writer.write(NL); + indent--; } else { @@ -538,7 +540,7 @@ private boolean isCacheGroupIdMessage(TypeElement te) { return cacheGroupIdMsgMirror != null && assignableFrom(te.asType(), cacheGroupIdMsgMirror); } - /** */ + /** Returns the element for {@code t}; for a type variable, uses its upper bound. */ private Element element(TypeMirror t) { return t.getKind() == TypeKind.DECLARED ? ((DeclaredType)t).asElement() : @@ -568,7 +570,7 @@ private static void appendBlock(List body, List block) { body.addAll(block); } - /** */ + /** Returns the type mirror for {@code qualifiedName}, or {@code null} if the type is not on the compilation classpath. */ private static TypeMirror mirror(ProcessingEnvironment env, String qualifiedName) { TypeElement elem = env.getElementUtils().getTypeElement(qualifiedName); return elem != null ? elem.asType() : null; From 5b571f502fb6747b10d1e01d29e8bc081ec54c7f Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 03:23:13 +0300 Subject: [PATCH 157/215] WIP --- .../calcite/message/GenericValueMessage.java | 4 +- .../calcite/message/QueryStartRequest.java | 4 +- .../ignite/internal/MessageGenerator.java | 2 +- .../internal/MessageMarshallerGenerator.java | 48 ++++++++++--------- .../internal/MessageSerializerGenerator.java | 2 + .../processors/cache/GridCacheEntryInfo.java | 4 +- .../processors/cache/GridCacheReturn.java | 4 +- .../GridDistributedTxPrepareRequest.java | 4 +- .../distributed/dht/GridDhtLockRequest.java | 4 +- .../atomic/GridDhtAtomicUpdateRequest.java | 4 +- .../GridNearAtomicFullUpdateRequest.java | 4 +- ...idNearAtomicSingleUpdateFilterRequest.java | 4 +- ...idNearAtomicSingleUpdateInvokeRequest.java | 4 +- .../GridDhtPartitionsFullMessage.java | 4 +- .../GridDhtPartitionsSingleMessage.java | 4 +- .../distributed/near/GridNearGetRequest.java | 4 +- .../near/GridNearTxPrepareResponse.java | 4 +- .../cache/query/GridCacheQueryRequest.java | 4 +- .../cache/transactions/IgniteTxEntry.java | 4 +- .../cache/transactions/TxLocksRequest.java | 4 +- .../cache/transactions/TxLocksResponse.java | 4 +- .../handlers/task/GridTaskResultResponse.java | 4 +- 22 files changed, 66 insertions(+), 62 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java index 8a2ceea7f1965..7587aa6be062b 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java @@ -21,10 +21,10 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; /** */ -public final class GenericValueMessage implements MarshallableMessage { +public final class GenericValueMessage implements CacheMarshallableMessage { /** */ private Object val; diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java index 0b6ca25f9dbdb..61289af51d0c1 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java @@ -26,13 +26,13 @@ import org.apache.ignite.internal.processors.query.calcite.metadata.FragmentDescription; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** * */ -public class QueryStartRequest implements MarshallableMessage, ExecutionContextAware { +public class QueryStartRequest implements CacheMarshallableMessage, ExecutionContextAware { /** */ @Order(0) String schema; diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java index bf98bbec1df68..cc0b67a019fa6 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java @@ -167,7 +167,7 @@ void writeClassHeader(Writer writer, String interfaceName, String clsName) throw writer.write(NL); writer.write(CLS_JAVADOC); writer.write(NL); - writer.write("public class " + clsName + " implements " + interfaceName + "<" + simpleNameWithGeneric(type) + "> {" + NL); + writer.write("public class " + clsName + " implements " + interfaceName + "<" + simpleNameWithGeneric(type) + ">"); } /** */ diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 8a5b643992f18..ba3af41d823df 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -71,14 +71,21 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** java.util.Collection type mirror. */ private final TypeMirror collectionMirror; - /** Whether the current message type implements {@code MarshallableMessage}. Set at the start of {@link #generateBody}. */ + /** CacheMarshallableMessage type mirror. */ + private final TypeMirror cacheMarshallableMsgType; + + /** Whether the current message type implements {@code MarshallableMessage}. */ private boolean marshallable; + /** Whether the current message type implements {@code CacheMarshallableMessage}. */ + private boolean cacheMarshallable; + /** */ MessageMarshallerGenerator(ProcessingEnvironment env) { super(env); marshallableMsgType = mirror(env, MARSHALLABLE_MESSAGE_INTERFACE); + cacheMarshallableMsgType = mirror(env, "org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage"); messageMirror = mirror(env, MESSAGE_INTERFACE); cacheObjectMirror = mirror(env, "org.apache.ignite.internal.processors.cache.CacheObject"); nonMarshallableMirror = mirror(env, "org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage"); @@ -101,10 +108,11 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** {@inheritDoc} */ @Override void generateBody(List fields) throws Exception { marshallable = marshallableMsgType != null && env.getTypeUtils().isAssignable(type.asType(), marshallableMsgType); + cacheMarshallable = cacheMarshallableMsgType != null && env.getTypeUtils().isAssignable(type.asType(), cacheMarshallableMsgType); indent = 1; - generateMarshallMethods(fields); + generatePrepareMarshalMethod(fields); generateUnmarshallMethods(fields); } @@ -118,6 +126,8 @@ public class MessageMarshallerGenerator extends MessageGenerator { imports.add("org.apache.ignite.marshaller.Marshaller"); writeClassHeader(writer, "MessageMarshaller", marshallerClsName); + + writer.write(" {" + NL); writeConstructor(writer, marshallerClsName); @@ -162,7 +172,7 @@ private void writeConstructor(Writer writer, String marshallerClsName) throws IO } /** */ - private void generateMarshallMethods(List orderedFields) { + private void generatePrepareMarshalMethod(List orderedFields) { imports.add("org.apache.ignite.IgniteCheckedException"); imports.add("org.apache.ignite.internal.GridKernalContext"); imports.add("org.apache.ignite.internal.processors.cache.GridCacheContext"); @@ -246,7 +256,7 @@ private void generateFinishUnmarshalMethod(String methodName, String params, Lis if (marshallable) { if (mode == MarshalMode.FINISH_CACHE) appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);"))); - else if (mode == MarshalMode.FINISH) + else if (mode == MarshalMode.FINISH && !cacheMarshallable) appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));"))); } @@ -319,8 +329,8 @@ private boolean needsCtxType(TypeMirror t) { return false; } - /** */ - private List marshall(TypeMirror t, String accessor, MarshalMode mode) { + /** Returns generated marshal/unmarshal code lines for field of type {@code t}, or empty if none needed. */ + private List codeFor(TypeMirror t, String accessor, MarshalMode mode) { if (t.getKind() == TypeKind.ARRAY) { TypeMirror comp = ((ArrayType)t).getComponentType(); @@ -465,26 +475,22 @@ private List wrapNullGuarded(String nullGuard, List inner) { List code = new ArrayList<>(); code.add(indentedLine("if (%s != null) {", nullGuard)); - - indent++; - + code.addAll(inner); - - indent--; - + code.add(indentedLine("}")); return code; } - /** Returns empty if {@code elemType} requires no marshalling. Leaves {@code this.indent} unchanged. */ + /** Returns empty if {@code elemType} requires no marshalling. */ private List forLoop(String typeName, TypeMirror elemType, String iterable, MarshalMode mode) { String el = "e" + (indent + 1); indent++; - - List inner = marshall(elemType, el, mode); - + + List inner = codeFor(elemType, el, mode); + indent--; if (inner.isEmpty()) @@ -493,13 +499,9 @@ private List forLoop(String typeName, TypeMirror elemType, String iterab List code = new ArrayList<>(); code.add(indentedLine("for (%s %s : %s) {", typeName, el, iterable)); - - indent++; - + code.addAll(inner); - - indent--; - + code.add(indentedLine("}")); return code; @@ -555,7 +557,7 @@ private static boolean isNioField(VariableElement field) { /** Marshals each field and appends non-empty results to {@code body}. */ private void appendFields(List body, List fields, MarshalMode mode) { for (VariableElement field : fields) { - List result = marshall(field.asType(), fieldAccessor(field), mode); + List result = codeFor(field.asType(), fieldAccessor(field), mode); if (!result.isEmpty()) appendBlock(body, result); diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index b8885e71a68ea..a9f1bbbeb2358 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -91,6 +91,8 @@ public class MessageSerializerGenerator extends MessageGenerator { @Override String buildClassCode(String serClsName) throws IOException { try (Writer writer = new StringWriter()) { writeSerializerHeader(writer, env.getElementUtils().getPackageOf(type).toString(), serClsName); + + writer.write(" {" + NL); writeClassFields(writer); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java index 293db4c0241b8..e63ec515d3b9a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java @@ -25,12 +25,12 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; /** * Entry information that gets passed over wire. */ -public class GridCacheEntryInfo implements MarshallableMessage, CacheIdAware { +public class GridCacheEntryInfo implements CacheMarshallableMessage, CacheIdAware { /** */ private static final int SIZE_OVERHEAD = 3 * 8 /* reference */ + 4 /* int */ + 2 * 8 /* long */ + 32 /* version */; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index dbf7758971436..3770aacc77e2c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -33,13 +33,13 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Return value for cases where both, value and success flag need to be returned. */ -public class GridCacheReturn implements MarshallableMessage, CacheIdAware { +public class GridCacheReturn implements CacheMarshallableMessage, CacheIdAware { /** Value. */ @GridToStringInclude(sensitive = true) private volatile Object v; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 0f227c74f8b84..c65c1a43b1bae 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -38,7 +38,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; @@ -47,7 +47,7 @@ * Transaction prepare request for optimistic and eventually consistent * transactions. */ -public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage implements IgniteTxStateAware, MarshallableMessage { +public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage implements IgniteTxStateAware, CacheMarshallableMessage { /** */ private static final int NEED_RETURN_VALUE_FLAG_MASK = 0x01; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index b3f8b9908adc2..68733f968e78b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -32,7 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,7 +40,7 @@ /** * DHT lock request. */ -public class GridDhtLockRequest extends GridDistributedLockRequest implements MarshallableMessage { +public class GridDhtLockRequest extends GridDistributedLockRequest implements CacheMarshallableMessage { /** Invalidate reader flags. */ @Order(0) BitSet invalidateEntries; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index e2a248c2c9566..a18e91f4f7d73 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -37,14 +37,14 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Lite dht cache backup update request. */ -public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements MarshallableMessage { +public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements CacheMarshallableMessage { /** Keys to update. */ @GridToStringInclude @Order(0) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index e82be8499ef99..af9e873d61660 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -42,7 +42,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,7 +53,7 @@ /** * Lite DHT cache update request sent from near node to primary node. */ -public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements MarshallableMessage { +public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements CacheMarshallableMessage { /** Keys to update. */ @Order(0) @GridToStringInclude diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java index 523b3341c4f6d..f9ef62894fdd8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java @@ -27,14 +27,14 @@ import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * */ -public class GridNearAtomicSingleUpdateFilterRequest extends GridNearAtomicSingleUpdateRequest implements MarshallableMessage { +public class GridNearAtomicSingleUpdateFilterRequest extends GridNearAtomicSingleUpdateRequest implements CacheMarshallableMessage { /** Filter. */ @Order(0) CacheEntryPredicate[] filter; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index e98035f795a3d..7f99ec4b04f98 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -36,7 +36,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -45,7 +45,7 @@ /** * */ -public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest implements MarshallableMessage { +public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest implements CacheMarshallableMessage { /** Optional arguments for entry processor. */ private @Nullable Object[] invokeArgs; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index 6cce1a2ac30ea..00473e4898074 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -40,7 +40,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -49,7 +49,7 @@ * GridDhtPartitionsSingleMessage}s were received.
May be also compacted as part of {@link * CacheAffinityChangeMessage} for node left or failed case.
*/ -public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { +public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessage implements CacheMarshallableMessage { /** */ private static final byte REBALANCED_FLAG_MASK = 0x01; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index 89a0d7f22d0db..50dbf868f20fc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -31,7 +31,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** @@ -39,7 +39,7 @@ * * Sent in response to {@link GridDhtPartitionsSingleRequest} and during processing partitions exchange future. */ -public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { +public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements CacheMarshallableMessage { /** Local partitions. */ @Order(0) @Compress diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index ed74674741ae0..4ffada383bb94 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -38,14 +38,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Get request. Responsible for obtaining entry from primary node. 'Near' means 'Initiating node' here, not 'Near Cache'. */ -public class GridNearGetRequest extends GridCacheIdMessage implements GridCacheDeployable, GridCacheVersionable, MarshallableMessage { +public class GridNearGetRequest extends GridCacheIdMessage implements GridCacheDeployable, GridCacheVersionable, CacheMarshallableMessage { /** */ private static final int READ_THROUGH_FLAG_MASK = 0x01; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index fefb2018598b2..b914ea44dcdfe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -36,13 +36,13 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Near cache prepare response. */ -public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse implements MarshallableMessage { +public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse implements CacheMarshallableMessage { /** Versions that are less than lock version ({@link #version()}). */ @GridToStringInclude @Order(0) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index ad1117edeb1a8..9c980e4b23587 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -34,7 +34,7 @@ import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgniteReducer; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.INDEX; @@ -44,7 +44,7 @@ /** * Query request. */ -public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, MarshallableMessage { +public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, CacheMarshallableMessage { /** */ private static final int FLAG_DATA_PAGE_SCAN_DFLT = 0b00; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index 1883734d6883c..c9341ef7c547f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -48,7 +48,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; @@ -60,7 +60,7 @@ * {@link #equals(Object)} method, as transaction entries should use referential * equality. */ -public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, CacheIdAware { +public class IgniteTxEntry implements GridPeerDeployAware, CacheMarshallableMessage, CacheIdAware { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java index cd3e43b69189d..499d9557e90d2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java @@ -28,12 +28,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; /** * Transactions lock list request. */ -public class TxLocksRequest extends GridCacheMessage implements MarshallableMessage { +public class TxLocksRequest extends GridCacheMessage implements CacheMarshallableMessage { /** Future ID. */ @Order(0) long futId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index a6ff66cc8e4b2..fde78bec7bbe2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -31,12 +31,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; /** * Transactions lock list response. */ -public class TxLocksResponse extends GridCacheMessage implements MarshallableMessage { +public class TxLocksResponse extends GridCacheMessage implements CacheMarshallableMessage { /** Future ID. */ @Order(0) long futId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java index 3661cae983735..11a5182de4301 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -21,13 +21,13 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Task result response. */ -public class GridTaskResultResponse implements MarshallableMessage { +public class GridTaskResultResponse implements CacheMarshallableMessage { /** Result. */ public @Nullable Object res; From c4b62d55fcc2eff3e885acd8a4246ab79736b055 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 03:32:18 +0300 Subject: [PATCH 158/215] WIP --- .../ignite/internal/MessageGenerator.java | 3 +- .../internal/MessageMarshallerGenerator.java | 28 +++----- .../internal/MessageSerializerGenerator.java | 68 ++++--------------- 3 files changed, 27 insertions(+), 72 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java index cc0b67a019fa6..ed69200219816 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java @@ -66,7 +66,7 @@ public abstract class MessageGenerator { /** Collection of message-specific imports. */ final java.util.Set imports = new TreeSet<>(); - /** Stored type of the message being processed. */ + /** Message type being generated for. */ TypeElement type; /** */ @@ -253,7 +253,6 @@ static String content(Reader reader) throws IOException { while ((line = br.readLine()) != null) sb.append(line).append(NL); - // Delete last line separator. sb.deleteCharAt(sb.length() - 1); return sb.toString(); diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index ba3af41d823df..9d49bf2544dd1 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -84,15 +84,15 @@ public class MessageMarshallerGenerator extends MessageGenerator { MessageMarshallerGenerator(ProcessingEnvironment env) { super(env); - marshallableMsgType = mirror(env, MARSHALLABLE_MESSAGE_INTERFACE); - cacheMarshallableMsgType = mirror(env, "org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage"); - messageMirror = mirror(env, MESSAGE_INTERFACE); - cacheObjectMirror = mirror(env, "org.apache.ignite.internal.processors.cache.CacheObject"); - nonMarshallableMirror = mirror(env, "org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage"); - cacheIdAwareMirror = mirror(env, "org.apache.ignite.plugin.extensions.communication.CacheIdAware"); - cacheGroupIdMsgMirror = mirror(env, "org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage"); - mapMirror = mirror(env, "java.util.Map"); - collectionMirror = mirror(env, "java.util.Collection"); + marshallableMsgType = type(MARSHALLABLE_MESSAGE_INTERFACE); + cacheMarshallableMsgType = type("org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage"); + messageMirror = type(MESSAGE_INTERFACE); + cacheObjectMirror = type("org.apache.ignite.internal.processors.cache.CacheObject"); + nonMarshallableMirror = type("org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage"); + cacheIdAwareMirror = type("org.apache.ignite.plugin.extensions.communication.CacheIdAware"); + cacheGroupIdMsgMirror = type("org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage"); + mapMirror = type("java.util.Map"); + collectionMirror = type("java.util.Collection"); } /** {@inheritDoc} */ @@ -107,8 +107,8 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** {@inheritDoc} */ @Override void generateBody(List fields) throws Exception { - marshallable = marshallableMsgType != null && env.getTypeUtils().isAssignable(type.asType(), marshallableMsgType); - cacheMarshallable = cacheMarshallableMsgType != null && env.getTypeUtils().isAssignable(type.asType(), cacheMarshallableMsgType); + marshallable = marshallableMsgType != null && assignableFrom(type.asType(), marshallableMsgType); + cacheMarshallable = cacheMarshallableMsgType != null && assignableFrom(type.asType(), cacheMarshallableMsgType); indent = 1; @@ -572,12 +572,6 @@ private static void appendBlock(List body, List block) { body.addAll(block); } - /** Returns the type mirror for {@code qualifiedName}, or {@code null} if the type is not on the compilation classpath. */ - private static TypeMirror mirror(ProcessingEnvironment env, String qualifiedName) { - TypeElement elem = env.getElementUtils().getTypeElement(qualifiedName); - return elem != null ? elem.asType() : null; - } - /** */ private enum MarshalMode { /** Marshal. */ diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index a9f1bbbeb2358..64e299e9c6e3d 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -90,7 +90,12 @@ public class MessageSerializerGenerator extends MessageGenerator { /** {@inheritDoc} */ @Override String buildClassCode(String serClsName) throws IOException { try (Writer writer = new StringWriter()) { - writeSerializerHeader(writer, env.getElementUtils().getPackageOf(type).toString(), serClsName); + imports.add(type.toString()); + imports.add("org.apache.ignite.plugin.extensions.communication.MessageSerializer"); + imports.add("org.apache.ignite.plugin.extensions.communication.MessageWriter"); + imports.add("org.apache.ignite.plugin.extensions.communication.MessageReader"); + + writeClassHeader(writer, "MessageSerializer", serClsName); writer.write(" {" + NL); @@ -98,13 +103,11 @@ public class MessageSerializerGenerator extends MessageGenerator { writeConstructor(writer, serClsName); - // Write #writeTo method. for (String w: write) writer.write(w + NL); writer.write(TAB + "}" + NL + NL); - // Write #readFrom method. for (String r: read) writer.write(r + NL); @@ -261,11 +264,7 @@ private void readField(VariableElement field, int opt) throws Exception { indent--; } - /** - * Discover access write methods, like {@code writeInt}. - * - * @param field Field to generate write code. - */ + /** */ private void returnFalseIfWriteFailed(VariableElement field) throws Exception { String getExpr = field.getSimpleName().toString(); @@ -410,13 +409,7 @@ private String typeNameToFieldName(String typeName) { return new String(typeNameChars); } - /** - * Generate code of writing header. - *
-     * if (!writer.writeHeader(msg.directType()))
-     *     return false;
-     * 
- */ + /** */ private void returnFalseIfWriteFailed(Collection code, String accessor, @Nullable String... args) { String argsStr = String.join(", ", args); @@ -429,9 +422,7 @@ private void returnFalseIfWriteFailed(Collection code, String accessor, indent--; } - /** - * Generate code of writing single field: - */ + /** */ private void returnFalseIfWriteFailed(Collection code, VariableElement field, String accessor, @Nullable String... args) { String argsStr = String.join(", ", args); @@ -449,9 +440,7 @@ private void returnFalseIfWriteFailed(Collection code, VariableElement f indent--; } - /** - * Generate code of writing single enum field mapped with EnumMapper: - */ + /** */ private void returnFalseIfEnumWriteFailed( Collection code, VariableElement field, @@ -473,11 +462,7 @@ private void returnFalseIfEnumWriteFailed( indent--; } - /** - * Discover access read methods, like {@code readInt}. - * - * @param field Field. - */ + /** */ private void returnFalseIfReadFailed(VariableElement field) throws Exception { TypeMirror type = field.asType(); @@ -755,12 +740,7 @@ private PrimitiveType unboxedType(TypeMirror type) { } } - /** - * Generate code of reading single field. - * - * @param field Field. - * @param mtd Method name. - */ + /** */ private void returnFalseIfReadFailed(VariableElement field, String mtd, String... args) { String argsStr = String.join(", ", args); @@ -783,11 +763,7 @@ private void returnFalseIfReadFailed(VariableElement field, String mtd, String.. indent--; } - /** - * Generate code of reading single field: - * - * @param mapperDecodeCallStmnt Method name. - */ + /** */ private void returnFalseIfEnumReadFailed(VariableElement field, String mapperDecodeCallStmnt, String enumValuesFieldName) { String readOp; @@ -828,11 +804,7 @@ private void finish(List code) { code.add(indentedLine("return true;")); } - /** - * Creates line from given arguments. - * - * @return Line. - */ + /** */ private String line(String format, Object... args) { SB sb = new SB(); @@ -859,16 +831,6 @@ private void writeClassFields(Writer writer) throws IOException { indent = 0; } - /** Write header of serializer class: license, imports, class declaration. */ - private void writeSerializerHeader(Writer writer, String pkgName, String serClsName) throws IOException { - imports.add(type.toString()); - imports.add("org.apache.ignite.plugin.extensions.communication.MessageSerializer"); - imports.add("org.apache.ignite.plugin.extensions.communication.MessageWriter"); - imports.add("org.apache.ignite.plugin.extensions.communication.MessageReader"); - - writeClassHeader(writer, "MessageSerializer", serClsName); - } - /** */ private boolean sameType(TypeMirror type, String typeStr) { return env.getTypeUtils().isSameType(type, type(typeStr)); @@ -886,7 +848,7 @@ public static boolean enumType(ProcessingEnvironment env, TypeMirror type) { return element != null && element.getKind() == ElementKind.ENUM; } - /** Converts string "BYTE" to string "Byte", with first capital latter. */ + /** Converts e.g. {@code "BYTE"} to {@code "Byte"}: uppercases first char, lowercases the rest. */ private String capitalizeOnlyFirst(String input) { return input.substring(0, 1).toUpperCase() + input.substring(1).toLowerCase(); } From 387f167e517fc12469864da2a3e00eb1c18f322a Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 03:35:46 +0300 Subject: [PATCH 159/215] WIP --- .../communication/CacheMarshallableMessage.java | 2 +- .../extensions/communication/MarshallableMessage.java | 8 ++++---- .../extensions/communication/MessageMarshaller.java | 8 ++++---- .../extensions/communication/NonMarshallableMessage.java | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java index d5bd508f03b91..32bd09eb0924a 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java @@ -17,6 +17,6 @@ package org.apache.ignite.plugin.extensions.communication; -/** Unmarshalls when CacheObjects are already unmarshalled. */ +/** Marker for {@link MarshallableMessage} whose {@code finishUnmarshal} requires CacheObject fields to be deserialized first. */ public interface CacheMarshallableMessage extends MarshallableMessage { } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java index 5f2f8c4196608..d15d50b625f9d 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java @@ -20,14 +20,14 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.marshaller.Marshaller; -/** A {@link Message} which still requires external custom pre-marshalling and post-unmarshalling. */ +/** A {@link Message} requiring a custom marshal/unmarshal step via {@link Marshaller}. */ public interface MarshallableMessage extends Message { - /** @param marsh External custom marshaller. */ + /** @param marsh Marshaller for pre-marshalling. */ public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException; /** - * @param marsh External custom marshaller. - * @param clsLdr External class loader to post-unmarshall. + * @param marsh Marshaller for post-unmarshalling. + * @param clsLdr Class loader for unmarshalling. */ public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException; } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index 36f945d94274a..43c35eb752130 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -22,17 +22,17 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.jetbrains.annotations.Nullable; -/** Marshalling logic for cache-object fields in a {@link Message}. */ +/** Handles {@code prepareMarshal}/{@code finishUnmarshal} for a {@link Message} type that requires custom serialization. */ public interface MessageMarshaller { - /** Marshals cache-object fields on the user thread. */ + /** Pre-marshals the message on the user thread before sending. */ public void prepareMarshal(M msg, GridKernalContext kctx, @Nullable GridCacheContext nested) throws IgniteCheckedException; - /** Unmarshals cache-object fields with full cache context and class loader. */ + /** Post-unmarshals the message with full cache context and class loader. */ public void finishUnmarshal(M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException; - /** Unmarshals message fields without a cache context. */ + /** Post-unmarshals message fields that do not require a cache context. */ public void finishUnmarshal(M msg, GridKernalContext kctx) throws IgniteCheckedException; /** Unmarshals only {@code @NioField}-annotated fields in the NIO/IO thread. No-op by default. */ diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/NonMarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/NonMarshallableMessage.java index d2699d2f915a7..8be7c31bd8211 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/NonMarshallableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/NonMarshallableMessage.java @@ -17,6 +17,6 @@ package org.apache.ignite.plugin.extensions.communication; -/** */ +/** Marker interface: no {@link MessageMarshaller} is generated for implementing classes. */ public interface NonMarshallableMessage extends Message { } From 1a77a5b0f09cabf2ae25414f46ae1f8ff79129e8 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 03:43:38 +0300 Subject: [PATCH 160/215] WIP --- .../processors/query/calcite/message/GenericValueMessage.java | 4 ++-- .../processors/query/calcite/message/QueryStartRequest.java | 4 ++-- .../ignite/internal/processors/cache/GridCacheEntryInfo.java | 4 ++-- .../ignite/internal/processors/cache/GridCacheReturn.java | 4 ++-- .../distributed/dht/atomic/GridDhtAtomicUpdateRequest.java | 4 ++-- .../dht/atomic/GridNearAtomicFullUpdateRequest.java | 4 ++-- .../dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java | 4 ++-- .../dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java | 4 ++-- .../dht/preloader/GridDhtPartitionsFullMessage.java | 4 ++-- .../dht/preloader/GridDhtPartitionsSingleMessage.java | 4 ++-- .../processors/cache/query/GridCacheQueryRequest.java | 4 ++-- .../internal/processors/cache/transactions/IgniteTxEntry.java | 4 ++-- .../processors/rest/handlers/task/GridTaskResultResponse.java | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java index 7587aa6be062b..8a2ceea7f1965 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java @@ -21,10 +21,10 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** */ -public final class GenericValueMessage implements CacheMarshallableMessage { +public final class GenericValueMessage implements MarshallableMessage { /** */ private Object val; diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java index 61289af51d0c1..0b6ca25f9dbdb 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java @@ -26,13 +26,13 @@ import org.apache.ignite.internal.processors.query.calcite.metadata.FragmentDescription; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * */ -public class QueryStartRequest implements CacheMarshallableMessage, ExecutionContextAware { +public class QueryStartRequest implements MarshallableMessage, ExecutionContextAware { /** */ @Order(0) String schema; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java index e63ec515d3b9a..293db4c0241b8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java @@ -25,12 +25,12 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * Entry information that gets passed over wire. */ -public class GridCacheEntryInfo implements CacheMarshallableMessage, CacheIdAware { +public class GridCacheEntryInfo implements MarshallableMessage, CacheIdAware { /** */ private static final int SIZE_OVERHEAD = 3 * 8 /* reference */ + 4 /* int */ + 2 * 8 /* long */ + 32 /* version */; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index 3770aacc77e2c..dbf7758971436 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -33,13 +33,13 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Return value for cases where both, value and success flag need to be returned. */ -public class GridCacheReturn implements CacheMarshallableMessage, CacheIdAware { +public class GridCacheReturn implements MarshallableMessage, CacheIdAware { /** Value. */ @GridToStringInclude(sensitive = true) private volatile Object v; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index a18e91f4f7d73..e2a248c2c9566 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -37,14 +37,14 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Lite dht cache backup update request. */ -public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements CacheMarshallableMessage { +public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements MarshallableMessage { /** Keys to update. */ @GridToStringInclude @Order(0) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index af9e873d61660..e82be8499ef99 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -42,7 +42,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,7 +53,7 @@ /** * Lite DHT cache update request sent from near node to primary node. */ -public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements CacheMarshallableMessage { +public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements MarshallableMessage { /** Keys to update. */ @Order(0) @GridToStringInclude diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java index f9ef62894fdd8..523b3341c4f6d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java @@ -27,14 +27,14 @@ import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * */ -public class GridNearAtomicSingleUpdateFilterRequest extends GridNearAtomicSingleUpdateRequest implements CacheMarshallableMessage { +public class GridNearAtomicSingleUpdateFilterRequest extends GridNearAtomicSingleUpdateRequest implements MarshallableMessage { /** Filter. */ @Order(0) CacheEntryPredicate[] filter; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index 7f99ec4b04f98..e98035f795a3d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -36,7 +36,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -45,7 +45,7 @@ /** * */ -public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest implements CacheMarshallableMessage { +public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest implements MarshallableMessage { /** Optional arguments for entry processor. */ private @Nullable Object[] invokeArgs; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index 00473e4898074..6cce1a2ac30ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -40,7 +40,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -49,7 +49,7 @@ * GridDhtPartitionsSingleMessage}s were received.
May be also compacted as part of {@link * CacheAffinityChangeMessage} for node left or failed case.
*/ -public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessage implements CacheMarshallableMessage { +public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { /** */ private static final byte REBALANCED_FLAG_MASK = 0x01; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index 50dbf868f20fc..89a0d7f22d0db 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -31,7 +31,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** @@ -39,7 +39,7 @@ * * Sent in response to {@link GridDhtPartitionsSingleRequest} and during processing partitions exchange future. */ -public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements CacheMarshallableMessage { +public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { /** Local partitions. */ @Order(0) @Compress diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 9c980e4b23587..ad1117edeb1a8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -34,7 +34,7 @@ import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgniteReducer; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.INDEX; @@ -44,7 +44,7 @@ /** * Query request. */ -public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, CacheMarshallableMessage { +public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, MarshallableMessage { /** */ private static final int FLAG_DATA_PAGE_SCAN_DFLT = 0b00; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index c9341ef7c547f..1883734d6883c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -48,7 +48,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; @@ -60,7 +60,7 @@ * {@link #equals(Object)} method, as transaction entries should use referential * equality. */ -public class IgniteTxEntry implements GridPeerDeployAware, CacheMarshallableMessage, CacheIdAware { +public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, CacheIdAware { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java index 11a5182de4301..3661cae983735 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -21,13 +21,13 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Task result response. */ -public class GridTaskResultResponse implements CacheMarshallableMessage { +public class GridTaskResultResponse implements MarshallableMessage { /** Result. */ public @Nullable Object res; From 2aa54c9d8315661c0e106a16c3b42f5be35ef03f Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 04:26:54 +0300 Subject: [PATCH 161/215] WIP --- .../processors/cache/GridCacheReturn.java | 17 +--- .../GridDistributedTxPrepareRequest.java | 39 ++++----- .../distributed/dht/GridDhtLockRequest.java | 17 +--- ...idNearAtomicSingleUpdateFilterRequest.java | 16 +--- .../distributed/near/GridNearGetRequest.java | 39 +++------ .../near/GridNearTxPrepareResponse.java | 47 ++++++----- .../cache/transactions/TxLocksRequest.java | 27 +++--- .../cache/transactions/TxLocksResponse.java | 82 +++++++++--------- .../communication/MessageMarshaller.java | 84 +++++++++++++++++-- 9 files changed, 198 insertions(+), 170 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java index dbf7758971436..a98d9b0e24158 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.Map; import javax.cache.processor.EntryProcessorResult; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.UnregisteredBinaryTypeException; @@ -31,15 +30,14 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; /** * Return value for cases where both, value and success flag need to be returned. */ -public class GridCacheReturn implements MarshallableMessage, CacheIdAware { +public class GridCacheReturn implements Message, CacheIdAware { /** Value. */ @GridToStringInclude(sensitive = true) private volatile Object v; @@ -347,17 +345,6 @@ public void marshalResult(GridCacheContext ctx) { } } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - // Mark the message as local — it has arrived at the target node. - loc = true; - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridCacheReturn.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index c65c1a43b1bae..405803a0193ec 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -38,7 +38,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; @@ -47,7 +47,7 @@ * Transaction prepare request for optimistic and eventually consistent * transactions. */ -public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage implements IgniteTxStateAware, CacheMarshallableMessage { +public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage implements IgniteTxStateAware, MarshallableMessage { /** */ private static final int NEED_RETURN_VALUE_FLAG_MASK = 0x01; @@ -105,11 +105,11 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage @GridToStringInclude private Map dhtVers; - /** */ + /** Wire-protocol keys for {@link #dhtVers}. */ @Order(7) public Collection dhtVerKeys; - /** */ + /** Wire-protocol values for {@link #dhtVers}. */ @Order(8) public Collection dhtVerVals; @@ -254,6 +254,22 @@ public void addDhtVersion(IgniteTxKey key, @Nullable GridCacheVersion dhtVer) { * @return Map of versions to be verified. */ public Map dhtVersions() { + if (dhtVerKeys != null && dhtVers == null) { + assert dhtVerVals != null; + assert dhtVerKeys.size() == dhtVerVals.size(); + + Iterator keyIt = dhtVerKeys.iterator(); + Iterator verIt = dhtVerVals.iterator(); + + dhtVers = U.newHashMap(dhtVerKeys.size()); + + while (keyIt.hasNext()) + dhtVers.put(keyIt.next(), verIt.next()); + + dhtVerKeys = null; + dhtVerVals = null; + } + return dhtVers == null ? Collections.emptyMap() : dhtVers; } @@ -423,21 +439,6 @@ private boolean isFlag(int mask) { /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (dhtVerKeys != null && dhtVers == null) { - assert dhtVerVals != null; - assert dhtVerKeys.size() == dhtVerVals.size(); - - Iterator keyIt = dhtVerKeys.iterator(); - Iterator verIt = dhtVerVals.iterator(); - - dhtVers = U.newHashMap(dhtVerKeys.size()); - - while (keyIt.hasNext()) { - IgniteTxKey key = keyIt.next(); - - dhtVers.put(key, verIt.next()); - } - } } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 68733f968e78b..4a0f7471fafe0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -32,7 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,7 +40,7 @@ /** * DHT lock request. */ -public class GridDhtLockRequest extends GridDistributedLockRequest implements CacheMarshallableMessage { +public class GridDhtLockRequest extends GridDistributedLockRequest implements MarshallableMessage { /** Invalidate reader flags. */ @Order(0) BitSet invalidateEntries; @@ -53,12 +53,12 @@ public class GridDhtLockRequest extends GridDistributedLockRequest implements Ca @GridToStringInclude private Map owned; - /** Array of keys from {@link #owned}. Used during marshalling and unmarshalling. */ + /** Wire-protocol keys for {@link #owned}. */ @Order(2) @GridToStringExclude KeyCacheObject[] ownedKeys; - /** Array of values from {@link #owned}. Used during marshalling and unmarshalling. */ + /** Wire-protocol values for {@link #owned}. */ @Order(3) @GridToStringExclude GridCacheVersion[] ownedValues; @@ -279,15 +279,6 @@ public long accessTtl() { /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (ownedKeys != null) { - owned = new GridLeanMap<>(ownedKeys.length); - - for (int i = 0; i < ownedKeys.length; i++) - owned.put(ownedKeys[i], ownedValues[i]); - - ownedKeys = null; - ownedValues = null; - } } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java index 523b3341c4f6d..d5bdab4971dce 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java @@ -19,22 +19,19 @@ import java.util.Arrays; import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * */ -public class GridNearAtomicSingleUpdateFilterRequest extends GridNearAtomicSingleUpdateRequest implements MarshallableMessage { +public class GridNearAtomicSingleUpdateFilterRequest extends GridNearAtomicSingleUpdateRequest { /** Filter. */ @Order(0) CacheEntryPredicate[] filter; @@ -91,17 +88,6 @@ public GridNearAtomicSingleUpdateFilterRequest() { return filter; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (filter != null && filter.length == 0) - filter = null; - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearAtomicSingleUpdateFilterRequest.class, this, "filter", Arrays.toString(filter), diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index 4ffada383bb94..925442c71ced2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -37,15 +37,13 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Get request. Responsible for obtaining entry from primary node. 'Near' means 'Initiating node' here, not 'Near Cache'. */ -public class GridNearGetRequest extends GridCacheIdMessage implements GridCacheDeployable, GridCacheVersionable, CacheMarshallableMessage { +public class GridNearGetRequest extends GridCacheIdMessage implements GridCacheDeployable, GridCacheVersionable { /** */ private static final int READ_THROUGH_FLAG_MASK = 0x01; @@ -216,6 +214,18 @@ public int taskNameHash() { * @return Keys. */ public LinkedHashMap keyMap() { + if (keyMap == null && !F.isEmpty(keys)) { + keyMap = U.newLinkedHashMap(keys.size()); + + Iterator keysIt = keys.iterator(); + + for (int i = 0; i < keys.size(); i++) { + Boolean addRdr = readersFlags != null ? readersFlags.get(i) : Boolean.FALSE; + + keyMap.put(keysIt.next(), addRdr); + } + } + return keyMap; } @@ -302,29 +312,6 @@ public long accessTtl() { return addDepInfo; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - assert !F.isEmpty(keys); - assert readersFlags == null || keys.size() == readersFlags.size(); - - if (keyMap == null) { - keyMap = U.newLinkedHashMap(keys.size()); - - Iterator keysIt = keys.iterator(); - - for (int i = 0; i < keys.size(); i++) { - Boolean addRdr = readersFlags != null ? readersFlags.get(i) : Boolean.FALSE; - - keyMap.put(keysIt.next(), addRdr); - } - } - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearGetRequest.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index b914ea44dcdfe..483ebf40e5d29 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -36,13 +36,13 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Near cache prepare response. */ -public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse implements CacheMarshallableMessage { +public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse implements MarshallableMessage { /** Versions that are less than lock version ({@link #version()}). */ @GridToStringInclude @Order(0) @@ -68,11 +68,11 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse @GridToStringInclude private Map ownedVals; - /** OwnedVals' keys for marshalling. */ + /** Wire-protocol keys for {@link #ownedVals}. */ @Order(5) @Nullable Collection ownedValKeys; - /** OwnedVals' values for marshalling. */ + /** Wire-protocol values for {@link #ownedVals}. */ @Order(6) @Nullable Collection ownedValVals; @@ -205,6 +205,8 @@ public void addOwnedValue(IgniteTxKey key, GridCacheVersion ver, CacheObject val * @return Map of owned values to set on near node. */ public Map ownedValues() { + rebuildOwnedValsIfNeeded(); + return ownedVals == null ? Collections.emptyMap() : Collections.unmodifiableMap(ownedVals); } @@ -232,9 +234,27 @@ public void filterFailedKeys(@Nullable Collection filterFailedKeys) * @return {@code True} if response has owned value for given key. */ public boolean hasOwnedValue(IgniteTxKey key) { + rebuildOwnedValsIfNeeded(); + return F.mapContainsKey(ownedVals, key); } + /** */ + private void rebuildOwnedValsIfNeeded() { + if (ownedValKeys != null && ownedVals == null) { + ownedVals = U.newHashMap(ownedValKeys.size()); + + Iterator keyIter = ownedValKeys.iterator(); + Iterator valIter = ownedValVals.iterator(); + + while (keyIter.hasNext()) + ownedVals.put(keyIter.next(), valIter.next()); + + ownedValKeys = null; + ownedValVals = null; + } + } + /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { if (ownedVals != null && ownedValKeys == null) { @@ -246,25 +266,8 @@ public boolean hasOwnedValue(IgniteTxKey key) { /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (ownedValKeys != null && ownedVals == null) { - ownedVals = U.newHashMap(ownedValKeys.size()); - - assert ownedValKeys.size() == ownedValVals.size(); - - Iterator keyIter = ownedValKeys.iterator(); - - Iterator valIter = ownedValVals.iterator(); - - while (keyIter.hasNext()) { - IgniteTxKey key = keyIter.next(); - - CacheVersionedValue val = valIter.next(); - - ownedVals.put(key, val); - } - } } - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearTxPrepareResponse.class, this, "super", super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java index 499d9557e90d2..5ac8a1941875f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java @@ -28,12 +28,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * Transactions lock list request. */ -public class TxLocksRequest extends GridCacheMessage implements CacheMarshallableMessage { +public class TxLocksRequest extends GridCacheMessage implements MarshallableMessage { /** Future ID. */ @Order(0) long futId; @@ -42,7 +42,7 @@ public class TxLocksRequest extends GridCacheMessage implements CacheMarshallabl @GridToStringInclude private Set txKeys; - /** Array of txKeys from {@link #txKeys}. Used during marshalling and unmarshalling. */ + /** Wire-protocol array for {@link #txKeys}. */ @GridToStringExclude @Order(1) IgniteTxKey[] txKeysArr; @@ -76,9 +76,22 @@ public long futureId() { * @return Tx keys. */ public Collection txKeys() { + if (txKeys == null && txKeysArr != null) { + txKeys = U.newHashSet(txKeysArr.length); + + for (IgniteTxKey key : txKeysArr) + txKeys.add(key); + + txKeysArr = null; + } + return txKeys; } + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(TxLocksRequest.class, this); @@ -98,12 +111,4 @@ public Collection txKeys() { for (IgniteTxKey key : txKeys) txKeysArr[i++] = key; } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - txKeys = U.newHashSet(txKeysArr.length); - - for (IgniteTxKey key : txKeysArr) - txKeys.add(key); - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index fde78bec7bbe2..c9c0e1dbe90fe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -31,12 +31,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * Transactions lock list response. */ -public class TxLocksResponse extends GridCacheMessage implements CacheMarshallableMessage { +public class TxLocksResponse extends GridCacheMessage implements MarshallableMessage { /** Future ID. */ @Order(0) long futId; @@ -49,17 +49,17 @@ public class TxLocksResponse extends GridCacheMessage implements CacheMarshallab @GridToStringInclude private Set txKeys; - /** Array of txKeys from {@link #nearTxKeyLocks}. Used during marshalling and unmarshalling. */ + /** Wire-protocol array of keys from {@link #nearTxKeyLocks}. */ @GridToStringExclude @Order(1) IgniteTxKey[] nearTxKeysArr; - /** Array of txKeys from {@link #txKeys}. Used during marshalling and unmarshalling. */ + /** Wire-protocol array for {@link #txKeys}. */ @GridToStringExclude @Order(2) IgniteTxKey[] txKeysArr; - /** Array of locksArr from {@link #nearTxKeyLocks}. Used during marshalling and unmarshalling. */ + /** Wire-protocol array of values from {@link #nearTxKeyLocks}. */ @GridToStringExclude @Order(3) List[] locksArr; @@ -86,9 +86,25 @@ public void futureId(long futId) { } /** - * @return Lock lists for all tx nearTxKeysArr. + * @return Lock lists for all near tx keys. */ public Map> txLocks() { + if (nearTxKeysArr != null) { + for (int i = 0; i < nearTxKeysArr.length; i++) { + IgniteTxKey txKey = nearTxKeysArr[i]; + + try { + nearTxKeyLocks.put(txKey, locksArr[i]); + } + catch (IllegalStateException ignored) { + // Skipping entries for missed cache. + } + } + + nearTxKeysArr = null; + locksArr = null; + } + return nearTxKeyLocks; } @@ -97,7 +113,7 @@ public Map> txLocks() { * @return Lock list for given tx key. */ public List txLocks(IgniteTxKey txKey) { - return nearTxKeyLocks.get(txKey); + return txLocks().get(txKey); } /** @@ -114,6 +130,21 @@ public void addTxLock(IgniteTxKey txKey, TxLock txLock) { * @return Remote txKeys involved into tx. */ public Set keys() { + if (txKeysArr != null) { + txKeys = U.newHashSet(txKeysArr.length); + + for (IgniteTxKey txKey : txKeysArr) { + try { + txKeys.add(txKey); + } + catch (IllegalStateException ignored) { + // Skipping entries for removed cache. + } + } + + txKeysArr = null; + } + return txKeys; } @@ -132,6 +163,10 @@ public void addKey(IgniteTxKey key) { return addDepInfo; } + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(TxLocksResponse.class, this); @@ -167,37 +202,4 @@ public void addKey(IgniteTxKey key) { } } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (nearTxKeysArr != null) { - for (int i = 0; i < nearTxKeysArr.length; i++) { - IgniteTxKey txKey = nearTxKeysArr[i]; - - try { - txLocks().put(txKey, locksArr[i]); - } - catch (IllegalStateException ignored) { - // Skipping entries for missed cache. - } - } - - nearTxKeysArr = null; - locksArr = null; - } - - if (txKeysArr != null) { - txKeys = U.newHashSet(txKeysArr.length); - - for (IgniteTxKey txKey : txKeysArr) { - try { - txKeys.add(txKey); - } - catch (IllegalStateException ignored) { - // Skipping entries for removed cache. - } - } - - txKeysArr = null; - } - } } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index 43c35eb752130..2bf108b4606e6 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -22,24 +22,63 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.jetbrains.annotations.Nullable; -/** Handles {@code prepareMarshal}/{@code finishUnmarshal} for a {@link Message} type that requires custom serialization. */ +/** + * Handles {@code prepareMarshal}/{@code finishUnmarshal} for a {@link Message} type that requires custom serialization. + * + * @param Message type. + */ public interface MessageMarshaller { - /** Pre-marshals the message on the user thread before sending. */ + /** + * Pre-marshals the message on the user thread before sending. + * + * @param msg Message to marshal. + * @param kctx Kernal context. + * @param nested Nested cache context, or {@code null} if not applicable. + * @throws IgniteCheckedException If marshalling failed. + */ public void prepareMarshal(M msg, GridKernalContext kctx, @Nullable GridCacheContext nested) throws IgniteCheckedException; - /** Post-unmarshals the message with full cache context and class loader. */ + /** + * Post-unmarshals the message with full cache context and class loader. + * + * @param msg Message to unmarshal. + * @param kctx Kernal context. + * @param nested Nested cache context, or {@code null} if not applicable. + * @param clsLdr Class loader for unmarshalling. + * @throws IgniteCheckedException If unmarshalling failed. + */ public void finishUnmarshal(M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException; - /** Post-unmarshals message fields that do not require a cache context. */ + /** + * Post-unmarshals message fields that do not require a cache context. + * + * @param msg Message to unmarshal. + * @param kctx Kernal context. + * @throws IgniteCheckedException If unmarshalling failed. + */ public void finishUnmarshal(M msg, GridKernalContext kctx) throws IgniteCheckedException; - /** Unmarshals only {@code @NioField}-annotated fields in the NIO/IO thread. No-op by default. */ + /** + * Unmarshals only {@code @NioField}-annotated fields in the NIO/IO thread. No-op by default. + * + * @param msg Message to unmarshal. + * @param kctx Kernal context. + * @throws IgniteCheckedException If unmarshalling failed. + */ default void finishUnmarshalNio(M msg, GridKernalContext kctx) throws IgniteCheckedException { } - /** Null-safe {@code finishUnmarshalNio} — skips when no marshaller is registered. */ + /** + * Null-safe {@code finishUnmarshalNio} — skips when no marshaller is registered. + * + * @param Message type. + * @param factory Message factory. + * @param msg Message to unmarshal. + * @param kctx Kernal context. + * @throws IgniteCheckedException If unmarshalling failed. + */ static void finishUnmarshalNio( MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { @@ -49,7 +88,16 @@ static void finishUnmarshalNio( m.finishUnmarshalNio(msg, kctx); } - /** Null-safe {@code prepareMarshal} — skips when no marshaller is registered. */ + /** + * Null-safe {@code prepareMarshal} — skips when no marshaller is registered. + * + * @param Message type. + * @param factory Message factory. + * @param msg Message to marshal. + * @param kctx Kernal context. + * @param nested Nested cache context, or {@code null} if not applicable. + * @throws IgniteCheckedException If marshalling failed. + */ static void prepareMarshal( MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested) throws IgniteCheckedException { @@ -59,7 +107,17 @@ static void prepareMarshal( m.prepareMarshal(msg, kctx, nested); } - /** Null-safe {@code finishUnmarshal} — skips when no marshaller is registered. */ + /** + * Null-safe {@code finishUnmarshal} — skips when no marshaller is registered. + * + * @param Message type. + * @param factory Message factory. + * @param msg Message to unmarshal. + * @param kctx Kernal context. + * @param nested Nested cache context, or {@code null} if not applicable. + * @param clsLdr Class loader for unmarshalling. + * @throws IgniteCheckedException If unmarshalling failed. + */ static void finishUnmarshal( MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { @@ -69,7 +127,15 @@ static void finishUnmarshal( m.finishUnmarshal(msg, kctx, nested, clsLdr); } - /** Null-safe {@code finishUnmarshal} (cache-free) — skips when no marshaller is registered. */ + /** + * Null-safe {@code finishUnmarshal} (cache-free) — skips when no marshaller is registered. + * + * @param Message type. + * @param factory Message factory. + * @param msg Message to unmarshal. + * @param kctx Kernal context. + * @throws IgniteCheckedException If unmarshalling failed. + */ static void finishUnmarshal( MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { From 20cb63efa59af72c22a523106ae37be32adcff8a Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 10:41:08 +0300 Subject: [PATCH 162/215] WIP --- .../org/apache/ignite/internal/MessageMarshallerGenerator.java | 2 +- .../dht/preloader/GridDhtPartitionsSingleMessage.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 9d49bf2544dd1..bc8b61a0aa303 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -254,7 +254,7 @@ private void generateFinishUnmarshalMethod(String methodName, String params, Lis appendFields(body, fields, mode); if (marshallable) { - if (mode == MarshalMode.FINISH_CACHE) + if (mode == MarshalMode.FINISH_CACHE && cacheMarshallable) appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);"))); else if (mode == MarshalMode.FINISH && !cacheMarshallable) appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));"))); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index 89a0d7f22d0db..ff9f2016f3464 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -318,7 +318,7 @@ public void exchangeStartTime(long exchangeStartTime) { } } } - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtPartitionsSingleMessage.class, this, super.toString()); From 623469a0362a65f33f5e116955c702a479f93b9d Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 10:45:33 +0300 Subject: [PATCH 163/215] WIP --- .../internal/processors/cache/verify/PartitionHashRecord.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java index 766ab1752e55c..0b0a28a6298a2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java @@ -265,7 +265,7 @@ public void hasExpiringEntries(boolean hasExpiringEntries) { if (updateCntrBytes != null) updateCntr = U.unmarshal(marsh, updateCntrBytes, clsLdr); - consistentId = null; + consistentIdBytes = null; updateCntrBytes = null; } From f4a4cd23c91987cc22f360eec2f21d8d64fdf9f3 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 11:25:11 +0300 Subject: [PATCH 164/215] WIP --- .../apache/ignite/internal/Marshalled.java | 34 ++++++++++ .../internal/MessageMarshallerGenerator.java | 62 ++++++++++++++++++- ...actMarshallableMessageFactoryProvider.java | 4 +- .../cache/DynamicCacheChangeRequest.java | 44 +++---------- .../processors/cache/StoredCacheData.java | 39 +++--------- .../binary/BinaryMetadataVersionInfo.java | 28 ++------- .../binary/MetadataUpdateProposedMessage.java | 24 ++----- .../cache/verify/PartitionHashRecord.java | 33 ++-------- .../cache/verify/TransactionsHashRecord.java | 24 ++----- .../cluster/ChangeGlobalStateMessage.java | 24 ++----- .../SchemaAddQueryEntityOperation.java | 26 ++------ .../service/ServiceDeploymentRequest.java | 24 ++----- .../ignite/spi/discovery/ObjectData.java | 25 ++------ 13 files changed, 150 insertions(+), 241 deletions(-) create mode 100644 modules/codegen/src/main/java/org/apache/ignite/internal/Marshalled.java diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/Marshalled.java b/modules/codegen/src/main/java/org/apache/ignite/internal/Marshalled.java new file mode 100644 index 0000000000000..88faa98116132 --- /dev/null +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/Marshalled.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marks a {@code byte[]} field as a wire-protocol buffer for a companion object field named by {@link #value()}. + * The code generator emits {@code U.marshal}/{@code U.unmarshal} calls in the {@code *Marshaller} class. + */ +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface Marshalled { + /** Companion object field whose value is serialized into / deserialized from this byte buffer. */ + String value(); +} diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index bc8b61a0aa303..c5015c2b0ce05 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -22,6 +22,7 @@ import java.io.Writer; import java.util.ArrayList; import java.util.List; +import java.util.function.BiFunction; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.QualifiedNameable; @@ -80,6 +81,9 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** Whether the current message type implements {@code CacheMarshallableMessage}. */ private boolean cacheMarshallable; + /** Whether the current message type has any {@code @Marshalled} fields. */ + private boolean hasMarshalled; + /** */ MessageMarshallerGenerator(ProcessingEnvironment env) { super(env); @@ -109,6 +113,7 @@ public class MessageMarshallerGenerator extends MessageGenerator { @Override void generateBody(List fields) throws Exception { marshallable = marshallableMsgType != null && assignableFrom(type.asType(), marshallableMsgType); cacheMarshallable = cacheMarshallableMsgType != null && assignableFrom(type.asType(), cacheMarshallableMsgType); + hasMarshalled = fields.stream().anyMatch(f -> f.getAnnotation(Marshalled.class) != null); indent = 1; @@ -122,7 +127,7 @@ public class MessageMarshallerGenerator extends MessageGenerator { imports.add(type.toString()); imports.add("org.apache.ignite.plugin.extensions.communication.MessageMarshaller"); - if (marshallable) + if (marshallable || hasMarshalled) imports.add("org.apache.ignite.marshaller.Marshaller"); writeClassHeader(writer, "MessageMarshaller", marshallerClsName); @@ -145,7 +150,7 @@ private void writeConstructor(Writer writer, String marshallerClsName) throws IO writer.write(indentedLine(METHOD_JAVADOC)); writer.write(NL); - if (marshallable) { + if (marshallable || hasMarshalled) { writer.write(indentedLine("private final Marshaller marshaller;")); writer.write(NL + NL); @@ -190,6 +195,8 @@ private void generatePrepareMarshalMethod(List orderedFields) { if (needsCtx(orderedFields)) appendBlock(body, List.of(ctxResolutionLine())); + appendMarshalledPrepare(body, orderedFields); + if (marshallable) appendBlock(body, List.of(indentedLine("msg.prepareMarshal(marshaller);"))); @@ -260,6 +267,9 @@ else if (mode == MarshalMode.FINISH && !cacheMarshallable) appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));"))); } + if (mode == MarshalMode.FINISH) + appendMarshalledFinish(body, fields); + marshall.addAll(body); indent--; @@ -467,6 +477,54 @@ private List marshallMap(DeclaredType t, String accessor, MarshalMode mo return wrapNullGuarded(accessor, combined); } + /** Generates {@code U.marshal} calls for all {@code @Marshalled} fields in prepareMarshal. */ + private void appendMarshalledPrepare(List body, List fields) { + forEachMarshalled(fields, (bytesAcc, objAcc) -> { + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null)", objAcc)); + + indent++; + + code.add(indentedLine("%s = U.marshal(marshaller, %s);", bytesAcc, objAcc)); + + indent--; + + return code; + }, body); + } + + private void appendMarshalledFinish(List body, List fields) { + forEachMarshalled(fields, (bytesAcc, objAcc) -> { + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null) {", bytesAcc)); + + indent++; + + code.add(indentedLine("%s = U.unmarshal(marshaller, %s, U.resolveClassLoader(kctx.config()));", objAcc, bytesAcc)); + + code.add(indentedLine("%s = null;", bytesAcc)); + + indent--; + + code.add(indentedLine("}")); + + return code; + }, body); + } + + private void forEachMarshalled(List fields, BiFunction> codeGen, List body) { + for (VariableElement field : fields) { + Marshalled ann = field.getAnnotation(Marshalled.class); + + if (ann == null) + continue; + + appendBlock(body, codeGen.apply("msg." + field.getSimpleName(), "msg." + ann.value())); + } + } + /** Returns empty if {@code inner} is empty. */ private List wrapNullGuarded(String nullGuard, List inner) { if (inner.isEmpty()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java index 5916292ceef82..625be4d1d3b1d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java @@ -66,9 +66,9 @@ protected static void register(MessageFactory factory, Class if (!NonMarshallableMessage.class.isAssignableFrom(cls)) { Class marshallerCls = Class.forName(cls.getName() + "Marshaller"); - boolean marshallable = MarshallableMessage.class.isAssignableFrom(cls); + boolean needsMarsh = marshallerCls.getConstructors()[0].getParameterCount() > 0; - marshaller = marshallable + marshaller = needsMarsh ? (MessageMarshaller)marshallerCls.getConstructor(Marshaller.class).newInstance(marsh) : (MessageMarshaller)marshallerCls.getConstructor().newInstance(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java index 68d0c8f07fd0a..952c4ed235584 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java @@ -19,25 +19,23 @@ import java.io.Serializable; import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.CoreMessagesProvider; import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.query.QuerySchema; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.typedef.T2; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; /** * Cache start/stop request. */ -public class DynamicCacheChangeRequest implements MarshallableMessage, Serializable { +public class DynamicCacheChangeRequest implements Message, Serializable { /** */ private static final long serialVersionUID = 0L; @@ -56,10 +54,10 @@ public class DynamicCacheChangeRequest implements MarshallableMessage, Serializa /** Cache start configuration. */ @GridToStringExclude - private CacheConfiguration startCfg; + CacheConfiguration startCfg; - /** Bytes of {@link #startCfg}. */ @Order(3) + @Marshalled("startCfg") byte[] cfgBytes; /** Cache type. */ @@ -72,10 +70,10 @@ public class DynamicCacheChangeRequest implements MarshallableMessage, Serializa /** Near cache configuration. */ @GridToStringExclude - private NearCacheConfiguration nearCacheCfg; + NearCacheConfiguration nearCacheCfg; - /** Bytes of {@link #nearCacheCfg}. */ @Order(6) + @Marshalled("nearCacheCfg") byte[] nearCfgBytes; /** Start only client cache, do not start data nodes. */ @@ -125,8 +123,8 @@ public class DynamicCacheChangeRequest implements MarshallableMessage, Serializa /** Dynamic schema. */ QuerySchema schema; - /** Bytes of {@link #schema}. */ @Order(18) + @Marshalled("schema") byte[] schemaBytes; /** Is transient. */ @@ -166,32 +164,6 @@ public DynamicCacheChangeRequest(UUID reqId, String cacheName, UUID initiatingNo this.initiatingNodeId = initiatingNodeId; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - cfgBytes = U.marshal(marsh, startCfg); - - if (nearCacheCfg != null) - nearCfgBytes = U.marshal(marsh, nearCacheCfg); - - if (schema != null) - schemaBytes = U.marshal(marsh, schema); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - startCfg = U.unmarshal(marsh, cfgBytes, clsLdr); - - if (nearCfgBytes != null) - nearCacheCfg = U.unmarshal(marsh, nearCfgBytes, clsLdr); - - if (schemaBytes != null) - schema = U.unmarshal(marsh, schemaBytes, clsLdr); - - cfgBytes = null; - nearCfgBytes = null; - schemaBytes = null; - } - /** * @param ctx Context. * @param cacheName Cache name. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java index 0f2e83c1fbbe7..ab530f73d9632 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java @@ -19,10 +19,10 @@ import java.io.Serializable; import java.util.Collection; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cdc.CdcCacheEvent; import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.encryption.GroupKeyEncrypted; import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager; @@ -31,10 +31,8 @@ import org.apache.ignite.internal.util.typedef.internal.A; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; /** @@ -45,24 +43,24 @@ *

* All changes must be made with the respect of RU rules. */ -public class StoredCacheData implements Serializable, CdcCacheEvent, MarshallableMessage { +public class StoredCacheData implements Serializable, CdcCacheEvent, Message { /** */ private static final long serialVersionUID = 0L; /** Cache configuration. */ @GridToStringInclude - private CacheConfiguration ccfg; + CacheConfiguration ccfg; - /** Serialized {@link #ccfg}. */ @Order(0) + @Marshalled("ccfg") transient byte[] ccfgBytes; /** Query entities. */ @GridToStringInclude - private Collection qryEntities; + Collection qryEntities; - /** Serialized {@link #qryEntities}. */ @Order(1) + @Marshalled("qryEntities") transient byte[] qryEntitiesBytes; /** SQL flag - {@code true} if cache was created with {@code CREATE TABLE}. */ @@ -224,27 +222,4 @@ public StoredCacheData withSplittedCacheConfig(CacheConfigurationSplitter splitt return ccfg; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (ccfg != null) - ccfgBytes = U.marshal(marsh, ccfg); - - if (qryEntities != null) - qryEntitiesBytes = U.marshal(marsh, qryEntities); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (ccfgBytes != null) { - ccfg = U.unmarshal(marsh, ccfgBytes, clsLdr); - - ccfgBytes = null; - } - - if (qryEntitiesBytes != null) { - qryEntities = U.unmarshal(marsh, qryEntitiesBytes, clsLdr); - - qryEntitiesBytes = null; - } - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java index 6fc0c20042832..ca86abbe4e4f9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java @@ -17,12 +17,10 @@ package org.apache.ignite.internal.processors.cache.binary; import java.io.Serializable; -import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.binary.BinaryMetadata; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; /** * Wrapper for {@link BinaryMetadata} which is stored in metadata local cache on each node. @@ -30,15 +28,15 @@ * The version refers solely to the internal protocol for updating BinaryMetadata and is unknown externally. * It can be updated dynamically from different nodes and threads on the same node. */ -public final class BinaryMetadataVersionInfo implements Serializable, MarshallableMessage { +public final class BinaryMetadataVersionInfo implements Serializable, Message { /** */ private static final long serialVersionUID = 0L; /** The actual binary metadata. */ - private BinaryMetadata metadata; + BinaryMetadata metadata; - /** Serialized binary metadata. */ @Order(0) + @Marshalled("metadata") transient byte[] metadataBytes; /** @@ -129,22 +127,6 @@ boolean removing() { return removing; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (metadata != null) - metadataBytes = U.marshal(marsh, metadata); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (metadataBytes != null) { - metadata = U.unmarshal(marsh, metadataBytes, clsLdr); - - // It is not required anymore. - metadataBytes = null; - } - } - /** {@inheritDoc} */ @Override public String toString() { return "[typeId=" + metadata.typeId() + diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java index b11b45b5ac96a..36a4f65fdc4e7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java @@ -17,18 +17,16 @@ package org.apache.ignite.internal.processors.cache.binary; import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.binary.BinaryMetadata; import org.apache.ignite.internal.binary.BinaryMetadataHandler; import org.apache.ignite.internal.managers.communication.ErrorMessage; import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; /** @@ -73,16 +71,16 @@ * it gets blocked until {@link MetadataUpdateAcceptedMessage} arrives with accepted version * equals to pending version of this metadata to the moment when is was initially read by the thread. */ -public final class MetadataUpdateProposedMessage extends DiscoveryCustomMessage implements MarshallableMessage { +public final class MetadataUpdateProposedMessage extends DiscoveryCustomMessage implements Message { /** Node UUID which initiated metadata update. */ @Order(0) UUID origNodeId; /** */ - private BinaryMetadata metadata; + BinaryMetadata metadata; - /** Serialized {@link #metadata}. */ @Order(1) + @Marshalled("metadata") byte[] metadataBytes; /** Metadata type id. */ @@ -191,18 +189,6 @@ public int typeId() { return typeId; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (metadata != null) - metadataBytes = U.marshal(marsh, metadata); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader ldr) throws IgniteCheckedException { - if (metadataBytes != null) - metadata = U.unmarshal(marsh, metadataBytes, ldr); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(MetadataUpdateProposedMessage.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java index 0b0a28a6298a2..930f0ce1b712f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java @@ -18,8 +18,8 @@ import java.io.Serializable; import java.util.Objects; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.BinaryConfiguration; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.binary.GridBinaryMarshaller; import org.apache.ignite.internal.management.cache.PartitionKey; @@ -27,16 +27,14 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.jetbrains.annotations.Nullable; /** * Record containing partition checksum, primary flag and consistent ID of owner. */ -public class PartitionHashRecord implements MarshallableMessage, Serializable { +public class PartitionHashRecord implements Message, Serializable { /** */ private static final long serialVersionUID = 0L; @@ -56,9 +54,9 @@ public class PartitionHashRecord implements MarshallableMessage, Serializable { @GridToStringInclude Object consistentId; - /** Bytes of {@link #consistentId}. */ @Order(2) @GridToStringExclude + @Marshalled("consistentId") byte[] consistentIdBytes; /** Partition entries content hash. */ @@ -75,9 +73,9 @@ public class PartitionHashRecord implements MarshallableMessage, Serializable { @GridToStringInclude Object updateCntr; - /** Bytes of {@link #updateCntr}. */ @Order(5) @GridToStringExclude + @Marshalled("updateCntr") byte[] updateCntrBytes; /** Size. */ @@ -248,27 +246,6 @@ public void hasExpiringEntries(boolean hasExpiringEntries) { this.hasExpiringEntries = hasExpiringEntries; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (consistentId != null) - consistentIdBytes = U.marshal(marsh, consistentId); - - if (updateCntr != null) - updateCntrBytes = U.marshal(marsh, updateCntr); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (consistentIdBytes != null) - consistentId = U.unmarshal(marsh, consistentIdBytes, clsLdr); - - if (updateCntrBytes != null) - updateCntr = U.unmarshal(marsh, updateCntrBytes, clsLdr); - - consistentIdBytes = null; - updateCntrBytes = null; - } - /** {@inheritDoc} */ @Override public String toString() { return size == MOVING_PARTITION_SIZE ? diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java index 3b22bdf1862fa..281cbcc21be08 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java @@ -18,16 +18,14 @@ package org.apache.ignite.internal.processors.cache.verify; import java.io.Serializable; -import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; /** Represents committed transactions hash for a pair of nodes. */ -public class TransactionsHashRecord implements MarshallableMessage, Serializable { +public class TransactionsHashRecord implements Message, Serializable { /** */ private static final long serialVersionUID = 0L; @@ -35,16 +33,16 @@ public class TransactionsHashRecord implements MarshallableMessage, Serializable @GridToStringInclude Object locConsistentId; - /** Bytes of {@link #locConsistentId}. */ @Order(0) + @Marshalled("locConsistentId") transient byte[] locConsistentIdBytes; /** Consistent ID of remote node that participated in the transactions. */ @GridToStringInclude Object rmtConsistentId; - /** Bytes of {@link #rmtConsistentId}. */ @Order(1) + @Marshalled("rmtConsistentId") transient byte[] rmtConsistentIdBytes; /** Committed transactions IDs hash. */ @@ -64,18 +62,6 @@ public TransactionsHashRecord(Object locConsistentId, Object rmtConsistentId, in this.txHash = txHash; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - locConsistentIdBytes = U.marshal(marsh, locConsistentId); - rmtConsistentIdBytes = U.marshal(marsh, rmtConsistentId); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - locConsistentId = U.unmarshal(marsh, locConsistentIdBytes, clsLdr); - rmtConsistentId = U.unmarshal(marsh, rmtConsistentIdBytes, clsLdr); - } - /** @return Committed transactions IDs hash. */ public int transactionHash() { return txHash; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java index 9d0f56da5a5fe..7f444b6b400c9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java @@ -19,8 +19,8 @@ import java.util.List; import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cluster.ClusterState; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.discovery.DiscoCache; import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; @@ -31,16 +31,14 @@ import org.apache.ignite.internal.processors.service.ServiceDeploymentActions; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; /** * Message represent request for change cluster global state. */ -public class ChangeGlobalStateMessage extends DiscoveryCustomMessage implements MarshallableMessage { +public class ChangeGlobalStateMessage extends DiscoveryCustomMessage implements Message { /** Request ID */ @Order(0) UUID reqId; @@ -58,10 +56,10 @@ public class ChangeGlobalStateMessage extends DiscoveryCustomMessage implements List storedCfgs; /** */ - @Nullable private BaselineTopology baselineTopology; + @Nullable BaselineTopology baselineTopology; - /** JDK Serialized version of baselineTopology. */ @Order(4) + @Marshalled("baselineTopology") byte[] baselineTopologyBytes; /** */ @@ -221,18 +219,6 @@ public UUID requestId() { return reqId; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (baselineTopology != null) - baselineTopologyBytes = U.marshal(marsh, baselineTopology); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (baselineTopologyBytes != null) - baselineTopology = U.unmarshal(marsh, baselineTopologyBytes, clsLdr); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(ChangeGlobalStateMessage.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java index 3066afad53449..905abf8d42794 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java @@ -19,25 +19,23 @@ import java.util.Collection; import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; /** * Enabling indexing on cache operation. */ -public class SchemaAddQueryEntityOperation extends SchemaAbstractOperation implements MarshallableMessage { +public class SchemaAddQueryEntityOperation extends SchemaAbstractOperation implements Message { /** */ private static final long serialVersionUID = 0L; /** */ - private Collection entities; + Collection entities; - /** Serialized form of query entities. */ @Order(0) + @Marshalled("entities") transient byte[] qryEntitiesBytes; /** */ @@ -94,19 +92,5 @@ public boolean isSqlEscape() { return sqlEscape; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (entities != null) - qryEntitiesBytes = U.marshal(marsh, entities); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (qryEntitiesBytes != null) { - entities = U.unmarshal(marsh, qryEntitiesBytes, clsLdr); - - qryEntitiesBytes = null; - } - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java index 4d1813477ad91..552bf15a85d0a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java @@ -17,25 +17,23 @@ package org.apache.ignite.internal.processors.service; -import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.jetbrains.annotations.NotNull; /** * Service deployment request. */ -public class ServiceDeploymentRequest extends ServiceChangeAbstractRequest implements MarshallableMessage { +public class ServiceDeploymentRequest extends ServiceChangeAbstractRequest implements Message { /** Service configuration. */ - private LazyServiceConfiguration cfg; + LazyServiceConfiguration cfg; - /** JDK serialization for {@link #cfg}. */ @Order(0) + @Marshalled("cfg") byte[] cfgBytes; /** Default constructor for {@link MessageFactory}. */ @@ -58,18 +56,6 @@ public LazyServiceConfiguration configuration() { return cfg; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (cfg != null) - cfgBytes = U.marshal(marsh, cfg); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (cfgBytes != null) - cfg = U.unmarshal(marsh, cfgBytes, clsLdr); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(ServiceDeploymentRequest.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java index e153290d3afe8..c52d6e952cb4a 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java @@ -18,26 +18,24 @@ package org.apache.ignite.spi.discovery; import java.io.Serializable; -import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; /** Wrapper message for serializable data. */ -public class ObjectData implements MarshallableMessage { +public class ObjectData implements Message { /** */ @GridToStringInclude - private Serializable data; + Serializable data; /** */ @GridToStringExclude @Order(0) + @Marshalled("data") byte[] dataBytes; /** */ @@ -50,21 +48,6 @@ public ObjectData(Serializable data) { this.data = data; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (data != null) - dataBytes = U.marshal(marsh, data); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (dataBytes != null) { - data = U.unmarshal(marsh, dataBytes, clsLdr); - - dataBytes = null; - } - } - /** * @param msg Message. * @param Type of data. From d9096012457ef0e33e8110ccf8d8eb283c66c9b9 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 12:00:58 +0300 Subject: [PATCH 165/215] WIP --- .../org/apache/ignite/internal/MessageMarshallerGenerator.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index c5015c2b0ce05..7fcffb776c3c2 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -494,6 +494,7 @@ private void appendMarshalledPrepare(List body, List fi }, body); } + /** */ private void appendMarshalledFinish(List body, List fields) { forEachMarshalled(fields, (bytesAcc, objAcc) -> { List code = new ArrayList<>(); @@ -514,6 +515,7 @@ private void appendMarshalledFinish(List body, List fie }, body); } + /** */ private void forEachMarshalled(List fields, BiFunction> codeGen, List body) { for (VariableElement field : fields) { Marshalled ann = field.getAnnotation(Marshalled.class); From a8b014f0dcdea9321d65bca6470d0151b8dd3342 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 12:12:53 +0300 Subject: [PATCH 166/215] WIP --- .../internal/GridJobSiblingsResponse.java | 27 ++------- .../cache/query/GridCacheQueryRequest.java | 56 +++++-------------- .../handlers/task/GridTaskResultResponse.java | 26 ++------- 3 files changed, 22 insertions(+), 87 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java index c78508b03a5cc..99534d8bb6cd8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java @@ -18,23 +18,21 @@ package org.apache.ignite.internal; import java.util.Collection; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.compute.ComputeJobSibling; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; /** * Job siblings response. */ -public class GridJobSiblingsResponse implements MarshallableMessage { +public class GridJobSiblingsResponse implements Message { /** */ - private @Nullable Collection siblings; + @Nullable Collection siblings; /** */ @Order(0) + @Marshalled("siblings") byte[] siblingsBytes; /** @@ -58,23 +56,6 @@ public GridJobSiblingsResponse(@Nullable Collection siblings) return siblings; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (siblings != null) - siblingsBytes = U.marshal(marsh, siblings); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - assert marsh != null; - - if (siblingsBytes != null) { - siblings = U.unmarshal(marsh, siblingsBytes, null); - - siblingsBytes = null; - } - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridJobSiblingsResponse.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index ad1117edeb1a8..62283666c1751 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -19,6 +19,7 @@ import java.util.Collection; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; @@ -34,7 +35,7 @@ import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgniteReducer; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.INDEX; @@ -44,7 +45,7 @@ /** * Query request. */ -public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, MarshallableMessage { +public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, Message { /** */ private static final int FLAG_DATA_PAGE_SCAN_DFLT = 0b00; @@ -75,10 +76,11 @@ public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCac String clause; /** */ - private IndexQueryDesc idxQryDesc; + IndexQueryDesc idxQryDesc; /** */ @Order(4) + @Marshalled("idxQryDesc") byte[] idxQryDescBytes; /** */ @@ -90,31 +92,35 @@ public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCac String clsName; /** */ - private IgniteBiPredicate keyValFilter; + IgniteBiPredicate keyValFilter; /** */ @Order(7) + @Marshalled("keyValFilter") byte[] keyValFilterBytes; /** */ - private IgniteReducer rdc; + IgniteReducer rdc; /** */ @Order(8) + @Marshalled("rdc") byte[] rdcBytes; /** */ - private IgniteClosure trans; + IgniteClosure trans; /** */ @Order(9) + @Marshalled("trans") byte[] transBytes; /** */ - private Object[] args; + Object[] args; /** */ @Order(10) + @Marshalled("args") byte[] argsBytes; /** */ @@ -612,42 +618,6 @@ public Collection skipKeys() { return part; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (keyValFilter != null && keyValFilterBytes == null) - keyValFilterBytes = U.marshal(marsh, keyValFilter); - - if (rdc != null && rdcBytes == null) - rdcBytes = U.marshal(marsh, rdc); - - if (trans != null && transBytes == null) - transBytes = U.marshal(marsh, trans); - - if (!F.isEmpty(args) && argsBytes == null) - argsBytes = U.marshal(marsh, args); - - if (idxQryDesc != null && idxQryDescBytes == null) - idxQryDescBytes = U.marshal(marsh, idxQryDesc); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (keyValFilterBytes != null && keyValFilter == null) - keyValFilter = U.unmarshal(marsh, keyValFilterBytes, clsLdr); - - if (rdcBytes != null && rdc == null) - rdc = U.unmarshal(marsh, rdcBytes, clsLdr); - - if (transBytes != null && trans == null) - trans = U.unmarshal(marsh, transBytes, clsLdr); - - if (argsBytes != null && args == null) - args = U.unmarshal(marsh, argsBytes, clsLdr); - - if (idxQryDescBytes != null && idxQryDesc == null) - idxQryDesc = U.unmarshal(marsh, idxQryDescBytes, clsLdr); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridCacheQueryRequest.class, this, super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java index 3661cae983735..9731389602480 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -17,22 +17,21 @@ package org.apache.ignite.internal.processors.rest.handlers.task; -import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; /** * Task result response. */ -public class GridTaskResultResponse implements MarshallableMessage { +public class GridTaskResultResponse implements Message { /** Result. */ public @Nullable Object res; - /** Serialized result. */ + /** */ @Order(0) + @Marshalled("res") @Nullable byte[] resBytes; /** Finished flag. */ @@ -96,19 +95,4 @@ public void error(String err) { this.err = err; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (res != null) - resBytes = U.marshal(marsh, res); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (resBytes != null) { - res = U.unmarshal(marsh, resBytes, clsLdr); - - // It is not required anymore. - resBytes = null; - } - } } From 11f5901fa80bc9e6218a4b3d5a3f1db9b3a3e447 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 12:19:12 +0300 Subject: [PATCH 167/215] WIP --- .../eventstorage/GridEventStorageMessage.java | 13 ++++--------- .../GridNearAtomicSingleUpdateInvokeRequest.java | 13 ++++--------- .../cache/transactions/IgniteTxEntry.java | 14 ++++---------- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java index 183062ac72c7e..490b2dc913a47 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java @@ -25,6 +25,7 @@ import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.events.Event; import org.apache.ignite.internal.GridTopicMessage; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -52,10 +53,11 @@ public class GridEventStorageMessage implements MarshallableMessage { byte[] filterBytes; /** */ - private Collection evts; + Collection evts; /** */ @Order(2) + @Marshalled("evts") byte[] evtsBytes; /** */ @@ -200,18 +202,11 @@ String userVersion() { @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { if (filter != null) filterBytes = U.marshal(marsh, filter); - - if (evts != null) - evtsBytes = U.marshal(marsh, evts); } /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader ldr) throws IgniteCheckedException { - if (evtsBytes != null) { - evts = U.unmarshal(marsh, evtsBytes, ldr); - - evtsBytes = null; - } + // No-op. } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index e98035f795a3d..b88bf61914c0e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -24,6 +24,7 @@ import javax.cache.processor.EntryProcessor; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; @@ -34,7 +35,6 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; @@ -54,10 +54,11 @@ public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingl @Nullable List invokeArgsBytes; /** Entry processors. */ - private @Nullable EntryProcessor entryProc; + @Nullable EntryProcessor entryProc; - /** Entry processors bytes. */ + /** */ @Order(1) + @Marshalled("entryProc") @Nullable byte[] entryProcBytes; /** @@ -188,18 +189,12 @@ public GridNearAtomicSingleUpdateInvokeRequest() { /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (entryProc != null && entryProcBytes == null) - entryProcBytes = U.marshal(marsh, entryProc); - if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) invokeArgsBytes = Arrays.asList(marshallInvokeArguments(invokeArgs, marsh)); } /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (entryProcBytes != null && entryProc == null) - entryProc = U.unmarshal(marsh, entryProcBytes, clsLdr); - if (invokeArgsBytes != null && invokeArgs == null) invokeArgs = unmarshalInvokeArguments(invokeArgsBytes.toArray(new byte[invokeArgsBytes.size()][]), marsh, clsLdr); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index 1883734d6883c..32129a9294b99 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -25,6 +25,7 @@ import javax.cache.processor.EntryProcessor; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; @@ -134,14 +135,15 @@ public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, /** Transform. */ @GridToStringInclude - private Collection, Object[]>> entryProcessorsCol; + Collection, Object[]>> entryProcessorsCol; /** Transient field for calculated entry processor value. */ private T2 entryProcessorCalcVal; - /** Transform closure bytes. */ + /** */ @GridToStringExclude @Order(4) + @Marshalled("entryProcessorsCol") byte[] transformClosBytes; /** Time to live. */ @@ -1044,10 +1046,6 @@ public void filtersSet(boolean filtersSet) { /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - // Do not serialize filters if they are null. - if (transformClosBytes == null && entryProcessorsCol != null) - transformClosBytes = U.marshal(marsh, entryProcessorsCol); - transferExpiryPlc = expiryPlc != null && expiryPlc != ctx.expiry(); if (transferExpiryPlc) { @@ -1060,10 +1058,6 @@ public void filtersSet(boolean filtersSet) { /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - // Unmarshal transform closure anyway if it exists. - if (transformClosBytes != null && entryProcessorsCol == null) - entryProcessorsCol = U.unmarshal(marsh, transformClosBytes, clsLdr); - if (filters == null) filters = CU.empty0(); From 78f1904a0b5ce3034a508accd465471448490d64 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Wed, 24 Jun 2026 22:14:31 +0300 Subject: [PATCH 168/215] WIP --- .mvn/jvm.config | 10 + .../apache/ignite/internal/Marshalled.java | 7 +- .../ignite/internal/MarshalledCollection.java | 31 + .../apache/ignite/internal/MarshalledMap.java | 34 + .../apache/ignite/internal/MarshalledSet.java | 31 + .../internal/MessageMarshallerGenerator.java | 719 ++++++++++++++---- .../internal/GridJobSiblingsResponse.java | 2 +- .../eventstorage/GridEventStorageMessage.java | 2 +- .../CacheObjectNotResolvedException.java | 32 + .../cache/DynamicCacheChangeRequest.java | 6 +- .../processors/cache/KeyCacheObjectImpl.java | 2 +- .../processors/cache/StoredCacheData.java | 4 +- .../binary/BinaryMetadataVersionInfo.java | 2 +- .../binary/MetadataUpdateProposedMessage.java | 2 +- .../GridDistributedTxPrepareRequest.java | 37 +- .../distributed/dht/GridDhtLockFuture.java | 3 - .../distributed/dht/GridDhtLockRequest.java | 66 +- .../dht/GridDhtTxPrepareRequest.java | 39 +- ...idNearAtomicSingleUpdateInvokeRequest.java | 2 +- .../near/GridNearTxPrepareResponse.java | 44 +- .../cache/query/GridCacheQueryRequest.java | 10 +- .../cache/transactions/IgniteTxEntry.java | 2 +- .../cache/transactions/IgniteTxKey.java | 1 - .../cache/transactions/TxLocksRequest.java | 36 +- .../cache/transactions/TxLocksResponse.java | 80 +- .../cache/verify/PartitionHashRecord.java | 4 +- .../cache/verify/TransactionsHashRecord.java | 4 +- .../cluster/ChangeGlobalStateMessage.java | 4 +- .../SchemaAddQueryEntityOperation.java | 2 +- .../handlers/task/GridTaskResultResponse.java | 2 +- .../service/ServiceDeploymentRequest.java | 2 +- .../ignite/spi/discovery/ObjectData.java | 2 +- .../tcp/internal/TcpDiscoveryNode.java | 21 +- .../TcpDiscoveryNodeAddFinishedMessage.java | 21 +- .../codegen/MessageProcessorTest.java | 54 ++ ...adlockDetectionMessageMarshallingTest.java | 9 +- .../TestMarshallableMessageMarshaller.java | 1 - .../TestMarshalledCollectionMessage.java | 34 + ...MarshalledCollectionMessageMarshaller.java | 87 +++ ...MarshalledCollectionMessageSerializer.java | 77 ++ .../codegen/TestMarshalledMapMessage.java | 38 + .../TestMarshalledMapMessageMarshaller.java | 115 +++ .../TestMarshalledMapMessageSerializer.java | 92 +++ .../codegen/TestMarshalledMessage.java | 32 + .../TestMarshalledMessageMarshaller.java | 61 ++ .../TestMarshalledMessageSerializer.java | 70 ++ 46 files changed, 1454 insertions(+), 482 deletions(-) create mode 100644 .mvn/jvm.config create mode 100644 modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledCollection.java create mode 100644 modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledMap.java create mode 100644 modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledSet.java create mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectNotResolvedException.java create mode 100644 modules/core/src/test/resources/codegen/TestMarshalledCollectionMessage.java create mode 100644 modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java create mode 100644 modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageSerializer.java create mode 100644 modules/core/src/test/resources/codegen/TestMarshalledMapMessage.java create mode 100644 modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java create mode 100644 modules/core/src/test/resources/codegen/TestMarshalledMapMessageSerializer.java create mode 100644 modules/core/src/test/resources/codegen/TestMarshalledMessage.java create mode 100644 modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java create mode 100644 modules/core/src/test/resources/codegen/TestMarshalledMessageSerializer.java diff --git a/.mvn/jvm.config b/.mvn/jvm.config new file mode 100644 index 0000000000000..30d183eed2cbc --- /dev/null +++ b/.mvn/jvm.config @@ -0,0 +1,10 @@ +--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED +--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED +--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED +--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED +--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED +--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED +--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED +--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED +--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED +--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/Marshalled.java b/modules/codegen/src/main/java/org/apache/ignite/internal/Marshalled.java index 88faa98116132..8c814643ff8ac 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/Marshalled.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/Marshalled.java @@ -22,13 +22,10 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Marks a {@code byte[]} field as a wire-protocol buffer for a companion object field named by {@link #value()}. - * The code generator emits {@code U.marshal}/{@code U.unmarshal} calls in the {@code *Marshaller} class. - */ +/** Marks an object field whose wire representation is a companion {@code byte[]} {@code @Order} field named by {@link #value()}. */ @Retention(RetentionPolicy.CLASS) @Target(ElementType.FIELD) public @interface Marshalled { - /** Companion object field whose value is serialized into / deserialized from this byte buffer. */ + /** Name of the {@code @Order} {@code byte[]} field that holds the serialized form. */ String value(); } diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledCollection.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledCollection.java new file mode 100644 index 0000000000000..5cc4f4e8819a6 --- /dev/null +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledCollection.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** Marks a {@code Collection} field whose wire form is a companion {@code @Order} array field named by {@link #value()}. */ +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface MarshalledCollection { + /** Name of the {@code @Order} array field that holds the elements. */ + String value(); +} diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledMap.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledMap.java new file mode 100644 index 0000000000000..8204326c1e0cf --- /dev/null +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledMap.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** Marks a {@code Map} field whose wire form is a pair of {@code @Order} companion fields: {@link #keys()} and {@link #values()}. */ +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface MarshalledMap { + /** Name of the {@code @Order} field that holds the keys. */ + String keys(); + + /** Name of the {@code @Order} field that holds the values. */ + String values(); +} diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledSet.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledSet.java new file mode 100644 index 0000000000000..01ea5e944798a --- /dev/null +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledSet.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** Marks a {@code Set} or {@code Collection} field whose wire form is a companion {@code @Order} array field named by {@link #value()}. */ +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface MarshalledSet { + /** Name of the {@code @Order} array field that holds the elements. */ + String value(); +} diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 7fcffb776c3c2..cceffa6fed419 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -21,10 +21,15 @@ import java.io.StringWriter; import java.io.Writer; import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.function.BiFunction; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; +import javax.lang.model.element.Modifier; import javax.lang.model.element.QualifiedNameable; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; @@ -33,6 +38,7 @@ import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVariable; +import javax.lang.model.util.ElementFilter; import javax.tools.Diagnostic; import static org.apache.ignite.internal.MessageProcessor.MARSHALLABLE_MESSAGE_INTERFACE; @@ -84,7 +90,10 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** Whether the current message type has any {@code @Marshalled} fields. */ private boolean hasMarshalled; - /** */ + /** Enclosed fields of the currently processed type. Computed once per {@link #generateBody} call. */ + private Map enclosed; + + /** @param env annotation processing environment. */ MessageMarshallerGenerator(ProcessingEnvironment env) { super(env); @@ -111,10 +120,11 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** {@inheritDoc} */ @Override void generateBody(List fields) throws Exception { + enclosed = enclosedFields(); marshallable = marshallableMsgType != null && assignableFrom(type.asType(), marshallableMsgType); cacheMarshallable = cacheMarshallableMsgType != null && assignableFrom(type.asType(), cacheMarshallableMsgType); - hasMarshalled = fields.stream().anyMatch(f -> f.getAnnotation(Marshalled.class) != null); - + hasMarshalled = enclosed.values().stream().anyMatch(f -> f.getAnnotation(Marshalled.class) != null); + indent = 1; generatePrepareMarshalMethod(fields); @@ -131,7 +141,7 @@ public class MessageMarshallerGenerator extends MessageGenerator { imports.add("org.apache.ignite.marshaller.Marshaller"); writeClassHeader(writer, "MessageMarshaller", marshallerClsName); - + writer.write(" {" + NL); writeConstructor(writer, marshallerClsName); @@ -145,7 +155,7 @@ public class MessageMarshallerGenerator extends MessageGenerator { } } - /** */ + /** Writes the constructor, including the {@code marshaller} field when needed. */ private void writeConstructor(Writer writer, String marshallerClsName) throws IOException { writer.write(indentedLine(METHOD_JAVADOC)); writer.write(NL); @@ -160,10 +170,10 @@ private void writeConstructor(Writer writer, String marshallerClsName) throws IO writer.write(NL); indent++; - + writer.write(indentedLine("this.marshaller = marshaller;")); writer.write(NL); - + indent--; } else { @@ -176,7 +186,7 @@ private void writeConstructor(Writer writer, String marshallerClsName) throws IO writer.write(NL + NL); } - /** */ + /** Generates the {@code prepareMarshal} method body and appends it to {@link #marshall}. */ private void generatePrepareMarshalMethod(List orderedFields) { imports.add("org.apache.ignite.IgniteCheckedException"); imports.add("org.apache.ignite.internal.GridKernalContext"); @@ -195,7 +205,8 @@ private void generatePrepareMarshalMethod(List orderedFields) { if (needsCtx(orderedFields)) appendBlock(body, List.of(ctxResolutionLine())); - appendMarshalledPrepare(body, orderedFields); + appendMarshalledFieldsPrepare(body); + appendMarshalledPrepare(body); if (marshallable) appendBlock(body, List.of(indentedLine("msg.prepareMarshal(marshaller);"))); @@ -209,7 +220,7 @@ private void generatePrepareMarshalMethod(List orderedFields) { marshall.add(indentedLine("}")); } - /** */ + /** Generates all {@code finishUnmarshal} overloads and appends them to {@link #marshall}. */ private void generateUnmarshallMethods(List orderedFields) { List nioFields = new ArrayList<>(); List workerFields = new ArrayList<>(); @@ -242,7 +253,7 @@ private void generateUnmarshallMethods(List orderedFields) { generateFinishUnmarshalNioMethod(msgParam, nioFields); } - /** */ + /** Generates a single {@code finishUnmarshal} overload for the given {@code mode}. */ private void generateFinishUnmarshalMethod(String methodName, String params, List fields, MarshalMode mode) { marshall.add(EMPTY); @@ -255,10 +266,12 @@ private void generateFinishUnmarshalMethod(String methodName, String params, Lis List body = new ArrayList<>(); - if (mode == MarshalMode.FINISH_CACHE && needsCtx(fields)) + Set wireFieldSkip = mode == MarshalMode.FINISH_CACHE ? marshalledWireFieldsToSkip() : Set.of(); + + if (mode == MarshalMode.FINISH_CACHE && (needsCtx(fields) || !wireFieldSkip.isEmpty())) appendBlock(body, List.of(ctxResolutionLine())); - appendFields(body, fields, mode); + appendFields(body, fields, mode, wireFieldSkip); if (marshallable) { if (mode == MarshalMode.FINISH_CACHE && cacheMarshallable) @@ -268,7 +281,12 @@ else if (mode == MarshalMode.FINISH && !cacheMarshallable) } if (mode == MarshalMode.FINISH) - appendMarshalledFinish(body, fields); + appendMarshalledFinish(body); + + if (mode == MarshalMode.FINISH_CACHE) { + appendMarshalledCollectionFinish(body); + appendMarshalledMapFinish(body); + } marshall.addAll(body); @@ -277,7 +295,7 @@ else if (mode == MarshalMode.FINISH && !cacheMarshallable) marshall.add(indentedLine("}")); } - /** */ + /** Generates the {@code finishUnmarshalNio} method for NIO-eligible {@code @Message} fields. */ private void generateFinishUnmarshalNioMethod(String params, List nioFields) { marshall.add(EMPTY); @@ -299,44 +317,453 @@ private void generateFinishUnmarshalNioMethod(String params, List ctx = nested == null ? " + - "kctx.cache().context().cacheContext(msg.cacheId()) : nested;"); - else if (isCacheGroupIdMessage(type)) - return indentedLine("GridCacheContext ctx = nested == null ? " + - "kctx.cache().context().cacheContext(msg.groupId()) : nested;"); - else - return indentedLine("GridCacheContext ctx = nested;"); + /** Generates logical→wire conversions for all {@code @MarshalledCollection} and {@code @MarshalledMap} fields. */ + private void appendMarshalledFieldsPrepare(List body) { + for (VariableElement field : enclosed.values()) { + appendCollectionPrepare(body, field); + appendMapPrepare(body, field); + } } - /** Returns {@code true} if any field requires {@code ctx} in generated marshal/unmarshal code. */ - private boolean needsCtx(List fields) { - return fields.stream().anyMatch(f -> needsCtxType(f.asType())); + /** Appends a {@code toArray} assignment for a {@code @MarshalledCollection} field, if present. */ + private void appendCollectionPrepare(List body, VariableElement field) { + MarshalledCollection ann = field.getAnnotation(MarshalledCollection.class); + + if (ann == null) + return; + + String colField = "msg." + field.getSimpleName(); + String arrField = "msg." + ann.value(); + String compName = arrayComponentName(requireEnclosed(enclosed, ann.value(), "@MarshalledCollection")); + + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null && %s == null)", colField, arrField)); + + indent++; + + code.add(indentedLine("%s = %s.toArray(new %s[0]);", arrField, colField, compName)); + + indent--; + + appendBlock(body, code); } - /** */ - private boolean needsCtxType(TypeMirror t) { - if (t.getKind() == TypeKind.ARRAY) - return needsCtxType(((ArrayType)t).getComponentType()); + /** Appends key/value array assignments for a {@code @MarshalledMap} field, if present. */ + private void appendMapPrepare(List body, VariableElement field) { + MarshalledMap ann = field.getAnnotation(MarshalledMap.class); - if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { - if (isMessage(t) || isCacheObject(t)) - return true; + if (ann == null) + return; - if (isMap(t)) { - List args = ((DeclaredType)t).getTypeArguments(); - return needsCtxType(args.get(0)) || needsCtxType(args.get(1)); - } + String mapField = "msg." + field.getSimpleName(); + String keysField = "msg." + ann.keys(); + String valuesField = "msg." + ann.values(); + VariableElement keysEl = requireEnclosed(enclosed, ann.keys(), "@MarshalledMap"); - if (isCollection(t)) { - List args = ((DeclaredType)t).getTypeArguments(); - return needsCtxType(args.get(0)); + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null && %s == null) {", mapField, keysField)); + + indent++; + + code.addAll(keysEl.asType().getKind() == TypeKind.ARRAY + ? arrayMapBody(ann, mapField, keysField, keysEl, valuesField) + : viewBasedMapBody(keysField, mapField, valuesField)); + + indent--; + + code.add(indentedLine("}")); + + appendBlock(body, code); + } + + /** Generates {@code U.marshal} calls for all {@code @Marshalled} fields in prepareMarshal. */ + private void appendMarshalledPrepare(List body) { + forEachMarshalled((bytesAcc, objAcc) -> { + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null)", objAcc)); + + indent++; + + code.add(indentedLine("%s = U.marshal(marshaller, %s);", bytesAcc, objAcc)); + + indent--; + + return code; + }, body); + } + + /** Generates {@code U.unmarshal} calls for all {@code @Marshalled} fields in finishUnmarshal. */ + private void appendMarshalledFinish(List body) { + forEachMarshalled((bytesAcc, objAcc) -> { + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null) {", bytesAcc)); + + indent++; + + code.add(indentedLine("%s = U.unmarshal(marshaller, %s, U.resolveClassLoader(kctx.config()));", objAcc, bytesAcc)); + code.add(EMPTY); + code.add(indentedLine("%s = null;", bytesAcc)); + + indent--; + + code.add(indentedLine("}")); + + return code; + }, body); + } + + /** Generates Set reconstruction for all {@code @MarshalledCollection} fields. */ + private void appendMarshalledCollectionFinish(List body) { + for (VariableElement field : enclosed.values()) { + MarshalledCollection colAnn = field.getAnnotation(MarshalledCollection.class); + + if (colAnn == null) + continue; + + String colField = "msg." + field.getSimpleName(); + String arrField = "msg." + colAnn.value(); + VariableElement wireField = requireEnclosed(enclosed, colAnn.value(), "@MarshalledCollection"); + + imports.add("org.apache.ignite.internal.processors.cache.CacheObjectNotResolvedException"); + + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null) {", arrField)); + + indent++; + + code.add(indentedLine("%s = U.newHashSet(%s.length);", colField, arrField)); + code.add(EMPTY); + code.addAll(collectionFinishForBlock(wireField, colField, arrField, field.getSimpleName().toString())); + code.add(EMPTY); + code.add(indentedLine("%s = null;", arrField)); + + indent--; + + code.add(indentedLine("}")); + + appendBlock(body, code); + } + } + + /** Generates the {@code for} loop body: per-element finishUnmarshal + try/catch add into the collection. */ + private List collectionFinishForBlock(VariableElement wireField, String colField, String arrField, String fieldName) { + String compName = arrayComponentName(wireField); + TypeMirror compType = ((ArrayType) wireField.asType()).getComponentType(); + + List code = new ArrayList<>(); + + code.add(indentedLine("for (%s e : %s) {", compName, arrField)); + + indent++; + + code.addAll(codeFor(compType, "e", MarshalMode.FINISH_CACHE)); + code.add(EMPTY); + code.add(indentedLine("try {")); + + indent++; + + code.add(indentedLine("%s.add(e);", colField)); + + indent--; + + code.add(indentedLine("}")); + code.add(indentedLine("catch (CacheObjectNotResolvedException ex) {")); + + indent++; + + code.add(indentedLine("U.warn(kctx.log(getClass()), \"Skipping unresolved element [field=%s]: \" + ex.getMessage());", fieldName)); + + indent--; + + code.add(indentedLine("}")); + + indent--; + + code.add(indentedLine("}")); + + return code; + } + + /** Returns names of wire fields skipped by {@link #appendFields} in FINISH_CACHE mode. */ + private Set marshalledWireFieldsToSkip() { + Set names = new HashSet<>(); + + for (VariableElement f : enclosed.values()) { + MarshalledCollection colAnn = f.getAnnotation(MarshalledCollection.class); + if (colAnn != null) + names.add(colAnn.value()); + + MarshalledMap mapAnn = f.getAnnotation(MarshalledMap.class); + if (mapAnn != null) { + names.add(mapAnn.keys()); + names.add(mapAnn.values()); } } - return false; + return names; + } + + /** Generates Map reconstruction for all {@code @MarshalledMap} fields. */ + private void appendMarshalledMapFinish(List body) { + for (VariableElement field : enclosed.values()) { + MarshalledMap ann = field.getAnnotation(MarshalledMap.class); + + if (ann == null) + continue; + + VariableElement keysEl = requireEnclosed(enclosed, ann.keys(), "@MarshalledMap"); + VariableElement valsEl = requireEnclosed(enclosed, ann.values(), "@MarshalledMap"); + + String mapField = "msg." + field.getSimpleName(); + String keysField = "msg." + ann.keys(); + String valsField = "msg." + ann.values(); + + imports.add("org.apache.ignite.internal.processors.cache.CacheObjectNotResolvedException"); + + List code = keysEl.asType().getKind() == TypeKind.ARRAY + ? mapFinishArrayBlock(field, keysEl, valsEl, mapField, keysField, valsField) + : mapFinishCollectionBlock(field, keysEl, valsEl, mapField, keysField, valsField); + + appendBlock(body, code); + } + } + + /** Generates indexed-loop Map reconstruction for array-backed {@code @MarshalledMap} fields. */ + private List mapFinishArrayBlock( + VariableElement field, + VariableElement keysEl, + VariableElement valsEl, + String mapField, + String keysField, + String valsField + ) { + boolean isFinal = field.getModifiers().contains(Modifier.FINAL); + String keyCompName = arrayComponentName(keysEl); + String valCompName = arrayComponentName(valsEl); + TypeMirror keyCompType = ((ArrayType)keysEl.asType()).getComponentType(); + TypeMirror valCompType = ((ArrayType)valsEl.asType()).getComponentType(); + + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null) {", keysField)); + + indent++; + + if (!isFinal) { + code.add(indentedLine("%s = U.newHashMap(%s.length);", mapField, keysField)); + code.add(EMPTY); + } + + code.add(indentedLine("for (int i = 0; i < %s.length; i++) {", keysField)); + + indent++; + + code.add(indentedLine("%s k = %s[i];", keyCompName, keysField)); + code.add(indentedLine("%s v = %s[i];", valCompName, valsField)); + + List keyUnmarshal = codeFor(keyCompType, "k", MarshalMode.FINISH_CACHE); + List valUnmarshal = codeFor(valCompType, "v", MarshalMode.FINISH_CACHE); + + if (!keyUnmarshal.isEmpty()) { + code.add(EMPTY); + code.addAll(keyUnmarshal); + } + + if (!valUnmarshal.isEmpty()) { + code.add(EMPTY); + code.addAll(valUnmarshal); + } + + code.add(EMPTY); + code.add(indentedLine("try {")); + + indent++; + + code.add(indentedLine("%s.put(k, v);", mapField)); + + indent--; + + code.add(indentedLine("}")); + code.add(indentedLine("catch (CacheObjectNotResolvedException ex) {")); + + indent++; + + code.add(indentedLine("U.warn(kctx.log(getClass()), \"Skipping unresolved element [field=%s]: \" + ex.getMessage());", + field.getSimpleName())); + + indent--; + + code.add(indentedLine("}")); + + indent--; + + code.add(indentedLine("}")); + code.add(EMPTY); + code.add(indentedLine("%s = null;", keysField)); + code.add(indentedLine("%s = null;", valsField)); + + indent--; + + code.add(indentedLine("}")); + + return code; + } + + /** Generates iterator-based Map reconstruction for collection-backed {@code @MarshalledMap} fields. */ + private List mapFinishCollectionBlock( + VariableElement field, + VariableElement keysEl, + VariableElement valsEl, + String mapField, + String keysField, + String valsField + ) { + List keyArgs = ((DeclaredType)keysEl.asType()).getTypeArguments(); + List valArgs = ((DeclaredType)valsEl.asType()).getTypeArguments(); + + TypeMirror keyCompType = keyArgs.get(0); + TypeMirror valCompType = valArgs.get(0); + + Element keyElem = element(keyCompType); + Element valElem = element(valCompType); + + String keyCompName = keyElem.getSimpleName().toString(); + String valCompName = valElem.getSimpleName().toString(); + + imports.add(((QualifiedNameable)keyElem).getQualifiedName().toString()); + imports.add(((QualifiedNameable)valElem).getQualifiedName().toString()); + imports.add("java.util.Iterator"); + + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null) {", keysField)); + + indent++; + + code.add(indentedLine("%s = U.newHashMap(%s.size());", mapField, keysField)); + code.add(EMPTY); + code.add(indentedLine("Iterator keyIter = %s.iterator();", keysField)); + code.add(indentedLine("Iterator valIter = %s.iterator();", valsField)); + code.add(EMPTY); + code.add(indentedLine("while (keyIter.hasNext()) {")); + + indent++; + + code.add(indentedLine("%s k = (%s)keyIter.next();", keyCompName, keyCompName)); + code.add(indentedLine("%s v = (%s)valIter.next();", valCompName, valCompName)); + + List keyUnmarshal = codeFor(keyCompType, "k", MarshalMode.FINISH_CACHE); + List valUnmarshal = codeFor(valCompType, "v", MarshalMode.FINISH_CACHE); + + if (!keyUnmarshal.isEmpty()) { + code.add(EMPTY); + code.addAll(keyUnmarshal); + } + + if (!valUnmarshal.isEmpty()) { + code.add(EMPTY); + code.addAll(valUnmarshal); + } + + code.add(EMPTY); + code.add(indentedLine("try {")); + + indent++; + + code.add(indentedLine("%s.put(k, v);", mapField)); + + indent--; + + code.add(indentedLine("}")); + code.add(indentedLine("catch (CacheObjectNotResolvedException ex) {")); + + indent++; + + code.add(indentedLine("U.warn(kctx.log(getClass()), \"Skipping unresolved element [field=%s]: \" + ex.getMessage());", + field.getSimpleName())); + + indent--; + + code.add(indentedLine("}")); + + indent--; + + code.add(indentedLine("}")); + code.add(EMPTY); + code.add(indentedLine("%s = null;", keysField)); + code.add(indentedLine("%s = null;", valsField)); + + indent--; + + code.add(indentedLine("}")); + + return code; + } + + /** Generates key/value array population from the map's entry set. */ + private List arrayMapBody( + MarshalledMap ann, + String mapField, + String keysField, + VariableElement keysEl, + String valuesField + ) { + String compName = arrayComponentName(keysEl); + String valCompName = arrayComponentName(requireEnclosed(enclosed, ann.values(), "@MarshalledMap")); + + List inner = new ArrayList<>(); + + imports.add("java.util.Map"); + + inner.add(indentedLine("%s = new %s[%s.size()];", keysField, compName, mapField)); + inner.add(indentedLine("%s = new %s[%s.length];", valuesField, valCompName, keysField)); + inner.add(indentedLine("int i = 0;")); + inner.add(indentedLine("for (Map.Entry e : %s.entrySet()) {", mapField)); + + indent++; + + inner.add(indentedLine("%s[i] = (%s)e.getKey();", keysField, compName)); + inner.add(indentedLine("%s[i] = (%s)e.getValue();", valuesField, valCompName)); + inner.add(indentedLine("i++;")); + + indent--; + + inner.add(indentedLine("}")); + + return inner; + } + + /** Generates key/value assignments backed by the map's own {@code keySet()} and {@code values()} views. */ + private List viewBasedMapBody(String keysField, String mapField, String valuesField) { + List inner = new ArrayList<>(); + + inner.add(indentedLine("%s = %s.keySet();", keysField, mapField)); + inner.add(indentedLine("%s = %s.values();", valuesField, mapField)); + + return inner; + } + + /** Marshals each field and appends non-empty results to {@code body}. */ + private void appendFields(List body, List fields, MarshalMode mode) { + appendFields(body, fields, mode, Set.of()); + } + + /** Marshals each field, skipping names in {@code skip}, and appends non-empty results to {@code body}. */ + private void appendFields(List body, List fields, MarshalMode mode, Set skip) { + for (VariableElement field : fields) { + if (skip.contains(field.getSimpleName().toString())) + continue; + + List result = codeFor(field.asType(), fieldAccessor(field), mode); + + if (!result.isEmpty()) + appendBlock(body, result); + } } /** Returns generated marshal/unmarshal code lines for field of type {@code t}, or empty if none needed. */ @@ -361,7 +788,7 @@ private List codeFor(TypeMirror t, String accessor, MarshalMode mode) { return List.of(); } - /** */ + /** Generates a null-guarded {@code MessageMarshaller.prepareMarshal/finishUnmarshal} call. */ private List marshallMessage(String accessor, MarshalMode mode) { List code = new ArrayList<>(); @@ -389,7 +816,7 @@ private List marshallMessage(String accessor, MarshalMode mode) { return code; } - /** */ + /** Generates a null-and-ctx-guarded {@code prepareMarshal/finishUnmarshal} call on a {@code CacheObject}. */ private List marshallCacheObject(String accessor, MarshalMode mode) { if (mode == MarshalMode.FINISH) return List.of(); @@ -409,7 +836,7 @@ private List marshallCacheObject(String accessor, MarshalMode mode) { return code; } - /** */ + /** Generates a null-guarded for-each loop over the array's elements. */ private List marshallArray(TypeMirror comp, String accessor, MarshalMode mode) { Element elem = ((DeclaredType)comp).asElement(); @@ -424,7 +851,7 @@ private List marshallArray(TypeMirror comp, String accessor, MarshalMode return wrapNullGuarded(accessor, loopCode); } - /** */ + /** Generates a null-guarded for-each loop over the collection's elements. */ private List marshallCollection(DeclaredType t, String accessor, MarshalMode mode) { TypeMirror arg = t.getTypeArguments().get(0); @@ -454,6 +881,7 @@ private List marshallMap(DeclaredType t, String accessor, MarshalMode mo indent++; List combined = new ArrayList<>(); + for (int i = 0; i < 2; i++) { TypeMirror elemType = args.get(i); @@ -477,131 +905,158 @@ private List marshallMap(DeclaredType t, String accessor, MarshalMode mo return wrapNullGuarded(accessor, combined); } - /** Generates {@code U.marshal} calls for all {@code @Marshalled} fields in prepareMarshal. */ - private void appendMarshalledPrepare(List body, List fields) { - forEachMarshalled(fields, (bytesAcc, objAcc) -> { - List code = new ArrayList<>(); - - code.add(indentedLine("if (%s != null)", objAcc)); - - indent++; - - code.add(indentedLine("%s = U.marshal(marshaller, %s);", bytesAcc, objAcc)); - - indent--; - - return code; - }, body); - } + /** Returns empty if {@code elemType} requires no marshalling; otherwise returns a for-each loop over {@code iterable}. */ + private List forLoop(String typeName, TypeMirror elemType, String iterable, MarshalMode mode) { + String el = "e" + (indent + 1); - /** */ - private void appendMarshalledFinish(List body, List fields) { - forEachMarshalled(fields, (bytesAcc, objAcc) -> { - List code = new ArrayList<>(); - - code.add(indentedLine("if (%s != null) {", bytesAcc)); - - indent++; - - code.add(indentedLine("%s = U.unmarshal(marshaller, %s, U.resolveClassLoader(kctx.config()));", objAcc, bytesAcc)); - - code.add(indentedLine("%s = null;", bytesAcc)); - - indent--; - - code.add(indentedLine("}")); - - return code; - }, body); - } + indent++; - /** */ - private void forEachMarshalled(List fields, BiFunction> codeGen, List body) { - for (VariableElement field : fields) { - Marshalled ann = field.getAnnotation(Marshalled.class); - - if (ann == null) - continue; - - appendBlock(body, codeGen.apply("msg." + field.getSimpleName(), "msg." + ann.value())); - } - } + List inner = codeFor(elemType, el, mode); + + indent--; - /** Returns empty if {@code inner} is empty. */ - private List wrapNullGuarded(String nullGuard, List inner) { if (inner.isEmpty()) return List.of(); List code = new ArrayList<>(); - code.add(indentedLine("if (%s != null) {", nullGuard)); - + code.add(indentedLine("for (%s %s : %s) {", typeName, el, iterable)); + code.addAll(inner); - + code.add(indentedLine("}")); return code; } - /** Returns empty if {@code elemType} requires no marshalling. */ - private List forLoop(String typeName, TypeMirror elemType, String iterable, MarshalMode mode) { - String el = "e" + (indent + 1); - - indent++; - - List inner = codeFor(elemType, el, mode); - - indent--; - + /** Returns empty if {@code inner} is empty; otherwise wraps {@code inner} in a null-guard on {@code nullGuard}. */ + private List wrapNullGuarded(String nullGuard, List inner) { if (inner.isEmpty()) return List.of(); List code = new ArrayList<>(); - code.add(indentedLine("for (%s %s : %s) {", typeName, el, iterable)); - + code.add(indentedLine("if (%s != null) {", nullGuard)); + code.addAll(inner); - + code.add(indentedLine("}")); return code; } - /** */ + /** Returns the {@code GridCacheContext ctx} resolution line for the current message type. */ + private String ctxResolutionLine() { + if (isCacheIdAwareMessage(type)) + return indentedLine("GridCacheContext ctx = nested == null ? " + + "kctx.cache().context().cacheContext(msg.cacheId()) : nested;"); + else if (isCacheGroupIdMessage(type)) + return indentedLine("GridCacheContext ctx = nested == null ? " + + "kctx.cache().context().cacheContext(msg.groupId()) : nested;"); + else + return indentedLine("GridCacheContext ctx = nested;"); + } + + /** Returns {@code true} if any field requires {@code ctx} in generated marshal/unmarshal code. */ + private boolean needsCtx(List fields) { + return fields.stream().anyMatch(f -> needsCtxType(f.asType())); + } + + /** Returns {@code true} if type {@code t} (or its element/key/value types) requires {@code ctx}. */ + private boolean needsCtxType(TypeMirror t) { + if (t.getKind() == TypeKind.ARRAY) + return needsCtxType(((ArrayType)t).getComponentType()); + + if (t.getKind() == TypeKind.DECLARED || t.getKind() == TypeKind.TYPEVAR) { + if (isMessage(t) || isCacheObject(t)) + return true; + + if (isMap(t)) { + List args = ((DeclaredType)t).getTypeArguments(); + return needsCtxType(args.get(0)) || needsCtxType(args.get(1)); + } + + if (isCollection(t)) { + List args = ((DeclaredType)t).getTypeArguments(); + return needsCtxType(args.get(0)); + } + } + + return false; + } + + /** Returns {@code true} if {@code type} is assignable to {@code Message}. */ + private boolean isMessage(TypeMirror type) { + return messageMirror != null && assignableFrom(type, messageMirror); + } + + /** Returns {@code true} if {@code type} is assignable to {@code CacheObject}. */ private boolean isCacheObject(TypeMirror type) { return cacheObjectMirror != null && assignableFrom(type, cacheObjectMirror); } - /** */ + /** Returns {@code true} if {@code type} (erased) is assignable to {@code java.util.Map}. */ private boolean isMap(TypeMirror type) { return mapMirror != null && assignableFrom(erasedType(type), mapMirror); } - /** */ + /** Returns {@code true} if {@code type} (erased) is assignable to {@code java.util.Collection}. */ private boolean isCollection(TypeMirror type) { return collectionMirror != null && assignableFrom(erasedType(type), collectionMirror); } - /** */ - private boolean isMessage(TypeMirror type) { - return messageMirror != null && assignableFrom(type, messageMirror); - } - - /** */ + /** Returns {@code true} if {@code te} implements {@code NonMarshallableMessage}. */ private boolean isNonMarshallableMessage(TypeElement te) { return nonMarshallableMirror != null && assignableFrom(te.asType(), nonMarshallableMirror); } - /** */ + /** Returns {@code true} if {@code te} implements {@code CacheIdAware}. */ private boolean isCacheIdAwareMessage(TypeElement te) { return cacheIdAwareMirror != null && assignableFrom(te.asType(), cacheIdAwareMirror); } - /** */ + /** Returns {@code true} if {@code te} is a {@code GridCacheGroupIdMessage}. */ private boolean isCacheGroupIdMessage(TypeElement te) { return cacheGroupIdMsgMirror != null && assignableFrom(te.asType(), cacheGroupIdMsgMirror); } + /** Returns {@code true} if {@code field} carries {@code @NioField}. */ + private static boolean isNioField(VariableElement field) { + return field.getAnnotation(NioField.class) != null; + } + + /** Returns all declared fields of the current type, keyed by simple name, preserving declaration order. */ + private Map enclosedFields() { + Map enclosed = new LinkedHashMap<>(); + + for (VariableElement f : ElementFilter.fieldsIn(type.getEnclosedElements())) + enclosed.put(f.getSimpleName().toString(), f); + + return enclosed; + } + + /** Returns the enclosed field named {@code name}, or throws if absent. */ + private VariableElement requireEnclosed(Map enclosed, String name, String annotationName) { + VariableElement el = enclosed.get(name); + + if (el == null) + throw new IllegalStateException(annotationName + " companion field '" + name + "' not found in " + type); + + return el; + } + + /** Iterates all {@code @Marshalled} fields and applies {@code codeGen(bytesAccessor, objAccessor)} to each. */ + private void forEachMarshalled(BiFunction> codeGen, List body) { + for (VariableElement field : enclosed.values()) { + Marshalled ann = field.getAnnotation(Marshalled.class); + + if (ann == null) + continue; + + appendBlock(body, codeGen.apply("msg." + ann.value(), "msg." + field.getSimpleName())); + } + } + /** Returns the element for {@code t}; for a type variable, uses its upper bound. */ private Element element(TypeMirror t) { return t.getKind() == TypeKind.DECLARED ? @@ -609,19 +1064,9 @@ private Element element(TypeMirror t) { ((DeclaredType)((TypeVariable)t).getUpperBound()).asElement(); } - /** */ - private static boolean isNioField(VariableElement field) { - return field.getAnnotation(NioField.class) != null; - } - - /** Marshals each field and appends non-empty results to {@code body}. */ - private void appendFields(List body, List fields, MarshalMode mode) { - for (VariableElement field : fields) { - List result = codeFor(field.asType(), fieldAccessor(field), mode); - - if (!result.isEmpty()) - appendBlock(body, result); - } + /** Returns the simple name of the array component type of {@code field}. */ + private static String arrayComponentName(VariableElement field) { + return ((DeclaredType)((ArrayType)field.asType()).getComponentType()).asElement().getSimpleName().toString(); } /** Appends {@code block} to {@code body}, inserting a blank-line separator when {@code body} is non-empty. */ @@ -632,7 +1077,7 @@ private static void appendBlock(List body, List block) { body.addAll(block); } - /** */ + /** Marshal mode controls which overload is being generated. */ private enum MarshalMode { /** Marshal. */ PREPARE, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java index 99534d8bb6cd8..d31c9fff4aeef 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java @@ -28,11 +28,11 @@ */ public class GridJobSiblingsResponse implements Message { /** */ + @Marshalled("siblingsBytes") @Nullable Collection siblings; /** */ @Order(0) - @Marshalled("siblings") byte[] siblingsBytes; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java index 490b2dc913a47..c41856b0fb5d2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java @@ -53,11 +53,11 @@ public class GridEventStorageMessage implements MarshallableMessage { byte[] filterBytes; /** */ + @Marshalled("evtsBytes") Collection evts; /** */ @Order(2) - @Marshalled("evts") byte[] evtsBytes; /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectNotResolvedException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectNotResolvedException.java new file mode 100644 index 0000000000000..e2f35ee8785ba --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectNotResolvedException.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +/** + * Thrown by {@link KeyCacheObjectImpl#hashCode()} when the object has not been deserialized yet, + * which happens when the owning cache has been removed before {@code finishUnmarshal} could complete. + */ +public class CacheObjectNotResolvedException extends RuntimeException { + /** */ + private static final long serialVersionUID = 0L; + + /** Disables stack trace for performance. */ + public CacheObjectNotResolvedException() { + super(null, null, true, false); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java index 952c4ed235584..454172428a502 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java @@ -54,10 +54,10 @@ public class DynamicCacheChangeRequest implements Message, Serializable { /** Cache start configuration. */ @GridToStringExclude + @Marshalled("cfgBytes") CacheConfiguration startCfg; @Order(3) - @Marshalled("startCfg") byte[] cfgBytes; /** Cache type. */ @@ -70,10 +70,10 @@ public class DynamicCacheChangeRequest implements Message, Serializable { /** Near cache configuration. */ @GridToStringExclude + @Marshalled("nearCfgBytes") NearCacheConfiguration nearCacheCfg; @Order(6) - @Marshalled("nearCacheCfg") byte[] nearCfgBytes; /** Start only client cache, do not start data nodes. */ @@ -121,10 +121,10 @@ public class DynamicCacheChangeRequest implements Message, Serializable { boolean resetLostPartitions; /** Dynamic schema. */ + @Marshalled("schemaBytes") QuerySchema schema; @Order(18) - @Marshalled("schema") byte[] schemaBytes; /** Is transient. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java index f4e6c60333838..e656a32892482 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java @@ -109,7 +109,7 @@ public KeyCacheObjectImpl(Object val, byte[] valBytes, int part) { /** {@inheritDoc} */ @Override public int hashCode() { if (val == null) - throw new IllegalStateException("Value is null"); + throw new CacheObjectNotResolvedException(); return IgniteUtils.hashCode(val); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java index ab530f73d9632..848ac5f7d0d38 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java @@ -49,18 +49,18 @@ public class StoredCacheData implements Serializable, CdcCacheEvent, Message { /** Cache configuration. */ @GridToStringInclude + @Marshalled("ccfgBytes") CacheConfiguration ccfg; @Order(0) - @Marshalled("ccfg") transient byte[] ccfgBytes; /** Query entities. */ @GridToStringInclude + @Marshalled("qryEntitiesBytes") Collection qryEntities; @Order(1) - @Marshalled("qryEntities") transient byte[] qryEntitiesBytes; /** SQL flag - {@code true} if cache was created with {@code CREATE TABLE}. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java index ca86abbe4e4f9..921515b30c4a8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java @@ -33,10 +33,10 @@ public final class BinaryMetadataVersionInfo implements Serializable, Message { private static final long serialVersionUID = 0L; /** The actual binary metadata. */ + @Marshalled("metadataBytes") BinaryMetadata metadata; @Order(0) - @Marshalled("metadata") transient byte[] metadataBytes; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java index 36a4f65fdc4e7..39bd81d68ddd7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java @@ -77,10 +77,10 @@ public final class MetadataUpdateProposedMessage extends DiscoveryCustomMessage UUID origNodeId; /** */ + @Marshalled("metadataBytes") BinaryMetadata metadata; @Order(1) - @Marshalled("metadata") byte[] metadataBytes; /** Metadata type id. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 405803a0193ec..90762aaba7bec 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -20,11 +20,11 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.internal.MarshalledMap; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; @@ -37,8 +37,6 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; @@ -47,7 +45,7 @@ * Transaction prepare request for optimistic and eventually consistent * transactions. */ -public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage implements IgniteTxStateAware, MarshallableMessage { +public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage implements IgniteTxStateAware { /** */ private static final int NEED_RETURN_VALUE_FLAG_MASK = 0x01; @@ -103,7 +101,8 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage /** DHT versions to verify. */ @GridToStringInclude - private Map dhtVers; + @MarshalledMap(keys = "dhtVerKeys", values = "dhtVerVals") + Map dhtVers; /** Wire-protocol keys for {@link #dhtVers}. */ @Order(7) @@ -254,22 +253,6 @@ public void addDhtVersion(IgniteTxKey key, @Nullable GridCacheVersion dhtVer) { * @return Map of versions to be verified. */ public Map dhtVersions() { - if (dhtVerKeys != null && dhtVers == null) { - assert dhtVerVals != null; - assert dhtVerKeys.size() == dhtVerVals.size(); - - Iterator keyIt = dhtVerKeys.iterator(); - Iterator verIt = dhtVerVals.iterator(); - - dhtVers = U.newHashMap(dhtVerKeys.size()); - - while (keyIt.hasNext()) - dhtVers.put(keyIt.next(), verIt.next()); - - dhtVerKeys = null; - dhtVerVals = null; - } - return dhtVers == null ? Collections.emptyMap() : dhtVers; } @@ -429,18 +412,6 @@ private boolean isFlag(int mask) { return (flags & mask) != 0; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (dhtVers != null && dhtVerKeys == null) { - dhtVerKeys = dhtVers.keySet(); - dhtVerVals = dhtVers.values(); - } - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - } - /** {@inheritDoc} */ @Override public String toString() { StringBuilder flags = new StringBuilder(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java index fef43785bef3a..73b4557a49fb7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java @@ -1004,9 +1004,6 @@ private void map(Iterable entries) { } assert added.dhtLocal(); - - if (added.ownerVersion() != null) - req.owned(e.key(), added.ownerVersion()); } catch (GridCacheEntryRemovedException ex) { if (log.isDebugEnabled()) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 4a0f7471fafe0..3d20269b8d91c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -18,21 +18,14 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; import java.util.BitSet; -import java.util.Map; import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockRequest; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.util.GridLeanMap; -import org.apache.ignite.internal.util.tostring.GridToStringExclude; -import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,7 +33,7 @@ /** * DHT lock request. */ -public class GridDhtLockRequest extends GridDistributedLockRequest implements MarshallableMessage { +public class GridDhtLockRequest extends GridDistributedLockRequest { /** Invalidate reader flags. */ @Order(0) BitSet invalidateEntries; @@ -49,38 +42,24 @@ public class GridDhtLockRequest extends GridDistributedLockRequest implements Ma @Order(1) IgniteUuid miniId; - /** Owner mapped version, if any. */ - @GridToStringInclude - private Map owned; - - /** Wire-protocol keys for {@link #owned}. */ - @Order(2) - @GridToStringExclude - KeyCacheObject[] ownedKeys; - - /** Wire-protocol values for {@link #owned}. */ - @Order(3) - @GridToStringExclude - GridCacheVersion[] ownedValues; - /** Topology version. */ - @Order(4) + @Order(2) AffinityTopologyVersion topVer; /** Task name hash. */ - @Order(5) + @Order(3) int taskNameHash; /** Indexes of keys needed to be preloaded. */ - @Order(6) + @Order(4) BitSet preloadKeys; /** TTL for read operation. */ - @Order(7) + @Order(5) long accessTtl; /** Transaction label. */ - @Order(8) + @Order(6) String txLbl; /** @@ -219,19 +198,6 @@ public boolean needPreloadKey(int idx) { return preloadKeys != null && preloadKeys.get(idx); } - /** - * Sets owner and its mapped version. - * - * @param key Key. - * @param ownerMapped Owner mapped version. - */ - public void owned(KeyCacheObject key, GridCacheVersion ownerMapped) { - if (owned == null) - owned = new GridLeanMap<>(3); - - owned.put(key, ownerMapped); - } - /** * @param idx Entry index to check. * @return {@code True} if near entry should be invalidated. @@ -261,26 +227,6 @@ public long accessTtl() { return txLbl; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (owned != null && ownedKeys == null) { - ownedKeys = new KeyCacheObject[owned.size()]; - ownedValues = new GridCacheVersion[ownedKeys.length]; - - int i = 0; - - for (Map.Entry entry : owned.entrySet()) { - ownedKeys[i] = entry.getKey(); - ownedValues[i] = entry.getValue(); - i++; - } - } - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtLockRequest.class, this, "super", super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 394de19760234..428da9d0178ec 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -20,10 +20,10 @@ import java.util.BitSet; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.Map; import java.util.UUID; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshalledMap; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; @@ -37,7 +37,6 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.marshaller.Marshaller; import org.jetbrains.annotations.Nullable; /** @@ -71,7 +70,8 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest { /** Owned versions by key. */ @GridToStringInclude - private Map owned; + @MarshalledMap(keys = "ownedKeys", values = "ownedVals") + Map owned; /** Owned keys. */ @Order(6) @@ -325,39 +325,6 @@ public boolean skipCompletedVersion() { prepareTxDeployment(nearWrites, ctx); } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (owned != null && ownedKeys == null) { - ownedKeys = owned.keySet(); - - ownedVals = owned.values(); - } - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (ownedKeys != null) { - assert ownedKeys.size() == ownedVals.size(); - - owned = U.newHashMap(ownedKeys.size()); - - Iterator keyIter = ownedKeys.iterator(); - - Iterator valIter = ownedVals.iterator(); - - while (keyIter.hasNext()) { - IgniteTxKey key = keyIter.next(); - - try { - owned.put(key, valIter.next()); - } - catch (IllegalStateException ignored) { - // Skipping entries for removed cache. - } - } - } - } - /** {@inheritDoc} */ @Override public int partition() { return U.safeAbs(version().hashCode()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index b88bf61914c0e..fbf1c1aa8cddd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -54,11 +54,11 @@ public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingl @Nullable List invokeArgsBytes; /** Entry processors. */ + @Marshalled("entryProcBytes") @Nullable EntryProcessor entryProc; /** */ @Order(1) - @Marshalled("entryProc") @Nullable byte[] entryProcBytes; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index 483ebf40e5d29..ded5ec37741a5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -20,9 +20,8 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshalledMap; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; @@ -33,16 +32,13 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Near cache prepare response. */ -public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse implements MarshallableMessage { +public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse { /** Versions that are less than lock version ({@link #version()}). */ @GridToStringInclude @Order(0) @@ -66,7 +62,8 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse /** Map of owned values to set on near node. */ @GridToStringInclude - private Map ownedVals; + @MarshalledMap(keys = "ownedValKeys", values = "ownedValVals") + Map ownedVals; /** Wire-protocol keys for {@link #ownedVals}. */ @Order(5) @@ -205,8 +202,6 @@ public void addOwnedValue(IgniteTxKey key, GridCacheVersion ver, CacheObject val * @return Map of owned values to set on near node. */ public Map ownedValues() { - rebuildOwnedValsIfNeeded(); - return ownedVals == null ? Collections.emptyMap() : Collections.unmodifiableMap(ownedVals); } @@ -234,40 +229,9 @@ public void filterFailedKeys(@Nullable Collection filterFailedKeys) * @return {@code True} if response has owned value for given key. */ public boolean hasOwnedValue(IgniteTxKey key) { - rebuildOwnedValsIfNeeded(); - return F.mapContainsKey(ownedVals, key); } - /** */ - private void rebuildOwnedValsIfNeeded() { - if (ownedValKeys != null && ownedVals == null) { - ownedVals = U.newHashMap(ownedValKeys.size()); - - Iterator keyIter = ownedValKeys.iterator(); - Iterator valIter = ownedValVals.iterator(); - - while (keyIter.hasNext()) - ownedVals.put(keyIter.next(), valIter.next()); - - ownedValKeys = null; - ownedValVals = null; - } - } - - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (ownedVals != null && ownedValKeys == null) { - ownedValKeys = ownedVals.keySet(); - - ownedValVals = ownedVals.values(); - } - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearTxPrepareResponse.class, this, "super", super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 62283666c1751..aacb131e011a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -76,11 +76,11 @@ public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCac String clause; /** */ + @Marshalled("idxQryDescBytes") IndexQueryDesc idxQryDesc; /** */ @Order(4) - @Marshalled("idxQryDesc") byte[] idxQryDescBytes; /** */ @@ -92,35 +92,35 @@ public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCac String clsName; /** */ + @Marshalled("keyValFilterBytes") IgniteBiPredicate keyValFilter; /** */ @Order(7) - @Marshalled("keyValFilter") byte[] keyValFilterBytes; /** */ + @Marshalled("rdcBytes") IgniteReducer rdc; /** */ @Order(8) - @Marshalled("rdc") byte[] rdcBytes; /** */ + @Marshalled("transBytes") IgniteClosure trans; /** */ @Order(9) - @Marshalled("trans") byte[] transBytes; /** */ + @Marshalled("argsBytes") Object[] args; /** */ @Order(10) - @Marshalled("args") byte[] argsBytes; /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index 32129a9294b99..603508110f057 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -135,6 +135,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, /** Transform. */ @GridToStringInclude + @Marshalled("transformClosBytes") Collection, Object[]>> entryProcessorsCol; /** Transient field for calculated entry processor value. */ @@ -143,7 +144,6 @@ public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, /** */ @GridToStringExclude @Order(4) - @Marshalled("entryProcessorsCol") byte[] transformClosBytes; /** Time to live. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java index 4ca6c017bf40e..b428069ae4875 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java @@ -90,7 +90,6 @@ public KeyCacheObject key() { return res; } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(IgniteTxKey.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java index 5ac8a1941875f..ef32a4415dfe9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java @@ -17,30 +17,27 @@ package org.apache.ignite.internal.processors.cache.transactions; -import java.util.Collection; import java.util.Set; -import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshalledCollection; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.A; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * Transactions lock list request. */ -public class TxLocksRequest extends GridCacheMessage implements MarshallableMessage { +public class TxLocksRequest extends GridCacheMessage { /** Future ID. */ @Order(0) long futId; /** Tx keys. */ @GridToStringInclude - private Set txKeys; + @MarshalledCollection("txKeysArr") + Set txKeys; /** Wire-protocol array for {@link #txKeys}. */ @GridToStringExclude @@ -75,23 +72,10 @@ public long futureId() { /** * @return Tx keys. */ - public Collection txKeys() { - if (txKeys == null && txKeysArr != null) { - txKeys = U.newHashSet(txKeysArr.length); - - for (IgniteTxKey key : txKeysArr) - txKeys.add(key); - - txKeysArr = null; - } - + public Set txKeys() { return txKeys; } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(TxLocksRequest.class, this); @@ -101,14 +85,4 @@ public Collection txKeys() { @Override public boolean addDeploymentInfo() { return addDepInfo; } - - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - txKeysArr = new IgniteTxKey[txKeys.size()]; - - int i = 0; - - for (IgniteTxKey key : txKeys) - txKeysArr[i++] = key; - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index c9c0e1dbe90fe..38927d33058ef 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -23,31 +23,31 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshalledCollection; +import org.apache.ignite.internal.MarshalledMap; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; /** * Transactions lock list response. */ -public class TxLocksResponse extends GridCacheMessage implements MarshallableMessage { +public class TxLocksResponse extends GridCacheMessage { /** Future ID. */ @Order(0) long futId; /** Locks for near txKeys of near transactions. */ @GridToStringInclude - private final Map> nearTxKeyLocks = new HashMap<>(); + @MarshalledMap(keys = "nearTxKeysArr", values = "locksArr") + final Map> nearTxKeyLocks = new HashMap<>(); /** Remote keys involved into transactions. Doesn't include near keys. */ @GridToStringInclude - private Set txKeys; + @MarshalledCollection("txKeysArr") + Set txKeys; /** Wire-protocol array of keys from {@link #nearTxKeyLocks}. */ @GridToStringExclude @@ -89,22 +89,6 @@ public void futureId(long futId) { * @return Lock lists for all near tx keys. */ public Map> txLocks() { - if (nearTxKeysArr != null) { - for (int i = 0; i < nearTxKeysArr.length; i++) { - IgniteTxKey txKey = nearTxKeysArr[i]; - - try { - nearTxKeyLocks.put(txKey, locksArr[i]); - } - catch (IllegalStateException ignored) { - // Skipping entries for missed cache. - } - } - - nearTxKeysArr = null; - locksArr = null; - } - return nearTxKeyLocks; } @@ -130,21 +114,6 @@ public void addTxLock(IgniteTxKey txKey, TxLock txLock) { * @return Remote txKeys involved into tx. */ public Set keys() { - if (txKeysArr != null) { - txKeys = U.newHashSet(txKeysArr.length); - - for (IgniteTxKey txKey : txKeysArr) { - try { - txKeys.add(txKey); - } - catch (IllegalStateException ignored) { - // Skipping entries for removed cache. - } - } - - txKeysArr = null; - } - return txKeys; } @@ -163,43 +132,8 @@ public void addKey(IgniteTxKey key) { return addDepInfo; } - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(TxLocksResponse.class, this); } - - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (nearTxKeyLocks != null && !nearTxKeyLocks.isEmpty()) { - int len = nearTxKeyLocks.size(); - - nearTxKeysArr = new IgniteTxKey[len]; - locksArr = (List[])new List[len]; - - int i = 0; - - for (Map.Entry> entry : nearTxKeyLocks.entrySet()) { - IgniteTxKey key = entry.getKey(); - - nearTxKeysArr[i] = key; - locksArr[i] = entry.getValue(); - - i++; - } - } - - if (txKeys != null && !txKeys.isEmpty()) { - txKeysArr = new IgniteTxKey[txKeys.size()]; - - int i = 0; - - for (IgniteTxKey key : txKeys) - txKeysArr[i++] = key; - } - } - } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java index 930f0ce1b712f..b1afae6b941fe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java @@ -52,11 +52,11 @@ public class PartitionHashRecord implements Message, Serializable { /** Consistent id. */ @GridToStringInclude + @Marshalled("consistentIdBytes") Object consistentId; @Order(2) @GridToStringExclude - @Marshalled("consistentId") byte[] consistentIdBytes; /** Partition entries content hash. */ @@ -71,11 +71,11 @@ public class PartitionHashRecord implements Message, Serializable { /** Update counter's state. */ @GridToStringInclude + @Marshalled("updateCntrBytes") Object updateCntr; @Order(5) @GridToStringExclude - @Marshalled("updateCntr") byte[] updateCntrBytes; /** Size. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java index 281cbcc21be08..a3049e2ef0c56 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java @@ -31,18 +31,18 @@ public class TransactionsHashRecord implements Message, Serializable { /** Consistent ID of local node that participated in the transaction. This node produces this record. */ @GridToStringInclude + @Marshalled("locConsistentIdBytes") Object locConsistentId; @Order(0) - @Marshalled("locConsistentId") transient byte[] locConsistentIdBytes; /** Consistent ID of remote node that participated in the transactions. */ @GridToStringInclude + @Marshalled("rmtConsistentIdBytes") Object rmtConsistentId; @Order(1) - @Marshalled("rmtConsistentId") transient byte[] rmtConsistentIdBytes; /** Committed transactions IDs hash. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java index 7f444b6b400c9..19cfee1e0b12c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java @@ -56,10 +56,10 @@ public class ChangeGlobalStateMessage extends DiscoveryCustomMessage implements List storedCfgs; /** */ - @Nullable BaselineTopology baselineTopology; + @Nullable @Marshalled("baselineTopologyBytes") + BaselineTopology baselineTopology; @Order(4) - @Marshalled("baselineTopology") byte[] baselineTopologyBytes; /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java index 905abf8d42794..d8a8b201f14d3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java @@ -32,10 +32,10 @@ public class SchemaAddQueryEntityOperation extends SchemaAbstractOperation imple private static final long serialVersionUID = 0L; /** */ + @Marshalled("qryEntitiesBytes") Collection entities; @Order(0) - @Marshalled("entities") transient byte[] qryEntitiesBytes; /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java index 9731389602480..3bf2cebf2653b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -27,11 +27,11 @@ */ public class GridTaskResultResponse implements Message { /** Result. */ + @Marshalled("resBytes") public @Nullable Object res; /** */ @Order(0) - @Marshalled("res") @Nullable byte[] resBytes; /** Finished flag. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java index 552bf15a85d0a..659ae6d0da461 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java @@ -30,10 +30,10 @@ */ public class ServiceDeploymentRequest extends ServiceChangeAbstractRequest implements Message { /** Service configuration. */ + @Marshalled("cfgBytes") LazyServiceConfiguration cfg; @Order(0) - @Marshalled("cfg") byte[] cfgBytes; /** Default constructor for {@link MessageFactory}. */ diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java index c52d6e952cb4a..425ec1ecdee38 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java @@ -30,12 +30,12 @@ public class ObjectData implements Message { /** */ @GridToStringInclude + @Marshalled("dataBytes") Serializable data; /** */ @GridToStringExclude @Order(0) - @Marshalled("data") byte[] dataBytes; /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java index 5d21dade1d772..2e7d6f44b7d0e 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java @@ -36,6 +36,7 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.ClusterMetricsSnapshot; import org.apache.ignite.internal.IgniteNodeAttributes; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.discovery.IgniteClusterNode; import org.apache.ignite.internal.processors.cluster.NodeMetricsMessage; @@ -73,7 +74,8 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Ignite /** Consistent ID. */ @GridToStringInclude - private Object consistentId; + @Marshalled("consistentIdBytes") + Object consistentId; /** Serialized {@link #consistentId}. */ @Order(1) @@ -81,7 +83,8 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Ignite /** Node attributes. */ @GridToStringExclude - private Map attrs; + @Marshalled("attrsBytes") + Map attrs; /** Serialized {@link #attrs}. */ @Order(2) @@ -221,28 +224,14 @@ public TcpDiscoveryNode(UUID id, /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (attrs != null) - attrsBytes = U.marshal(marsh, attrs); - - if (consistentId != null) - consistentIdBytes = U.marshal(marsh, consistentId); - metricsMsg = new NodeMetricsMessage(metrics); } /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (attrsBytes != null) - attrs = U.unmarshal(marsh, attrsBytes, clsLdr); - - if (consistentIdBytes != null) - consistentId = U.unmarshal(marsh, consistentIdBytes, clsLdr); - if (metricsMsg != null) metrics = new ClusterMetricsSnapshot(metricsMsg); - attrsBytes = null; - consistentIdBytes = null; metricsMsg = null; } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java index ff6b252c439e0..4d68ba5b492e7 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java @@ -19,12 +19,10 @@ import java.util.Map; import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.spi.discovery.tcp.internal.DiscoveryDataPacket; import org.jetbrains.annotations.Nullable; @@ -47,7 +45,8 @@ public class TcpDiscoveryNodeAddFinishedMessage extends TcpDiscoveryAbstractTrac /** */ @GridToStringExclude - private Map clientNodeAttrs; + @Marshalled("clientNodeAttrsBytes") + Map clientNodeAttrs; /** Serialized client node attributes. */ @Order(2) @@ -122,20 +121,6 @@ public void clientNodeAttributes(Map clientNodeAttrs) { clientNodeAttrsBytes = null; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (clientNodeAttrs != null) - clientNodeAttrsBytes = U.marshal(marsh, clientNodeAttrs); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (clientNodeAttrsBytes != null) - clientNodeAttrs = U.unmarshal(marsh, clientNodeAttrsBytes, clsLdr); - - clientNodeAttrsBytes = null; - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(TcpDiscoveryNodeAddFinishedMessage.class, this, "super", super.toString()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java index a82cdf376f8b0..32eeb7da18a5f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java @@ -402,6 +402,60 @@ public void testNioFieldOnNonMessageTypeFails() { assertThat(compilation).hadErrorContaining("@NioField has no effect on non-Message field"); } + /** Verifies that {@code @Marshalled} generates {@code U.unmarshal} with blank line before null-out in finishUnmarshal. */ + @Test + public void testMarshalledMessage() { + Compilation compilation = compile("TestMarshalledMessage.java"); + + assertThat(compilation).succeeded(); + + assertEquals(2, compilation.generatedSourceFiles().size()); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMarshalledMessageSerializer") + .hasSourceEquivalentTo(javaFile("TestMarshalledMessageSerializer.java")); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMarshalledMessageMarshaller") + .hasSourceEquivalentTo(javaFile("TestMarshalledMessageMarshaller.java")); + } + + /** Verifies that {@code @MarshalledCollection} generates Set reconstruction in FINISH_CACHE mode. */ + @Test + public void testMarshalledCollectionMessage() { + Compilation compilation = compile("TestMarshalledCollectionMessage.java"); + + assertThat(compilation).succeeded(); + + assertEquals(2, compilation.generatedSourceFiles().size()); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMarshalledCollectionMessageSerializer") + .hasSourceEquivalentTo(javaFile("TestMarshalledCollectionMessageSerializer.java")); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMarshalledCollectionMessageMarshaller") + .hasSourceEquivalentTo(javaFile("TestMarshalledCollectionMessageMarshaller.java")); + } + + /** Verifies that {@code @MarshalledMap} generates Map reconstruction in FINISH_CACHE mode. */ + @Test + public void testMarshalledMapMessage() { + Compilation compilation = compile("TestMarshalledMapMessage.java"); + + assertThat(compilation).succeeded(); + + assertEquals(2, compilation.generatedSourceFiles().size()); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMarshalledMapMessageSerializer") + .hasSourceEquivalentTo(javaFile("TestMarshalledMapMessageSerializer.java")); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMarshalledMapMessageMarshaller") + .hasSourceEquivalentTo(javaFile("TestMarshalledMapMessageMarshaller.java")); + } + /** */ private Compilation compile(String... srcFiles) { return compile(new MessageProcessor(), srcFiles); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java index e6f32de834b40..bbbde263386ad 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java @@ -31,6 +31,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Test; @@ -65,7 +66,13 @@ public void testMessageUnmarshallWithoutCacheContext() throws Exception { @Override public void onMessage(UUID nodeId, Object msg, byte plc) { if (msg instanceof TxLocksResponse) { try { - ((TxLocksResponse)msg).finishUnmarshal(clientCtx.marshaller(), clientCtx.deploy().globalLoader()); + MessageMarshaller.finishUnmarshal( + clientCtx.kernalContext().messageFactory(), + (TxLocksResponse)msg, + clientCtx.kernalContext(), + null, + clientCtx.deploy().globalLoader() + ); res.set(true); } diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java index 805f382bbb672..52c75c2d3860e 100644 --- a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java @@ -47,7 +47,6 @@ public TestMarshallableMessageMarshaller(Marshaller marshaller) { /** */ @Override public void finishUnmarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - msg.finishUnmarshal(marshaller, clsLdr); } /** */ diff --git a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessage.java b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessage.java new file mode 100644 index 0000000000000..61360b0d46142 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessage.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.util.Set; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.plugin.extensions.communication.Message; + +public class TestMarshalledCollectionMessage implements Message { + @MarshalledCollection("keysArr") + Set keys; + + @Order(0) + GridCacheVersion[] keysArr; + + public short directType() { + return 0; + } +} diff --git a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java new file mode 100644 index 0000000000000..3237a01e16209 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.TestMarshalledCollectionMessage; +import org.apache.ignite.internal.processors.cache.CacheObjectNotResolvedException; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMarshalledCollectionMessageMarshaller implements MessageMarshaller { + /** */ + public TestMarshalledCollectionMessageMarshaller() { + + } + + /** */ + @Override public void prepareMarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.keys != null && msg.keysArr == null) + msg.keysArr = msg.keys.toArray(new GridCacheVersion[0]); + + if (msg.keysArr != null) { + for (GridCacheVersion e4 : msg.keysArr) { + if (e4 != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e4, kctx, ctx); + } + } + } + + /** */ + @Override public void finishUnmarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.keysArr != null) { + msg.keys = U.newHashSet(msg.keysArr.length); + + for (GridCacheVersion e : msg.keysArr) { + if (e != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); + + try { + msg.keys.add(e); + } + catch (CacheObjectNotResolvedException ex) { + U.warn(kctx.log(getClass()), "Skipping unresolved element [field=keys]: " + ex.getMessage()); + } + } + + msg.keysArr = null; + } + } + + /** */ + @Override public void finishUnmarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + if (msg.keysArr != null) { + for (GridCacheVersion e4 : msg.keysArr) { + if (e4 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx); + } + } + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageSerializer.java new file mode 100644 index 0000000000000..74612611f526a --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageSerializer.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.internal.TestMarshalledCollectionMessage; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.plugin.extensions.communication.MessageArrayType; +import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; +import org.apache.ignite.plugin.extensions.communication.MessageItemType; +import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageWriter; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMarshalledCollectionMessageSerializer implements MessageSerializer { + /** */ + private static final MessageArrayType keysArrCollDesc = new MessageArrayType(new MessageItemType(MessageCollectionItemType.MSG), GridCacheVersion.class); + + /** */ + public TestMarshalledCollectionMessageSerializer() { + + } + + /** */ + @Override public boolean writeTo(TestMarshalledCollectionMessage msg, MessageWriter writer) { + if (!writer.isHeaderWritten()) { + if (!writer.writeHeader(msg.directType())) + return false; + + writer.onHeaderWritten(); + } + + switch (writer.state()) { + case 0: + if (!writer.writeObjectArray(msg.keysArr, keysArrCollDesc)) + return false; + + writer.incrementState(); + } + + return true; + } + + /** */ + @Override public boolean readFrom(TestMarshalledCollectionMessage msg, MessageReader reader) { + switch (reader.state()) { + case 0: + msg.keysArr = reader.readObjectArray(keysArrCollDesc); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + } + + return true; + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMapMessage.java b/modules/core/src/test/resources/codegen/TestMarshalledMapMessage.java new file mode 100644 index 0000000000000..e2a77b6fb2b43 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshalledMapMessage.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.util.Collection; +import java.util.Map; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.plugin.extensions.communication.Message; + +public class TestMarshalledMapMessage implements Message { + @MarshalledMap(keys = "mapKeys", values = "mapVals") + Map theMap; + + @Order(0) + Collection mapKeys; + + @Order(1) + Collection mapVals; + + public short directType() { + return 0; + } +} diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java new file mode 100644 index 0000000000000..86a7c09d1f434 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.util.Collection; +import java.util.Iterator; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.TestMarshalledMapMessage; +import org.apache.ignite.internal.processors.cache.CacheObjectNotResolvedException; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMarshalledMapMessageMarshaller implements MessageMarshaller { + /** */ + public TestMarshalledMapMessageMarshaller() { + + } + + /** */ + @Override public void prepareMarshal(TestMarshalledMapMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.theMap != null && msg.mapKeys == null) { + msg.mapKeys = msg.theMap.keySet(); + msg.mapVals = msg.theMap.values(); + } + + if (msg.mapKeys != null) { + for (GridCacheVersion e4 : (Collection)msg.mapKeys) { + if (e4 != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e4, kctx, ctx); + } + } + + if (msg.mapVals != null) { + for (GridCacheVersion e4 : (Collection)msg.mapVals) { + if (e4 != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e4, kctx, ctx); + } + } + } + + /** */ + @Override public void finishUnmarshal(TestMarshalledMapMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + GridCacheContext ctx = nested; + + if (msg.mapKeys != null) { + msg.theMap = U.newHashMap(msg.mapKeys.size()); + + Iterator keyIter = msg.mapKeys.iterator(); + Iterator valIter = msg.mapVals.iterator(); + + while (keyIter.hasNext()) { + GridCacheVersion k = (GridCacheVersion)keyIter.next(); + GridCacheVersion v = (GridCacheVersion)valIter.next(); + + if (k != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), k, kctx, ctx, clsLdr); + + if (v != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), v, kctx, ctx, clsLdr); + + try { + msg.theMap.put(k, v); + } + catch (CacheObjectNotResolvedException ex) { + U.warn(kctx.log(getClass()), "Skipping unresolved element [field=theMap]: " + ex.getMessage()); + } + } + + msg.mapKeys = null; + msg.mapVals = null; + } + } + + /** */ + @Override public void finishUnmarshal(TestMarshalledMapMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + if (msg.mapKeys != null) { + for (GridCacheVersion e4 : (Collection)msg.mapKeys) { + if (e4 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx); + } + } + + if (msg.mapVals != null) { + for (GridCacheVersion e4 : (Collection)msg.mapVals) { + if (e4 != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx); + } + } + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageSerializer.java new file mode 100644 index 0000000000000..f9bd0bf24e195 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageSerializer.java @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.internal.TestMarshalledMapMessage; +import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; +import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; +import org.apache.ignite.plugin.extensions.communication.MessageItemType; +import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageWriter; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMarshalledMapMessageSerializer implements MessageSerializer { + /** */ + private static final MessageCollectionType mapKeysCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.MSG), false); + /** */ + private static final MessageCollectionType mapValsCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.MSG), false); + + /** */ + public TestMarshalledMapMessageSerializer() { + + } + + /** */ + @Override public boolean writeTo(TestMarshalledMapMessage msg, MessageWriter writer) { + if (!writer.isHeaderWritten()) { + if (!writer.writeHeader(msg.directType())) + return false; + + writer.onHeaderWritten(); + } + + switch (writer.state()) { + case 0: + if (!writer.writeCollection(msg.mapKeys, mapKeysCollDesc)) + return false; + + writer.incrementState(); + + case 1: + if (!writer.writeCollection(msg.mapVals, mapValsCollDesc)) + return false; + + writer.incrementState(); + } + + return true; + } + + /** */ + @Override public boolean readFrom(TestMarshalledMapMessage msg, MessageReader reader) { + switch (reader.state()) { + case 0: + msg.mapKeys = reader.readCollection(mapKeysCollDesc); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + + case 1: + msg.mapVals = reader.readCollection(mapValsCollDesc); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + } + + return true; + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMessage.java b/modules/core/src/test/resources/codegen/TestMarshalledMessage.java new file mode 100644 index 0000000000000..a110f5e9ecb59 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshalledMessage.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.plugin.extensions.communication.Message; + +public class TestMarshalledMessage implements Message { + @Marshalled("dataBytes") + Object data; + + @Order(0) + byte[] dataBytes; + + public short directType() { + return 0; + } +} diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java new file mode 100644 index 0000000000000..6de3f72eb0ba3 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.TestMarshalledMessage; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMarshalledMessageMarshaller implements MessageMarshaller { + /** */ + private final Marshaller marshaller; + + /** */ + public TestMarshalledMessageMarshaller(Marshaller marshaller) { + this.marshaller = marshaller; + + } + + /** */ + @Override public void prepareMarshal(TestMarshalledMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + if (msg.data != null) + msg.dataBytes = U.marshal(marshaller, msg.data); + } + + /** */ + @Override public void finishUnmarshal(TestMarshalledMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + } + + /** */ + @Override public void finishUnmarshal(TestMarshalledMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + if (msg.dataBytes != null) { + msg.data = U.unmarshal(marshaller, msg.dataBytes, U.resolveClassLoader(kctx.config())); + + msg.dataBytes = null; + } + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMarshalledMessageSerializer.java new file mode 100644 index 0000000000000..bcd6ec5ba8ee8 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshalledMessageSerializer.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.internal.TestMarshalledMessage; +import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageWriter; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMarshalledMessageSerializer implements MessageSerializer { + /** */ + public TestMarshalledMessageSerializer() { + + } + + /** */ + @Override public boolean writeTo(TestMarshalledMessage msg, MessageWriter writer) { + if (!writer.isHeaderWritten()) { + if (!writer.writeHeader(msg.directType())) + return false; + + writer.onHeaderWritten(); + } + + switch (writer.state()) { + case 0: + if (!writer.writeByteArray(msg.dataBytes)) + return false; + + writer.incrementState(); + } + + return true; + } + + /** */ + @Override public boolean readFrom(TestMarshalledMessage msg, MessageReader reader) { + switch (reader.state()) { + case 0: + msg.dataBytes = reader.readByteArray(); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + } + + return true; + } +} \ No newline at end of file From ec5ed63ae146646477db1c4a6b2130d83bf33eb7 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Thu, 25 Jun 2026 23:59:49 +0300 Subject: [PATCH 169/215] WIP --- .../calcite/message/QueryStartRequest.java | 50 +--- .../query/calcite/message/QueryTxEntry.java | 13 +- .../internal/MessageDeploymentGenerator.java | 273 ++++++++++++++++++ .../ignite/internal/MessageGenerator.java | 71 ++--- .../internal/MessageMarshallerGenerator.java | 118 +++----- .../ignite/internal/MessageProcessor.java | 26 +- .../internal/MessageSerializerGenerator.java | 43 ++- .../org/apache/ignite/internal/NioField.java | 4 +- .../ignite/internal/CoreMessagesProvider.java | 4 +- .../apache/ignite/internal/TxEntriesInfo.java | 5 +- .../IgniteMessageFactoryImpl.java | 28 +- ...actMarshallableMessageFactoryProvider.java | 56 ++-- .../CacheObjectNotResolvedException.java | 2 +- .../processors/cache/DeployableMessage.java | 35 +++ .../processors/cache/GridCacheIoManager.java | 6 +- .../processors/cache/GridCacheMessage.java | 55 +--- .../cache/GridCacheMessageDeployer.java | 113 ++++++++ .../cache/IgniteCacheOffheapManagerImpl.java | 4 +- .../GridCacheTtlUpdateRequest.java | 15 - .../GridDistributedLockRequest.java | 12 - .../GridDistributedLockResponse.java | 9 - .../GridDistributedTxPrepareRequest.java | 17 +- .../distributed/GridNearUnlockRequest.java | 9 - .../distributed/dht/GridDhtLockResponse.java | 17 +- .../dht/GridDhtTxPrepareRequest.java | 19 +- .../distributed/dht/GridDhtUnlockRequest.java | 8 - .../TransactionAttributesAwareRequest.java | 7 - ...omicApplicationAttributesAwareRequest.java | 7 - .../atomic/GridDhtAtomicUpdateRequest.java | 58 ++-- .../atomic/GridDhtAtomicUpdateResponse.java | 12 - .../GridNearAtomicFullUpdateRequest.java | 50 ++-- ...idNearAtomicSingleUpdateInvokeRequest.java | 39 ++- .../GridNearAtomicSingleUpdateRequest.java | 15 - .../atomic/GridNearAtomicUpdateResponse.java | 24 +- .../preloader/GridDhtForceKeysRequest.java | 12 - .../preloader/GridDhtForceKeysResponse.java | 14 +- .../GridDhtPartitionSupplyMessage.java | 3 +- .../GridDhtPartitionsExchangeFuture.java | 3 +- .../distributed/near/CacheVersionedValue.java | 6 +- .../distributed/near/GridNearGetRequest.java | 19 -- .../near/GridNearSingleGetRequest.java | 14 - .../near/GridNearSingleGetResponse.java | 12 +- .../near/GridNearTxPrepareResponse.java | 4 +- .../IncrementalSnapshotAwareMessage.java | 7 - .../cache/query/GridCacheQueryRequest.java | 70 ++--- .../cache/query/GridCacheQueryResponse.java | 45 ++- .../cache/transactions/IgniteTxEntry.java | 6 +- .../cache/transactions/IgniteTxHandler.java | 5 +- .../cache/transactions/IgniteTxManager.java | 9 +- .../cache/transactions/TxLocksRequest.java | 19 +- .../cache/transactions/TxLocksResponse.java | 6 +- .../communication/CacheIdAware.java | 7 +- .../CacheMarshallableMessage.java | 2 +- .../communication/MarshallableMessage.java | 2 +- .../communication/MessageFactory.java | 28 ++ .../communication/MessageMarshaller.java | 16 +- .../communication/MessageSerializer.java | 2 +- .../ignite/spi/discovery/ObjectData.java | 2 +- .../codegen/MessageProcessorTest.java | 50 +++- .../MessageSerializationArchitectureTest.java | 43 ++- .../MessageDirectTypeIdConflictTest.java | 3 +- ...adlockDetectionMessageMarshallingTest.java | 12 +- .../DataStreamerImplSelfTest.java | 4 +- .../IgniteExceptionInNioWorkerSelfTest.java | 8 +- .../p2p/ClassLoadingProblemExceptionTest.java | 3 +- .../tcp/TestDelayMessageSerializer.java | 6 +- .../DiscoveryUnmarshalVulnerabilityTest.java | 18 +- .../ignite/testframework/GridTestUtils.java | 2 +- .../junits/GridTestKernalContext.java | 2 +- .../codegen/NioFieldOnNonMessageMessage.java | 3 + .../resources/codegen/TestCacheIdMessage.java | 47 +++ .../codegen/TestCacheIdMessageDeployer.java | 44 +++ .../codegen/TestDeployableMessage.java | 41 +++ .../TestDeployableMessageDeployer.java | 40 +++ .../codegen/TestNestedDeployMessage.java | 33 +++ .../TestNestedDeployMessageDeployer.java | 35 +++ .../codegen/TestNoCacheCtxMessage.java | 34 +++ .../zk/internal/DiscoveryMessageParser.java | 5 +- .../zk/internal/ZkMessageFactory.java | 6 +- 79 files changed, 1237 insertions(+), 739 deletions(-) create mode 100644 modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java create mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DeployableMessage.java create mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java create mode 100644 modules/core/src/test/resources/codegen/TestCacheIdMessage.java create mode 100644 modules/core/src/test/resources/codegen/TestCacheIdMessageDeployer.java create mode 100644 modules/core/src/test/resources/codegen/TestDeployableMessage.java create mode 100644 modules/core/src/test/resources/codegen/TestDeployableMessageDeployer.java create mode 100644 modules/core/src/test/resources/codegen/TestNestedDeployMessage.java create mode 100644 modules/core/src/test/resources/codegen/TestNestedDeployMessageDeployer.java create mode 100644 modules/core/src/test/resources/codegen/TestNoCacheCtxMessage.java diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java index 0b6ca25f9dbdb..dc43c49281720 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java @@ -29,9 +29,7 @@ import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; -/** - * - */ +/** Message sent to remote nodes to start a query fragment execution. */ public class QueryStartRequest implements MarshallableMessage, ExecutionContextAware { /** */ @Order(0) @@ -41,7 +39,7 @@ public class QueryStartRequest implements MarshallableMessage, ExecutionContextA @Order(1) UUID qryId; - /** */ + /** Sequential local counter; see {@link #qryId} for the cluster-wide UUID. */ @Order(2) long originatingQryId; @@ -72,7 +70,7 @@ public class QueryStartRequest implements MarshallableMessage, ExecutionContextA @Order(8) long timeout; - /** */ + /** Transaction entries to mix in during query processing, or {@code null} if not inside a tx. */ @Order(9) @Nullable Collection qryTxEntries; @@ -116,14 +114,12 @@ public QueryStartRequest( this.keepBinaryMode = keepBinaryMode; } - /** */ + /** Default no-arg constructor required for deserialization. */ public QueryStartRequest() { // No-op. } - /** - * @return Schema name. - */ + /** */ public String schema() { return schema; } @@ -133,9 +129,7 @@ public String schema() { return qryId; } - /** - * @return Registered local query ID on originating node. - */ + /** */ public long originatingQueryId() { return originatingQryId; } @@ -145,60 +139,44 @@ public long originatingQueryId() { return fragmentDesc.fragmentId(); } - /** - * @return Fragment description. - */ + /** */ public FragmentDescription fragmentDescription() { return fragmentDesc; } - /** - * @return Topology version. - */ + /** */ public AffinityTopologyVersion topologyVersion() { return ver; } - /** - * @return Fragment plan. - */ + /** */ public String root() { return root; } - /** - * @return Total count of fragments in query for this node. - */ + /** */ public int totalFragmentsCount() { return totalFragmentsCnt; } - /** - * @return Query parameters. - */ + /** */ @SuppressWarnings("AssignmentOrReturnOfFieldWithMutableType") public @Nullable Object[] parameters() { return params; } - /** - * @return Query parameters marshalled. - */ + /** */ @SuppressWarnings("AssignmentOrReturnOfFieldWithMutableType") public byte[] parametersMarshalled() { return paramsBytes; } - /** - * @return Query timeout. - */ + /** */ public long timeout() { return timeout; } - /** - * @return Transaction entries to mixin on query processing. - */ + /** */ public @Nullable Collection queryTransactionEntries() { return qryTxEntries; } diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java index 5b5640f094825..024e3ae039b18 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java @@ -54,19 +54,12 @@ public class QueryTxEntry implements Message, CacheIdAware { @Order(3) GridCacheVersion ver; - /** - * Empty constructor. - */ + /** */ public QueryTxEntry() { // No-op. } - /** - * @param cacheId Cache id. - * @param key Key. - * @param val Value. - * @param ver Version. - */ + /** */ public QueryTxEntry(int cacheId, KeyCacheObject key, CacheObject val, GridCacheVersion ver) { this.cacheId = cacheId; this.key = key; @@ -74,7 +67,7 @@ public QueryTxEntry(int cacheId, KeyCacheObject key, CacheObject val, GridCacheV this.ver = ver; } - /** {@inheritDoc} */ + /** {@inheritDoc} */ @Override public int cacheId() { return cacheId; } diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java new file mode 100644 index 0000000000000..89f0581655003 --- /dev/null +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java @@ -0,0 +1,273 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.type.WildcardType; +import javax.lang.model.util.ElementFilter; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.internal.systemview.SystemViewRowAttributeWalkerProcessor.superclasses; + +/** + * Generates a {@code *Deployer} class for messages whose {@code @Order} fields have a type that indicates deployment + * need: {@code CacheObject} subtypes, {@code Collection}, {@code Iterable}, or a + * nested {@code GridCacheMessage} (whose deployment is delegated). The strategy is inferred entirely from the field type. + * + *

A message with deployment logic that cannot be inferred from field types implements {@code DeployableMessage}; + * the generated deployer then also delegates to its {@code prepareDeployment}, mirroring {@code prepareMarshal}. + */ +public class MessageDeploymentGenerator extends MessageGenerator { + /** FQN of GridCacheMessage; hierarchy scan stops here (exclusive). */ + private static final String GRID_CACHE_MESSAGE = "org.apache.ignite.internal.processors.cache.GridCacheMessage"; + + private final TypeMirror cacheIdMsgMirror; + private final TypeMirror cacheGroupIdMsgMirror; + private final TypeMirror gridCacheMessageMirror; + private final TypeMirror deployableMessageMirror; + private final TypeMirror cacheObjectMirror; + private final TypeMirror txEntryMirror; + private final TypeMirror collectionMirror; + private final TypeMirror iterableMirror; + + /** Accumulated source lines for the generated {@code prepareDeployment} method. */ + private final List deploy = new ArrayList<>(); + + /** */ + private boolean needsCctx; + + MessageDeploymentGenerator(ProcessingEnvironment env) { + super(env); + + cacheIdMsgMirror = type("org.apache.ignite.internal.processors.cache.GridCacheIdMessage"); + cacheGroupIdMsgMirror = type("org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage"); + gridCacheMessageMirror = type(GRID_CACHE_MESSAGE); + deployableMessageMirror = type("org.apache.ignite.internal.processors.cache.DeployableMessage"); + cacheObjectMirror = type("org.apache.ignite.internal.processors.cache.CacheObject"); + txEntryMirror = type("org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry"); + collectionMirror = erasedType(type("java.util.Collection")); + iterableMirror = erasedType(type("java.lang.Iterable")); + } + + /** {@inheritDoc} */ + @Override String typeSuffix() { + return "Deployer"; + } + + /** {@inheritDoc} */ + @Override boolean shouldSkip(TypeElement type) { + if (gridCacheMessageMirror == null || !assignableFrom(type.asType(), gridCacheMessageMirror)) + return true; + + // Generate when the message carries custom deployment logic... + if (hasCustomDeployment(type)) + return false; + + // ...or has any field whose deployment can be inferred from its type. + for (VariableElement f : allHierarchyFields(type)) { + if (deployKind(f) != null) + return false; + } + + return true; + } + + /** @return {@code true} if {@code type} implements {@code DeployableMessage} (has hand-written {@code prepareDeployment}). */ + private boolean hasCustomDeployment(TypeElement type) { + return deployableMessageMirror != null && assignableFrom(type.asType(), deployableMessageMirror); + } + + /** {@inheritDoc} */ + @Override void generateBody(List fields) { + indent = 1; + + deploy.add(indentedLine(METHOD_JAVADOC)); + deploy.add(indentedLine( + "@Override public void prepareDeployment(%s msg, GridCacheSharedContext ctx) throws IgniteCheckedException {", + simpleNameWithGeneric(type))); + + indent++; + + List body = new ArrayList<>(); + + for (VariableElement field : allHierarchyFields(type)) { + DeployKind kind = deployKind(field); + + if (kind == null) + continue; + + String stmt; + + switch (kind) { + case CACHE_OBJECT: + needsCctx = true; + stmt = "GridCacheMessageDeployer.prepareCacheObject(msg, %s, cctx);"; + + break; + + case CACHE_OBJECTS: + needsCctx = true; + stmt = "GridCacheMessageDeployer.prepareCacheObjects(msg, %s, cctx);"; + + break; + + case TX_ENTRIES: + stmt = "GridCacheMessageDeployer.prepareTxEntries(msg, %s, ctx);"; + + break; + + case NESTED: + stmt = "GridCacheMessageDeployer.prepareDeployment(ctx.kernalContext().messageFactory(), %s, ctx);"; + + break; + + default: + throw new IllegalStateException("Unexpected deploy kind: " + kind); + } + + appendBlock(body, List.of(indentedLine(stmt, fieldAccessor(field)))); + } + + if (needsCctx) { + deploy.add(indentedLine(cctxResolutionLine())); + deploy.add(EMPTY); + } + + deploy.addAll(body); + + // Delegate the non-inferable part to the message's own prepareDeployment, mirroring msg.prepareMarshal(). + if (hasCustomDeployment(type)) { + if (!body.isEmpty()) + deploy.add(EMPTY); + + deploy.add(indentedLine("msg.prepareDeployment(ctx);")); + } + + indent--; + + deploy.add(indentedLine("}")); + } + + /** {@inheritDoc} */ + @Override String buildClassCode(String deployerClsName) throws IOException { + try (Writer writer = new StringWriter()) { + imports.add(type.toString()); + imports.add("org.apache.ignite.IgniteCheckedException"); + imports.add("org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer"); + imports.add("org.apache.ignite.internal.processors.cache.GridCacheSharedContext"); + + if (needsCctx) + imports.add("org.apache.ignite.internal.processors.cache.GridCacheContext"); + + writeClassHeader(writer, "GridCacheMessageDeployer", deployerClsName); + + writer.write(" {" + NL); + + for (String line : deploy) + writer.write(line + NL); + + writer.write("}"); + + return writer.toString(); + } + } + + /** Returns the line that resolves {@code cctx} from {@code ctx} based on the message type hierarchy. */ + private String cctxResolutionLine() { + if (cacheGroupIdMsgMirror != null && assignableFrom(type.asType(), cacheGroupIdMsgMirror)) + return "GridCacheContext cctx = ctx.cacheContext(msg.groupId());"; + + if (cacheIdMsgMirror != null && assignableFrom(type.asType(), cacheIdMsgMirror)) + return "GridCacheContext cctx = ctx.cacheContext(msg.cacheId());"; + + throw new IllegalStateException("Cannot resolve cache context for " + type.getQualifiedName() + + ": message has CacheObject field(s) but is neither GridCacheIdMessage nor GridCacheGroupIdMessage."); + } + + /** All fields declared across the class hierarchy of {@code te}, up to but excluding {@code Object}. */ + private List allHierarchyFields(TypeElement te) { + List result = new ArrayList<>(); + + superclasses(env, te).forEach(c -> result.addAll(ElementFilter.fieldsIn(c.getEnclosedElements()))); + + return result; + } + + /** Returns the deployment strategy for {@code field} based on its Java type, or {@code null} if not deployable. */ + private @Nullable DeployKind deployKind(VariableElement field) { + // Only serialized fields are sent over the wire and thus need deployment; transient fields are skipped. + if (field.getAnnotation(Order.class) == null) + return null; + + TypeMirror fieldType = field.asType(); + + if (fieldType.getKind() == TypeKind.ARRAY || fieldType.getKind().isPrimitive()) + return null; + + if (cacheObjectMirror != null && assignableFrom(fieldType, cacheObjectMirror)) + return DeployKind.CACHE_OBJECT; + + if (!(fieldType instanceof DeclaredType)) + return null; + + List args = ((DeclaredType)fieldType).getTypeArguments(); + TypeMirror erased = erasedType(fieldType); + + if (!args.isEmpty()) { + TypeMirror elemType = erasedType(elementBound(args.get(0))); + + if (cacheObjectMirror != null && collectionMirror != null + && assignableFrom(erased, collectionMirror) + && assignableFrom(elemType, cacheObjectMirror)) + return DeployKind.CACHE_OBJECTS; + + if (txEntryMirror != null && iterableMirror != null + && assignableFrom(erased, iterableMirror) + && env.getTypeUtils().isSameType(elemType, txEntryMirror)) + return DeployKind.TX_ENTRIES; + } + + // A nested message field delegates its own deployment (a no-op when that message has no deployer). + if (gridCacheMessageMirror != null && assignableFrom(fieldType, gridCacheMessageMirror)) + return DeployKind.NESTED; + + return null; + } + + /** Unwraps the upper bound of a wildcard type; returns the type as-is for non-wildcards. */ + private TypeMirror elementBound(TypeMirror arg) { + if (arg instanceof WildcardType) { + TypeMirror bound = ((WildcardType)arg).getExtendsBound(); + return bound != null ? bound : arg; + } + + return arg; + } + + private enum DeployKind { CACHE_OBJECT, CACHE_OBJECTS, TX_ENTRIES, NESTED } +} diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java index ed69200219816..c25f46370dc00 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java @@ -24,13 +24,16 @@ import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.TreeSet; import javax.annotation.processing.FilerException; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; import javax.lang.model.util.Elements; import javax.tools.Diagnostic; import javax.tools.FileObject; @@ -41,19 +44,17 @@ /** Base class for message code generators ({@link MessageSerializerGenerator}, {@link MessageMarshallerGenerator}). */ public abstract class MessageGenerator { - /** */ + /** Blank separator line in generated code. */ public static final String EMPTY = ""; - /** */ public static final String NL = System.lineSeparator(); - /** */ public static final String TAB = " "; - /** */ + /** Javadoc stub emitted on every generated {@code @Override} method. */ public static final String METHOD_JAVADOC = "/** */"; - /** */ + /** Javadoc block emitted on every generated class. */ public static final String CLS_JAVADOC = "/**" + NL + " * This class is generated automatically." + NL + " *" + NL + @@ -63,23 +64,20 @@ public abstract class MessageGenerator { /** */ final ProcessingEnvironment env; - /** Collection of message-specific imports. */ + /** */ final java.util.Set imports = new TreeSet<>(); - /** Message type being generated for. */ + /** */ TypeElement type; /** */ int indent; - /** */ MessageGenerator(ProcessingEnvironment env) { this.env = env; } - /** - * Generates and writes the source file for the given message type. - * Template method: subclasses implement {@link #generateBody} and {@link #buildClassCode}. + /** Generates and writes the source file for {@code type}; skipped when {@link #shouldSkip} returns {@code true}. */ final void generate(TypeElement type, List fields) throws Exception { assert this.type == null : "Message" + typeSuffix() + " generator isn't stateless and is supposed to be single-use."; @@ -105,8 +103,7 @@ final void generate(TypeElement type, List fields) throws Excep } catch (FilerException e) { if (!identicalFileIsAlreadyGenerated(env, code, fqnClsName)) { - env.getMessager().printMessage( - Diagnostic.Kind.ERROR, + env.getMessager().printMessage(Diagnostic.Kind.ERROR, "Message" + typeSuffix() + " " + clsName + " is already generated. Try 'mvn clean install' to fix the issue."); throw e; @@ -117,24 +114,19 @@ final void generate(TypeElement type, List fields) throws Excep /** @return Class name suffix: {@code "Serializer"} or {@code "Marshaller"}. */ abstract String typeSuffix(); - /** - * @return {@code true} if no source file should be generated for the given message type. - * Default: {@code false} (generate for all types). - */ + /** @return {@code true} if no file should be generated for this type; default is {@code false}. */ boolean shouldSkip(TypeElement type) { return false; } - /** - * Generates the body of the class by populating internal state (e.g. write/read or marshal/unmarshal lists). - * Called before {@link #buildClassCode}. + /** Populates internal state (method body lines etc.) from {@code fields}; called before {@link #buildClassCode}. */ abstract void generateBody(List fields) throws Exception; /** Generates and returns the complete source code for the generated class. */ abstract String buildClassCode(String clsName) throws IOException; - /** Writes the Apache license header to the given writer. */ + /** */ void writeLicense(Writer writer) throws IOException { try (InputStream in = getClass().getClassLoader().getResourceAsStream("license.txt"); BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { @@ -147,14 +139,7 @@ void writeLicense(Writer writer) throws IOException { } } - /** - * Writes the common class header: license, package declaration, imports, Javadoc, and class declaration line. - * Callers must have already populated {@link #imports} with all required imports before calling this method. - * - * @param writer Target writer. - * @param interfaceName Simple name of the implemented interface (e.g. {@code "MessageSerializer"}). - * @param clsName Generated class name (e.g. {@code "FooSerializer"}). - */ + /** Writes license, package, imports, javadoc, and class declaration; {@link #imports} must be populated before calling. */ void writeClassHeader(Writer writer, String interfaceName, String clsName) throws IOException { writeLicense(writer); @@ -170,7 +155,7 @@ void writeClassHeader(Writer writer, String interfaceName, String clsName) throw writer.write("public class " + clsName + " implements " + interfaceName + "<" + simpleNameWithGeneric(type) + ">"); } - /** */ + /** @return {@code format} formatted with {@code args}, prefixed with {@link #indent} tabs. */ String indentedLine(String format, Object... args) { SB sb = new SB(); @@ -182,7 +167,7 @@ String indentedLine(String format, Object... args) { return sb.toString(); } - /** */ + /** @return simple name of {@code te} with {@code } wildcard type arguments appended when parameterised. */ String simpleNameWithGeneric(TypeElement te) { if (F.size(te.getTypeParameters()) == 0) return te.getSimpleName().toString(); @@ -206,7 +191,7 @@ boolean assignableFrom(TypeMirror type, TypeMirror superType) { return env.getTypeUtils().isAssignable(type, superType); } - /** */ + /** @return the {@link TypeMirror} for the fully-qualified {@code clazz}, or {@code null} if not on classpath. */ TypeMirror type(String clazz) { Elements elementUtils = env.getElementUtils(); TypeElement typeElement = elementUtils.getTypeElement(clazz); @@ -218,12 +203,30 @@ TypeMirror erasedType(TypeMirror type) { return env.getTypeUtils().erasure(type); } - /** */ + /** @return {@code "msg."} accessor expression for {@code field}. */ String fieldAccessor(VariableElement field) { return "msg." + field.getSimpleName().toString(); } - /** @return {@code true} if a file with identical content is already generated (e.g. during IDE incremental build). */ + /** Returns all fields declared directly on {@link #type}, in declaration order. */ + protected Map enclosedFields() { + Map result = new LinkedHashMap<>(); + + for (VariableElement f : ElementFilter.fieldsIn(type.getEnclosedElements())) + result.put(f.getSimpleName().toString(), f); + + return result; + } + + /** Appends {@code block} to {@code body}, inserting a blank-line separator when {@code body} is non-empty. */ + protected static void appendBlock(List body, List block) { + if (!body.isEmpty()) + body.add(EMPTY); + + body.addAll(block); + } + + /** @return {@code true} if a file with identical content is already generated (e.g. during incremental build). */ public static boolean identicalFileIsAlreadyGenerated(ProcessingEnvironment env, String srcCode, String fqnClsName) { try { String fileName = fqnClsName.replace('.', '/') + ".java"; diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index cceffa6fed419..f38a9df01243c 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -22,7 +22,7 @@ import java.io.Writer; import java.util.ArrayList; import java.util.HashSet; -import java.util.LinkedHashMap; + import java.util.List; import java.util.Map; import java.util.Set; @@ -38,62 +38,59 @@ import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVariable; -import javax.lang.model.util.ElementFilter; + import javax.tools.Diagnostic; import static org.apache.ignite.internal.MessageProcessor.MARSHALLABLE_MESSAGE_INTERFACE; import static org.apache.ignite.internal.MessageProcessor.MESSAGE_INTERFACE; /** - * Generates marshaller class for a given {@code Message} class. The generated marshaller follows the naming convention: - * {@code org.apache.ignite.internal.codegen.[MessageClassName]Marshaller}. - *

- * No marshaller is generated for {@code NonMarshallableMessage} types. + * Generates {@code *Marshaller} classes for {@link org.apache.ignite.plugin.extensions.communication.Message} + * types that are not {@link NonMarshallableMessage}. */ public class MessageMarshallerGenerator extends MessageGenerator { /** Accumulated source lines for all generated marshal/unmarshal methods. */ private final List marshall = new ArrayList<>(); - /** MarshallableMessage type mirror. */ + /** */ private final TypeMirror marshallableMsgType; - /** Message type mirror. */ + /** */ private final TypeMirror messageMirror; - /** CacheObject type mirror. */ + /** */ private final TypeMirror cacheObjectMirror; - /** NonMarshallableMessage type mirror. */ + /** */ private final TypeMirror nonMarshallableMirror; - /** CacheIdAware type mirror. */ + /** */ private final TypeMirror cacheIdAwareMirror; - /** GridCacheGroupIdMessage type mirror. */ + /** */ private final TypeMirror cacheGroupIdMsgMirror; - /** java.util.Map type mirror. */ + /** */ private final TypeMirror mapMirror; - /** java.util.Collection type mirror. */ + /** */ private final TypeMirror collectionMirror; - /** CacheMarshallableMessage type mirror. */ + /** */ private final TypeMirror cacheMarshallableMsgType; - /** Whether the current message type implements {@code MarshallableMessage}. */ + /** */ private boolean marshallable; - /** Whether the current message type implements {@code CacheMarshallableMessage}. */ + /** */ private boolean cacheMarshallable; - /** Whether the current message type has any {@code @Marshalled} fields. */ + /** */ private boolean hasMarshalled; /** Enclosed fields of the currently processed type. Computed once per {@link #generateBody} call. */ private Map enclosed; - /** @param env annotation processing environment. */ MessageMarshallerGenerator(ProcessingEnvironment env) { super(env); @@ -194,9 +191,8 @@ private void generatePrepareMarshalMethod(List orderedFields) { marshall.add(indentedLine(METHOD_JAVADOC)); - marshall.add(indentedLine( - "@Override public void prepareMarshal(" + simpleNameWithGeneric(type) + - " msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException {")); + marshall.add(indentedLine("@Override public void prepareMarshal(" + simpleNameWithGeneric(type) + + " msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException {")); indent++; @@ -233,8 +229,7 @@ private void generateUnmarshallMethods(List orderedFields) { else { if (nioField) env.getMessager().printMessage(Diagnostic.Kind.ERROR, - "@NioField has no effect on non-Message field '" + f.getSimpleName() + "' of type " + f.asType(), - f); + "@NioField has no effect on non-Message field '" + f.getSimpleName() + "' of type " + f.asType(), f); workerFields.add(f); } @@ -259,8 +254,7 @@ private void generateFinishUnmarshalMethod(String methodName, String params, Lis marshall.add(indentedLine(METHOD_JAVADOC)); - marshall.add(indentedLine( - "@Override public void " + methodName + "(" + params + ") throws IgniteCheckedException {")); + marshall.add(indentedLine("@Override public void " + methodName + "(" + params + ") throws IgniteCheckedException {")); indent++; @@ -301,8 +295,7 @@ private void generateFinishUnmarshalNioMethod(String params, List body) { } /** Generates indexed-loop Map reconstruction for array-backed {@code @MarshalledMap} fields. */ - private List mapFinishArrayBlock( - VariableElement field, - VariableElement keysEl, - VariableElement valsEl, - String mapField, - String keysField, - String valsField - ) { + private List mapFinishArrayBlock(VariableElement field, VariableElement keysEl, VariableElement valsEl, String mapField, + String keysField, String valsField) { boolean isFinal = field.getModifiers().contains(Modifier.FINAL); String keyCompName = arrayComponentName(keysEl); String valCompName = arrayComponentName(valsEl); @@ -615,14 +602,8 @@ private List mapFinishArrayBlock( } /** Generates iterator-based Map reconstruction for collection-backed {@code @MarshalledMap} fields. */ - private List mapFinishCollectionBlock( - VariableElement field, - VariableElement keysEl, - VariableElement valsEl, - String mapField, - String keysField, - String valsField - ) { + private List mapFinishCollectionBlock(VariableElement field, VariableElement keysEl, VariableElement valsEl, String mapField, + String keysField, String valsField) { List keyArgs = ((DeclaredType)keysEl.asType()).getTypeArguments(); List valArgs = ((DeclaredType)valsEl.asType()).getTypeArguments(); @@ -706,13 +687,7 @@ private List mapFinishCollectionBlock( } /** Generates key/value array population from the map's entry set. */ - private List arrayMapBody( - MarshalledMap ann, - String mapField, - String keysField, - VariableElement keysEl, - String valuesField - ) { + private List arrayMapBody(MarshalledMap ann, String mapField, String keysField, VariableElement keysEl, String valuesField) { String compName = arrayComponentName(keysEl); String valCompName = arrayComponentName(requireEnclosed(enclosed, ann.values(), "@MarshalledMap")); @@ -798,16 +773,13 @@ private List marshallMessage(String accessor, MarshalMode mode) { switch (mode) { case PREPARE: - code.add(indentedLine( - "MessageMarshaller.prepareMarshal(kctx.messageFactory(), %s, kctx, ctx);", accessor)); + code.add(indentedLine("MessageMarshaller.prepareMarshal(kctx.messageFactory(), %s, kctx, ctx);", accessor)); break; case FINISH: - code.add(indentedLine( - "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx);", accessor)); + code.add(indentedLine("MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx);", accessor)); break; case FINISH_CACHE: - code.add(indentedLine( - "MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx, ctx, clsLdr);", accessor)); + code.add(indentedLine("MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx, ctx, clsLdr);", accessor)); break; } @@ -985,12 +957,12 @@ private boolean needsCtxType(TypeMirror t) { return false; } - /** Returns {@code true} if {@code type} is assignable to {@code Message}. */ + /** */ private boolean isMessage(TypeMirror type) { return messageMirror != null && assignableFrom(type, messageMirror); } - /** Returns {@code true} if {@code type} is assignable to {@code CacheObject}. */ + /** */ private boolean isCacheObject(TypeMirror type) { return cacheObjectMirror != null && assignableFrom(type, cacheObjectMirror); } @@ -1005,36 +977,26 @@ private boolean isCollection(TypeMirror type) { return collectionMirror != null && assignableFrom(erasedType(type), collectionMirror); } - /** Returns {@code true} if {@code te} implements {@code NonMarshallableMessage}. */ + /** */ private boolean isNonMarshallableMessage(TypeElement te) { return nonMarshallableMirror != null && assignableFrom(te.asType(), nonMarshallableMirror); } - /** Returns {@code true} if {@code te} implements {@code CacheIdAware}. */ + /** */ private boolean isCacheIdAwareMessage(TypeElement te) { return cacheIdAwareMirror != null && assignableFrom(te.asType(), cacheIdAwareMirror); } - /** Returns {@code true} if {@code te} is a {@code GridCacheGroupIdMessage}. */ + /** */ private boolean isCacheGroupIdMessage(TypeElement te) { return cacheGroupIdMsgMirror != null && assignableFrom(te.asType(), cacheGroupIdMsgMirror); } - /** Returns {@code true} if {@code field} carries {@code @NioField}. */ + /** */ private static boolean isNioField(VariableElement field) { return field.getAnnotation(NioField.class) != null; } - /** Returns all declared fields of the current type, keyed by simple name, preserving declaration order. */ - private Map enclosedFields() { - Map enclosed = new LinkedHashMap<>(); - - for (VariableElement f : ElementFilter.fieldsIn(type.getEnclosedElements())) - enclosed.put(f.getSimpleName().toString(), f); - - return enclosed; - } - /** Returns the enclosed field named {@code name}, or throws if absent. */ private VariableElement requireEnclosed(Map enclosed, String name, String annotationName) { VariableElement el = enclosed.get(name); @@ -1069,17 +1031,9 @@ private static String arrayComponentName(VariableElement field) { return ((DeclaredType)((ArrayType)field.asType()).getComponentType()).asElement().getSimpleName().toString(); } - /** Appends {@code block} to {@code body}, inserting a blank-line separator when {@code body} is non-empty. */ - private static void appendBlock(List body, List block) { - if (!body.isEmpty()) - body.add(EMPTY); - - body.addAll(block); - } - /** Marshal mode controls which overload is being generated. */ private enum MarshalMode { - /** Marshal. */ + /** */ PREPARE, /** Lightweight unmarshal. Messages only, CacheObject fields are skipped (no cache context available). */ diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java index 369db73b59e0b..8bca797b71a3d 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java @@ -90,12 +90,10 @@ public class MessageProcessor extends AbstractProcessor { "org.apache.ignite.spi.communication.tcp.TestDelayMessage" }; - /** */ + /** Tracks enum-to-mapper bindings to detect inconsistent mapper usage across messages. */ private final Map> enumMappersInUse = new HashMap<>(); - /** - * Processes all classes implementing the {@code Message} interface and generates corresponding serializer code. - */ + /** Processes all classes implementing the {@code Message} interface and generates corresponding serializer code. */ @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { TypeMirror msgType = processingEnv.getElementUtils().getTypeElement(MESSAGE_INTERFACE).asType(); @@ -147,10 +145,16 @@ public class MessageProcessor extends AbstractProcessor { new MessageMarshallerGenerator(processingEnv).generate(type.getKey(), type.getValue()); } catch (Exception e) { - processingEnv.getMessager().printMessage( - Diagnostic.Kind.ERROR, - "Failed to generate a message marshaller:" + e.getMessage(), - type.getKey()); + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, + "Failed to generate a message marshaller:" + e.getMessage(), type.getKey()); + } + + try { + new MessageDeploymentGenerator(processingEnv).generate(type.getKey(), type.getValue()); + } + catch (Exception e) { + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, + "Failed to generate a message deployer:" + e.getMessage(), type.getKey()); } } @@ -163,7 +167,7 @@ public class MessageProcessor extends AbstractProcessor { * The resulting list is sorted in ascending order of the {@code @Order} value. * * @param type the {@code TypeElement} representing the class to inspect. - * @return a list of {@code VariableElement} objects representing all ordered fields, including those declared in superclasses. + * @return all ordered fields including those in superclasses, sorted by ascending {@code @Order} value. */ private List orderedFields(TypeElement type) { List> hierList = hierarchicalOrderedFields(type); @@ -188,7 +192,7 @@ private List orderedFields(TypeElement type) { return result; } - /** */ + /** Recursively collects ordered fields from {@code type} and all its superclasses, one list per level. */ private List> hierarchicalOrderedFields(TypeElement type) { Element superType = processingEnv.getTypeUtils().asElement(type.getSuperclass()); @@ -217,7 +221,7 @@ private List> hierarchicalOrderedFields(TypeElement type) } /** - * Validates consistency of enum field mappers configuration: the same mapper is used for the same enum in different messages, + * Validates consistency of enum field mappers configuration: the same mapper is used for the same enum across different messages, * CustomMapper annotation is used only for enum fields. * * @param type Type implementing Message interface. diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 64e299e9c6e3d..810a89e9302b2 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -45,31 +45,27 @@ import static org.apache.ignite.internal.MessageProcessor.COMPRESSED_MESSAGE_CLASS; import static org.apache.ignite.internal.MessageProcessor.MESSAGE_INTERFACE; -/** - * Generates serializer class for given {@code Message} class. The generated serializer follows the naming convention: - * {@code org.apache.ignite.internal.codegen.[MessageClassName]Serializer}. - */ +/** Generates {@code *Serializer} classes for {@link org.apache.ignite.plugin.extensions.communication.Message} types. */ public class MessageSerializerGenerator extends MessageGenerator { /** */ private static final String RETURN_FALSE_STMT = "return false;"; - /** */ + /** FQN of the default enum mapper used when no custom mapper is specified. */ static final String DLFT_ENUM_MAPPER_CLS = "org.apache.ignite.plugin.extensions.communication.mappers.DefaultEnumMapper"; /** */ private static final String COMPRESSED_MSG_ERROR = "CompressedMessage should not be used explicitly. " + "To compress the required field use the @Compress annotation."; - /** Collection of lines for {@code writeTo} method. */ + /** */ private final List write = new ArrayList<>(); - /** Collection of lines for {@code readFrom} method. */ + /** */ private final List read = new ArrayList<>(); - /** Collection of Serializer class fields containing mappers for message enum fields. */ + /** Enum-mapper field declarations emitted at the top of the generated {@code *Serializer} class. */ private final Set fields = new java.util.TreeSet<>(); - /** */ MessageSerializerGenerator(ProcessingEnvironment env) { super(env); } @@ -119,7 +115,7 @@ public class MessageSerializerGenerator extends MessageGenerator { } } - /** */ + /** Writes a no-arg constructor stub to the generated serializer class. */ private void writeConstructor(Writer writer, String serClsName) throws IOException { ++indent; @@ -173,8 +169,7 @@ private void start(Collection code, boolean write) { code.add(indentedLine(METHOD_JAVADOC)); code.add(indentedLine("@Override public boolean %s(" + simpleNameWithGeneric(type) + " msg, %s) {", - write ? "writeTo" : "readFrom", - write ? "MessageWriter writer" : "MessageReader reader")); + write ? "writeTo" : "readFrom", write ? "MessageWriter writer" : "MessageReader reader")); indent++; @@ -264,7 +259,7 @@ private void readField(VariableElement field, int opt) throws Exception { indent--; } - /** */ + /** Appends a write-fail guard for {@code field}, emitting {@code return false;} when the write fails. */ private void returnFalseIfWriteFailed(VariableElement field) throws Exception { String getExpr = field.getSimpleName().toString(); @@ -409,7 +404,7 @@ private String typeNameToFieldName(String typeName) { return new String(typeNameChars); } - /** */ + /** Appends an accessor-based write-fail guard, emitting {@code return false;} when the write fails. */ private void returnFalseIfWriteFailed(Collection code, String accessor, @Nullable String... args) { String argsStr = String.join(", ", args); @@ -422,7 +417,7 @@ private void returnFalseIfWriteFailed(Collection code, String accessor, indent--; } - /** */ + /** Appends a field-based write-fail guard, casting to the declaring class for inherited fields. */ private void returnFalseIfWriteFailed(Collection code, VariableElement field, String accessor, @Nullable String... args) { String argsStr = String.join(", ", args); @@ -440,7 +435,7 @@ private void returnFalseIfWriteFailed(Collection code, VariableElement f indent--; } - /** */ + /** Appends an enum write-fail guard using the mapper call to convert the field value before writing. */ private void returnFalseIfEnumWriteFailed( Collection code, VariableElement field, @@ -462,7 +457,7 @@ private void returnFalseIfEnumWriteFailed( indent--; } - /** */ + /** Appends a read-fail guard for {@code field}, returning {@code false} when reading is incomplete. */ private void returnFalseIfReadFailed(VariableElement field) throws Exception { TypeMirror type = field.asType(); @@ -588,7 +583,7 @@ else if (enumType(env, type)) { throw new IllegalArgumentException("Unsupported type kind: " + type.getKind()); } - /** */ + /** @return the field name of the item-type descriptor constant for {@code field}'s collection element type. */ private String messageCollectionItemTypes(VariableElement field, TypeMirror type) throws Exception { String desc = messageCollectionItemTypeDescriptor(type); String descName = field.getSimpleName() + "CollDesc"; @@ -599,7 +594,7 @@ private String messageCollectionItemTypes(VariableElement field, TypeMirror type return descName; } - /** */ + /** @return constructor expression for the {@code MessageCollectionItemType} descriptor of {@code type}. */ private String messageCollectionItemTypeDescriptor(TypeMirror type) throws Exception { imports.add("org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType"); @@ -740,7 +735,7 @@ private PrimitiveType unboxedType(TypeMirror type) { } } - /** */ + /** Appends a read-fail guard using {@code mtd} to read and assign {@code field}, casting for inherited fields. */ private void returnFalseIfReadFailed(VariableElement field, String mtd, String... args) { String argsStr = String.join(", ", args); @@ -763,7 +758,7 @@ private void returnFalseIfReadFailed(VariableElement field, String mtd, String.. indent--; } - /** */ + /** Appends an enum read-fail guard using the mapper decode call to set {@code field}. */ private void returnFalseIfEnumReadFailed(VariableElement field, String mapperDecodeCallStmnt, String enumValuesFieldName) { String readOp; @@ -791,7 +786,7 @@ private void returnFalseIfEnumReadFailed(VariableElement field, String mapperDec indent--; } - /** */ + /** Closes the write/read method with a final {@code return true;} statement. */ private void finish(List code) { String lastLine = code.get(code.size() - 1); @@ -804,7 +799,7 @@ private void finish(List code) { code.add(indentedLine("return true;")); } - /** */ + /** @return {@code format} with {@code args} applied, without indentation. */ private String line(String format, Object... args) { SB sb = new SB(); @@ -831,7 +826,7 @@ private void writeClassFields(Writer writer) throws IOException { indent = 0; } - /** */ + /** @return {@code true} if {@code type} corresponds to the class named {@code typeStr}. */ private boolean sameType(TypeMirror type, String typeStr) { return env.getTypeUtils().isSameType(type, type(typeStr)); } diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/NioField.java b/modules/codegen/src/main/java/org/apache/ignite/internal/NioField.java index 23ded719e0ddf..cac0e7e5b3585 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/NioField.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/NioField.java @@ -23,8 +23,8 @@ import java.lang.annotation.Target; /** - * Marks a {@link Message}-typed {@link Order @Order} field whose {@code finishUnmarshal} runs in the NIO/IO thread. - * All other {@link Message}-typed fields have {@code finishUnmarshal} deferred to the worker thread. + * Marks a {@link Message}-typed {@link Order @Order} field whose {@code finishUnmarshal} runs in the NIO thread + * rather than being deferred to the worker thread. */ @Retention(RetentionPolicy.CLASS) @Target(ElementType.FIELD) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java b/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java index 355314ce30adf..8af2aa2030bac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java @@ -286,7 +286,7 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryStatusCheckMessage; import org.jetbrains.annotations.Nullable; -/** */ +/** Registers all built-in core messages into {@link MessageFactory}. */ public class CoreMessagesProvider extends AbstractMarshallableMessageFactoryProvider { /** Node ID message type. */ public static final short NODE_ID_MSG_TYPE = 11500; @@ -297,7 +297,7 @@ public class CoreMessagesProvider extends AbstractMarshallableMessageFactoryProv /** Handshake wait message type. */ public static final short HANDSHAKE_WAIT_MSG_TYPE = HANDSHAKE_MSG_TYPE + 1; - /** */ + /** Upper bound on message type IDs allocated by this provider; used to detect range exhaustion. */ public static final short MAX_MESSAGE_ID = 15_000; /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java index 4b13bc58c965e..2f48500fc950d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java @@ -26,13 +26,13 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.CacheIdAware; -/** */ +/** Diagnostic request carrying cache keys pending transaction lock info for a specific cache. */ public final class TxEntriesInfo extends IgniteDiagnosticRequest.DiagnosticBaseInfo implements CacheIdAware { /** */ @Order(0) int cacheId; - /** */ + /** Keys to look up lock/entry diagnostic information for. */ @Order(1) Collection keys; @@ -52,7 +52,6 @@ public TxEntriesInfo() { this.keys = new HashSet<>(keys); } - /** {@inheritDoc} */ @Override public void appendInfo(StringBuilder sb, GridKernalContext ctx) { sb.append(U.nl()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java index 62b32658efe9d..814c7a67ec204 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java @@ -20,6 +20,7 @@ import java.lang.reflect.Array; import java.util.function.Supplier; import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; @@ -46,6 +47,10 @@ public class IgniteMessageFactoryImpl implements MessageFactory { /** Message marshallers (null entry = no marshaller registered for that type). */ private final MessageMarshaller[] msgMarshallers = (MessageMarshaller[])Array.newInstance(MessageMarshaller.class, ARR_SIZE); + /** Message deployers (null entry = no deployer registered for that type). */ + private final GridCacheMessageDeployer[] msgDeployers = + (GridCacheMessageDeployer[])Array.newInstance(GridCacheMessageDeployer.class, ARR_SIZE); + /** Initialized flag. If {@code true} then new message type couldn't be registered. */ private boolean initialized; @@ -78,20 +83,23 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] factories) { register(directType, supplier, serializer, null); } + /** {@inheritDoc} */ + @Override public void register(short directType, Supplier supplier, MessageSerializer serializer, + @Nullable MessageMarshaller marshaller) throws IgniteException { + register(directType, supplier, serializer, marshaller, null); + } + /** - * Registers a message type with both a serializer and an optional marshaller. + * Registers a message type with a serializer, an optional marshaller, and an optional deployer. * * @param directType Direct type. * @param supplier Message factory. * @param serializer Message serializer. * @param marshaller Message marshaller, or {@code null} for NonMarshallableMessage types. + * @param deployer Message deployer, or {@code null} for messages without deployable fields. */ - @Override public void register( - short directType, - Supplier supplier, - MessageSerializer serializer, - @Nullable MessageMarshaller marshaller - ) throws IgniteException { + @Override public void register(short directType, Supplier supplier, MessageSerializer serializer, + @Nullable MessageMarshaller marshaller, @Nullable GridCacheMessageDeployer deployer) throws IgniteException { if (initialized) { throw new IllegalStateException("Message factory is already initialized. " + "Registration of new message types is forbidden."); @@ -113,6 +121,7 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] factories) { msgSuppliers[idx] = supplier; msgSerializers[idx] = serializer; msgMarshallers[idx] = marshaller; + msgDeployers[idx] = deployer; minIdx = Math.min(idx, minIdx); @@ -159,6 +168,11 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] factories) { return msgMarshallers[directTypeToIndex(directType)]; } + /** {@inheritDoc} */ + @Override public @Nullable GridCacheMessageDeployer deployer(short directType) { + return msgDeployers[directTypeToIndex(directType)]; + } + /** * Returns direct types of all registered messages. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java index 625be4d1d3b1d..053e2a51f2988 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java @@ -21,6 +21,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; @@ -30,6 +31,7 @@ import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage; +import org.jetbrains.annotations.Nullable; /** * An extension of {@link MessageFactoryProvider} allowing to use provided schema-aware marshaller @@ -52,32 +54,24 @@ public void init(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, ClassLoader this.schemaAwareMarsh = schemaAwareMarsh; } - /** Registers message automatically generating message supplier, serializer, and marshaller (if applicable). */ + /** Registers a message with its generated serializer, marshaller (if marshallable), and deployer (if any). */ protected static void register(MessageFactory factory, Class cls, short id, Marshaller marsh) { Constructor ctor; - MessageSerializer serializer; - MessageMarshaller marshaller = null; try { ctor = cls.getConstructor(); - - Class serCls = Class.forName(cls.getName() + "Serializer"); - serializer = (MessageSerializer)serCls.getConstructor().newInstance(); - - if (!NonMarshallableMessage.class.isAssignableFrom(cls)) { - Class marshallerCls = Class.forName(cls.getName() + "Marshaller"); - boolean needsMarsh = marshallerCls.getConstructors()[0].getParameterCount() > 0; - - marshaller = needsMarsh - ? (MessageMarshaller)marshallerCls.getConstructor(Marshaller.class).newInstance(marsh) - : (MessageMarshaller)marshallerCls.getConstructor().newInstance(); - } } - catch (Exception e) { + catch (NoSuchMethodException e) { throw new IgniteException("Failed to register message of type " + cls.getSimpleName(), e); } - MessageMarshaller marshallerFinal = marshaller; + MessageSerializer serializer = loadGenerated(cls, "Serializer", marsh); + + MessageMarshaller marshaller = NonMarshallableMessage.class.isAssignableFrom(cls) + ? null + : loadGenerated(cls, "Marshaller", marsh); + + GridCacheMessageDeployer deployer = loadGenerated(cls, "Deployer", marsh); factory.register( id, @@ -90,7 +84,33 @@ protected static void register(MessageFactory factory, Class } }, serializer, - marshallerFinal + marshaller, + deployer ); } + + /** + * Loads and instantiates the generated companion class {@code Serializer/Marshaller/Deployer}, or returns + * {@code null} when it does not exist. The sole declared constructor is used, passing {@code marsh} when it takes one. + */ + @SuppressWarnings("unchecked") + private static @Nullable T loadGenerated(Class cls, String suffix, Marshaller marsh) { + Class generated; + + try { + generated = Class.forName(cls.getName() + suffix); + } + catch (ClassNotFoundException ignored) { + return null; + } + + try { + Constructor ctor = generated.getConstructors()[0]; + + return (T)(ctor.getParameterCount() == 0 ? ctor.newInstance() : ctor.newInstance(marsh)); + } + catch (Exception e) { + throw new IgniteException("Failed to instantiate " + cls.getSimpleName() + suffix, e); + } + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectNotResolvedException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectNotResolvedException.java index e2f35ee8785ba..e8cb4f32f05ed 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectNotResolvedException.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectNotResolvedException.java @@ -25,7 +25,7 @@ public class CacheObjectNotResolvedException extends RuntimeException { /** */ private static final long serialVersionUID = 0L; - /** Disables stack trace for performance. */ + /** */ public CacheObjectNotResolvedException() { super(null, null, true, false); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DeployableMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DeployableMessage.java new file mode 100644 index 0000000000000..5d4fb9d92faff --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DeployableMessage.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.IgniteCheckedException; + +/** + * A {@link GridCacheMessage} with custom deployment logic that cannot be inferred from field types (conditional + * deployment, non-standard accessors, etc.). The generated {@code *Deployer} calls {@link #prepareDeployment} after + * its inferred field deployment, mirroring how a generated marshaller calls {@code MarshallableMessage#prepareMarshal}. + */ +public interface DeployableMessage { + /** + * Prepares deployment info for fields whose handling cannot be inferred from their type. + * + * @param ctx Cache shared context. + * @throws IgniteCheckedException If failed. + */ + void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException; +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index 8138ade11bdc7..6da49c1f7b7d2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -1096,7 +1096,7 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I msg.messageId(idGen.incrementAndGet()); if (destNodeId == null || !cctx.localNodeId().equals(destNodeId)) { - msg.prepareDeployment(cctx); + GridCacheMessageDeployer.prepareDeployment(cctx.kernalContext().messageFactory(), msg, cctx); if (msg instanceof GridCacheDeployable && msg.addDeploymentInfo()) cctx.deploy().prepare((GridCacheDeployable)msg); @@ -1552,8 +1552,8 @@ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) { log.debug("Set P2P context [senderId=" + nodeId + ", msg=" + cacheMsg + ']'); } - MessageMarshaller.finishUnmarshal( - cctx.kernalContext().messageFactory(), cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); + MessageMarshaller.finishUnmarshal(cctx.kernalContext().messageFactory(), + cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); } catch (IgniteCheckedException e) { cacheMsg.onClassError(e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index 61834dd58fc26..e35c1c31add8d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -203,7 +203,7 @@ public void lastAffinityChangedTopologyVersion(AffinityTopologyVersion topVer) { * @param ctx Context. * @throws IgniteCheckedException If failed. */ - protected final void prepareObjectDeployment(@Nullable Object o, GridCacheContext ctx) throws IgniteCheckedException { + final void prepareObjectDeployment(@Nullable Object o, GridCacheContext ctx) throws IgniteCheckedException { prepareObjectDeployment(o, ctx.shared()); } @@ -212,7 +212,7 @@ protected final void prepareObjectDeployment(@Nullable Object o, GridCacheContex * @param ctx Context. * @throws IgniteCheckedException If failed. */ - protected final void prepareObjectDeployment(@Nullable Object o, GridCacheSharedContext ctx) throws IgniteCheckedException { + final void prepareObjectDeployment(@Nullable Object o, GridCacheSharedContext ctx) throws IgniteCheckedException { assert addDepInfo || forceAddDepInfo; if (!skipPrepare && o != null) { @@ -261,24 +261,13 @@ 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 prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - // No-op. - } - /** * @param info Entry to marshal. * @param ctx Context. * @param cacheObjCtx Cache object context. * @throws IgniteCheckedException If failed. */ - protected final void prepareInfoDeployment(GridCacheEntryInfo info, + final void prepareInfoDeployment(GridCacheEntryInfo info, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx ) throws IgniteCheckedException { @@ -305,11 +294,8 @@ protected final void prepareInfoDeployment(GridCacheEntryInfo info, * @param ctx Context. * @throws IgniteCheckedException If failed. */ - protected final void prepareInfosDeployment( - Iterable infos, - GridCacheSharedContext ctx, - CacheObjectContext cacheObjCtx - ) throws IgniteCheckedException { + final void prepareInfosDeployment(Iterable infos, GridCacheSharedContext ctx, + CacheObjectContext cacheObjCtx) throws IgniteCheckedException { assert ctx != null; if (infos != null) @@ -322,7 +308,7 @@ protected final void prepareInfosDeployment( * @param ctx Context. * @throws IgniteCheckedException If failed. */ - protected final void prepareTxDeployment(Iterable txEntries, GridCacheSharedContext ctx) + final void prepareTxDeployment(Iterable txEntries, GridCacheSharedContext ctx) throws IgniteCheckedException { assert ctx != null; @@ -383,7 +369,7 @@ else if (p2pEnabled && e.entryProcessors() != null) { * @param ctx Context. * @throws IgniteCheckedException If failed. */ - protected final void prepareInvokeArgumentsDeployment(@Nullable Object[] args, GridCacheContext ctx) + final void prepareInvokeArgumentsDeployment(@Nullable Object[] args, GridCacheContext ctx) throws IgniteCheckedException { assert ctx != null; @@ -438,43 +424,28 @@ protected final void prepareInvokeArgumentsDeployment(@Nullable Object[] args, G } /** + * Prepares each element of {@code col} for deployment, calling {@link #prepareObjectDeployment} on each item. + * * @param col Collection to marshal. * @param ctx Context. * @throws IgniteCheckedException If failed. */ - @Nullable protected void prepareCollectionDeployment(@Nullable Collection col, + final void prepareCollectionDeployment(@Nullable Collection col, GridCacheContext ctx) throws IgniteCheckedException { assert ctx != null; - + for (Object o : col) { if (addDepInfo) prepareObjectDeployment(o, ctx.shared()); } } - /** - * @param col Collection. - * @param ctx Cache context. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings("ForLoopReplaceableByForEach") - public final void prepareCacheObjectsDeployment(@Nullable List col, - GridCacheContext ctx) throws IgniteCheckedException { - if (col == null) - return; - - int size = col.size(); - - for (int i = 0; i < size; i++) - prepareCacheObjectDeployment(col.get(i), ctx); - } - /** * @param obj Object. * @param ctx Context. * @throws IgniteCheckedException If failed. */ - public final void prepareCacheObjectDeployment(CacheObject obj, GridCacheContext ctx) throws IgniteCheckedException { + final void prepareCacheObjectDeployment(CacheObject obj, GridCacheContext ctx) throws IgniteCheckedException { if (obj != null) { if (addDepInfo) prepareObjectDeployment(obj.value(ctx.cacheObjectContext(), false), ctx.shared()); @@ -486,7 +457,7 @@ public final void prepareCacheObjectDeployment(CacheObject obj, GridCacheContext * @param ctx Cache context. * @throws IgniteCheckedException If failed. */ - protected final void prepareCacheObjectsDeployment(@Nullable Collection col, + final void prepareCacheObjectsDeployment(@Nullable Collection col, GridCacheContext ctx) throws IgniteCheckedException { if (col == null) return; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java new file mode 100644 index 0000000000000..f9767ceda411f --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.util.Collection; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; +import org.apache.ignite.plugin.extensions.communication.MessageFactory; +import org.jetbrains.annotations.Nullable; + +/** + * Per-message deployer. A generated {@code Deployer} implements {@link #prepareDeployment} to deploy the message's + * fields. The {@code static} methods are the facade through which all non-generated code (custom {@code prepareDeployment} + * in messages, message-building code) reaches {@link GridCacheMessage}'s package-private deployment helpers — so that, as + * with marshalling, deployment internals are never touched directly from outside the {@code cache} package. + */ +public interface GridCacheMessageDeployer { + /** Prepares deployment info for all deployable fields of {@code msg}. */ + void prepareDeployment(M msg, GridCacheSharedContext ctx) throws IgniteCheckedException; + + /** Bridge to {@link GridCacheMessage#prepareObjectDeployment}; no-op when the cache context is absent. */ + static void prepareObject(GridCacheMessage msg, @Nullable Object o, @Nullable GridCacheContext cctx) + throws IgniteCheckedException { + if (cctx != null) + msg.prepareObjectDeployment(o, cctx); + } + + /** Bridge to {@link GridCacheMessage#prepareCacheObjectDeployment}; no-op when the cache context is absent. */ + static void prepareCacheObject(GridCacheMessage msg, @Nullable CacheObject obj, @Nullable GridCacheContext cctx) + throws IgniteCheckedException { + if (cctx != null) + msg.prepareCacheObjectDeployment(obj, cctx); + } + + /** Bridge to {@link GridCacheMessage#prepareCacheObjectsDeployment}; no-op when the cache context is absent. */ + static void prepareCacheObjects(GridCacheMessage msg, @Nullable Collection col, + @Nullable GridCacheContext cctx) throws IgniteCheckedException { + if (cctx != null) + msg.prepareCacheObjectsDeployment(col, cctx); + } + + /** Bridge to {@link GridCacheMessage#prepareCollectionDeployment}; no-op when the cache context is absent. */ + static void prepareCollection(GridCacheMessage msg, @Nullable Collection col, @Nullable GridCacheContext cctx) + throws IgniteCheckedException { + if (cctx != null) + msg.prepareCollectionDeployment(col, cctx); + } + + /** Bridge to {@link GridCacheMessage#prepareInvokeArgumentsDeployment}; no-op when the cache context is absent. */ + static void prepareInvokeArguments(GridCacheMessage msg, @Nullable Object[] args, @Nullable GridCacheContext cctx) + throws IgniteCheckedException { + if (cctx != null) + msg.prepareInvokeArgumentsDeployment(args, cctx); + } + + /** Bridge to {@link GridCacheMessage#prepareInfosDeployment}; no-op when the cache context is absent. */ + static void prepareInfos(GridCacheMessage msg, @Nullable Iterable infos, + @Nullable GridCacheContext cctx) throws IgniteCheckedException { + if (cctx != null) + msg.prepareInfosDeployment(infos, cctx.shared(), cctx.cacheObjectContext()); + } + + /** Bridge to {@link GridCacheMessage#prepareInfoDeployment}. */ + static void prepareInfo(GridCacheMessage msg, GridCacheEntryInfo info, GridCacheSharedContext ctx, + CacheObjectContext cacheObjCtx) throws IgniteCheckedException { + msg.prepareInfoDeployment(info, ctx, cacheObjCtx); + } + + /** Bridge to {@link GridCacheMessage#prepareTxDeployment} for generated deployers. */ + static void prepareTxEntries(GridCacheMessage msg, @Nullable Iterable entries, GridCacheSharedContext ctx) + throws IgniteCheckedException { + msg.prepareTxDeployment(entries, ctx); + } + + /** Forces deployment info on {@code msg} when peer-class-loading is enabled. */ + static void forceDeploymentInfo(GridCacheMessage msg, GridCacheSharedContext ctx) { + if (!msg.addDepInfo && ctx.deploymentEnabled()) + msg.addDepInfo = true; + } + + /** + * Prepares deployment for {@code msg} through its factory-registered deployer (a no-op when {@code msg} is + * {@code null} — e.g. an absent nested message — or the message has no registered deployer). Single entry point + * for message deployment: called both by message-sending code and by a generated deployer delegating to a nested + * message. Mirrors the static {@code MessageMarshaller#prepareMarshal}. + */ + @SuppressWarnings({"unchecked", "rawtypes"}) + static void prepareDeployment(MessageFactory factory, @Nullable GridCacheMessage msg, GridCacheSharedContext ctx) + throws IgniteCheckedException { + if (msg == null) + return; + + GridCacheMessageDeployer deployer = factory.deployer(msg.directType()); + + if (deployer != null) + deployer.prepareDeployment(msg, ctx); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java index 000752998796b..b39ec316b314a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java @@ -1000,9 +1000,7 @@ private long allocateForTree() throws IgniteCheckedException { info.value(), info.version(), part.id(), - info.expireTime(), - info.cacheId(), - grp.storeCacheIdInDataPage())); + info.expireTime(), info.cacheId(), grp.storeCacheIdInDataPage())); } catch (IllegalStateException th) { assert ctx.cacheContext(info.cacheId()) == null; // Ignoring removed cache entries. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java index d8f00c54b6bfa..306b2f6d90181 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java @@ -19,12 +19,9 @@ import java.util.ArrayList; import java.util.List; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -155,23 +152,11 @@ public List nearVersions() { return nearVers; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareCacheObjectsDeployment(keys, cctx); - - prepareCacheObjectsDeployment(nearKeys, cctx); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return false; } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridCacheTtlUpdateRequest.class, this, "super", super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index 389c53390d946..a488669cb0db5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -20,10 +20,8 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -382,16 +380,6 @@ public long timeout() { return ctx.txLockMessageLogger(); } - /** {@inheritDoc} - * @param ctx*/ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareCacheObjectsDeployment(keys, cctx); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDistributedLockRequest.class, this, "keysCnt", retVals.length, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java index db26cf3901027..04a4c67b5a89c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; @@ -159,14 +158,6 @@ protected int valuesSize() { return ctx.txLockMessageLogger(); } - /** {@inheritDoc} - * @param ctx*/ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - prepareCacheObjectsDeployment(vals, ctx.cacheContext(cacheId)); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDistributedLockResponse.class, this, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 90762aaba7bec..5f9b018372f08 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.internal.MarshalledMap; import org.apache.ignite.internal.Order; @@ -36,7 +35,6 @@ import org.apache.ignite.internal.util.tostring.GridToStringBuilder; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; @@ -104,11 +102,11 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage @MarshalledMap(keys = "dhtVerKeys", values = "dhtVerVals") Map dhtVers; - /** Wire-protocol keys for {@link #dhtVers}. */ + /** */ @Order(7) public Collection dhtVerKeys; - /** Wire-protocol values for {@link #dhtVers}. */ + /** */ @Order(8) public Collection dhtVerVals; @@ -371,17 +369,6 @@ public void applicationAttributes(Map appAttrs) { this.txState = txState; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - if (writes != null) - prepareTxDeployment(writes, ctx); - - if (reads != null) - prepareTxDeployment(reads, ctx); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo || forceAddDepInfo; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java index 3d93d9368e3f3..268b923232f0c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridNearUnlockRequest.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; @@ -93,14 +92,6 @@ public void addKey(KeyCacheObject key) { return keys != null && !keys.isEmpty() ? keys.get(0).partition() : -1; } - /** {@inheritDoc} - * @param ctx*/ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - prepareCacheObjectsDeployment(keys, ctx.cacheContext(cacheId)); - } - /** {@inheritDoc} */ @Override public IgniteLogger messageLogger(GridCacheSharedContext ctx) { return ctx.txLockMessageLogger(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index c6528afb1092a..248d942c65c05 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -23,8 +23,10 @@ import java.util.List; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; +import org.apache.ignite.internal.processors.cache.DeployableMessage; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockResponse; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -36,7 +38,7 @@ * DHT cache lock response. */ @SuppressWarnings("AssignmentOrReturnOfFieldWithMutableType") -public class GridDhtLockResponse extends GridDistributedLockResponse { +public class GridDhtLockResponse extends GridDistributedLockResponse implements DeployableMessage { /** Mini future ID. */ @Order(0) IgniteUuid miniId; @@ -125,14 +127,13 @@ public Collection preloadEntries() { /** {@inheritDoc} */ @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); + if (preloadEntries != null) { + GridCacheContext cctx = ctx.cacheContext(cacheId); - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (preloadEntries != null) - prepareInfosDeployment(preloadEntries, cctx.shared(), cctx.cacheObjectContext()); + GridCacheMessageDeployer.prepareInfos(this, preloadEntries, cctx); + } } - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtLockResponse.class, this, super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 428da9d0178ec..aeecb7c098713 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -26,7 +26,9 @@ import org.apache.ignite.internal.MarshalledMap; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareRequest; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; @@ -42,7 +44,7 @@ /** * DHT prepare request. */ -public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest { +public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest implements DeployableMessage { /** Max order. */ @Order(0) UUID nearNodeId; @@ -304,25 +306,16 @@ public boolean skipCompletedVersion() { return txLbl; } - /** - * {@inheritDoc} - * - * @param ctx - */ + /** {@inheritDoc} */ @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - if (owned != null && ownedKeys == null) { - for (IgniteTxKey key: owned.keySet()) { + for (IgniteTxKey key : owned.keySet()) { GridCacheContext cctx = ctx.cacheContext(key.cacheId()); if (addDepInfo) - prepareObjectDeployment(key, cctx); + GridCacheMessageDeployer.prepareObject(this, key, cctx); } } - - if (nearWrites != null) - prepareTxDeployment(nearWrites, ctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index 168731d40b353..609e319171a3e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -21,7 +21,6 @@ import java.util.List; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.GridNearUnlockRequest; import org.apache.ignite.internal.util.typedef.internal.S; @@ -70,13 +69,6 @@ public void addNearKey(KeyCacheObject key) nearKeys.add(key); } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - prepareCacheObjectsDeployment(nearKeys, ctx.cacheContext(cacheId)); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtUnlockRequest.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/TransactionAttributesAwareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/TransactionAttributesAwareRequest.java index 84d9c76410f9b..e24d5c0d41816 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/TransactionAttributesAwareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/TransactionAttributesAwareRequest.java @@ -18,10 +18,8 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; import java.util.Map; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheMessage; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareRequest; /** Wraps transaction prepare request with application attributes. */ @@ -57,11 +55,6 @@ public Map applicationAttributes() { return appAttrs; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - payload.prepareDeployment(ctx); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicApplicationAttributesAwareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicApplicationAttributesAwareRequest.java index fc6cec6affe0e..49bdc531a3049 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicApplicationAttributesAwareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicApplicationAttributesAwareRequest.java @@ -18,10 +18,8 @@ package org.apache.ignite.internal.processors.cache.distributed.dht.atomic; import java.util.Map; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; /** Wraps atomic updates with application attributes. */ public class AtomicApplicationAttributesAwareRequest extends GridCacheIdMessage { @@ -57,11 +55,6 @@ public Map applicationAttributes() { return appAttrs; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - payload.prepareDeployment(ctx); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index e2a248c2c9566..4b467a68d1041 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -26,7 +26,9 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; @@ -44,7 +46,7 @@ /** * Lite dht cache backup update request. */ -public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements MarshallableMessage { +public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements MarshallableMessage, DeployableMessage { /** Keys to update. */ @GridToStringInclude @Order(0) @@ -100,14 +102,14 @@ public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateReque boolean forceTransformBackups; /** Entry processors. */ - private List> entryProcessors; + List> entryProcessors; /** Entry processors bytes. */ @Order(12) List entryProcessorsBytes; /** Near entry processors. */ - private List> nearEntryProcessors; + List> nearEntryProcessors; /** Near entry processors bytes. */ @Order(13) @@ -466,38 +468,6 @@ else if (conflictVers != null) return invokeArgs; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareCacheObjectsDeployment(keys, cctx); - - prepareCacheObjectsDeployment(vals, cctx); - - prepareCacheObjectsDeployment(nearKeys, cctx); - - prepareCacheObjectsDeployment(nearVals, cctx); - - prepareCacheObjectsDeployment(prevVals, cctx); - - if (forceTransformBackups) { - // force addition of deployment info for entry processors if P2P is enabled globally. - if (!addDepInfo && ctx.deploymentEnabled()) - addDepInfo = true; - - if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) - prepareInvokeArgumentsDeployment(invokeArgs, cctx); - - if (entryProcessorsBytes == null) - prepareCollectionDeployment(entryProcessors, cctx); - - if (nearEntryProcessorsBytes == null) - prepareCollectionDeployment(nearEntryProcessors, cctx); - } - } - /** {@inheritDoc} */ @Override protected void cleanup() { nearVals = null; @@ -532,6 +502,24 @@ else if (conflictVers != null) } } + /** {@inheritDoc} */ + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + if (forceTransformBackups) { + GridCacheContext cctx = ctx.cacheContext(cacheId); + + GridCacheMessageDeployer.forceDeploymentInfo(this, ctx); + + if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) + GridCacheMessageDeployer.prepareInvokeArguments(this, invokeArgs, cctx); + + if (entryProcessorsBytes == null) + GridCacheMessageDeployer.prepareCollection(this, entryProcessors, cctx); + + if (nearEntryProcessorsBytes == null) + GridCacheMessageDeployer.prepareCollection(this, nearEntryProcessors, cctx); + } + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtAtomicUpdateRequest.class, this, "super", super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index 861717cb9147e..451a3c26ae25d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -22,7 +22,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; @@ -118,17 +117,6 @@ public void nearEvicted(List nearEvicted) { return partId; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - // Can be null if client near cache was removed, in this case assume do not need prepareMarshal. - if (cctx != null) - prepareCacheObjectsDeployment(nearEvicted, cctx); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index e82be8499ef99..23ba2731d7d05 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -29,7 +29,9 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; @@ -53,7 +55,7 @@ /** * Lite DHT cache update request sent from near node to primary node. */ -public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements MarshallableMessage { +public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements MarshallableMessage, DeployableMessage { /** Keys to update. */ @Order(0) @GridToStringInclude @@ -64,7 +66,7 @@ public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdat List vals; /** Entry processors. */ - private List> entryProcessors; + List> entryProcessors; /** Entry processors bytes. */ @Order(2) @@ -329,32 +331,6 @@ else if (conflictVers != null) return expiryPlc; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareCacheObjectsDeployment(keys, cctx); - - if (filter != null && filter.length == 0) - filter = null; - - if (operation() == TRANSFORM) { - // force addition of deployment info for entry processors if P2P is enabled globally. - if (!addDepInfo && ctx.deploymentEnabled()) - addDepInfo = true; - - if (entryProcessorsBytes == null) - prepareCollectionDeployment(entryProcessors, cctx); - - if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) - prepareInvokeArgumentsDeployment(invokeArgs, cctx); - } - else - prepareCacheObjectsDeployment(vals, cctx); - } - /** {@inheritDoc} */ @Override public int partition() { assert !F.isEmpty(keys); @@ -402,6 +378,24 @@ else if (conflictVers != null) } } + /** {@inheritDoc} */ + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + if (filter != null && filter.length == 0) + filter = null; + + if (operation() == TRANSFORM) { + GridCacheContext cctx = ctx.cacheContext(cacheId); + + GridCacheMessageDeployer.forceDeploymentInfo(this, ctx); + + if (entryProcessorsBytes == null) + GridCacheMessageDeployer.prepareCollection(this, entryProcessors, cctx); + + if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) + GridCacheMessageDeployer.prepareInvokeArguments(this, invokeArgs, cctx); + } + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearAtomicFullUpdateRequest.class, this, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index fbf1c1aa8cddd..4a9cfcf2987f4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -28,7 +28,9 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; @@ -45,7 +47,8 @@ /** * */ -public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest implements MarshallableMessage { +public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest + implements MarshallableMessage, DeployableMessage { /** Optional arguments for entry processor. */ private @Nullable Object[] invokeArgs; @@ -161,25 +164,6 @@ public GridNearAtomicSingleUpdateInvokeRequest() { return invokeArgs; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - // force addition of deployment info for entry processors if P2P is enabled globally. - if (!addDepInfo && ctx.deploymentEnabled()) - addDepInfo = true; - - if (entryProc != null && entryProcBytes == null) { - if (addDepInfo) - prepareObjectDeployment(entryProc, cctx); - } - - if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) - prepareInvokeArgumentsDeployment(invokeArgs, cctx); - } - /** {@inheritDoc} */ @Override public void cleanup(boolean clearKey) { super.cleanup(clearKey); @@ -199,6 +183,21 @@ public GridNearAtomicSingleUpdateInvokeRequest() { invokeArgs = unmarshalInvokeArguments(invokeArgsBytes.toArray(new byte[invokeArgsBytes.size()][]), marsh, clsLdr); } + /** {@inheritDoc} */ + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + GridCacheContext cctx = ctx.cacheContext(cacheId); + + GridCacheMessageDeployer.forceDeploymentInfo(this, ctx); + + if (entryProc != null && entryProcBytes == null) { + if (addDepInfo) + GridCacheMessageDeployer.prepareObject(this, entryProc, cctx); + } + + if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) + GridCacheMessageDeployer.prepareInvokeArguments(this, invokeArgs, cctx); + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearAtomicSingleUpdateRequest.class, this, super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java index 01152618b6917..80b8d0b2f0e96 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java @@ -22,15 +22,12 @@ import java.util.UUID; import javax.cache.expiry.ExpiryPolicy; import javax.cache.processor.EntryProcessor; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheOperation; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.GridCacheUtils; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -216,18 +213,6 @@ public GridNearAtomicSingleUpdateRequest() { return CU.EXPIRE_TIME_CALCULATE; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareCacheObjectDeployment(key, cctx); - - if (val != null) - prepareCacheObjectDeployment(val, cctx); - } - /** {@inheritDoc} */ @Override public void cleanup(boolean clearKey) { val = null; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index 270acaceacf77..207a8779f1bd0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -25,10 +25,12 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheReturn; +import org.apache.ignite.internal.processors.cache.DeployableMessage; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -39,7 +41,7 @@ /** * DHT atomic cache near update response. */ -public class GridNearAtomicUpdateResponse extends GridCacheIdMessage implements GridCacheDeployable { +public class GridNearAtomicUpdateResponse extends GridCacheIdMessage implements GridCacheDeployable, DeployableMessage { /** Cache message index. */ public static final int CACHE_MSG_IDX = nextIndexId(); @@ -337,16 +339,6 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { errs.addFailedKeys(keys, e); } - /** {@inheritDoc} - * @param ctx*/ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (nearUpdates != null) - prepareCacheObjectsDeployment(nearUpdates.nearValues(), cctx); - } /** * @return Data for near cache update. @@ -384,6 +376,14 @@ public void partition(int partId) { return ctx.atomicMessageLogger(); } + /** {@inheritDoc} */ + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + if (nearUpdates != null) { + GridCacheContext cctx = ctx.cacheContext(cacheId); + + GridCacheMessageDeployer.prepareCacheObjects(this, nearUpdates.nearValues(), cctx); + } + } /** {@inheritDoc} */ @Override public String toString() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 37d0c42732970..36e74d86c20be 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -18,13 +18,10 @@ package org.apache.ignite.internal.processors.cache.distributed.dht.preloader; import java.util.Collection; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.F; @@ -113,15 +110,6 @@ public Collection keys() { return topVer; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareCacheObjectsDeployment(keys, cctx); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index 519dbd680a9b6..09afa95023c1b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -23,11 +23,9 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.managers.communication.ErrorMessage; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.F; @@ -131,21 +129,11 @@ public void addInfo(GridCacheEntryInfo info) { infos.add(info); } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (missedKeys != null) - prepareCacheObjectsDeployment(missedKeys, cctx); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; } - + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtForceKeysResponse.class, this, super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index 212474a532247..a63a5551103f8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -31,6 +31,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; import org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; @@ -214,7 +215,7 @@ void addEntry0(int p, boolean historical, GridCacheEntryInfo info, GridCacheShar assert info.value() != null || historical : info; // Need to call this method to initialize info properly. - prepareInfoDeployment(info, ctx, cacheObjCtx); + GridCacheMessageDeployer.prepareInfo(this, info, ctx, cacheObjCtx); msgSize += info.marshalledSize(cacheObjCtx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java index e622ed94fe89f..e163b11b2f3b5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java @@ -84,6 +84,7 @@ import org.apache.ignite.internal.processors.cache.ExchangeFailureMessage; import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate; import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; @@ -3875,7 +3876,7 @@ else if (exchCtx.events().hasServerLeft()) else if (forceAffReassignment) msg.idealAffinityDiff(idealAffDiff); - msg.prepareDeployment(cctx); + GridCacheMessageDeployer.prepareDeployment(cctx.kernalContext().messageFactory(), msg, cctx); timeBag.finishGlobalStage("Full message preparing"); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java index 1cd8b6456b037..8ea758b2ffa4f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java @@ -43,15 +43,11 @@ public class CacheVersionedValue implements Message, CacheIdAware { @Order(2) int cacheId; - /** */ public CacheVersionedValue() { // No-op. } - /** - * @param val Cache value. - * @param ver Cache version. - */ + /** */ public CacheVersionedValue(CacheObject val, GridCacheVersion ver, int cacheId) { this.val = val; this.ver = ver; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index 925442c71ced2..972aa6f0ebe0b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -22,13 +22,10 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionable; @@ -291,22 +288,6 @@ public long accessTtl() { return txLbl; } - /** - * @param ctx Cache context. - * @throws IgniteCheckedException If failed. - */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - assert ctx != null; - assert !F.isEmpty(keys); - assert readersFlags == null || keys.size() == readersFlags.size(); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareCacheObjectsDeployment(keys, cctx); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java index 8350d8b61819d..45bb7739bf4ae 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java @@ -17,13 +17,10 @@ package org.apache.ignite.internal.processors.cache.distributed.near; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.typedef.internal.S; import org.jetbrains.annotations.NotNull; @@ -249,17 +246,6 @@ public boolean recovery() { return (flags & RECOVERY_FLAG_MASK) != 0; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - assert key != null; - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - prepareCacheObjectDeployment(key, cctx); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java index 9225b42c07138..b12470b2b201c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java @@ -22,9 +22,11 @@ import org.apache.ignite.internal.managers.communication.ErrorMessage; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.plugin.extensions.communication.Message; @@ -33,7 +35,7 @@ /** * */ -public class GridNearSingleGetResponse extends GridCacheIdMessage implements GridCacheDeployable { +public class GridNearSingleGetResponse extends GridCacheIdMessage implements GridCacheDeployable, DeployableMessage { /** */ public static final int INVALID_PART_FLAG_MASK = 0x1; @@ -145,13 +147,10 @@ public long futureId() { /** {@inheritDoc} */ @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - if (res != null) { + if (res instanceof CacheObject) { GridCacheContext cctx = ctx.cacheContext(cacheId); - if (res instanceof CacheObject) - prepareCacheObjectDeployment((CacheObject)res, cctx); + GridCacheMessageDeployer.prepareCacheObject(this, (CacheObject)res, cctx); } } @@ -160,7 +159,6 @@ public long futureId() { return addDepInfo; } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearSingleGetResponse.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index ded5ec37741a5..3621239be3892 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -65,11 +65,11 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse @MarshalledMap(keys = "ownedValKeys", values = "ownedValVals") Map ownedVals; - /** Wire-protocol keys for {@link #ownedVals}. */ + /** */ @Order(5) @Nullable Collection ownedValKeys; - /** Wire-protocol values for {@link #ownedVals}. */ + /** */ @Order(6) @Nullable Collection ownedValVals; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotAwareMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotAwareMessage.java index abac24c67ceaf..cfaa9eb031402 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotAwareMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotAwareMessage.java @@ -18,10 +18,8 @@ package org.apache.ignite.internal.processors.cache.persistence.snapshot; import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.cache.GridCacheMessage; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.jetbrains.annotations.Nullable; /** @@ -81,11 +79,6 @@ public long snapshotTopologyVersion() { return topVer; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - payload.prepareDeployment(ctx); - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index aacb131e011a1..46503ecb7f8d3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -22,9 +22,11 @@ import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -45,7 +47,7 @@ /** * Query request. */ -public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, Message { +public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, Message, DeployableMessage { /** */ private static final int FLAG_DATA_PAGE_SCAN_DFLT = 0b00; @@ -411,40 +413,6 @@ private static byte setDataPageScanEnabled(int flags, Boolean enabled) { return topVer != null ? topVer : AffinityTopologyVersion.NONE; } - /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (keyValFilter != null && keyValFilterBytes == null) { - if (addDepInfo) - prepareObjectDeployment(keyValFilter, cctx); - } - - if (rdc != null && rdcBytes == null) { - if (addDepInfo) - prepareObjectDeployment(rdc, cctx); - } - - if (trans != null && transBytes == null) { - if (addDepInfo) - prepareObjectDeployment(trans, cctx); - } - - if (!F.isEmpty(args) && argsBytes == null) { - if (addDepInfo) { - for (Object arg : args) - prepareObjectDeployment(arg, cctx); - } - } - - if (idxQryDesc != null && idxQryDescBytes == null) { - if (addDepInfo) - prepareObjectDeployment(idxQryDesc, cctx); - } - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; @@ -618,6 +586,38 @@ public Collection skipKeys() { return part; } + /** {@inheritDoc} */ + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + GridCacheContext cctx = ctx.cacheContext(cacheId); + + if (keyValFilter != null && keyValFilterBytes == null) { + if (addDepInfo) + GridCacheMessageDeployer.prepareObject(this, keyValFilter, cctx); + } + + if (rdc != null && rdcBytes == null) { + if (addDepInfo) + GridCacheMessageDeployer.prepareObject(this, rdc, cctx); + } + + if (trans != null && transBytes == null) { + if (addDepInfo) + GridCacheMessageDeployer.prepareObject(this, trans, cctx); + } + + if (!F.isEmpty(args) && argsBytes == null) { + if (addDepInfo) { + for (Object arg : args) + GridCacheMessageDeployer.prepareObject(this, arg, cctx); + } + } + + if (idxQryDesc != null && idxQryDescBytes == null) { + if (addDepInfo) + GridCacheMessageDeployer.prepareObject(this, idxQryDesc, cctx); + } + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridCacheQueryRequest.class, this, super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index fa65280fc6e26..46f3f4a6134ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -23,9 +23,11 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.cache.query.index.IndexQueryResultMeta; import org.apache.ignite.internal.managers.communication.ErrorMessage; +import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; @@ -36,7 +38,7 @@ /** * Page of cache query response. */ -public class GridCacheQueryResponse extends GridCacheIdMessage implements GridCacheDeployable, MarshallableMessage { +public class GridCacheQueryResponse extends GridCacheIdMessage implements GridCacheDeployable, MarshallableMessage, DeployableMessage { /** */ @Order(0) boolean finished; @@ -99,28 +101,6 @@ public GridCacheQueryResponse(int cacheId, long reqId, Throwable err, boolean ad finished = true; } - /** {@inheritDoc} - * @param ctx*/ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { - super.prepareDeployment(ctx); - - GridCacheContext cctx = ctx.cacheContext(cacheId); - - if (dataBytes == null && data != null) - prepareCollectionDeployment(data, cctx); - - if (addDepInfo && !F.isEmpty(data)) { - for (Object o : data) { - if (o instanceof Map.Entry) { - Map.Entry e = (Map.Entry)o; - - prepareObjectDeployment(e.getKey(), cctx); - prepareObjectDeployment(e.getValue(), cctx); - } - } - } - } - /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return addDepInfo; @@ -190,6 +170,25 @@ public boolean fields() { data = unmarshalCollection(dataBytes, marsh, clsLdr); } + /** {@inheritDoc} */ + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + GridCacheContext cctx = ctx.cacheContext(cacheId); + + if (dataBytes == null && data != null) + GridCacheMessageDeployer.prepareCollection(this, data, cctx); + + if (addDepInfo && !F.isEmpty(data)) { + for (Object o : data) { + if (o instanceof Map.Entry) { + Map.Entry e = (Map.Entry)o; + + GridCacheMessageDeployer.prepareObject(this, e.getKey(), cctx); + GridCacheMessageDeployer.prepareObject(this, e.getValue(), cctx); + } + } + } + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridCacheQueryResponse.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index 603508110f057..f7c801b0903c8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -71,10 +71,10 @@ public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, /** Dummy version for any existing entry read in SERIALIZABLE transaction. */ public static final GridCacheVersion SER_READ_NOT_EMPTY_VER = new GridCacheVersion(0, 0, 1); - /** */ + /** Dummy version for an updated entry read in GET operation. */ public static final GridCacheVersion GET_ENTRY_INVALID_VER_UPDATED = new GridCacheVersion(0, 0, 2); - /** */ + /** Dummy version for an entry read after a GET operation. */ public static final GridCacheVersion GET_ENTRY_INVALID_VER_AFTER_GET = new GridCacheVersion(0, 0, 3); /** Skip store flag bit mask. */ @@ -212,7 +212,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, /** Partition update counter. */ private long partUpdateCntr; - /** */ + /** Version read in SERIALIZABLE transaction to track conflicts. */ @Order(12) GridCacheVersion serReadVer; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java index d7023ca336edc..df5d8aaabdb0a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java @@ -371,9 +371,8 @@ public IgniteInternalFuture prepareColocatedTx( * @return First entry. * @throws IgniteCheckedException If failed. */ - private IgniteTxEntry initialize( - @Nullable Collection entries, - AffinityTopologyVersion topVer) throws IgniteCheckedException { + private IgniteTxEntry initialize(@Nullable Collection entries, AffinityTopologyVersion topVer) + throws IgniteCheckedException { if (entries == null) return null; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index bf891be4cc4ac..cf0a6fe0c63e9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -66,6 +66,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException; import org.apache.ignite.internal.processors.cache.GridCacheMapEntry; import org.apache.ignite.internal.processors.cache.GridCacheMessage; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate; import org.apache.ignite.internal.processors.cache.GridCacheReturnCompletableWrapper; import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter; @@ -2432,7 +2433,7 @@ void txLocksInfo(UUID nodeId, TxDeadlockFuture fut, Set txKeys) { try { if (!cctx.localNodeId().equals(nodeId)) - req.prepareDeployment(cctx); + GridCacheMessageDeployer.prepareDeployment(cctx.kernalContext().messageFactory(), req, cctx); cctx.gridIO().sendToGridTopic(node, TOPIC_TX, req, SYSTEM_POOL); } @@ -3362,7 +3363,7 @@ private class DeadlockDetectionListener implements GridMessageListener { try { if (!cctx.localNodeId().equals(nodeId)) - res.prepareDeployment(cctx); + GridCacheMessageDeployer.prepareDeployment(cctx.kernalContext().messageFactory(), res, cctx); cctx.gridIO().sendToGridTopic(nodeId, TOPIC_TX, res, SYSTEM_POOL); } @@ -3447,8 +3448,8 @@ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) { return; try { - MessageMarshaller.finishUnmarshal( - cctx.kernalContext().messageFactory(), cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); + MessageMarshaller.finishUnmarshal(cctx.kernalContext().messageFactory(), + cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); } catch (IgniteCheckedException e) { cacheMsg.onClassError(e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java index ef32a4415dfe9..6b63922b80b54 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java @@ -39,22 +39,17 @@ public class TxLocksRequest extends GridCacheMessage { @MarshalledCollection("txKeysArr") Set txKeys; - /** Wire-protocol array for {@link #txKeys}. */ + /** */ @GridToStringExclude @Order(1) IgniteTxKey[] txKeysArr; - /** - * Default constructor. - */ + /** */ public TxLocksRequest() { // No-op. } - /** - * @param futId Future ID. - * @param txKeys Target tx keys. - */ + /** */ public TxLocksRequest(long futId, Set txKeys) { A.notEmpty(txKeys, "txKeys"); @@ -62,16 +57,12 @@ public TxLocksRequest(long futId, Set txKeys) { this.txKeys = txKeys; } - /** - * @return Future ID. - */ + /** */ public long futureId() { return futId; } - /** - * @return Tx keys. - */ + /** */ public Set txKeys() { return txKeys; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index 38927d33058ef..9293c6d4bfe20 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -49,17 +49,17 @@ public class TxLocksResponse extends GridCacheMessage { @MarshalledCollection("txKeysArr") Set txKeys; - /** Wire-protocol array of keys from {@link #nearTxKeyLocks}. */ + /** */ @GridToStringExclude @Order(1) IgniteTxKey[] nearTxKeysArr; - /** Wire-protocol array for {@link #txKeys}. */ + /** */ @GridToStringExclude @Order(2) IgniteTxKey[] txKeysArr; - /** Wire-protocol array of values from {@link #nearTxKeyLocks}. */ + /** */ @GridToStringExclude @Order(3) List[] locksArr; diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java index 3233d054dd2d8..869c386a3e604 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java @@ -16,10 +16,9 @@ */ package org.apache.ignite.plugin.extensions.communication; -/** */ + +/** Implemented by messages that carry a cache ID identifying the target cache. */ public interface CacheIdAware { - /** - * @return Cache ID. - */ + /** */ public int cacheId(); } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java index 32bd09eb0924a..b7a08ed3ec26f 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java @@ -17,6 +17,6 @@ package org.apache.ignite.plugin.extensions.communication; -/** Marker for {@link MarshallableMessage} whose {@code finishUnmarshal} requires CacheObject fields to be deserialized first. */ +/** A {@link MarshallableMessage} whose {@code finishUnmarshal} needs CacheObjects deserialized first. */ public interface CacheMarshallableMessage extends MarshallableMessage { } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java index d15d50b625f9d..48c055ca23f3a 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java @@ -22,7 +22,7 @@ /** A {@link Message} requiring a custom marshal/unmarshal step via {@link Marshaller}. */ public interface MarshallableMessage extends Message { - /** @param marsh Marshaller for pre-marshalling. */ + /** */ public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException; /** diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java index 8a0e5b16707a3..3f3a6b6ed86c4 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java @@ -19,6 +19,7 @@ import java.util.function.Supplier; import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.jetbrains.annotations.Nullable; /** @@ -116,6 +117,22 @@ default void register(short directType, Supplier supplier, MessageSeria register(directType, supplier, serializer); } + /** + * Register message factory with given direct type, serializer, marshaller, and deployer. All messages must be + * registered during construction of class which implements this interface. + * + * @param directType Direct type. + * @param supplier Message factory. + * @param serializer Message serializer. + * @param marshaller Message marshaller, or {@code null} for non-marshallable messages. + * @param deployer Message deployer, or {@code null} for messages without deployable fields. + * @throws IgniteException In case of attempt to register message with direct type which is already registered. + */ + default void register(short directType, Supplier supplier, MessageSerializer serializer, + @Nullable MessageMarshaller marshaller, @Nullable GridCacheMessageDeployer deployer) throws IgniteException { + register(directType, supplier, serializer, marshaller); + } + /** * Returns {@code MessageSerializer} for provided type. * @@ -132,4 +149,15 @@ default void register(short directType, Supplier supplier, MessageSeria * @return Message marshaller, or {@code null}. */ public @Nullable MessageMarshaller marshaller(short type); + + /** + * Returns {@code GridCacheMessageDeployer} for provided type, or {@code null} if none is registered + * (e.g. for messages without deployable fields). + * + * @param type Message type. + * @return Message deployer, or {@code null}. + */ + default @Nullable GridCacheMessageDeployer deployer(short type) { + return null; + } } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index 2bf108b4606e6..1b9dc2a91dc3f 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -79,8 +79,7 @@ default void finishUnmarshalNio(M msg, GridKernalContext kctx) throws IgniteChec * @param kctx Kernal context. * @throws IgniteCheckedException If unmarshalling failed. */ - static void finishUnmarshalNio( - MessageFactory factory, M msg, GridKernalContext kctx) + static void finishUnmarshalNio(MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); @@ -98,9 +97,8 @@ static void finishUnmarshalNio( * @param nested Nested cache context, or {@code null} if not applicable. * @throws IgniteCheckedException If marshalling failed. */ - static void prepareMarshal( - MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested) - throws IgniteCheckedException { + static void prepareMarshal(MessageFactory factory, M msg, GridKernalContext kctx, + @Nullable GridCacheContext nested) throws IgniteCheckedException { MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); if (m != null) @@ -118,9 +116,8 @@ static void prepareMarshal( * @param clsLdr Class loader for unmarshalling. * @throws IgniteCheckedException If unmarshalling failed. */ - static void finishUnmarshal( - MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) - throws IgniteCheckedException { + static void finishUnmarshal(MessageFactory factory, M msg, GridKernalContext kctx, + @Nullable GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); if (m != null) @@ -136,8 +133,7 @@ static void finishUnmarshal( * @param kctx Kernal context. * @throws IgniteCheckedException If unmarshalling failed. */ - static void finishUnmarshal( - MessageFactory factory, M msg, GridKernalContext kctx) + static void finishUnmarshal(MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index 0557ad96eb1ce..ea2c59377df17 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -17,7 +17,7 @@ package org.apache.ignite.plugin.extensions.communication; -/** Message serialization logic. */ +/** */ public interface MessageSerializer { /** * Writes this message to provided byte buffer. diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java index 425ec1ecdee38..93f558772ae68 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/ObjectData.java @@ -38,7 +38,7 @@ public class ObjectData implements Message { @Order(0) byte[] dataBytes; - /** */ + /** Default no-arg constructor required for deserialization. */ public ObjectData() {} /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java index 32eeb7da18a5f..f1fce2ed5cc05 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java @@ -35,6 +35,7 @@ import org.apache.ignite.internal.MessageProcessor; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.cache.query.QueryIndexMessage; +import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; import org.apache.ignite.internal.util.CommonUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgniteUuid; @@ -402,7 +403,7 @@ public void testNioFieldOnNonMessageTypeFails() { assertThat(compilation).hadErrorContaining("@NioField has no effect on non-Message field"); } - /** Verifies that {@code @Marshalled} generates {@code U.unmarshal} with blank line before null-out in finishUnmarshal. */ + /** Verifies that {@code @Marshalled} generates {@code U.unmarshal} with a blank line before the null-out. */ @Test public void testMarshalledMessage() { Compilation compilation = compile("TestMarshalledMessage.java"); @@ -456,6 +457,53 @@ public void testMarshalledMapMessage() { .hasSourceEquivalentTo(javaFile("TestMarshalledMapMessageMarshaller.java")); } + /** Verifies a deployable {@link GridCacheIdMessage} gets a generated deployer that bridges cache-object fields. */ + @Test + public void testDeployerGeneration() { + Compilation compilation = compile("TestCacheIdMessage.java"); + + assertThat(compilation).succeeded(); + + assertEquals(3, compilation.generatedSourceFiles().size()); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestCacheIdMessageDeployer") + .hasSourceEquivalentTo(javaFile("TestCacheIdMessageDeployer.java")); + } + + /** Verifies a {@code DeployableMessage}'s generated deployer delegates to its custom {@code prepareDeployment}. */ + @Test + public void testDeployerDelegatesToCustomDeployment() { + Compilation compilation = compile("TestDeployableMessage.java"); + + assertThat(compilation).succeeded(); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestDeployableMessageDeployer") + .hasSourceEquivalentTo(javaFile("TestDeployableMessageDeployer.java")); + } + + /** Verifies a nested {@link GridCacheMessage} field is deployed by delegating to the static facade entry point. */ + @Test + public void testDeployerHandlesNestedMessage() { + Compilation compilation = compile("TestNestedDeployMessage.java", "TestCacheIdMessage.java"); + + assertThat(compilation).succeeded(); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestNestedDeployMessageDeployer") + .hasSourceEquivalentTo(javaFile("TestNestedDeployMessageDeployer.java")); + } + + /** Verifies the generator fails fast when a deployable message cannot resolve a cache context. */ + @Test + public void testDeployerFailsWithoutCacheContext() { + Compilation compilation = compile("TestNoCacheCtxMessage.java"); + + assertThat(compilation).failed(); + assertThat(compilation).hadErrorContaining("Cannot resolve cache context"); + } + /** */ private Compilation compile(String... srcFiles) { return compile(new MessageProcessor(), srcFiles); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java index d8c1dc78c90a9..bf868bc8fa312 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java @@ -25,6 +25,7 @@ import com.tngtech.archunit.core.importer.ClassFileImporter; import com.tngtech.archunit.core.importer.ImportOption; import com.tngtech.archunit.lang.ArchRule; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.plugin.extensions.communication.MessageSerializer; import org.junit.BeforeClass; @@ -32,13 +33,13 @@ import static com.tngtech.archunit.core.domain.JavaCall.Predicates.target; import static com.tngtech.archunit.core.domain.JavaClass.Predicates.assignableTo; -import static com.tngtech.archunit.core.domain.properties.HasName.Predicates.nameMatching; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; /** - * Verifies that instance methods of {@link MessageSerializer} and {@link MessageMarshaller} are only - * called from classes that implement these interfaces (i.e. generated serializers/marshallers and their - * hand-written wrappers). All other code must use the static convenience methods: + * Verifies that instance methods of {@link MessageSerializer}, {@link MessageMarshaller} and + * {@link GridCacheMessageDeployer} are only called from classes that implement these interfaces (i.e. generated + * serializers/marshallers/deployers and their hand-written wrappers). All other code must use the static + * convenience methods: *

    *
  • {@link MessageSerializer#writeTo(org.apache.ignite.plugin.extensions.communication.MessageFactory, * org.apache.ignite.plugin.extensions.communication.Message, @@ -48,7 +49,11 @@ * org.apache.ignite.plugin.extensions.communication.MessageReader)}
  • *
  • {@link MessageMarshaller#prepareMarshal}
  • *
  • {@link MessageMarshaller#finishUnmarshal}
  • + *
  • static {@code GridCacheMessageDeployer.prepareDeployment(factory, msg, ctx)}
  • *
+ * + *

The rules key on whether the called method is {@code static}, not on its name — so any instance method added + * to these interfaces is covered automatically. */ public class MessageSerializationArchitectureTest { /** Matches method calls that resolve to a non-static (instance) method. */ @@ -92,9 +97,7 @@ public void serializerInstanceMethodsOnlyCalledFromImplementations() { // Exclude MessageSerializer itself and all its implementations (generated + wrappers). .areNotAssignableTo(MessageSerializer.class) .should() - .callMethodWhere( - TO_INSTANCE_METHOD - .and(target(nameMatching("writeTo|readFrom"))) + .callMethodWhere(TO_INSTANCE_METHOD .and(target(HasOwner.Predicates.With.owner(assignableTo(MessageSerializer.class)))) ) .because("Use static MessageSerializer.writeTo(factory, msg, writer) and " + @@ -118,9 +121,7 @@ public void marshallerInstanceMethodsOnlyCalledFromImplementations() { // Exclude MessageMarshaller itself and all its implementations (generated + wrappers). .areNotAssignableTo(MessageMarshaller.class) .should() - .callMethodWhere( - TO_INSTANCE_METHOD - .and(target(nameMatching("prepareMarshal|finishUnmarshal"))) + .callMethodWhere(TO_INSTANCE_METHOD .and(target(HasOwner.Predicates.With.owner(assignableTo(MessageMarshaller.class)))) ) .because("Use static MessageMarshaller.prepareMarshal(factory, ...) and " + @@ -128,4 +129,26 @@ public void marshallerInstanceMethodsOnlyCalledFromImplementations() { rule.check(classes); } + + /** + * Instance method of {@link GridCacheMessageDeployer} ({@code prepareDeployment}) must only be called from + * within classes that themselves implement {@link GridCacheMessageDeployer} — i.e. generated deployers. + * + * Everyone else must use the static {@code GridCacheMessageDeployer.prepareDeployment(factory, msg, ctx)} facade. + */ + @Test + public void deployerInstanceMethodOnlyCalledFromImplementations() { + ArchRule rule = noClasses() + .that() + // Exclude GridCacheMessageDeployer itself and all its implementations (generated deployers). + .areNotAssignableTo(GridCacheMessageDeployer.class) + .should() + .callMethodWhere(TO_INSTANCE_METHOD + .and(target(HasOwner.Predicates.With.owner(assignableTo(GridCacheMessageDeployer.class)))) + ) + .because("Use static GridCacheMessageDeployer.prepareDeployment(factory, msg, ctx) instead of " + + "calling the instance method directly."); + + rule.check(classes); + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java index 124f30ae5daae..6ecf67b611bf5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java @@ -81,8 +81,7 @@ public static class TestPluginProvider extends AbstractTestPluginProvider { @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) { registry.registerExtension(MessageFactoryProvider.class, new MessageFactoryProvider() { @Override public void registerAll(MessageFactory factory) { - factory.register(DIRECT_TYPE, - DuplicateDirectTypeIdMessage::new, new DuplicateDirectTypeIdMessageSerializer()); + factory.register(DIRECT_TYPE, DuplicateDirectTypeIdMessage::new, new DuplicateDirectTypeIdMessageSerializer()); } }); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java index bbbde263386ad..0e18a0ab82d96 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java @@ -28,6 +28,7 @@ import org.apache.ignite.internal.managers.communication.GridIoPolicy; import org.apache.ignite.internal.managers.communication.GridMessageListener; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.processors.cache.KeyCacheObject; @@ -66,13 +67,8 @@ public void testMessageUnmarshallWithoutCacheContext() throws Exception { @Override public void onMessage(UUID nodeId, Object msg, byte plc) { if (msg instanceof TxLocksResponse) { try { - MessageMarshaller.finishUnmarshal( - clientCtx.kernalContext().messageFactory(), - (TxLocksResponse)msg, - clientCtx.kernalContext(), - null, - clientCtx.deploy().globalLoader() - ); + MessageMarshaller.finishUnmarshal(clientCtx.kernalContext().messageFactory(), (TxLocksResponse)msg, + clientCtx.kernalContext(), null, clientCtx.deploy().globalLoader()); res.set(true); } @@ -93,7 +89,7 @@ public void testMessageUnmarshallWithoutCacheContext() throws Exception { TxLocksResponse msg = new TxLocksResponse(); msg.addKey(cctx.txKey(key)); - msg.prepareDeployment(cctx.shared()); + GridCacheMessageDeployer.prepareDeployment(cctx.kernalContext().messageFactory(), msg, cctx.shared()); ((IgniteKernal)ignite).context().cache().context().gridIO().sendToCustomTopic( ((IgniteKernal)client).localNode(), TOPIC, msg, GridIoPolicy.PUBLIC_POOL); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java index aaa36fc73f51c..4d10e412a0634 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java @@ -716,8 +716,8 @@ private static class StaleTopologyCommunicationSpi extends TcpCommunicationSpi { ); try { - MessageMarshaller.prepareMarshal( - ((IgniteEx)ignite).context().messageFactory(), msg, ((IgniteEx)ignite).context(), null); + MessageMarshaller.prepareMarshal(((IgniteEx)ignite).context().messageFactory(), + msg, ((IgniteEx)ignite).context(), null); } catch (IgniteCheckedException e) { throw new RuntimeException(e); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java index 0f46c4715f857..ce3f9fbeca5f0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java @@ -86,12 +86,12 @@ private static class BrokenMessage extends IgniteDiagnosticRequest { // No-op. } - /** */ + /** Serializer that throws on the first {@code writeTo} call to simulate a broken message. */ private static class BrokenMessageSerializer implements MessageSerializer { /** */ private boolean fail = true; - /** */ + /** {@inheritDoc} */ @Override public boolean writeTo(BrokenMessage msg, MessageWriter writer) { if (!writer.isHeaderWritten()) { if (!writer.writeHeader(msg.directType())) @@ -109,13 +109,13 @@ private static class BrokenMessageSerializer implements MessageSerializer { - /** */ + /** {@inheritDoc} */ @Override public boolean writeTo(TestDelayMessage msg, MessageWriter writer) { if (!writer.isHeaderWritten()) { if (!writer.writeHeader(msg.directType())) @@ -46,7 +46,7 @@ public class TestDelayMessageSerializer implements MessageSerializer serializer; @@ -99,8 +99,7 @@ public class DiscoveryUnmarshalVulnerabilityTest extends GridCommonAbstractTest factory.register( (short)(CoreMessagesProvider.MAX_MESSAGE_ID + 1), ExploitMessage::new, - serializer, - marshaller); + serializer, marshaller); } }; @@ -256,7 +255,7 @@ private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOE } } - /** */ + /** Lazily-initialized {@link MessageSerializer} wrapper resolved from the plugin provider. */ private static class MessageSerializerWrapper implements MessageSerializer { /** */ private final AbstractMarshallableMessageFactoryProvider provider; @@ -267,7 +266,6 @@ private static class MessageSerializerWrapper implements MessageSerializer serde; - /** */ private MessageSerializerWrapper(AbstractMarshallableMessageFactoryProvider provider) { this.provider = provider; } @@ -293,7 +291,7 @@ private void initIfNecessary() { } } - /** */ + /** Lazily-initialized {@link MessageMarshaller} wrapper resolved from the plugin provider. */ private static class MessageMarshallerWrapper implements MessageMarshaller { /** */ private final AbstractMarshallableMessageFactoryProvider provider; @@ -304,7 +302,6 @@ private static class MessageMarshallerWrapper implements MessageMarshaller marsh; - /** */ private MessageMarshallerWrapper(AbstractMarshallableMessageFactoryProvider provider) { this.provider = provider; } @@ -318,8 +315,8 @@ private MessageMarshallerWrapper(AbstractMarshallableMessageFactoryProvider prov } /** {@inheritDoc} */ - @Override public void finishUnmarshal(ExploitMessage msg, GridKernalContext kctx, GridCacheContext nested, - ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void finishUnmarshal(ExploitMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) + throws IgniteCheckedException { initIfNecessary(); marsh.finishUnmarshal(msg, kctx, nested, clsLdr); @@ -332,7 +329,6 @@ private MessageMarshallerWrapper(AbstractMarshallableMessageFactoryProvider prov marsh.finishUnmarshal(msg, kctx); } - /** */ private void initIfNecessary() { if (init.get() && init.compareAndSet(true, false)) marsh = loadMarshaller(ExploitMessage.class, U.field(provider, "dfltMarsh")); diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java index 6ca8d374816c5..7f0ed8b0af031 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java @@ -2717,7 +2717,7 @@ public static MessageSerializer loadSerializer(Class MessageMarshaller loadMarshaller(Class msgCls, @Nullable Marshaller dfltMarsh) { try { diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java index 3b5bf716479d8..c33dc0e7a33e0 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java @@ -47,7 +47,7 @@ * Test context. */ public class GridTestKernalContext extends GridKernalContextImpl { - /** */ + /** Message factory override for tests; when non-null, replaces the default factory. */ public MessageFactory messageFactory; /** diff --git a/modules/core/src/test/resources/codegen/NioFieldOnNonMessageMessage.java b/modules/core/src/test/resources/codegen/NioFieldOnNonMessageMessage.java index a8ac50154d9df..40df58fafac65 100644 --- a/modules/core/src/test/resources/codegen/NioFieldOnNonMessageMessage.java +++ b/modules/core/src/test/resources/codegen/NioFieldOnNonMessageMessage.java @@ -19,11 +19,14 @@ import org.apache.ignite.plugin.extensions.communication.Message; +/** */ public class NioFieldOnNonMessageMessage implements Message { + /** */ @NioField @Order(0) int id; + /** */ public short directType() { return 0; } diff --git a/modules/core/src/test/resources/codegen/TestCacheIdMessage.java b/modules/core/src/test/resources/codegen/TestCacheIdMessage.java new file mode 100644 index 0000000000000..749e5fd007b60 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestCacheIdMessage.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.util.Collection; +import java.util.List; +import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; +import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; + +public class TestCacheIdMessage extends GridCacheIdMessage { + @Order(0) + KeyCacheObject key; + + @Order(1) + CacheObject val; + + @Order(2) + List keys; + + @Order(3) + Collection writes; + + public short directType() { + return 0; + } + + @Override public boolean addDeploymentInfo() { + return true; + } +} diff --git a/modules/core/src/test/resources/codegen/TestCacheIdMessageDeployer.java b/modules/core/src/test/resources/codegen/TestCacheIdMessageDeployer.java new file mode 100644 index 0000000000000..a2311bd1bf72d --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestCacheIdMessageDeployer.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.TestCacheIdMessage; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestCacheIdMessageDeployer implements GridCacheMessageDeployer { + /** */ + @Override public void prepareDeployment(TestCacheIdMessage msg, GridCacheSharedContext ctx) throws IgniteCheckedException { + GridCacheContext cctx = ctx.cacheContext(msg.cacheId()); + + GridCacheMessageDeployer.prepareCacheObject(msg, msg.key, cctx); + + GridCacheMessageDeployer.prepareCacheObject(msg, msg.val, cctx); + + GridCacheMessageDeployer.prepareCacheObjects(msg, msg.keys, cctx); + + GridCacheMessageDeployer.prepareTxEntries(msg, msg.writes, ctx); + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestDeployableMessage.java b/modules/core/src/test/resources/codegen/TestDeployableMessage.java new file mode 100644 index 0000000000000..de1667b8dba91 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestDeployableMessage.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.processors.cache.DeployableMessage; +import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.KeyCacheObject; + +public class TestDeployableMessage extends GridCacheIdMessage implements DeployableMessage { + @Order(0) + KeyCacheObject key; + + public short directType() { + return 0; + } + + @Override public boolean addDeploymentInfo() { + return true; + } + + @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + // Custom deployment that cannot be inferred from field types. + } +} diff --git a/modules/core/src/test/resources/codegen/TestDeployableMessageDeployer.java b/modules/core/src/test/resources/codegen/TestDeployableMessageDeployer.java new file mode 100644 index 0000000000000..20a54907a2843 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestDeployableMessageDeployer.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.TestDeployableMessage; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestDeployableMessageDeployer implements GridCacheMessageDeployer { + /** */ + @Override public void prepareDeployment(TestDeployableMessage msg, GridCacheSharedContext ctx) throws IgniteCheckedException { + GridCacheContext cctx = ctx.cacheContext(msg.cacheId()); + + GridCacheMessageDeployer.prepareCacheObject(msg, msg.key, cctx); + + msg.prepareDeployment(ctx); + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestNestedDeployMessage.java b/modules/core/src/test/resources/codegen/TestNestedDeployMessage.java new file mode 100644 index 0000000000000..2ce620f2b724a --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestNestedDeployMessage.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; + +public class TestNestedDeployMessage extends GridCacheIdMessage { + @Order(0) + TestCacheIdMessage nested; + + public short directType() { + return 0; + } + + @Override public boolean addDeploymentInfo() { + return true; + } +} diff --git a/modules/core/src/test/resources/codegen/TestNestedDeployMessageDeployer.java b/modules/core/src/test/resources/codegen/TestNestedDeployMessageDeployer.java new file mode 100644 index 0000000000000..b0a063b437cdc --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestNestedDeployMessageDeployer.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.TestNestedDeployMessage; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestNestedDeployMessageDeployer implements GridCacheMessageDeployer { + /** */ + @Override public void prepareDeployment(TestNestedDeployMessage msg, GridCacheSharedContext ctx) throws IgniteCheckedException { + GridCacheMessageDeployer.prepareDeployment(ctx.kernalContext().messageFactory(), msg.nested, ctx); + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestNoCacheCtxMessage.java b/modules/core/src/test/resources/codegen/TestNoCacheCtxMessage.java new file mode 100644 index 0000000000000..a9cb826dc8f8e --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestNoCacheCtxMessage.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.GridCacheMessage; + +public class TestNoCacheCtxMessage extends GridCacheMessage { + @Order(0) + CacheObject val; + + public short directType() { + return 0; + } + + @Override public boolean addDeploymentInfo() { + return true; + } +} diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index c06a3480836b5..a979fd7581748 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -51,7 +51,6 @@ public class DiscoveryMessageParser { /** */ private final ZookeeperDiscoverySpi spi; - /** */ public DiscoveryMessageParser(MessageFactory msgFactory, ZookeeperDiscoverySpi spi) { this.msgFactory = msgFactory; this.spi = spi; @@ -84,7 +83,7 @@ public T unmarshalZip(byte[] bytes) { } } - /** */ + /** Serializes {@code m} (type prefix + payload) into {@code out}. */ private void serializeMessage(Message m, OutputStream out) throws IOException { DirectMessageWriter msgWriter = new DirectMessageWriter(msgFactory); ByteBuffer msgBuf = ByteBuffer.allocate(MSG_BUFFER_SIZE); @@ -110,7 +109,7 @@ private void serializeMessage(Message m, OutputStream out) throws IOException { while (!finished); } - /** */ + /** Deserializes a message (type prefix + payload) from {@code in}. */ private T deserializeMessage(InputStream in) throws IOException { DirectMessageReader msgReader = new DirectMessageReader(msgFactory, null); ByteBuffer msgBuf = ByteBuffer.allocate(MSG_BUFFER_SIZE); diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java index df2274248fc81..e478613e9c76c 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java @@ -24,10 +24,8 @@ public class ZkMessageFactory implements MessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - factory.register(400, - ZkCommunicationErrorResolveFinishMessage::new, new ZkCommunicationErrorResolveFinishMessageSerializer()); - factory.register(401, - ZkCommunicationErrorResolveStartMessage::new, new ZkCommunicationErrorResolveStartMessageSerializer()); + factory.register(400, ZkCommunicationErrorResolveFinishMessage::new, new ZkCommunicationErrorResolveFinishMessageSerializer()); + factory.register(401, ZkCommunicationErrorResolveStartMessage::new, new ZkCommunicationErrorResolveStartMessageSerializer()); factory.register(402, ZkForceNodeFailMessage::new, new ZkForceNodeFailMessageSerializer()); factory.register(403, ZkNoServersMessage::new, new ZkNoServersMessageSerializer()); } From 72fb5d5beec39581244844e07e1bc3570c71ddc0 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 26 Jun 2026 01:31:27 +0300 Subject: [PATCH 170/215] WIP --- .../internal/MessageDeploymentGenerator.java | 31 ++++++++++++++++++- .../ignite/internal/MessageGenerator.java | 3 ++ .../internal/MessageMarshallerGenerator.java | 5 ++- .../internal/MessageSerializerGenerator.java | 1 + .../cache/DynamicCacheChangeRequest.java | 3 ++ .../processors/cache/StoredCacheData.java | 2 ++ .../binary/BinaryMetadataVersionInfo.java | 1 + .../binary/MetadataUpdateProposedMessage.java | 1 + .../distributed/dht/GridDhtLockResponse.java | 2 +- .../atomic/GridNearAtomicUpdateResponse.java | 5 ++- .../distributed/near/CacheVersionedValue.java | 1 + .../cache/verify/PartitionHashRecord.java | 2 ++ .../cache/verify/TransactionsHashRecord.java | 2 ++ .../cluster/ChangeGlobalStateMessage.java | 1 + .../SchemaAddQueryEntityOperation.java | 3 +- .../service/ServiceDeploymentRequest.java | 1 + .../communication/CacheIdAware.java | 2 +- .../communication/MarshallableMessage.java | 2 +- .../MessageDirectTypeIdConflictTest.java | 2 +- .../DiscoveryUnmarshalVulnerabilityTest.java | 3 ++ .../zk/internal/DiscoveryMessageParser.java | 4 +++ .../zk/internal/ZkMessageFactory.java | 4 +-- 22 files changed, 66 insertions(+), 15 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java index 89f0581655003..2b8814181ee39 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java @@ -46,13 +46,28 @@ public class MessageDeploymentGenerator extends MessageGenerator { /** FQN of GridCacheMessage; hierarchy scan stops here (exclusive). */ private static final String GRID_CACHE_MESSAGE = "org.apache.ignite.internal.processors.cache.GridCacheMessage"; + /** */ private final TypeMirror cacheIdMsgMirror; + + /** */ private final TypeMirror cacheGroupIdMsgMirror; + + /** */ private final TypeMirror gridCacheMessageMirror; + + /** */ private final TypeMirror deployableMessageMirror; + + /** */ private final TypeMirror cacheObjectMirror; + + /** */ private final TypeMirror txEntryMirror; + + /** */ private final TypeMirror collectionMirror; + + /** */ private final TypeMirror iterableMirror; /** Accumulated source lines for the generated {@code prepareDeployment} method. */ @@ -61,6 +76,7 @@ public class MessageDeploymentGenerator extends MessageGenerator { /** */ private boolean needsCctx; + /** @param env Annotation processing environment. */ MessageDeploymentGenerator(ProcessingEnvironment env) { super(env); @@ -269,5 +285,18 @@ private TypeMirror elementBound(TypeMirror arg) { return arg; } - private enum DeployKind { CACHE_OBJECT, CACHE_OBJECTS, TX_ENTRIES, NESTED } + /** Deployment strategy inferred from a field's type. */ + private enum DeployKind { + /** */ + CACHE_OBJECT, + + /** */ + CACHE_OBJECTS, + + /** */ + TX_ENTRIES, + + /** */ + NESTED + } } diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java index c25f46370dc00..2da9806a29f92 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java @@ -47,8 +47,10 @@ public abstract class MessageGenerator { /** Blank separator line in generated code. */ public static final String EMPTY = ""; + /** Platform line separator used in generated code. */ public static final String NL = System.lineSeparator(); + /** Single indentation unit. */ public static final String TAB = " "; /** Javadoc stub emitted on every generated {@code @Override} method. */ @@ -73,6 +75,7 @@ public abstract class MessageGenerator { /** */ int indent; + /** @param env Annotation processing environment. */ MessageGenerator(ProcessingEnvironment env) { this.env = env; } diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index f38a9df01243c..3a3a38569fa05 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -22,7 +22,6 @@ import java.io.Writer; import java.util.ArrayList; import java.util.HashSet; - import java.util.List; import java.util.Map; import java.util.Set; @@ -38,7 +37,6 @@ import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVariable; - import javax.tools.Diagnostic; import static org.apache.ignite.internal.MessageProcessor.MARSHALLABLE_MESSAGE_INTERFACE; @@ -91,6 +89,7 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** Enclosed fields of the currently processed type. Computed once per {@link #generateBody} call. */ private Map enclosed; + /** @param env Annotation processing environment. */ MessageMarshallerGenerator(ProcessingEnvironment env) { super(env); @@ -446,7 +445,7 @@ private void appendMarshalledCollectionFinish(List body) { /** Generates the {@code for} loop body: per-element finishUnmarshal + try/catch add into the collection. */ private List collectionFinishForBlock(VariableElement wireField, String colField, String arrField, String fieldName) { String compName = arrayComponentName(wireField); - TypeMirror compType = ((ArrayType) wireField.asType()).getComponentType(); + TypeMirror compType = ((ArrayType)wireField.asType()).getComponentType(); List code = new ArrayList<>(); diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 810a89e9302b2..7a5b43a749e2d 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -66,6 +66,7 @@ public class MessageSerializerGenerator extends MessageGenerator { /** Enum-mapper field declarations emitted at the top of the generated {@code *Serializer} class. */ private final Set fields = new java.util.TreeSet<>(); + /** @param env Annotation processing environment. */ MessageSerializerGenerator(ProcessingEnvironment env) { super(env); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java index 454172428a502..43e375c45d7d0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java @@ -57,6 +57,7 @@ public class DynamicCacheChangeRequest implements Message, Serializable { @Marshalled("cfgBytes") CacheConfiguration startCfg; + /** Bytes of {@link #startCfg}. */ @Order(3) byte[] cfgBytes; @@ -73,6 +74,7 @@ public class DynamicCacheChangeRequest implements Message, Serializable { @Marshalled("nearCfgBytes") NearCacheConfiguration nearCacheCfg; + /** Bytes of {@link #nearCacheCfg}. */ @Order(6) byte[] nearCfgBytes; @@ -124,6 +126,7 @@ public class DynamicCacheChangeRequest implements Message, Serializable { @Marshalled("schemaBytes") QuerySchema schema; + /** Bytes of {@link #schema}. */ @Order(18) byte[] schemaBytes; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java index 848ac5f7d0d38..415bd5f890fc8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StoredCacheData.java @@ -52,6 +52,7 @@ public class StoredCacheData implements Serializable, CdcCacheEvent, Message { @Marshalled("ccfgBytes") CacheConfiguration ccfg; + /** Serialized {@link #ccfg}. */ @Order(0) transient byte[] ccfgBytes; @@ -60,6 +61,7 @@ public class StoredCacheData implements Serializable, CdcCacheEvent, Message { @Marshalled("qryEntitiesBytes") Collection qryEntities; + /** Serialized {@link #qryEntities}. */ @Order(1) transient byte[] qryEntitiesBytes; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java index 921515b30c4a8..ca112d9f8777c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java @@ -36,6 +36,7 @@ public final class BinaryMetadataVersionInfo implements Serializable, Message { @Marshalled("metadataBytes") BinaryMetadata metadata; + /** Serialized binary metadata. */ @Order(0) transient byte[] metadataBytes; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java index 39bd81d68ddd7..16fcca485ec0f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java @@ -80,6 +80,7 @@ public final class MetadataUpdateProposedMessage extends DiscoveryCustomMessage @Marshalled("metadataBytes") BinaryMetadata metadata; + /** Serialized {@link #metadata}. */ @Order(1) byte[] metadataBytes; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index 248d942c65c05..f480c2c2643fb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -23,9 +23,9 @@ import java.util.List; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockResponse; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index 207a8779f1bd0..b7c39b8657c9c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -25,12 +25,12 @@ import org.apache.ignite.internal.Order; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.DeployableMessage; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheReturn; -import org.apache.ignite.internal.processors.cache.DeployableMessage; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -339,7 +339,6 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { errs.addFailedKeys(keys, e); } - /** * @return Data for near cache update. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java index 8ea758b2ffa4f..5546df99c8806 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java @@ -43,6 +43,7 @@ public class CacheVersionedValue implements Message, CacheIdAware { @Order(2) int cacheId; + /** */ public CacheVersionedValue() { // No-op. } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java index b1afae6b941fe..49b938754087b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/PartitionHashRecord.java @@ -55,6 +55,7 @@ public class PartitionHashRecord implements Message, Serializable { @Marshalled("consistentIdBytes") Object consistentId; + /** Bytes of {@link #consistentId}. */ @Order(2) @GridToStringExclude byte[] consistentIdBytes; @@ -74,6 +75,7 @@ public class PartitionHashRecord implements Message, Serializable { @Marshalled("updateCntrBytes") Object updateCntr; + /** Bytes of {@link #updateCntr}. */ @Order(5) @GridToStringExclude byte[] updateCntrBytes; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java index a3049e2ef0c56..1aa7a72c2e1ec 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/TransactionsHashRecord.java @@ -34,6 +34,7 @@ public class TransactionsHashRecord implements Message, Serializable { @Marshalled("locConsistentIdBytes") Object locConsistentId; + /** Bytes of {@link #locConsistentId}. */ @Order(0) transient byte[] locConsistentIdBytes; @@ -42,6 +43,7 @@ public class TransactionsHashRecord implements Message, Serializable { @Marshalled("rmtConsistentIdBytes") Object rmtConsistentId; + /** Bytes of {@link #rmtConsistentId}. */ @Order(1) transient byte[] rmtConsistentIdBytes; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java index 19cfee1e0b12c..bf24db10164e9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java @@ -59,6 +59,7 @@ public class ChangeGlobalStateMessage extends DiscoveryCustomMessage implements @Nullable @Marshalled("baselineTopologyBytes") BaselineTopology baselineTopology; + /** JDK Serialized version of baselineTopology. */ @Order(4) byte[] baselineTopologyBytes; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java index d8a8b201f14d3..606c117e0a162 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaAddQueryEntityOperation.java @@ -35,6 +35,7 @@ public class SchemaAddQueryEntityOperation extends SchemaAbstractOperation imple @Marshalled("qryEntitiesBytes") Collection entities; + /** Serialized form of query entities. */ @Order(0) transient byte[] qryEntitiesBytes; @@ -91,6 +92,4 @@ public int queryParallelism() { public boolean isSqlEscape() { return sqlEscape; } - - } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java index 659ae6d0da461..b58c0968ce3b7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceDeploymentRequest.java @@ -33,6 +33,7 @@ public class ServiceDeploymentRequest extends ServiceChangeAbstractRequest imple @Marshalled("cfgBytes") LazyServiceConfiguration cfg; + /** JDK serialization for {@link #cfg}. */ @Order(0) byte[] cfgBytes; diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java index 869c386a3e604..005e0c4652f00 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java @@ -19,6 +19,6 @@ /** Implemented by messages that carry a cache ID identifying the target cache. */ public interface CacheIdAware { - /** */ + /** @return Cache ID identifying the target cache. */ public int cacheId(); } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java index 48c055ca23f3a..d15d50b625f9d 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java @@ -22,7 +22,7 @@ /** A {@link Message} requiring a custom marshal/unmarshal step via {@link Marshaller}. */ public interface MarshallableMessage extends Message { - /** */ + /** @param marsh Marshaller for pre-marshalling. */ public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException; /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java index 6ecf67b611bf5..f540a08293d02 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/MessageDirectTypeIdConflictTest.java @@ -81,7 +81,7 @@ public static class TestPluginProvider extends AbstractTestPluginProvider { @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) { registry.registerExtension(MessageFactoryProvider.class, new MessageFactoryProvider() { @Override public void registerAll(MessageFactory factory) { - factory.register(DIRECT_TYPE, DuplicateDirectTypeIdMessage::new, new DuplicateDirectTypeIdMessageSerializer()); + factory.register(DIRECT_TYPE, DuplicateDirectTypeIdMessage::new, new DuplicateDirectTypeIdMessageSerializer()); } }); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index 206bb7be83fc4..acd2827404199 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -266,6 +266,7 @@ private static class MessageSerializerWrapper implements MessageSerializer serde; + /** */ private MessageSerializerWrapper(AbstractMarshallableMessageFactoryProvider provider) { this.provider = provider; } @@ -302,6 +303,7 @@ private static class MessageMarshallerWrapper implements MessageMarshaller marsh; + /** */ private MessageMarshallerWrapper(AbstractMarshallableMessageFactoryProvider provider) { this.provider = provider; } @@ -329,6 +331,7 @@ private MessageMarshallerWrapper(AbstractMarshallableMessageFactoryProvider prov marsh.finishUnmarshal(msg, kctx); } + /** */ private void initIfNecessary() { if (init.get() && init.compareAndSet(true, false)) marsh = loadMarshaller(ExploitMessage.class, U.field(provider, "dfltMarsh")); diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index a979fd7581748..817571c2e3c76 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -51,6 +51,10 @@ public class DiscoveryMessageParser { /** */ private final ZookeeperDiscoverySpi spi; + /** + * @param msgFactory Message factory. + * @param spi Discovery SPI. + */ public DiscoveryMessageParser(MessageFactory msgFactory, ZookeeperDiscoverySpi spi) { this.msgFactory = msgFactory; this.spi = spi; diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java index a1530dd5bf3a9..cf9f95a908f7e 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java @@ -24,8 +24,8 @@ public class ZkMessageFactory implements MessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - factory.register(400, ZkCommunicationErrorResolveFinishMessage::new, new ZkCommunicationErrorResolveFinishMessageSerializer()); - factory.register(401, ZkCommunicationErrorResolveStartMessage::new, new ZkCommunicationErrorResolveStartMessageSerializer()); + factory.register(400, ZkCommunicationErrorResolveFinishMessage::new, new ZkCommunicationErrorResolveFinishMessageSerializer()); + factory.register(401, ZkCommunicationErrorResolveStartMessage::new, new ZkCommunicationErrorResolveStartMessageSerializer()); factory.register(402, ZkForceNodeFailMessage::new, new ZkForceNodeFailMessageSerializer()); factory.register(403, ZkNoServersMessage::new, new ZkNoServersMessageSerializer()); factory.register(404, ZkDiscoDataBagWrapper::new, new ZkDiscoDataBagWrapperSerializer()); From 86a31ec2e7ac5dc0756ebf23590ec180e6caca32 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 26 Jun 2026 12:40:36 +0300 Subject: [PATCH 171/215] WIP --- .../distributed/dht/atomic/GridDhtAtomicUpdateRequest.java | 4 ++-- .../dht/atomic/GridNearAtomicFullUpdateRequest.java | 5 +++-- .../dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java | 4 ++-- .../dht/preloader/GridDhtPartitionsFullMessage.java | 4 ++-- .../dht/preloader/GridDhtPartitionsSingleMessage.java | 4 ++-- .../processors/cache/query/GridCacheQueryResponse.java | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 4b467a68d1041..a0866ee0b39b6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -39,14 +39,14 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Lite dht cache backup update request. */ -public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements MarshallableMessage, DeployableMessage { +public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements CacheMarshallableMessage, DeployableMessage { /** Keys to update. */ @GridToStringInclude @Order(0) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index 23ba2731d7d05..fe5d5b9a98529 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -44,7 +44,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -55,7 +55,8 @@ /** * Lite DHT cache update request sent from near node to primary node. */ -public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements MarshallableMessage, DeployableMessage { +public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest + implements CacheMarshallableMessage, DeployableMessage { /** Keys to update. */ @Order(0) @GridToStringInclude diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index 4a9cfcf2987f4..127f50a26c021 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -38,7 +38,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,7 +48,7 @@ * */ public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest - implements MarshallableMessage, DeployableMessage { + implements CacheMarshallableMessage, DeployableMessage { /** Optional arguments for entry processor. */ private @Nullable Object[] invokeArgs; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index 6cce1a2ac30ea..00473e4898074 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -40,7 +40,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -49,7 +49,7 @@ * GridDhtPartitionsSingleMessage}s were received.
May be also compacted as part of {@link * CacheAffinityChangeMessage} for node left or failed case.
*/ -public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { +public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessage implements CacheMarshallableMessage { /** */ private static final byte REBALANCED_FLAG_MASK = 0x01; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index ff9f2016f3464..3236281848cf5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -31,7 +31,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** @@ -39,7 +39,7 @@ * * Sent in response to {@link GridDhtPartitionsSingleRequest} and during processing partitions exchange future. */ -public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { +public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements CacheMarshallableMessage { /** Local partitions. */ @Order(0) @Compress diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index 46f3f4a6134ea..040443b18a514 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -32,13 +32,13 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Page of cache query response. */ -public class GridCacheQueryResponse extends GridCacheIdMessage implements GridCacheDeployable, MarshallableMessage, DeployableMessage { +public class GridCacheQueryResponse extends GridCacheIdMessage implements GridCacheDeployable, CacheMarshallableMessage, DeployableMessage { /** */ @Order(0) boolean finished; From 3f77c7403fd55f504e61ce2cc0ca2dfea6c06b4d Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Fri, 26 Jun 2026 16:00:29 +0300 Subject: [PATCH 172/215] WIP --- .../internal/MessageMarshallerGenerator.java | 18 +++++++-------- .../atomic/GridDhtAtomicUpdateRequest.java | 4 ++-- .../GridNearAtomicFullUpdateRequest.java | 5 ++--- ...idNearAtomicSingleUpdateInvokeRequest.java | 4 ++-- .../GridDhtPartitionsFullMessage.java | 4 ++-- .../GridDhtPartitionsSingleMessage.java | 4 ++-- .../cache/query/GridCacheQueryResponse.java | 4 ++-- .../CacheMarshallableMessage.java | 22 ------------------- .../TestMarshallableMessageMarshaller.java | 1 + 9 files changed, 22 insertions(+), 44 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 3a3a38569fa05..37dd9147bfe17 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -69,19 +69,19 @@ public class MessageMarshallerGenerator extends MessageGenerator { private final TypeMirror cacheGroupIdMsgMirror; /** */ - private final TypeMirror mapMirror; + private final TypeMirror gridCacheMessageMirror; /** */ - private final TypeMirror collectionMirror; + private final TypeMirror mapMirror; /** */ - private final TypeMirror cacheMarshallableMsgType; + private final TypeMirror collectionMirror; /** */ private boolean marshallable; - /** */ - private boolean cacheMarshallable; + /** Whether the message is a {@code GridCacheMessage} subtype, i.e. received via the cache deployment path. */ + private boolean cacheMsg; /** */ private boolean hasMarshalled; @@ -94,12 +94,12 @@ public class MessageMarshallerGenerator extends MessageGenerator { super(env); marshallableMsgType = type(MARSHALLABLE_MESSAGE_INTERFACE); - cacheMarshallableMsgType = type("org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage"); messageMirror = type(MESSAGE_INTERFACE); cacheObjectMirror = type("org.apache.ignite.internal.processors.cache.CacheObject"); nonMarshallableMirror = type("org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage"); cacheIdAwareMirror = type("org.apache.ignite.plugin.extensions.communication.CacheIdAware"); cacheGroupIdMsgMirror = type("org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage"); + gridCacheMessageMirror = type("org.apache.ignite.internal.processors.cache.GridCacheMessage"); mapMirror = type("java.util.Map"); collectionMirror = type("java.util.Collection"); } @@ -118,7 +118,7 @@ public class MessageMarshallerGenerator extends MessageGenerator { @Override void generateBody(List fields) throws Exception { enclosed = enclosedFields(); marshallable = marshallableMsgType != null && assignableFrom(type.asType(), marshallableMsgType); - cacheMarshallable = cacheMarshallableMsgType != null && assignableFrom(type.asType(), cacheMarshallableMsgType); + cacheMsg = gridCacheMessageMirror != null && assignableFrom(type.asType(), gridCacheMessageMirror); hasMarshalled = enclosed.values().stream().anyMatch(f -> f.getAnnotation(Marshalled.class) != null); indent = 1; @@ -267,9 +267,9 @@ private void generateFinishUnmarshalMethod(String methodName, String params, Lis appendFields(body, fields, mode, wireFieldSkip); if (marshallable) { - if (mode == MarshalMode.FINISH_CACHE && cacheMarshallable) + if (mode == MarshalMode.FINISH_CACHE) appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);"))); - else if (mode == MarshalMode.FINISH && !cacheMarshallable) + else if (mode == MarshalMode.FINISH && !cacheMsg) appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));"))); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index a0866ee0b39b6..4b467a68d1041 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -39,14 +39,14 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Lite dht cache backup update request. */ -public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements CacheMarshallableMessage, DeployableMessage { +public class GridDhtAtomicUpdateRequest extends GridDhtAtomicAbstractUpdateRequest implements MarshallableMessage, DeployableMessage { /** Keys to update. */ @GridToStringInclude @Order(0) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index fe5d5b9a98529..23ba2731d7d05 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -44,7 +44,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -55,8 +55,7 @@ /** * Lite DHT cache update request sent from near node to primary node. */ -public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest - implements CacheMarshallableMessage, DeployableMessage { +public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdateRequest implements MarshallableMessage, DeployableMessage { /** Keys to update. */ @Order(0) @GridToStringInclude diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index 127f50a26c021..4a9cfcf2987f4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -38,7 +38,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,7 +48,7 @@ * */ public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingleUpdateRequest - implements CacheMarshallableMessage, DeployableMessage { + implements MarshallableMessage, DeployableMessage { /** Optional arguments for entry processor. */ private @Nullable Object[] invokeArgs; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index 00473e4898074..6cce1a2ac30ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -40,7 +40,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -49,7 +49,7 @@ * GridDhtPartitionsSingleMessage}s were received.
May be also compacted as part of {@link * CacheAffinityChangeMessage} for node left or failed case.
*/ -public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessage implements CacheMarshallableMessage { +public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { /** */ private static final byte REBALANCED_FLAG_MASK = 0x01; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index 3236281848cf5..ff9f2016f3464 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -31,7 +31,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** @@ -39,7 +39,7 @@ * * Sent in response to {@link GridDhtPartitionsSingleRequest} and during processing partitions exchange future. */ -public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements CacheMarshallableMessage { +public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMessage implements MarshallableMessage { /** Local partitions. */ @Order(0) @Compress diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index 040443b18a514..46f3f4a6134ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -32,13 +32,13 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.CacheMarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Page of cache query response. */ -public class GridCacheQueryResponse extends GridCacheIdMessage implements GridCacheDeployable, CacheMarshallableMessage, DeployableMessage { +public class GridCacheQueryResponse extends GridCacheIdMessage implements GridCacheDeployable, MarshallableMessage, DeployableMessage { /** */ @Order(0) boolean finished; diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java deleted file mode 100644 index b7a08ed3ec26f..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheMarshallableMessage.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.plugin.extensions.communication; - -/** A {@link MarshallableMessage} whose {@code finishUnmarshal} needs CacheObjects deserialized first. */ -public interface CacheMarshallableMessage extends MarshallableMessage { -} diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java index 52c75c2d3860e..805f382bbb672 100644 --- a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java @@ -47,6 +47,7 @@ public TestMarshallableMessageMarshaller(Marshaller marshaller) { /** */ @Override public void finishUnmarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + msg.finishUnmarshal(marshaller, clsLdr); } /** */ From f2eab1eb75bc0d2dee3ffe27e58c308099bd5104 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sat, 27 Jun 2026 17:51:44 +0300 Subject: [PATCH 173/215] WIP --- .../internal/MessageMarshallerGenerator.java | 27 ++----- .../apache/ignite/IgniteSystemProperties.java | 4 + .../managers/communication/GridIoManager.java | 5 ++ .../communication/MessageMarshaller.java | 78 +++++++++++++++++++ .../codegen/MessageMarshalOnceTest.java | 65 ++++++++++++++++ .../MessageFinishUnmarshalOnceTest.java | 60 ++++++++++++++ .../junits/GridAbstractTest.java | 2 + .../testsuites/IgniteBasicTestSuite.java | 4 + .../TestMarshalledMessageMarshaller.java | 9 +-- 9 files changed, 230 insertions(+), 24 deletions(-) create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageMarshalOnceTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageFinishUnmarshalOnceTest.java diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 37dd9147bfe17..b57d6d8e1a90d 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -68,9 +68,6 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** */ private final TypeMirror cacheGroupIdMsgMirror; - /** */ - private final TypeMirror gridCacheMessageMirror; - /** */ private final TypeMirror mapMirror; @@ -80,9 +77,6 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** */ private boolean marshallable; - /** Whether the message is a {@code GridCacheMessage} subtype, i.e. received via the cache deployment path. */ - private boolean cacheMsg; - /** */ private boolean hasMarshalled; @@ -99,7 +93,6 @@ public class MessageMarshallerGenerator extends MessageGenerator { nonMarshallableMirror = type("org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage"); cacheIdAwareMirror = type("org.apache.ignite.plugin.extensions.communication.CacheIdAware"); cacheGroupIdMsgMirror = type("org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage"); - gridCacheMessageMirror = type("org.apache.ignite.internal.processors.cache.GridCacheMessage"); mapMirror = type("java.util.Map"); collectionMirror = type("java.util.Collection"); } @@ -118,7 +111,6 @@ public class MessageMarshallerGenerator extends MessageGenerator { @Override void generateBody(List fields) throws Exception { enclosed = enclosedFields(); marshallable = marshallableMsgType != null && assignableFrom(type.asType(), marshallableMsgType); - cacheMsg = gridCacheMessageMirror != null && assignableFrom(type.asType(), gridCacheMessageMirror); hasMarshalled = enclosed.values().stream().anyMatch(f -> f.getAnnotation(Marshalled.class) != null); indent = 1; @@ -269,12 +261,11 @@ private void generateFinishUnmarshalMethod(String methodName, String params, Lis if (marshallable) { if (mode == MarshalMode.FINISH_CACHE) appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);"))); - else if (mode == MarshalMode.FINISH && !cacheMsg) + else appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));"))); } - if (mode == MarshalMode.FINISH) - appendMarshalledFinish(body); + appendMarshalledFinish(body, mode); if (mode == MarshalMode.FINISH_CACHE) { appendMarshalledCollectionFinish(body); @@ -375,7 +366,7 @@ private void appendMarshalledPrepare(List body) { forEachMarshalled((bytesAcc, objAcc) -> { List code = new ArrayList<>(); - code.add(indentedLine("if (%s != null)", objAcc)); + code.add(indentedLine("if (%s != null && %s == null)", objAcc, bytesAcc)); indent++; @@ -388,22 +379,20 @@ private void appendMarshalledPrepare(List body) { } /** Generates {@code U.unmarshal} calls for all {@code @Marshalled} fields in finishUnmarshal. */ - private void appendMarshalledFinish(List body) { + private void appendMarshalledFinish(List body, MarshalMode mode) { + String clsLdr = mode == MarshalMode.FINISH_CACHE ? "clsLdr" : "U.resolveClassLoader(kctx.config())"; + forEachMarshalled((bytesAcc, objAcc) -> { List code = new ArrayList<>(); - code.add(indentedLine("if (%s != null) {", bytesAcc)); + code.add(indentedLine("if (%s != null)", bytesAcc)); indent++; - code.add(indentedLine("%s = U.unmarshal(marshaller, %s, U.resolveClassLoader(kctx.config()));", objAcc, bytesAcc)); - code.add(EMPTY); - code.add(indentedLine("%s = null;", bytesAcc)); + code.add(indentedLine("%s = U.unmarshal(marshaller, %s, %s);", objAcc, bytesAcc, clsLdr)); indent--; - code.add(indentedLine("}")); - return code; }, body); } diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java index b1c36a9015827..13be8fa4dc102 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java @@ -1967,6 +1967,10 @@ public final class IgniteSystemProperties extends IgniteCommonsSystemProperties @SystemProperty(value = "Packages list to expose in configuration view") public static final String IGNITE_CONFIGURATION_VIEW_PACKAGES = "IGNITE_CONFIGURATION_VIEW_PACKAGES"; + /** Enables the assertion that a message is finish-unmarshalled at most once. For tests; off in production. */ + @SystemProperty("Enables the message finish-unmarshal-once self-check (tests only)") + public static final String IGNITE_MESSAGE_UNMARSHAL_ONCE_CHECK = "IGNITE_MESSAGE_UNMARSHAL_ONCE_CHECK"; + /** * Enforces singleton. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index dd52ba1611d27..aa85812275543 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -91,6 +91,7 @@ import org.apache.ignite.internal.managers.discovery.CustomEventListener; import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager; import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener; +import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory; import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIO; @@ -1458,6 +1459,10 @@ private void processRegularMessage0(GridIoMessage msg, UUID nodeId) { /** */ private void finishUnmarshalPayload(GridIoMessage msg) { + // Unmarshalled by GridCacheIoManager with the deployment loader; the loader here can't see its peer classes. + if (msg.message() instanceof GridCacheMessage) + return; + try { MessageMarshaller.finishUnmarshal(ctx.messageFactory(), msg.message(), ctx); } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index 1b9dc2a91dc3f..186156a7bb1c0 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -17,7 +17,13 @@ package org.apache.ignite.plugin.extensions.communication; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.jetbrains.annotations.Nullable; @@ -118,6 +124,8 @@ static void prepareMarshal(MessageFactory factory, M msg, Gr */ static void finishUnmarshal(MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + assert !Dedup.ENABLED || Dedup.firstUnmarshal(msg) : "Message finish-unmarshalled more than once: " + msg.getClass().getName(); + MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); if (m != null) @@ -135,9 +143,79 @@ static void finishUnmarshal(MessageFactory factory, M msg, G */ static void finishUnmarshal(MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { + assert !Dedup.ENABLED || Dedup.firstUnmarshal(msg) : "Message finish-unmarshalled more than once: " + msg.getClass().getName(); + MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); if (m != null) m.finishUnmarshal(msg, kctx); } + + /** + * Detects a {@link MarshallableMessage} instance being finish-unmarshalled more than once — a class-loader or + * receive-path bug. Gated by {@link #ENABLED}, so it runs only under tests and is folded away in production. + */ + class Dedup { + /** + * When {@code true}, the no-double-unmarshal check runs. {@code static final} so the JIT folds the guard away + * in production (even with assertions on); enabled only by tests via {@code IGNITE_MESSAGE_UNMARSHAL_ONCE_CHECK}. + */ + static final boolean ENABLED = IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_MESSAGE_UNMARSHAL_ONCE_CHECK); + + /** Queue of collected referents, drained on each call to evict stale {@link IdRef}s from {@link #SEEN}. */ + private static final ReferenceQueue Q = new ReferenceQueue<>(); + + /** Finish-unmarshalled instances, held weakly and keyed by identity so they vanish with the message. */ + private static final Set SEEN = ConcurrentHashMap.newKeySet(); + + /** */ + private Dedup() { + // No-op. + } + + /** + * @param msg Message about to be finish-unmarshalled. + * @return {@code true} if {@code msg} is not a {@link MarshallableMessage} or is finish-unmarshalled the first time. + */ + static boolean firstUnmarshal(Message msg) { + if (!(msg instanceof MarshallableMessage)) + return true; + + for (Reference r; (r = Q.poll()) != null; ) + SEEN.remove(r); + + return SEEN.add(new IdRef(msg)); + } + + /** Weak reference to a message keyed by identity, so two equal-but-distinct messages remain distinct keys. */ + private static final class IdRef extends WeakReference { + /** Referent identity hash, captured up front since the referent may be cleared later. */ + private final int hash; + + /** @param msg Tracked message. */ + IdRef(Message msg) { + super(msg, Q); + + hash = System.identityHashCode(msg); + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return hash; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof IdRef)) + return false; + + Message m = get(); + + return m != null && m == ((IdRef)o).get(); + } + } + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageMarshalOnceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageMarshalOnceTest.java new file mode 100644 index 0000000000000..d76b0b0f40a41 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageMarshalOnceTest.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.codegen; + +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.processors.cache.verify.TransactionsHashRecord; +import org.apache.ignite.internal.processors.cache.verify.TransactionsHashRecordMarshaller; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Guards against a marshalling performance regression. The codegen wraps each {@code @Marshalled} field's + * {@code U.marshal} in a {@code wireField == null} guard, so a message {@code prepareMarshal}'d N times (broadcast to + * N nodes) marshals each field at most once: the wire bytes are computed on the first call and reused thereafter. + * Verified behaviourally — the wire array is the same reference after a second {@code prepareMarshal}, independent of + * how the guard is formatted (a re-marshal would create a new array). + */ +public class MessageMarshalOnceTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + super.afterTest(); + } + + /** @throws Exception If failed. */ + @Test + public void testPrepareMarshalMarshalsOnce() throws Exception { + GridKernalContext kctx = startGrid(0).context(); + + // One @Marshalled message is representative: the marshal-once guard comes from one generator template + // (only field names vary), so a regression in it breaks every such message identically. + TransactionsHashRecord msg = new TransactionsHashRecord("local", "remote", 0); + + TransactionsHashRecordMarshaller marshaller = new TransactionsHashRecordMarshaller(kctx.marshaller()); + + marshaller.prepareMarshal(msg, kctx, null); + + byte[] first = GridTestUtils.getFieldValue(msg, "locConsistentIdBytes"); + + assertNotNull("First prepareMarshal must marshal the field", first); + + marshaller.prepareMarshal(msg, kctx, null); + + byte[] second = GridTestUtils.getFieldValue(msg, "locConsistentIdBytes"); + + assertTrue("Second prepareMarshal re-marshalled the field — missing 'wire-field == null' guard", first == second); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageFinishUnmarshalOnceTest.java b/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageFinishUnmarshalOnceTest.java new file mode 100644 index 0000000000000..d24bf03c13fc8 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageFinishUnmarshalOnceTest.java @@ -0,0 +1,60 @@ +/* + * 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.marshaller.Marshaller; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Verifies the no-double-unmarshal check itself, not its coverage: {@link MessageMarshaller.Dedup#firstUnmarshal} must + * detect a second finish-unmarshal of the same instance, and the check must be enabled for every test — otherwise the + * suite-wide guard would silently turn off and pass every test vacuously. The actual coverage (no real receive path + * unmarshals an instance twice) comes from running the check across the whole suite via {@code GridAbstractTest}. + */ +public class MessageFinishUnmarshalOnceTest extends GridCommonAbstractTest { + /** The suite-wide guard must be on, so a silently-disabled check cannot pass every test without verifying anything. */ + @Test + public void testCheckEnabled() { + assertTrue("IGNITE_MESSAGE_UNMARSHAL_ONCE_CHECK must be set for every test by GridAbstractTest", + MessageMarshaller.Dedup.ENABLED); + } + + /** A second finish-unmarshal of the same instance must be detected; the first must be allowed. */ + @Test + public void testSecondUnmarshalDetected() { + MarshallableMessage msg = new NoopMarshallableMessage(); + + assertTrue("First finish-unmarshal must be allowed", MessageMarshaller.Dedup.firstUnmarshal(msg)); + assertFalse("Second finish-unmarshal of the same instance must be detected", + MessageMarshaller.Dedup.firstUnmarshal(msg)); + } + + /** Minimal {@link MarshallableMessage}; only its identity matters to the check. */ + private static class NoopMarshallableMessage implements MarshallableMessage { + /** {@inheritDoc} */ + @Override public void prepareMarshal(Marshaller marsh) { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) { + // No-op. + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java index 5029cb64a8953..c214494931ab7 100755 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java @@ -159,6 +159,7 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_CLIENT_CACHE_CHANGE_MESSAGE_TIMEOUT; import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISCO_FAILED_CLIENT_RECONNECT_DELAY; import static org.apache.ignite.IgniteSystemProperties.IGNITE_LOG_CLASSPATH_CONTENT_ON_STARTUP; +import static org.apache.ignite.IgniteSystemProperties.IGNITE_MESSAGE_UNMARSHAL_ONCE_CHECK; import static org.apache.ignite.IgniteSystemProperties.IGNITE_TEST_ENV; import static org.apache.ignite.IgniteSystemProperties.IGNITE_TO_STRING_INCLUDE_SENSITIVE; import static org.apache.ignite.IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER; @@ -291,6 +292,7 @@ public String getName() { System.setProperty(IGNITE_CLIENT_CACHE_CHANGE_MESSAGE_TIMEOUT, "1000"); System.setProperty(IGNITE_LOG_CLASSPATH_CONTENT_ON_STARTUP, "false"); System.setProperty(IGNITE_TEST_ENV, "true"); + System.setProperty(IGNITE_MESSAGE_UNMARSHAL_ONCE_CHECK, "true"); S.setIncludeSensitiveSupplier(() -> getBoolean(IGNITE_TO_STRING_INCLUDE_SENSITIVE, true)); diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java index 8d5e881c707e9..8fd3df6498520 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java @@ -36,6 +36,7 @@ import org.apache.ignite.internal.IgniteSlowClientDetectionSelfTest; import org.apache.ignite.internal.TransactionsMXBeanImplTest; import org.apache.ignite.internal.codegen.IgniteDataTransferObjectProcessorTest; +import org.apache.ignite.internal.codegen.MessageMarshalOnceTest; import org.apache.ignite.internal.codegen.MessageProcessorTest; import org.apache.ignite.internal.codegen.MessageSerializationArchitectureTest; import org.apache.ignite.internal.managers.communication.CompressedMessageTest; @@ -72,6 +73,7 @@ import org.apache.ignite.messaging.GridMessagingSelfTest; import org.apache.ignite.messaging.IgniteMessagingSendAsyncTest; import org.apache.ignite.messaging.IgniteMessagingWithClientTest; +import org.apache.ignite.plugin.extensions.communication.MessageFinishUnmarshalOnceTest; import org.apache.ignite.spi.GridSpiLocalHostInjectionTest; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTestSelfTest; import org.apache.ignite.testframework.junits.multijvm.JavaVersionCommandParserTest; @@ -152,6 +154,8 @@ ClientSessionOutboundQueueLimitTest.class, MessageProcessorTest.class, + MessageMarshalOnceTest.class, + MessageFinishUnmarshalOnceTest.class, MessageSerializationArchitectureTest.class, ErrorMessageSelfTest.class, DefaultEnumMapperTest.class, diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java index 6de3f72eb0ba3..857b5c80ea5a9 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java @@ -42,20 +42,19 @@ public TestMarshalledMessageMarshaller(Marshaller marshaller) { /** */ @Override public void prepareMarshal(TestMarshalledMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - if (msg.data != null) + if (msg.data != null && msg.dataBytes == null) msg.dataBytes = U.marshal(marshaller, msg.data); } /** */ @Override public void finishUnmarshal(TestMarshalledMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + if (msg.dataBytes != null) + msg.data = U.unmarshal(marshaller, msg.dataBytes, clsLdr); } /** */ @Override public void finishUnmarshal(TestMarshalledMessage msg, GridKernalContext kctx) throws IgniteCheckedException { - if (msg.dataBytes != null) { + if (msg.dataBytes != null) msg.data = U.unmarshal(marshaller, msg.dataBytes, U.resolveClassLoader(kctx.config())); - - msg.dataBytes = null; - } } } \ No newline at end of file From b5d144ada7d702bacafac570658336b0742a3d6e Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sat, 27 Jun 2026 19:49:41 +0300 Subject: [PATCH 174/215] WIP --- .../ignite/internal/managers/communication/GridIoManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index aa85812275543..e672f646e0f3d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1182,6 +1182,9 @@ private void onChannelOpened0(UUID rmtNodeId, GridIoMessage initMsg, Channel cha byte plc = initMsg.policy(); + // Restore the @NioField topic (as onMessage0 does); otherwise GridIoMessage.topic() is null here. + MessageMarshaller.finishUnmarshalNio(ctx.messageFactory(), initMsg, ctx); + MessageMarshaller.finishUnmarshal(ctx.messageFactory(), initMsg, ctx); pools.poolForPolicy(plc).execute(new Runnable() { From fb22cfe68b9ead470fe90868cf83fd8efd3bfae6 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sat, 27 Jun 2026 22:21:58 +0300 Subject: [PATCH 175/215] WIP --- .../calcite/message/MessageServiceImpl.java | 30 ++----------------- .../exec/rel/AbstractExecutionTest.java | 5 ---- .../calcite/planner/AbstractPlannerTest.java | 5 ---- .../codegen/MessageMarshalOnceTest.java | 8 ++--- 4 files changed, 5 insertions(+), 43 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java index 98211b8cb8876..db27d20a703ce 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java @@ -23,8 +23,6 @@ import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.failure.FailureContext; -import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.GridTopic; import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException; @@ -36,10 +34,8 @@ import org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor; import org.apache.ignite.internal.processors.query.calcite.exec.QueryTaskExecutor; import org.apache.ignite.internal.processors.query.calcite.util.AbstractService; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; /** * @@ -51,9 +47,6 @@ public class MessageServiceImpl extends AbstractService implements MessageServic /** */ private final GridCacheSharedContext ctx; - /** */ - private final ClassLoader clsLdr; - /** */ private UUID locNodeId; @@ -74,7 +67,6 @@ public MessageServiceImpl(GridKernalContext ctx) { super(ctx); this.ctx = ctx.cache().context(); - clsLdr = U.resolveClassLoader(ctx.config()); ioMgr = ctx.io(); msgLsnr = this::onMessage; } @@ -179,18 +171,6 @@ public FailureProcessor failureProcessor() { } } - /** */ - protected void prepareUnmarshal(Message msg) throws IgniteCheckedException { - try { - MessageMarshaller.finishUnmarshal(ctx.kernalContext().messageFactory(), msg, ctx.kernalContext(), null, clsLdr); - } - catch (Exception e) { - failureProcessor().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); - - throw e; - } - } - /** */ protected void onMessage(UUID nodeId, Message msg) { if (msg instanceof ExecutionContextAware) { @@ -213,14 +193,8 @@ private void onMessage(UUID nodeId, Object msg, byte plc) { /** */ private void onMessageInternal(UUID nodeId, Message msg) { - try { - prepareUnmarshal(msg); + MessageListener lsnr = Objects.requireNonNull(lsnrs.get(msg.getClass())); - MessageListener lsnr = Objects.requireNonNull(lsnrs.get(msg.getClass())); - lsnr.onMessage(nodeId, msg); - } - catch (IgniteCheckedException e) { - throw U.convertException(e); - } + lsnr.onMessage(nodeId, msg); } } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java index 5dd910a20c7e9..b7f5880259be2 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java @@ -399,11 +399,6 @@ private TestMessageServiceImpl(GridKernalContext kernal, TestIoManager mgr) { @Override public boolean alive(UUID nodeId) { return true; } - - /** {@inheritDoc} */ - @Override protected void prepareUnmarshal(Message msg) { - // No-op: TestIoManager delivers messages in-memory, no deserialization needed. - } } /** diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java index 82ee3fab07fdd..b49af08b5c700 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java @@ -786,11 +786,6 @@ static class TestMessageServiceImpl extends MessageServiceImpl { @Override public boolean alive(UUID nodeId) { return true; } - - /** {@inheritDoc} */ - @Override protected void prepareUnmarshal(Message msg) { - // No-op: TestIoManager delivers messages in-memory, no deserialization needed. - } } /** */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageMarshalOnceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageMarshalOnceTest.java index d76b0b0f40a41..d7da3676043bf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageMarshalOnceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageMarshalOnceTest.java @@ -19,7 +19,7 @@ import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.cache.verify.TransactionsHashRecord; -import org.apache.ignite.internal.processors.cache.verify.TransactionsHashRecordMarshaller; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Test; @@ -48,15 +48,13 @@ public void testPrepareMarshalMarshalsOnce() throws Exception { // (only field names vary), so a regression in it breaks every such message identically. TransactionsHashRecord msg = new TransactionsHashRecord("local", "remote", 0); - TransactionsHashRecordMarshaller marshaller = new TransactionsHashRecordMarshaller(kctx.marshaller()); - - marshaller.prepareMarshal(msg, kctx, null); + MessageMarshaller.prepareMarshal(kctx.messageFactory(), msg, kctx, null); byte[] first = GridTestUtils.getFieldValue(msg, "locConsistentIdBytes"); assertNotNull("First prepareMarshal must marshal the field", first); - marshaller.prepareMarshal(msg, kctx, null); + MessageMarshaller.prepareMarshal(kctx.messageFactory(), msg, kctx, null); byte[] second = GridTestUtils.getFieldValue(msg, "locConsistentIdBytes"); From a46d91606432d7bf0707e5f601900d5a9b17906b Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sun, 28 Jun 2026 00:52:24 +0300 Subject: [PATCH 176/215] WIP --- .../spi/discovery/tcp/internal/TcpDiscoveryNode.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java index 2e7d6f44b7d0e..1fe4710a6a43c 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java @@ -272,6 +272,10 @@ public void lastSuccessfulAddress(InetSocketAddress lastSuccessfulAddr) { map.put(ATTR_NODE_CONSISTENT_ID, consistentId); attrs = Collections.unmodifiableMap(map); + + // Invalidate the @Marshalled caches — both fields are mutated here (see setAttributes). + consistentIdBytes = null; + attrsBytes = null; } /** {@inheritDoc} */ @@ -300,6 +304,10 @@ public void lastSuccessfulAddress(InetSocketAddress lastSuccessfulAddr) { */ public void setAttributes(Map attrs) { this.attrs = U.sealMap(attrs); + + // Invalidate the @Marshalled cache: attrs are mutated after the first marshal (auth adds the security + // subject on join), and a stale attrsBytes would propagate the pre-auth attributes. + attrsBytes = null; } /** From 0418e2b339d8280edb47cd6754c760bd397d9470 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sun, 28 Jun 2026 01:25:54 +0300 Subject: [PATCH 177/215] WIP --- .../calcite/message/MessageServiceImpl.java | 30 +++++++++++++++++-- .../exec/rel/AbstractExecutionTest.java | 5 ++++ .../calcite/planner/AbstractPlannerTest.java | 5 ++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java index db27d20a703ce..98211b8cb8876 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java @@ -23,6 +23,8 @@ import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.GridTopic; import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException; @@ -34,8 +36,10 @@ import org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor; import org.apache.ignite.internal.processors.query.calcite.exec.QueryTaskExecutor; import org.apache.ignite.internal.processors.query.calcite.util.AbstractService; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; /** * @@ -47,6 +51,9 @@ public class MessageServiceImpl extends AbstractService implements MessageServic /** */ private final GridCacheSharedContext ctx; + /** */ + private final ClassLoader clsLdr; + /** */ private UUID locNodeId; @@ -67,6 +74,7 @@ public MessageServiceImpl(GridKernalContext ctx) { super(ctx); this.ctx = ctx.cache().context(); + clsLdr = U.resolveClassLoader(ctx.config()); ioMgr = ctx.io(); msgLsnr = this::onMessage; } @@ -171,6 +179,18 @@ public FailureProcessor failureProcessor() { } } + /** */ + protected void prepareUnmarshal(Message msg) throws IgniteCheckedException { + try { + MessageMarshaller.finishUnmarshal(ctx.kernalContext().messageFactory(), msg, ctx.kernalContext(), null, clsLdr); + } + catch (Exception e) { + failureProcessor().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); + + throw e; + } + } + /** */ protected void onMessage(UUID nodeId, Message msg) { if (msg instanceof ExecutionContextAware) { @@ -193,8 +213,14 @@ private void onMessage(UUID nodeId, Object msg, byte plc) { /** */ private void onMessageInternal(UUID nodeId, Message msg) { - MessageListener lsnr = Objects.requireNonNull(lsnrs.get(msg.getClass())); + try { + prepareUnmarshal(msg); - lsnr.onMessage(nodeId, msg); + MessageListener lsnr = Objects.requireNonNull(lsnrs.get(msg.getClass())); + lsnr.onMessage(nodeId, msg); + } + catch (IgniteCheckedException e) { + throw U.convertException(e); + } } } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java index b7f5880259be2..5dd910a20c7e9 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java @@ -399,6 +399,11 @@ private TestMessageServiceImpl(GridKernalContext kernal, TestIoManager mgr) { @Override public boolean alive(UUID nodeId) { return true; } + + /** {@inheritDoc} */ + @Override protected void prepareUnmarshal(Message msg) { + // No-op: TestIoManager delivers messages in-memory, no deserialization needed. + } } /** diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java index b49af08b5c700..82ee3fab07fdd 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java @@ -786,6 +786,11 @@ static class TestMessageServiceImpl extends MessageServiceImpl { @Override public boolean alive(UUID nodeId) { return true; } + + /** {@inheritDoc} */ + @Override protected void prepareUnmarshal(Message msg) { + // No-op: TestIoManager delivers messages in-memory, no deserialization needed. + } } /** */ From 4b7adb34a69479bda44e20250c94ac48f97aa31d Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sun, 28 Jun 2026 14:11:17 +0300 Subject: [PATCH 178/215] WIP --- .../communication/MessageMarshaller.java | 40 +++++++++++++------ .../tcp/internal/TcpDiscoveryNode.java | 4 -- .../MessageFinishUnmarshalOnceTest.java | 25 ++++++++---- 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index 186156a7bb1c0..08fdd478ee853 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -124,7 +124,7 @@ static void prepareMarshal(MessageFactory factory, M msg, Gr */ static void finishUnmarshal(MessageFactory factory, M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - assert !Dedup.ENABLED || Dedup.firstUnmarshal(msg) : "Message finish-unmarshalled more than once: " + msg.getClass().getName(); + assert !Dedup.ENABLED || Dedup.firstUnmarshal(msg, true) : "Finish-unmarshalled more than once: " + msg.getClass().getName(); MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); @@ -143,7 +143,7 @@ static void finishUnmarshal(MessageFactory factory, M msg, G */ static void finishUnmarshal(MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { - assert !Dedup.ENABLED || Dedup.firstUnmarshal(msg) : "Message finish-unmarshalled more than once: " + msg.getClass().getName(); + assert !Dedup.ENABLED || Dedup.firstUnmarshal(msg, false) : "Finish-unmarshalled more than once: " + msg.getClass().getName(); MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); @@ -152,8 +152,10 @@ static void finishUnmarshal(MessageFactory factory, M msg, G } /** - * Detects a {@link MarshallableMessage} instance being finish-unmarshalled more than once — a class-loader or - * receive-path bug. Gated by {@link #ENABLED}, so it runs only under tests and is folded away in production. + * Detects a {@link MarshallableMessage} instance being finish-unmarshalled more than once within the same pass + * (cache-aware or cache-free) — a class-loader or receive-path bug. The two passes over one message (e.g. the + * generic {@code GridIoManager} pass plus a subsystem's cache-aware pass) are legitimate and tracked separately. + * Gated by {@link #ENABLED}, so it runs only under tests and is folded away in production. */ class Dedup { /** @@ -175,28 +177,38 @@ private Dedup() { /** * @param msg Message about to be finish-unmarshalled. - * @return {@code true} if {@code msg} is not a {@link MarshallableMessage} or is finish-unmarshalled the first time. + * @param cacheMode {@code true} for the cache-aware pass, {@code false} for the cache-free pass; the two passes + * over one message are legitimate and tracked separately, so only a repeat of the same pass is reported. + * @return {@code true} if {@code msg} is not a {@link MarshallableMessage} or is finish-unmarshalled the first + * time in this pass. */ - static boolean firstUnmarshal(Message msg) { + static boolean firstUnmarshal(Message msg, boolean cacheMode) { if (!(msg instanceof MarshallableMessage)) return true; for (Reference r; (r = Q.poll()) != null; ) SEEN.remove(r); - return SEEN.add(new IdRef(msg)); + return SEEN.add(new IdRef(msg, cacheMode)); } - /** Weak reference to a message keyed by identity, so two equal-but-distinct messages remain distinct keys. */ + /** Weak reference to a message keyed by (identity, pass), so distinct messages and the two passes stay distinct. */ private static final class IdRef extends WeakReference { - /** Referent identity hash, captured up front since the referent may be cleared later. */ + /** Referent identity hash folded with the pass, captured up front since the referent may be cleared later. */ private final int hash; - /** @param msg Tracked message. */ - IdRef(Message msg) { + /** Unmarshal pass: cache-aware vs cache-free. Keeps the two legitimate passes over one message distinct. */ + private final boolean cacheMode; + + /** + * @param msg Tracked message. + * @param cacheMode Unmarshal pass. + */ + IdRef(Message msg, boolean cacheMode) { super(msg, Q); - hash = System.identityHashCode(msg); + this.cacheMode = cacheMode; + hash = 31 * System.identityHashCode(msg) + (cacheMode ? 1 : 0); } /** {@inheritDoc} */ @@ -212,9 +224,11 @@ private static final class IdRef extends WeakReference { if (!(o instanceof IdRef)) return false; + IdRef ref = (IdRef)o; + Message m = get(); - return m != null && m == ((IdRef)o).get(); + return m != null && m == ref.get() && cacheMode == ref.cacheMode; } } } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java index 1fe4710a6a43c..636c96cacaf2d 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java @@ -272,10 +272,6 @@ public void lastSuccessfulAddress(InetSocketAddress lastSuccessfulAddr) { map.put(ATTR_NODE_CONSISTENT_ID, consistentId); attrs = Collections.unmodifiableMap(map); - - // Invalidate the @Marshalled caches — both fields are mutated here (see setAttributes). - consistentIdBytes = null; - attrsBytes = null; } /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageFinishUnmarshalOnceTest.java b/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageFinishUnmarshalOnceTest.java index d24bf03c13fc8..fca0a92e8e3ca 100644 --- a/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageFinishUnmarshalOnceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageFinishUnmarshalOnceTest.java @@ -23,9 +23,10 @@ /** * Verifies the no-double-unmarshal check itself, not its coverage: {@link MessageMarshaller.Dedup#firstUnmarshal} must - * detect a second finish-unmarshal of the same instance, and the check must be enabled for every test — otherwise the - * suite-wide guard would silently turn off and pass every test vacuously. The actual coverage (no real receive path - * unmarshals an instance twice) comes from running the check across the whole suite via {@code GridAbstractTest}. + * detect a second finish-unmarshal of the same instance within one pass, while allowing the two legitimate passes + * (cache-free and cache-aware), and the check must be enabled for every test — otherwise the suite-wide guard would + * silently turn off and pass every test vacuously. The actual coverage (no real receive path unmarshals an instance + * twice in the same pass) comes from running the check across the whole suite via {@code GridAbstractTest}. */ public class MessageFinishUnmarshalOnceTest extends GridCommonAbstractTest { /** The suite-wide guard must be on, so a silently-disabled check cannot pass every test without verifying anything. */ @@ -35,14 +36,24 @@ public void testCheckEnabled() { MessageMarshaller.Dedup.ENABLED); } - /** A second finish-unmarshal of the same instance must be detected; the first must be allowed. */ + /** A second finish-unmarshal of the same instance within one pass must be detected; the first must be allowed. */ @Test public void testSecondUnmarshalDetected() { MarshallableMessage msg = new NoopMarshallableMessage(); - assertTrue("First finish-unmarshal must be allowed", MessageMarshaller.Dedup.firstUnmarshal(msg)); - assertFalse("Second finish-unmarshal of the same instance must be detected", - MessageMarshaller.Dedup.firstUnmarshal(msg)); + assertTrue("First finish-unmarshal must be allowed", MessageMarshaller.Dedup.firstUnmarshal(msg, false)); + assertFalse("Second finish-unmarshal of the same instance in the same pass must be detected", + MessageMarshaller.Dedup.firstUnmarshal(msg, false)); + } + + /** The two legitimate passes (cache-free and cache-aware) over one instance must both be allowed. */ + @Test + public void testBothPassesAllowed() { + MarshallableMessage msg = new NoopMarshallableMessage(); + + assertTrue("Cache-free pass must be allowed", MessageMarshaller.Dedup.firstUnmarshal(msg, false)); + assertTrue("Cache-aware pass over the same instance must also be allowed", + MessageMarshaller.Dedup.firstUnmarshal(msg, true)); } /** Minimal {@link MarshallableMessage}; only its identity matters to the check. */ From 4a013f1aedba6f62a142ccc4e6b0c0fa72acb942 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sun, 28 Jun 2026 19:31:33 +0300 Subject: [PATCH 179/215] WIP --- .../MarshallerCacheFreeFinishTest.java | 110 ++++++++++++++++++ .../testsuites/IgniteBasicTestSuite.java | 2 + 2 files changed, 112 insertions(+) create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/codegen/MarshallerCacheFreeFinishTest.java diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MarshallerCacheFreeFinishTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MarshallerCacheFreeFinishTest.java new file mode 100644 index 0000000000000..858163384d487 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MarshallerCacheFreeFinishTest.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.codegen; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import com.tngtech.archunit.base.DescribedPredicate; +import com.tngtech.archunit.core.domain.JavaClass; +import com.tngtech.archunit.core.domain.JavaClasses; +import com.tngtech.archunit.core.domain.JavaCodeUnit; +import com.tngtech.archunit.core.domain.JavaMethodCall; +import com.tngtech.archunit.core.importer.ClassFileImporter; +import com.tngtech.archunit.core.importer.ImportOption; +import com.tngtech.archunit.lang.ArchRule; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; +import org.junit.BeforeClass; +import org.junit.Test; + +import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; + +/** + * A message is finish-unmarshalled in two passes — cache-free (via {@code GridIoManager}) and cache-aware (via a + * subsystem) — and the mode-aware no-double-unmarshal check ({@link MessageMarshaller.Dedup}) deliberately allows + * both. So whatever the cache-free pass does must stay correct when the cache-aware pass runs it again. + * + *

The distinction is the side effect. A plain {@code @Marshalled} field unmarshals by assignment + * ({@code msg.x = ...}); assigning the same value twice is a no-op, so it is idempotent and needs no guarding. A + * {@code @MarshalledCollection} / {@code @MarshalledMap} field unmarshals by mutation ({@code collection.add} / + * {@code map.put}); running that twice appends the elements twice — a doubled, corrupt collection. So a collection/map + * mutation is the one thing that must not run in both passes, and the generator keeps it in the cache-aware pass only. + * + *

That is exactly what this rule checks — purely the mutating side effect, not the fields: the cache-free + * {@code finishUnmarshal(msg, kctx)} overload of every generated marshaller must not call {@link Collection#add} or + * {@link Map#put}. Assignments are left unchecked (they can't break); a generator regression that moved an append into + * the cache-free pass — a real double-add the runtime check can't see, since it allows both passes — fails here. + */ +public class MarshallerCacheFreeFinishTest { + /** + * The two-arg, cache-free {@code finishUnmarshal} overload. The cache-aware overload takes a cache context and a + * class loader (four args); {@code finishUnmarshalNio} shares the two-arg shape, so the name is matched too. + */ + private static final DescribedPredicate CACHE_FREE_FINISH = + new DescribedPredicate<>("cache-free finishUnmarshal(msg, kctx)") { + @Override public boolean test(JavaCodeUnit unit) { + List params = unit.getRawParameterTypes(); + + return "finishUnmarshal".equals(unit.getName()) + && params.size() == 2 + && params.get(1).isEquivalentTo(GridKernalContext.class); + } + }; + + /** A {@link Collection#add} or {@link Map#put} append made from within the cache-free {@code finishUnmarshal}. */ + private static final DescribedPredicate CACHE_FREE_FINISH_APPEND = + new DescribedPredicate<>("Collection.add / Map.put from the cache-free finishUnmarshal pass") { + @Override public boolean test(JavaMethodCall call) { + if (!CACHE_FREE_FINISH.test(call.getOrigin())) + return false; + + JavaClass owner = call.getTarget().getOwner(); + String mtd = call.getTarget().getName(); + + return owner.isAssignableTo(Collection.class) && "add".equals(mtd) + || owner.isAssignableTo(Map.class) && "put".equals(mtd); + } + }; + + /** All production classes on the classpath (the generated marshallers among them), excluding JARs. */ + private static JavaClasses classes; + + /** */ + @BeforeClass + public static void importClasses() { + classes = new ClassFileImporter() + .withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_JARS) + .importPackages("org.apache.ignite"); + } + + /** The cache-free {@code finishUnmarshal} overload must not append to collections/maps; those are cache-pass only. */ + @Test + public void cacheFreeFinishDoesNotAppendToCollections() { + ArchRule rule = noClasses() + .that() + .areAssignableTo(MessageMarshaller.class) + .should() + .callMethodWhere(CACHE_FREE_FINISH_APPEND) + .because("@MarshalledCollection/@MarshalledMap appends are non-idempotent and run only in the cache-aware " + + "finishUnmarshal pass; an append in the cache-free pass would double-add when both passes run, which " + + "the mode-aware unmarshal-once check (MessageMarshaller.Dedup) permits and cannot catch."); + + rule.check(classes); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java index 8fd3df6498520..8eddfec6ecbb8 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java @@ -36,6 +36,7 @@ import org.apache.ignite.internal.IgniteSlowClientDetectionSelfTest; import org.apache.ignite.internal.TransactionsMXBeanImplTest; import org.apache.ignite.internal.codegen.IgniteDataTransferObjectProcessorTest; +import org.apache.ignite.internal.codegen.MarshallerCacheFreeFinishTest; import org.apache.ignite.internal.codegen.MessageMarshalOnceTest; import org.apache.ignite.internal.codegen.MessageProcessorTest; import org.apache.ignite.internal.codegen.MessageSerializationArchitectureTest; @@ -156,6 +157,7 @@ MessageProcessorTest.class, MessageMarshalOnceTest.class, MessageFinishUnmarshalOnceTest.class, + MarshallerCacheFreeFinishTest.class, MessageSerializationArchitectureTest.class, ErrorMessageSelfTest.class, DefaultEnumMapperTest.class, From d5800c32a7bd3d04fa76e53cb09a5fc0abe8a399 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sun, 28 Jun 2026 20:06:47 +0300 Subject: [PATCH 180/215] WIP --- .../ignite/internal/MarshalledObjects.java | 36 ++++++++ .../internal/MessageMarshallerGenerator.java | 83 ++++++++++++++++++- .../cache/query/GridCacheQueryResponse.java | 20 +---- 3 files changed, 122 insertions(+), 17 deletions(-) create mode 100644 modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledObjects.java diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledObjects.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledObjects.java new file mode 100644 index 0000000000000..f64192462ea93 --- /dev/null +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledObjects.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marks a {@code Collection} field of arbitrary (non-{@code Message}) objects whose wire form is a companion + * {@code @Order Collection} field named by {@link #value()}: each element is marshalled to its own + * {@code byte[]}, so elements that need different deployment class loaders survive. Use {@code @MarshalledCollection} + * instead when the elements are {@code Message}s. + */ +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface MarshalledObjects { + /** Name of the {@code @Order Collection} field that holds the per-element marshalled bytes. */ + String value(); +} diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index b57d6d8e1a90d..bf48c7a6d8bf6 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -111,7 +111,8 @@ public class MessageMarshallerGenerator extends MessageGenerator { @Override void generateBody(List fields) throws Exception { enclosed = enclosedFields(); marshallable = marshallableMsgType != null && assignableFrom(type.asType(), marshallableMsgType); - hasMarshalled = enclosed.values().stream().anyMatch(f -> f.getAnnotation(Marshalled.class) != null); + hasMarshalled = enclosed.values().stream().anyMatch(f -> + f.getAnnotation(Marshalled.class) != null || f.getAnnotation(MarshalledObjects.class) != null); indent = 1; @@ -270,6 +271,7 @@ private void generateFinishUnmarshalMethod(String methodName, String params, Lis if (mode == MarshalMode.FINISH_CACHE) { appendMarshalledCollectionFinish(body); appendMarshalledMapFinish(body); + appendMarshalledObjectsFinish(body); } marshall.addAll(body); @@ -305,9 +307,44 @@ private void appendMarshalledFieldsPrepare(List body) { for (VariableElement field : enclosed.values()) { appendCollectionPrepare(body, field); appendMapPrepare(body, field); + appendObjectsPrepare(body, field); } } + /** Generates the {@code Collection} build-up for a {@code @MarshalledObjects} field in prepareMarshal. */ + private void appendObjectsPrepare(List body, VariableElement field) { + MarshalledObjects ann = field.getAnnotation(MarshalledObjects.class); + + if (ann == null) + return; + + String objField = "msg." + field.getSimpleName(); + String bytesField = "msg." + ann.value(); + + imports.add("java.util.ArrayList"); + + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null && %s == null) {", objField, bytesField)); + + indent++; + + code.add(indentedLine("%s = new ArrayList<>(%s.size());", bytesField, objField)); + code.add(EMPTY); + code.add(indentedLine("for (Object e : %s)", objField)); + + indent++; + + code.add(indentedLine("%s.add(U.marshal(marshaller, e));", bytesField)); + + indent--; + indent--; + + code.add(indentedLine("}")); + + appendBlock(body, code); + } + /** Appends a {@code toArray} assignment for a {@code @MarshalledCollection} field, if present. */ private void appendCollectionPrepare(List body, VariableElement field) { MarshalledCollection ann = field.getAnnotation(MarshalledCollection.class); @@ -431,6 +468,46 @@ private void appendMarshalledCollectionFinish(List body) { } } + /** Generates Collection reconstruction for all {@code @MarshalledObjects} fields (cache-aware pass only). */ + private void appendMarshalledObjectsFinish(List body) { + for (VariableElement field : enclosed.values()) { + MarshalledObjects ann = field.getAnnotation(MarshalledObjects.class); + + if (ann == null) + continue; + + String objField = "msg." + field.getSimpleName(); + String bytesField = "msg." + ann.value(); + + imports.add("java.util.ArrayList"); + + List code = new ArrayList<>(); + + code.add(indentedLine("if (%s != null) {", bytesField)); + + indent++; + + code.add(indentedLine("%s = new ArrayList<>(%s.size());", objField, bytesField)); + code.add(EMPTY); + code.add(indentedLine("for (byte[] e : %s)", bytesField)); + + indent++; + + code.add(indentedLine("%s.add(U.unmarshal(marshaller, e, clsLdr));", objField)); + + indent--; + + code.add(EMPTY); + code.add(indentedLine("%s = null;", bytesField)); + + indent--; + + code.add(indentedLine("}")); + + appendBlock(body, code); + } + } + /** Generates the {@code for} loop body: per-element finishUnmarshal + try/catch add into the collection. */ private List collectionFinishForBlock(VariableElement wireField, String colField, String arrField, String fieldName) { String compName = arrayComponentName(wireField); @@ -484,6 +561,10 @@ private Set marshalledWireFieldsToSkip() { names.add(mapAnn.keys()); names.add(mapAnn.values()); } + + MarshalledObjects objAnn = f.getAnnotation(MarshalledObjects.class); + if (objAnn != null) + names.add(objAnn.value()); } return names; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index 46f3f4a6134ea..b51881fb2e665 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.Map; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.MarshalledObjects; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.cache.query.index.IndexQueryResultMeta; import org.apache.ignite.internal.managers.communication.ErrorMessage; @@ -31,14 +32,12 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; import org.jetbrains.annotations.Nullable; /** * Page of cache query response. */ -public class GridCacheQueryResponse extends GridCacheIdMessage implements GridCacheDeployable, MarshallableMessage, DeployableMessage { +public class GridCacheQueryResponse extends GridCacheIdMessage implements GridCacheDeployable, DeployableMessage { /** */ @Order(0) boolean finished; @@ -64,7 +63,8 @@ public class GridCacheQueryResponse extends GridCacheIdMessage implements GridCa Collection dataBytes; /** */ - private Collection data; + @MarshalledObjects("dataBytes") + Collection data; /** * Empty constructor. @@ -158,18 +158,6 @@ public boolean fields() { return fields; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (data != null) - dataBytes = marshallCollection(data, marsh); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (dataBytes != null) - data = unmarshalCollection(dataBytes, marsh, clsLdr); - } - /** {@inheritDoc} */ @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { GridCacheContext cctx = ctx.cacheContext(cacheId); From b0dd3c22864495ed980b8da34b373fedf9442ca0 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sun, 28 Jun 2026 21:17:11 +0300 Subject: [PATCH 181/215] WIP --- .../managers/communication/GridIoManager.java | 8 +++++++ .../communication/IgniteIoTestMessage.java | 24 +++++-------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index df745aeca85ee..4724e69e47a62 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -507,6 +507,8 @@ public void resetMetrics() { msg0.senderNodeId(nodeId); + msg0.onAfterRead(); + if (msg0.request()) { IgniteIoTestMessage res = new IgniteIoTestMessage(msg0.id(), false, null); @@ -516,6 +518,8 @@ public void resetMetrics() { res.copyDataFromRequest(msg0); try { + res.onBeforeWrite(); + sendToGridTopic(node, GridTopic.TOPIC_IO_TEST, res, GridIoPolicy.SYSTEM_POOL); } catch (IgniteCheckedException e) { @@ -560,6 +564,8 @@ public IgniteInternalFuture sendIoTest(List nodes, byte[] payload, ioTestMap().put(id, fut); + msg.onBeforeWrite(); + for (int i = 0; i < nodes.size(); i++) { ClusterNode node = nodes.get(i); @@ -597,6 +603,8 @@ public IgniteInternalFuture> sendIoTest( ioTestMap().put(id, fut); + msg.onBeforeWrite(); + try { sendToGridTopic(node, GridTopic.TOPIC_IO_TEST, msg, GridIoPolicy.SYSTEM_POOL); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java index 7c1c242642811..afa447e0d5c3d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java @@ -18,16 +18,14 @@ package org.apache.ignite.internal.managers.communication; import java.util.UUID; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.Order; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; /** * */ -public class IgniteIoTestMessage implements MarshallableMessage { +public class IgniteIoTestMessage implements Message { /** */ private static final byte FLAG_PROC_FROM_NIO = 1; @@ -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, + * not during unmarshalling. */ public void onAfterRead() { if (req && reqRcvTs == 0) { @@ -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, + * not during marshalling. */ public void onBeforeWrite() { if (req && reqSndTs == 0) { @@ -324,16 +322,6 @@ public void senderNodeId(UUID sndNodeId) { this.sndNodeId = sndNodeId; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - onBeforeWrite(); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - onAfterRead(); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(IgniteIoTestMessage.class, this); From dae107f3fac21cbf32e5796c211c333d01c6b2ea Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sun, 28 Jun 2026 21:41:03 +0300 Subject: [PATCH 182/215] WIP --- .../processors/plugin/PluginsDataBagItem.java | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/PluginsDataBagItem.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/PluginsDataBagItem.java index 9f7f503e674f4..64860f731f0d2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/PluginsDataBagItem.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/PluginsDataBagItem.java @@ -19,17 +19,15 @@ import java.io.Serializable; import java.util.Map; -import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.Marshalled; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.MarshallableMessage; +import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; /** */ -public class PluginsDataBagItem implements MarshallableMessage { +public class PluginsDataBagItem implements Message { /** Original plugins data. */ + @Marshalled("dataBytes") @Nullable Map data; /** Serialized plugins data. */ @@ -44,18 +42,6 @@ public PluginsDataBagItem(@Nullable Map data) { this.data = data; } - /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (!F.isEmpty(data)) - dataBytes = U.marshal(marsh, data); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { - if (dataBytes != null) - data = U.unmarshal(marsh, dataBytes, clsLdr); - } - /** @return Original plugins data. */ public @Nullable Map data() { return data; From dd7e0f4dd1802b0f87f7fda63377b32926d6743e Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sun, 28 Jun 2026 22:11:27 +0300 Subject: [PATCH 183/215] WIP --- .../GridDhtPartitionsFullMessage.java | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index 6cce1a2ac30ea..49543242acce5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -92,17 +92,13 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa @Order(6) AffinityTopologyVersion topVer; - /** Exceptions. */ - @GridToStringInclude - private Map errs; - /** - * Used as a stub for serialization of {@link #errs}. - * All logic resides within getter and setter. + * Exceptions in wire form. The logical {@code Map} is exposed via + * {@link #getErrorsMap()} / {@link #setErrorsMap(Map)}. */ @Order(7) @Compress - @SuppressWarnings("unused") + @GridToStringInclude Map errMsgs; /** */ @@ -169,7 +165,7 @@ public GridDhtPartitionsFullMessage(@Nullable GridDhtPartitionExchangeId id, cp.partsToReload = partsToReload; cp.partsSizes = partsSizes; cp.topVer = topVer; - cp.errs = errs; + cp.errMsgs = errMsgs; cp.resTopVer = resTopVer; cp.joinedNodeAff = joinedNodeAff; cp.idealAffDiff = idealAffDiff; @@ -364,14 +360,17 @@ public Map> partitionSizes() { * @return Errors map. */ @Nullable Map getErrorsMap() { - return errs; + return errMsgs == null ? null : F.viewReadOnly(errMsgs, e -> e.error()); } /** * @param errs Errors map. */ void setErrorsMap(Map errs) { - this.errs = new HashMap<>(errs); + errMsgs = new HashMap<>(); + + for (Map.Entry e : errs.entrySet()) + errMsgs.put(e.getKey(), new ErrorMessage(e.getValue())); } /** @@ -392,14 +391,6 @@ public void rebalanced(boolean rebalanced) { @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { if (!F.isEmpty(parts) && locParts == null) locParts = copyPartitionsMap(parts); - - if (errs != null) { - errMsgs = new HashMap<>(); - - for (Map.Entry entry : errs.entrySet()) { - errMsgs.put(entry.getKey(), new ErrorMessage(entry.getValue())); - } - } } /** @@ -449,8 +440,6 @@ public void topologyVersion(AffinityTopologyVersion topVer) { if (parts == null) parts = new HashMap<>(); - - errs = errMsgs == null ? null : F.viewReadOnly(errMsgs, e -> e.error()); } From a382a7ea1e63ad10c053542b7f77029138f1db27 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Sun, 28 Jun 2026 22:24:39 +0300 Subject: [PATCH 184/215] WIP --- .../processors/cache/transactions/IgniteTxEntry.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index f7c801b0903c8..e6efe9ae1d14f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -198,9 +198,6 @@ public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, /** Expiry policy. */ private ExpiryPolicy expiryPlc; - /** Expiry policy transfer flag. */ - private boolean transferExpiryPlc; - /** Expiry policy bytes. */ @Order(10) byte[] expiryPlcBytes; @@ -418,7 +415,6 @@ public IgniteTxEntry copy() { cp.nodeId = nodeId; cp.locMapped = locMapped; cp.expiryPlc = expiryPlc; - cp.transferExpiryPlc = transferExpiryPlc; cp.expiryPlcBytes = expiryPlcBytes; cp.flags = flags; cp.partUpdateCntr = partUpdateCntr; @@ -463,7 +459,6 @@ public void restoreFrom(IgniteTxEntry snapshot) { nodeId = snapshot.nodeId; locMapped = snapshot.locMapped; expiryPlc = snapshot.expiryPlc; - transferExpiryPlc = snapshot.transferExpiryPlc; expiryPlcBytes = snapshot.expiryPlcBytes; flags = snapshot.flags; partUpdateCntr = snapshot.partUpdateCntr; @@ -1046,9 +1041,9 @@ public void filtersSet(boolean filtersSet) { /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - transferExpiryPlc = expiryPlc != null && expiryPlc != ctx.expiry(); + boolean transfer = expiryPlc != null && expiryPlc != ctx.expiry(); - if (transferExpiryPlc) { + if (transfer) { if (expiryPlcBytes == null) expiryPlcBytes = U.marshal(marsh, new IgniteExternalizableExpiryPolicy(expiryPlc)); } From cb085d78958a8675c240edacb7047fcf0d5f781f Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 29 Jun 2026 00:24:57 +0300 Subject: [PATCH 185/215] WIP --- .../internal/MessageMarshallerGenerator.java | 85 ++++--------------- .../communication/MessageMarshaller.java | 18 ++-- .../DiscoveryUnmarshalVulnerabilityTest.java | 6 +- .../codegen/ChildMessageMarshaller.java | 6 +- ...stomMapperEnumFieldsMessageMarshaller.java | 6 +- ...aultMapperEnumFieldsMessageMarshaller.java | 6 +- .../TestCollectionsMessageMarshaller.java | 14 +-- .../codegen/TestMapMessageMarshaller.java | 18 ++-- .../TestMarshallableMessageMarshaller.java | 6 +- ...MarshalledCollectionMessageMarshaller.java | 18 ++-- .../TestMarshalledMapMessageMarshaller.java | 18 ++-- .../TestMarshalledMessageMarshaller.java | 6 +- .../codegen/TestMessageMarshaller.java | 18 ++-- parent/pom.xml | 1 + 14 files changed, 82 insertions(+), 144 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index bf48c7a6d8bf6..3e32913109796 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -179,12 +179,12 @@ private void writeConstructor(Writer writer, String marshallerClsName) throws IO private void generatePrepareMarshalMethod(List orderedFields) { imports.add("org.apache.ignite.IgniteCheckedException"); imports.add("org.apache.ignite.internal.GridKernalContext"); - imports.add("org.apache.ignite.internal.processors.cache.GridCacheContext"); + imports.add("org.apache.ignite.internal.processors.cache.CacheObjectContext"); marshall.add(indentedLine(METHOD_JAVADOC)); marshall.add(indentedLine("@Override public void prepareMarshal(" + simpleNameWithGeneric(type) + - " msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException {")); + " msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException {")); indent++; @@ -231,7 +231,7 @@ private void generateUnmarshallMethods(List orderedFields) { String msgParam = simpleNameWithGeneric(type) + " msg, GridKernalContext kctx"; - generateFinishUnmarshalMethod("finishUnmarshal", msgParam + ", GridCacheContext nested, ClassLoader clsLdr", + generateFinishUnmarshalMethod("finishUnmarshal", msgParam + ", CacheObjectContext nested, ClassLoader clsLdr", workerFields, MarshalMode.FINISH_CACHE); generateFinishUnmarshalMethod("finishUnmarshal", msgParam, workerFields, MarshalMode.FINISH); @@ -446,8 +446,6 @@ private void appendMarshalledCollectionFinish(List body) { String arrField = "msg." + colAnn.value(); VariableElement wireField = requireEnclosed(enclosed, colAnn.value(), "@MarshalledCollection"); - imports.add("org.apache.ignite.internal.processors.cache.CacheObjectNotResolvedException"); - List code = new ArrayList<>(); code.add(indentedLine("if (%s != null) {", arrField)); @@ -521,27 +519,10 @@ private List collectionFinishForBlock(VariableElement wireField, String code.addAll(codeFor(compType, "e", MarshalMode.FINISH_CACHE)); code.add(EMPTY); - code.add(indentedLine("try {")); - - indent++; - code.add(indentedLine("%s.add(e);", colField)); indent--; - code.add(indentedLine("}")); - code.add(indentedLine("catch (CacheObjectNotResolvedException ex) {")); - - indent++; - - code.add(indentedLine("U.warn(kctx.log(getClass()), \"Skipping unresolved element [field=%s]: \" + ex.getMessage());", fieldName)); - - indent--; - - code.add(indentedLine("}")); - - indent--; - code.add(indentedLine("}")); return code; @@ -585,8 +566,6 @@ private void appendMarshalledMapFinish(List body) { String keysField = "msg." + ann.keys(); String valsField = "msg." + ann.values(); - imports.add("org.apache.ignite.internal.processors.cache.CacheObjectNotResolvedException"); - List code = keysEl.asType().getKind() == TypeKind.ARRAY ? mapFinishArrayBlock(field, keysEl, valsEl, mapField, keysField, valsField) : mapFinishCollectionBlock(field, keysEl, valsEl, mapField, keysField, valsField); @@ -636,28 +615,10 @@ private List mapFinishArrayBlock(VariableElement field, VariableElement } code.add(EMPTY); - code.add(indentedLine("try {")); - - indent++; - code.add(indentedLine("%s.put(k, v);", mapField)); indent--; - code.add(indentedLine("}")); - code.add(indentedLine("catch (CacheObjectNotResolvedException ex) {")); - - indent++; - - code.add(indentedLine("U.warn(kctx.log(getClass()), \"Skipping unresolved element [field=%s]: \" + ex.getMessage());", - field.getSimpleName())); - - indent--; - - code.add(indentedLine("}")); - - indent--; - code.add(indentedLine("}")); code.add(EMPTY); code.add(indentedLine("%s = null;", keysField)); @@ -721,28 +682,10 @@ private List mapFinishCollectionBlock(VariableElement field, VariableEle } code.add(EMPTY); - code.add(indentedLine("try {")); - - indent++; - code.add(indentedLine("%s.put(k, v);", mapField)); indent--; - code.add(indentedLine("}")); - code.add(indentedLine("catch (CacheObjectNotResolvedException ex) {")); - - indent++; - - code.add(indentedLine("U.warn(kctx.log(getClass()), \"Skipping unresolved element [field=%s]: \" + ex.getMessage());", - field.getSimpleName())); - - indent--; - - code.add(indentedLine("}")); - - indent--; - code.add(indentedLine("}")); code.add(EMPTY); code.add(indentedLine("%s = null;", keysField)); @@ -869,8 +812,8 @@ private List marshallCacheObject(String accessor, MarshalMode mode) { indent++; code.add(mode == MarshalMode.PREPARE - ? indentedLine("%s.prepareMarshal(ctx.cacheObjectContext());", accessor) - : indentedLine("%s.finishUnmarshal(ctx.cacheObjectContext(), clsLdr);", accessor)); + ? indentedLine("%s.prepareMarshal(ctx);", accessor) + : indentedLine("%s.finishUnmarshal(ctx, clsLdr);", accessor)); indent--; @@ -986,16 +929,22 @@ private List wrapNullGuarded(String nullGuard, List inner) { return code; } - /** Returns the {@code GridCacheContext ctx} resolution line for the current message type. */ + /** + * Returns the {@code CacheObjectContext ctx} resolution line for the current message type. Cache messages resolve + * via the cache, group messages via the cache group — the group's context outlives the stop of individual caches, + * so cache objects still unmarshal while a cache (group) is being destroyed. + */ private String ctxResolutionLine() { if (isCacheIdAwareMessage(type)) - return indentedLine("GridCacheContext ctx = nested == null ? " + - "kctx.cache().context().cacheContext(msg.cacheId()) : nested;"); + return indentedLine("CacheObjectContext ctx = nested != null ? nested : " + + "kctx.cache().context().cacheContext(msg.cacheId()) == null ? null : " + + "kctx.cache().context().cacheContext(msg.cacheId()).cacheObjectContext();"); else if (isCacheGroupIdMessage(type)) - return indentedLine("GridCacheContext ctx = nested == null ? " + - "kctx.cache().context().cacheContext(msg.groupId()) : nested;"); + return indentedLine("CacheObjectContext ctx = nested != null ? nested : " + + "kctx.cache().cacheGroup(msg.groupId()) == null ? null : " + + "kctx.cache().cacheGroup(msg.groupId()).cacheObjectContext();"); else - return indentedLine("GridCacheContext ctx = nested;"); + return indentedLine("CacheObjectContext ctx = nested;"); } /** Returns {@code true} if any field requires {@code ctx} in generated marshal/unmarshal code. */ diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index 08fdd478ee853..e629718cf4b5b 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -25,7 +25,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.jetbrains.annotations.Nullable; /** @@ -39,10 +39,10 @@ public interface MessageMarshaller { * * @param msg Message to marshal. * @param kctx Kernal context. - * @param nested Nested cache context, or {@code null} if not applicable. + * @param nested Cache object context, or {@code null} if not applicable. * @throws IgniteCheckedException If marshalling failed. */ - public void prepareMarshal(M msg, GridKernalContext kctx, @Nullable GridCacheContext nested) + public void prepareMarshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested) throws IgniteCheckedException; /** @@ -50,11 +50,11 @@ public void prepareMarshal(M msg, GridKernalContext kctx, @Nullable GridCacheCon * * @param msg Message to unmarshal. * @param kctx Kernal context. - * @param nested Nested cache context, or {@code null} if not applicable. + * @param nested Cache object context, or {@code null} if not applicable. * @param clsLdr Class loader for unmarshalling. * @throws IgniteCheckedException If unmarshalling failed. */ - public void finishUnmarshal(M msg, GridKernalContext kctx, @Nullable GridCacheContext nested, ClassLoader clsLdr) + public void finishUnmarshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException; /** @@ -100,11 +100,11 @@ static void finishUnmarshalNio(MessageFactory factory, M msg * @param factory Message factory. * @param msg Message to marshal. * @param kctx Kernal context. - * @param nested Nested cache context, or {@code null} if not applicable. + * @param nested Cache object context, or {@code null} if not applicable. * @throws IgniteCheckedException If marshalling failed. */ static void prepareMarshal(MessageFactory factory, M msg, GridKernalContext kctx, - @Nullable GridCacheContext nested) throws IgniteCheckedException { + @Nullable CacheObjectContext nested) throws IgniteCheckedException { MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); if (m != null) @@ -118,12 +118,12 @@ static void prepareMarshal(MessageFactory factory, M msg, Gr * @param factory Message factory. * @param msg Message to unmarshal. * @param kctx Kernal context. - * @param nested Nested cache context, or {@code null} if not applicable. + * @param nested Cache object context, or {@code null} if not applicable. * @param clsLdr Class loader for unmarshalling. * @throws IgniteCheckedException If unmarshalling failed. */ static void finishUnmarshal(MessageFactory factory, M msg, GridKernalContext kctx, - @Nullable GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Nullable CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { assert !Dedup.ENABLED || Dedup.firstUnmarshal(msg, true) : "Finish-unmarshalled more than once: " + msg.getClass().getName(); MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index acd2827404199..3ea68492a8d66 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -32,7 +32,7 @@ import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.direct.DirectMessageWriter; import org.apache.ignite.internal.plugin.AbstractMarshallableMessageFactoryProvider; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshallers; @@ -309,7 +309,7 @@ private MessageMarshallerWrapper(AbstractMarshallableMessageFactoryProvider prov } /** {@inheritDoc} */ - @Override public void prepareMarshal(ExploitMessage msg, GridKernalContext kctx, GridCacheContext nested) + @Override public void prepareMarshal(ExploitMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { initIfNecessary(); @@ -317,7 +317,7 @@ private MessageMarshallerWrapper(AbstractMarshallableMessageFactoryProvider prov } /** {@inheritDoc} */ - @Override public void finishUnmarshal(ExploitMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) + @Override public void finishUnmarshal(ExploitMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { initIfNecessary(); diff --git a/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java b/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java index b86dcbfb5c33c..ff153a16120fb 100644 --- a/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java @@ -20,7 +20,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.ChildMessage; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; @@ -36,11 +36,11 @@ public ChildMessageMarshaller() { } /** */ - @Override public void prepareMarshal(ChildMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + @Override public void prepareMarshal(ChildMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { } /** */ - @Override public void finishUnmarshal(ChildMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void finishUnmarshal(ChildMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { } /** */ diff --git a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java index 4e7b972c1c9d7..b7acb977a6239 100644 --- a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java @@ -20,7 +20,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.CustomMapperEnumFieldsMessage; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; @@ -36,11 +36,11 @@ public CustomMapperEnumFieldsMessageMarshaller() { } /** */ - @Override public void prepareMarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + @Override public void prepareMarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { } /** */ - @Override public void finishUnmarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void finishUnmarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { } /** */ diff --git a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java index 563f88502f3a2..81f0c16900c37 100644 --- a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java @@ -20,7 +20,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.DefaultMapperEnumFieldsMessage; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; @@ -36,11 +36,11 @@ public DefaultMapperEnumFieldsMessageMarshaller() { } /** */ - @Override public void prepareMarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + @Override public void prepareMarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { } /** */ - @Override public void finishUnmarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void finishUnmarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { } /** */ diff --git a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java index d62e4b4c5aad4..09434b2688e76 100644 --- a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java @@ -34,7 +34,7 @@ import org.apache.ignite.internal.TestCollectionsMessage; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.GridLongList; import org.apache.ignite.internal.util.typedef.internal.U; @@ -53,8 +53,8 @@ public TestCollectionsMessageMarshaller() { } /** */ - @Override public void prepareMarshal(TestCollectionsMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; + @Override public void prepareMarshal(TestCollectionsMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + CacheObjectContext ctx = nested; if (msg.messageList != null) { for (GridCacheVersion e4 : (Collection)msg.messageList) { @@ -66,14 +66,14 @@ public TestCollectionsMessageMarshaller() { if (msg.cacheObjectSet != null) { for (CacheObject e4 : (Collection)msg.cacheObjectSet) { if (e4 != null && ctx != null) - e4.prepareMarshal(ctx.cacheObjectContext()); + e4.prepareMarshal(ctx); } } } /** */ - @Override public void finishUnmarshal(TestCollectionsMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - GridCacheContext ctx = nested; + @Override public void finishUnmarshal(TestCollectionsMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + CacheObjectContext ctx = nested; if (msg.messageList != null) { for (GridCacheVersion e4 : (Collection)msg.messageList) { @@ -85,7 +85,7 @@ public TestCollectionsMessageMarshaller() { if (msg.cacheObjectSet != null) { for (CacheObject e4 : (Collection)msg.cacheObjectSet) { if (e4 != null && ctx != null) - e4.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + e4.finishUnmarshal(ctx, clsLdr); } } } diff --git a/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java index 5aaed6f7210d4..cf580e995df6a 100644 --- a/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java @@ -36,7 +36,7 @@ import org.apache.ignite.internal.TestMapMessage; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.GridLongList; @@ -56,8 +56,8 @@ public TestMapMessageMarshaller() { } /** */ - @Override public void prepareMarshal(TestMapMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; + @Override public void prepareMarshal(TestMapMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + CacheObjectContext ctx = nested; if (msg.messageBoxedDoubleMap != null) { for (GridCacheVersion e4 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { @@ -69,7 +69,7 @@ public TestMapMessageMarshaller() { if (msg.gridCacheObjectMap != null) { for (KeyCacheObject e4 : ((Collection)msg.gridCacheObjectMap.keySet())) { if (e4 != null && ctx != null) - e4.prepareMarshal(ctx.cacheObjectContext()); + e4.prepareMarshal(ctx); } for (Map e4 : ((Collection)msg.gridCacheObjectMap.values())) { if (e4 != null) { @@ -77,7 +77,7 @@ public TestMapMessageMarshaller() { if (e6 != null) { for (CacheObject e8 : (Collection)e6) { if (e8 != null && ctx != null) - e8.prepareMarshal(ctx.cacheObjectContext()); + e8.prepareMarshal(ctx); } } } @@ -87,8 +87,8 @@ public TestMapMessageMarshaller() { } /** */ - @Override public void finishUnmarshal(TestMapMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - GridCacheContext ctx = nested; + @Override public void finishUnmarshal(TestMapMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + CacheObjectContext ctx = nested; if (msg.messageBoxedDoubleMap != null) { for (GridCacheVersion e4 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { @@ -100,7 +100,7 @@ public TestMapMessageMarshaller() { if (msg.gridCacheObjectMap != null) { for (KeyCacheObject e4 : ((Collection)msg.gridCacheObjectMap.keySet())) { if (e4 != null && ctx != null) - e4.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + e4.finishUnmarshal(ctx, clsLdr); } for (Map e4 : ((Collection)msg.gridCacheObjectMap.values())) { if (e4 != null) { @@ -108,7 +108,7 @@ public TestMapMessageMarshaller() { if (e6 != null) { for (CacheObject e8 : (Collection)e6) { if (e8 != null && ctx != null) - e8.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + e8.finishUnmarshal(ctx, clsLdr); } } } diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java index 805f382bbb672..761596bd8d92c 100644 --- a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java @@ -20,7 +20,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMarshallableMessage; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; @@ -41,12 +41,12 @@ public TestMarshallableMessageMarshaller(Marshaller marshaller) { } /** */ - @Override public void prepareMarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + @Override public void prepareMarshal(TestMarshallableMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { msg.prepareMarshal(marshaller); } /** */ - @Override public void finishUnmarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void finishUnmarshal(TestMarshallableMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { msg.finishUnmarshal(marshaller, clsLdr); } diff --git a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java index 3237a01e16209..42fb9378e1637 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java @@ -20,8 +20,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMarshalledCollectionMessage; -import org.apache.ignite.internal.processors.cache.CacheObjectNotResolvedException; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; @@ -38,8 +37,8 @@ public TestMarshalledCollectionMessageMarshaller() { } /** */ - @Override public void prepareMarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; + @Override public void prepareMarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + CacheObjectContext ctx = nested; if (msg.keys != null && msg.keysArr == null) msg.keysArr = msg.keys.toArray(new GridCacheVersion[0]); @@ -53,8 +52,8 @@ public TestMarshalledCollectionMessageMarshaller() { } /** */ - @Override public void finishUnmarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - GridCacheContext ctx = nested; + @Override public void finishUnmarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + CacheObjectContext ctx = nested; if (msg.keysArr != null) { msg.keys = U.newHashSet(msg.keysArr.length); @@ -63,12 +62,7 @@ public TestMarshalledCollectionMessageMarshaller() { if (e != null) MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); - try { - msg.keys.add(e); - } - catch (CacheObjectNotResolvedException ex) { - U.warn(kctx.log(getClass()), "Skipping unresolved element [field=keys]: " + ex.getMessage()); - } + msg.keys.add(e); } msg.keysArr = null; diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java index 86a7c09d1f434..58c00c0c025d7 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java @@ -22,8 +22,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMarshalledMapMessage; -import org.apache.ignite.internal.processors.cache.CacheObjectNotResolvedException; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; @@ -40,8 +39,8 @@ public TestMarshalledMapMessageMarshaller() { } /** */ - @Override public void prepareMarshal(TestMarshalledMapMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; + @Override public void prepareMarshal(TestMarshalledMapMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + CacheObjectContext ctx = nested; if (msg.theMap != null && msg.mapKeys == null) { msg.mapKeys = msg.theMap.keySet(); @@ -64,8 +63,8 @@ public TestMarshalledMapMessageMarshaller() { } /** */ - @Override public void finishUnmarshal(TestMarshalledMapMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - GridCacheContext ctx = nested; + @Override public void finishUnmarshal(TestMarshalledMapMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + CacheObjectContext ctx = nested; if (msg.mapKeys != null) { msg.theMap = U.newHashMap(msg.mapKeys.size()); @@ -83,12 +82,7 @@ public TestMarshalledMapMessageMarshaller() { if (v != null) MessageMarshaller.finishUnmarshal(kctx.messageFactory(), v, kctx, ctx, clsLdr); - try { - msg.theMap.put(k, v); - } - catch (CacheObjectNotResolvedException ex) { - U.warn(kctx.log(getClass()), "Skipping unresolved element [field=theMap]: " + ex.getMessage()); - } + msg.theMap.put(k, v); } msg.mapKeys = null; diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java index 857b5c80ea5a9..e4957a29a66ee 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java @@ -20,7 +20,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMarshalledMessage; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; @@ -41,13 +41,13 @@ public TestMarshalledMessageMarshaller(Marshaller marshaller) { } /** */ - @Override public void prepareMarshal(TestMarshalledMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + @Override public void prepareMarshal(TestMarshalledMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { if (msg.data != null && msg.dataBytes == null) msg.dataBytes = U.marshal(marshaller, msg.data); } /** */ - @Override public void finishUnmarshal(TestMarshalledMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void finishUnmarshal(TestMarshalledMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { if (msg.dataBytes != null) msg.data = U.unmarshal(marshaller, msg.dataBytes, clsLdr); } diff --git a/modules/core/src/test/resources/codegen/TestMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMessageMarshaller.java index e8084a5126a0f..7acc5a2c9e0e4 100644 --- a/modules/core/src/test/resources/codegen/TestMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMessageMarshaller.java @@ -21,7 +21,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.TestMessage; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; @@ -38,8 +38,8 @@ public TestMessageMarshaller() { } /** */ - @Override public void prepareMarshal(TestMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { - GridCacheContext ctx = nested; + @Override public void prepareMarshal(TestMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + CacheObjectContext ctx = nested; if (msg.ver != null) MessageMarshaller.prepareMarshal(kctx.messageFactory(), msg.ver, kctx, ctx); @@ -52,18 +52,18 @@ public TestMessageMarshaller() { } if (msg.keyCacheObject != null && ctx != null) - msg.keyCacheObject.prepareMarshal(ctx.cacheObjectContext()); + msg.keyCacheObject.prepareMarshal(ctx); if (msg.cacheObject != null && ctx != null) - msg.cacheObject.prepareMarshal(ctx.cacheObjectContext()); + msg.cacheObject.prepareMarshal(ctx); if (msg.ver2 != null) MessageMarshaller.prepareMarshal(kctx.messageFactory(), msg.ver2, kctx, ctx); } /** */ - @Override public void finishUnmarshal(TestMessage msg, GridKernalContext kctx, GridCacheContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - GridCacheContext ctx = nested; + @Override public void finishUnmarshal(TestMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + CacheObjectContext ctx = nested; if (msg.verArr != null) { for (GridCacheVersion e4 : msg.verArr) { @@ -73,10 +73,10 @@ public TestMessageMarshaller() { } if (msg.keyCacheObject != null && ctx != null) - msg.keyCacheObject.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + msg.keyCacheObject.finishUnmarshal(ctx, clsLdr); if (msg.cacheObject != null && ctx != null) - msg.cacheObject.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); + msg.cacheObject.finishUnmarshal(ctx, clsLdr); } /** */ diff --git a/parent/pom.xml b/parent/pom.xml index 507e6d27edf36..406d6e78bb414 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -863,6 +863,7 @@ **/.asf.yaml .travis.yml .github/PULL_REQUEST_TEMPLATE.md + .mvn/jvm.config idea/ignite_codeStyle.xml **/DEVNOTES*.txt **/NOTICE* From fb0f25d33b0a589032ef08b33623ef744fcbc250 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 29 Jun 2026 01:43:57 +0300 Subject: [PATCH 186/215] WIP --- .../calcite/message/MessageServiceImpl.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java index 98211b8cb8876..4b94456877eb1 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java @@ -205,22 +205,24 @@ protected void onMessage(UUID nodeId, Message msg) { ); } - /** */ + /** Listener for messages arriving from remote nodes; they are marshalled and must be finish-unmarshalled here. */ private void onMessage(UUID nodeId, Object msg, byte plc) { - if (msg instanceof Message && CalciteMessageFactory.isCalciteMessage((Message)msg)) + if (msg instanceof Message && CalciteMessageFactory.isCalciteMessage((Message)msg)) { + try { + prepareUnmarshal((Message)msg); + } + catch (IgniteCheckedException e) { + throw U.convertException(e); + } + onMessage(nodeId, (Message)msg); + } } /** */ private void onMessageInternal(UUID nodeId, Message msg) { - try { - prepareUnmarshal(msg); + MessageListener lsnr = Objects.requireNonNull(lsnrs.get(msg.getClass())); - MessageListener lsnr = Objects.requireNonNull(lsnrs.get(msg.getClass())); - lsnr.onMessage(nodeId, msg); - } - catch (IgniteCheckedException e) { - throw U.convertException(e); - } + lsnr.onMessage(nodeId, msg); } } From 06e05fe768a0236deae65e5a81c6e20a5bc36607 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 29 Jun 2026 15:21:31 +0300 Subject: [PATCH 187/215] WIP --- .../calcite/metadata/ColocationGroup.java | 2 +- .../managers/communication/GridIoManager.java | 109 +++++++------ .../codegen/MessageMarshalOnceTest.java | 63 -------- .../communication/MessageMarshalOnceTest.java | 149 ++++++++++++++++++ .../testsuites/IgniteBasicTestSuite.java | 2 +- 5 files changed, 214 insertions(+), 111 deletions(-) delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageMarshalOnceTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageMarshalOnceTest.java diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java index cee6beefb7012..3dd75d35fb6b1 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java @@ -315,7 +315,7 @@ public int[] partitions(UUID nodeId) { /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - if (assignments == null || primaryAssignment) + if (!F.isEmpty(marshalledAssignments) || assignments == null || primaryAssignment) return; Map nodeIdxs = new HashMap<>(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 4724e69e47a62..cc7f5eb51ad4d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -2028,25 +2028,72 @@ else if (async) else { MessageMarshaller.prepareMarshal(ctx.messageFactory(), ioMsg, ctx, null); + sendMarshalled(node, ioMsg, topic, msg, plc, ackC); + } + } + } + + /** + * Sends an already-marshalled message to a remote node. Marshalling is the caller's job, so one {@code ioMsg} can + * be prepared once and delivered to many nodes (see {@link #sendToMany}). + */ + private void sendMarshalled(ClusterNode node, GridIoMessage ioMsg, Object topic, Message msg, byte plc, + IgniteInClosure ackC) throws IgniteCheckedException { + try { + if ((CommunicationSpi)getSpi() instanceof TcpCommunicationSpi) + getTcpCommunicationSpi().sendMessage(node, ioMsg, ackC); + else + getSpi().sendMessage(node, ioMsg); + } + catch (IgniteSpiException e) { + if (e.getCause() instanceof ClusterTopologyCheckedException) + throw (ClusterTopologyCheckedException)e.getCause(); + + if (!ctx.discovery().alive(node)) + throw new ClusterTopologyCheckedException("Failed to send message, node left: " + node.id(), e); + + throw new IgniteCheckedException("Failed to send message (node may have left the grid or " + + "TCP connection cannot be established due to firewall issues) " + + "[node=" + node + ", topic=" + topic + + ", msg=" + msg + ", policy=" + plc + ']', e); + } + } + + /** + * Marshals {@code msg} once and delivers it to every node, instead of re-marshalling per destination. The local + * node, if present, goes through the regular per-node path, unmarshalled. + */ + private void sendToMany(Collection nodes, Object topic, Message msg, byte plc, + boolean ordered, long timeout, boolean skipOnTimeout) throws IgniteCheckedException { + try (TraceSurroundings ignored = support(null)) { + GridIoMessage ioMsg = null; + + IgniteCheckedException err = null; + + for (ClusterNode node : nodes) { try { - if ((CommunicationSpi)getSpi() instanceof TcpCommunicationSpi) - getTcpCommunicationSpi().sendMessage(node, ioMsg, ackC); - else - getSpi().sendMessage(node, ioMsg); - } - catch (IgniteSpiException e) { - if (e.getCause() instanceof ClusterTopologyCheckedException) - throw (ClusterTopologyCheckedException)e.getCause(); + if (locNodeId.equals(node.id())) + send(node, topic, msg, plc, ordered, timeout, skipOnTimeout, null, false); + else { + if (ioMsg == null) { + ioMsg = createGridIoMessage(topic, msg, plc, ordered, timeout, skipOnTimeout); - if (!ctx.discovery().alive(node)) - throw new ClusterTopologyCheckedException("Failed to send message, node left: " + node.id(), e); + MessageMarshaller.prepareMarshal(ctx.messageFactory(), ioMsg, ctx, null); + } - throw new IgniteCheckedException("Failed to send message (node may have left the grid or " + - "TCP connection cannot be established due to firewall issues) " + - "[node=" + node + ", topic=" + topic + - ", msg=" + msg + ", policy=" + plc + ']', e); + sendMarshalled(node, ioMsg, topic, msg, plc, null); + } + } + catch (IgniteCheckedException e) { + if (err == null) + err = e; + else + err.addSuppressed(e); } } + + if (err != null) + throw err; } } @@ -2214,22 +2261,7 @@ void sendOrderedMessageToGridTopic( throws IgniteCheckedException { assert timeout > 0 || skipOnTimeout; - IgniteCheckedException err = null; - - for (ClusterNode node : nodes) { - try { - send(node, topic, msg, plc, true, timeout, skipOnTimeout, null, false); - } - catch (IgniteCheckedException e) { - if (err == null) - err = e; - else - err.addSuppressed(e); - } - } - - if (err != null) - throw err; + sendToMany(nodes, topic, msg, plc, true, timeout, skipOnTimeout); } /** @@ -2245,22 +2277,7 @@ public void sendToGridTopic( Message msg, byte plc ) throws IgniteCheckedException { - IgniteCheckedException err = null; - - for (ClusterNode node : nodes) { - try { - send(node, topic, msg, plc, false, 0, false, null, false); - } - catch (IgniteCheckedException e) { - if (err == null) - err = e; - else - err.addSuppressed(e); - } - } - - if (err != null) - throw err; + sendToMany(nodes, topic, msg, plc, false, 0, false); } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageMarshalOnceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageMarshalOnceTest.java deleted file mode 100644 index d7da3676043bf..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageMarshalOnceTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.codegen; - -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.processors.cache.verify.TransactionsHashRecord; -import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; - -/** - * Guards against a marshalling performance regression. The codegen wraps each {@code @Marshalled} field's - * {@code U.marshal} in a {@code wireField == null} guard, so a message {@code prepareMarshal}'d N times (broadcast to - * N nodes) marshals each field at most once: the wire bytes are computed on the first call and reused thereafter. - * Verified behaviourally — the wire array is the same reference after a second {@code prepareMarshal}, independent of - * how the guard is formatted (a re-marshal would create a new array). - */ -public class MessageMarshalOnceTest extends GridCommonAbstractTest { - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllGrids(); - - super.afterTest(); - } - - /** @throws Exception If failed. */ - @Test - public void testPrepareMarshalMarshalsOnce() throws Exception { - GridKernalContext kctx = startGrid(0).context(); - - // One @Marshalled message is representative: the marshal-once guard comes from one generator template - // (only field names vary), so a regression in it breaks every such message identically. - TransactionsHashRecord msg = new TransactionsHashRecord("local", "remote", 0); - - MessageMarshaller.prepareMarshal(kctx.messageFactory(), msg, kctx, null); - - byte[] first = GridTestUtils.getFieldValue(msg, "locConsistentIdBytes"); - - assertNotNull("First prepareMarshal must marshal the field", first); - - MessageMarshaller.prepareMarshal(kctx.messageFactory(), msg, kctx, null); - - byte[] second = GridTestUtils.getFieldValue(msg, "locConsistentIdBytes"); - - assertTrue("Second prepareMarshal re-marshalled the field — missing 'wire-field == null' guard", first == second); - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageMarshalOnceTest.java b/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageMarshalOnceTest.java new file mode 100644 index 0000000000000..de35455fe7b6c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageMarshalOnceTest.java @@ -0,0 +1,149 @@ +/* + * 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 java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.CoreMessagesProvider; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.GridTopic; +import org.apache.ignite.internal.TestRecordingCommunicationSpi; +import org.apache.ignite.internal.managers.communication.GridIoPolicy; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; +import org.apache.ignite.plugin.AbstractTestPluginProvider; +import org.apache.ignite.plugin.ExtensionRegistry; +import org.apache.ignite.plugin.PluginContext; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Verifies the marshal-once-before-fan-out contract of the collection {@code send}: a message broadcast to N remote + * nodes is marshalled exactly once (prepared before the fan-out and reused for every destination), not once per + * destination. A counting marshaller is registered for a test message; broadcasting it to {@link #RMT_CNT} remote nodes + * must produce {@code RMT_CNT} sends but a single {@code prepareMarshal}. Counting the sends keeps the check honest (a + * lone send would also marshal once). The unmarshal-once counterpart lives in {@link MessageFinishUnmarshalOnceTest}. + */ +public class MessageMarshalOnceTest extends GridCommonAbstractTest { + /** Direct type for the test message, past the core range. */ + private static final short TYPE = (short)(CoreMessagesProvider.MAX_MESSAGE_ID + 1); + + /** Number of remote destinations to broadcast to (a single marshal must serve all of them). */ + private static final int RMT_CNT = 4; + + /** Counts {@code prepareMarshal} invocations of {@link MarshalOnceCheckMessage} across the JVM. */ + private static final AtomicInteger MARSHAL_CNT = new AtomicInteger(); + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); + + cfg.setPluginProviders(new AbstractTestPluginProvider() { + @Override public String name() { + return "marshal-once-test"; + } + + @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) { + registry.registerExtension(MessageFactoryProvider.class, factory -> + factory.register(TYPE, MarshalOnceCheckMessage::new, new Serializer(), new CountingMarshaller())); + } + }); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + super.afterTest(); + } + + /** @throws Exception If failed. */ + @Test + public void testBroadcastMarshalsExactlyOnce() throws Exception { + startGrids(RMT_CNT + 1); + + TestRecordingCommunicationSpi commSpi = TestRecordingCommunicationSpi.spi(grid(0)); + + commSpi.record(MarshalOnceCheckMessage.class); + + List rmts = new ArrayList<>(RMT_CNT); + + for (int i = 1; i <= RMT_CNT; i++) + rmts.add(grid(i).localNode()); + + MARSHAL_CNT.set(0); + + grid(0).context().io().sendToGridTopic(rmts, GridTopic.TOPIC_IO_TEST, new MarshalOnceCheckMessage(), + GridIoPolicy.PUBLIC_POOL); + + assertEquals("Broadcast must be sent to all " + RMT_CNT + " nodes", RMT_CNT, commSpi.recordedMessages(true).size()); + + assertEquals("A message broadcast to " + RMT_CNT + " nodes must be marshalled exactly once, not per destination", + 1, MARSHAL_CNT.get()); + } + + /** Fieldless message; only the registered marshaller's invocation count matters. */ + private static class MarshalOnceCheckMessage implements Message { + // No fields. + } + + /** Header-only serializer for the fieldless {@link MarshalOnceCheckMessage}. */ + private static class Serializer implements MessageSerializer { + /** {@inheritDoc} */ + @Override public boolean writeTo(MarshalOnceCheckMessage msg, MessageWriter writer) { + if (!writer.isHeaderWritten()) { + if (!writer.writeHeader(msg.directType())) + return false; + + writer.onHeaderWritten(); + } + + return true; + } + + /** {@inheritDoc} */ + @Override public boolean readFrom(MarshalOnceCheckMessage msg, MessageReader reader) { + return true; + } + } + + /** Marshaller that only counts {@code prepareMarshal} calls — no idempotency guard, so it counts raw invocations. */ + private static class CountingMarshaller implements MessageMarshaller { + /** {@inheritDoc} */ + @Override public void prepareMarshal(MarshalOnceCheckMessage msg, GridKernalContext kctx, CacheObjectContext nested) { + MARSHAL_CNT.incrementAndGet(); + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(MarshalOnceCheckMessage msg, GridKernalContext kctx, CacheObjectContext nested, + ClassLoader clsLdr) { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void finishUnmarshal(MarshalOnceCheckMessage msg, GridKernalContext kctx) { + // No-op. + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java index 8eddfec6ecbb8..b249da56d1711 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java @@ -37,7 +37,6 @@ import org.apache.ignite.internal.TransactionsMXBeanImplTest; import org.apache.ignite.internal.codegen.IgniteDataTransferObjectProcessorTest; import org.apache.ignite.internal.codegen.MarshallerCacheFreeFinishTest; -import org.apache.ignite.internal.codegen.MessageMarshalOnceTest; import org.apache.ignite.internal.codegen.MessageProcessorTest; import org.apache.ignite.internal.codegen.MessageSerializationArchitectureTest; import org.apache.ignite.internal.managers.communication.CompressedMessageTest; @@ -75,6 +74,7 @@ import org.apache.ignite.messaging.IgniteMessagingSendAsyncTest; import org.apache.ignite.messaging.IgniteMessagingWithClientTest; import org.apache.ignite.plugin.extensions.communication.MessageFinishUnmarshalOnceTest; +import org.apache.ignite.plugin.extensions.communication.MessageMarshalOnceTest; import org.apache.ignite.spi.GridSpiLocalHostInjectionTest; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTestSelfTest; import org.apache.ignite.testframework.junits.multijvm.JavaVersionCommandParserTest; From 5caad1dffe6caabb286a975500cb799e7d7d3b76 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 29 Jun 2026 16:19:26 +0300 Subject: [PATCH 188/215] WIP --- .../org/apache/ignite/internal/MessageMarshallerGenerator.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 3e32913109796..b77f6abbb7640 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -937,8 +937,7 @@ private List wrapNullGuarded(String nullGuard, List inner) { private String ctxResolutionLine() { if (isCacheIdAwareMessage(type)) return indentedLine("CacheObjectContext ctx = nested != null ? nested : " + - "kctx.cache().context().cacheContext(msg.cacheId()) == null ? null : " + - "kctx.cache().context().cacheContext(msg.cacheId()).cacheObjectContext();"); + "kctx.cache().context().cacheObjectContext(msg.cacheId());"); else if (isCacheGroupIdMessage(type)) return indentedLine("CacheObjectContext ctx = nested != null ? nested : " + "kctx.cache().cacheGroup(msg.groupId()) == null ? null : " + From d732f64a45368a1c9d3cf02ed6940bbd5f3133b9 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Mon, 29 Jun 2026 18:42:04 +0300 Subject: [PATCH 189/215] WIP --- .../calcite/message/QueryStartRequest.java | 42 ++++++++++++++----- .../query/calcite/message/QueryTxEntry.java | 11 ++++- ...idNearAtomicSingleUpdateInvokeRequest.java | 2 +- .../near/GridNearTxPrepareResponse.java | 4 +- .../cache/transactions/IgniteTxEntry.java | 2 +- .../cache/transactions/TxLocksRequest.java | 15 +++++-- .../cache/transactions/TxLocksResponse.java | 8 ++-- .../handlers/task/GridTaskResultResponse.java | 2 +- .../communication/MessageSerializer.java | 4 +- .../DiscoveryUnmarshalVulnerabilityTest.java | 2 +- 10 files changed, 64 insertions(+), 28 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java index dc43c49281720..12157a9c41be9 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java @@ -114,12 +114,14 @@ public QueryStartRequest( this.keepBinaryMode = keepBinaryMode; } - /** Default no-arg constructor required for deserialization. */ + /** */ public QueryStartRequest() { // No-op. } - /** */ + /** + * @return Schema name. + */ public String schema() { return schema; } @@ -129,7 +131,9 @@ public String schema() { return qryId; } - /** */ + /** + * @return Registered local query ID on originating node. + */ public long originatingQueryId() { return originatingQryId; } @@ -139,44 +143,60 @@ public long originatingQueryId() { return fragmentDesc.fragmentId(); } - /** */ + /** + * @return Fragment description. + */ public FragmentDescription fragmentDescription() { return fragmentDesc; } - /** */ + /** + * @return Topology version. + */ public AffinityTopologyVersion topologyVersion() { return ver; } - /** */ + /** + * @return Fragment plan. + */ public String root() { return root; } - /** */ + /** + * @return Total count of fragments in query for this node. + */ public int totalFragmentsCount() { return totalFragmentsCnt; } - /** */ + /** + * @return Query parameters. + */ @SuppressWarnings("AssignmentOrReturnOfFieldWithMutableType") public @Nullable Object[] parameters() { return params; } - /** */ + /** + * @return Query parameters marshalled. + */ @SuppressWarnings("AssignmentOrReturnOfFieldWithMutableType") public byte[] parametersMarshalled() { return paramsBytes; } - /** */ + /** + * @return Query timeout. + */ public long timeout() { return timeout; } - /** */ + /** + * @return Transaction entries to mixin on query processing. + */ public @Nullable Collection queryTransactionEntries() { return qryTxEntries; } diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java index 024e3ae039b18..6f3e6e4b5afb9 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryTxEntry.java @@ -54,12 +54,19 @@ public class QueryTxEntry implements Message, CacheIdAware { @Order(3) GridCacheVersion ver; - /** */ + /** + * Empty constructor. + */ public QueryTxEntry() { // No-op. } - /** */ + /** + * @param cacheId Cache id. + * @param key Key. + * @param val Value. + * @param ver Version. + */ public QueryTxEntry(int cacheId, KeyCacheObject key, CacheObject val, GridCacheVersion ver) { this.cacheId = cacheId; this.key = key; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index 4a9cfcf2987f4..c49917c951488 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -60,7 +60,7 @@ public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingl @Marshalled("entryProcBytes") @Nullable EntryProcessor entryProc; - /** */ + /** Entry processors bytes. */ @Order(1) @Nullable byte[] entryProcBytes; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index 3621239be3892..b352bb7538a74 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -65,11 +65,11 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse @MarshalledMap(keys = "ownedValKeys", values = "ownedValVals") Map ownedVals; - /** */ + /** OwnedVals' keys for marshalling. */ @Order(5) @Nullable Collection ownedValKeys; - /** */ + /** OwnedVals' values for marshalling. */ @Order(6) @Nullable Collection ownedValVals; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index e6efe9ae1d14f..ddb0a7f47f124 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -141,7 +141,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, /** Transient field for calculated entry processor value. */ private T2 entryProcessorCalcVal; - /** */ + /** Transform closure bytes. */ @GridToStringExclude @Order(4) byte[] transformClosBytes; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java index 6b63922b80b54..3e2ba30b559ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java @@ -39,17 +39,22 @@ public class TxLocksRequest extends GridCacheMessage { @MarshalledCollection("txKeysArr") Set txKeys; - /** */ + /** Array of txKeys from {@link #txKeys}. Used during marshalling and unmarshalling. */ @GridToStringExclude @Order(1) IgniteTxKey[] txKeysArr; - /** */ + /** + * Default constructor. + */ public TxLocksRequest() { // No-op. } - /** */ + /** + * @param futId Future ID. + * @param txKeys Target tx keys. + */ public TxLocksRequest(long futId, Set txKeys) { A.notEmpty(txKeys, "txKeys"); @@ -57,7 +62,9 @@ public TxLocksRequest(long futId, Set txKeys) { this.txKeys = txKeys; } - /** */ + /** + * @return Future ID. + */ public long futureId() { return futId; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index 9293c6d4bfe20..e2b9ed39a267d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -49,17 +49,17 @@ public class TxLocksResponse extends GridCacheMessage { @MarshalledCollection("txKeysArr") Set txKeys; - /** */ + /** Array of txKeys from {@link #nearTxKeyLocks}. Used during marshalling and unmarshalling. */ @GridToStringExclude @Order(1) IgniteTxKey[] nearTxKeysArr; - /** */ + /** Array of txKeys from {@link #txKeys}. Used during marshalling and unmarshalling. */ @GridToStringExclude @Order(2) IgniteTxKey[] txKeysArr; - /** */ + /** Array of locksArr from {@link #nearTxKeyLocks}. Used during marshalling and unmarshalling. */ @GridToStringExclude @Order(3) List[] locksArr; @@ -86,7 +86,7 @@ public void futureId(long futId) { } /** - * @return Lock lists for all near tx keys. + * @return Lock lists for all tx nearTxKeysArr. */ public Map> txLocks() { return nearTxKeyLocks; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java index 3bf2cebf2653b..32b6ef00ba5ff 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -30,7 +30,7 @@ public class GridTaskResultResponse implements Message { @Marshalled("resBytes") public @Nullable Object res; - /** */ + /** Serialized result. */ @Order(0) @Nullable byte[] resBytes; diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index ea2c59377df17..46f7a0ea80141 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -17,7 +17,9 @@ package org.apache.ignite.plugin.extensions.communication; -/** */ +/** + * Interface for message serialization logic. + */ public interface MessageSerializer { /** * Writes this message to provided byte buffer. diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index 3ea68492a8d66..29ee98d32c552 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -60,7 +60,7 @@ */ @WithSystemProperty(key = IGNITE_ENABLE_OBJECT_INPUT_FILTER_AUTOCONFIGURATION, value = "false") public class DiscoveryUnmarshalVulnerabilityTest extends GridCommonAbstractTest { - /** */ + /** Shared value. */ private static final AtomicBoolean SHARED = new AtomicBoolean(); /** */ From 3dbb32b5b1032bd81f657b627d4aecaf2e3cb684 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 02:15:25 +0300 Subject: [PATCH 190/215] WIP --- .../discovery/zk/internal/ZkMessageFactory.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java index cf9f95a908f7e..eed938cf63cfd 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java @@ -17,17 +17,17 @@ package org.apache.ignite.spi.discovery.zk.internal; +import org.apache.ignite.internal.plugin.AbstractMarshallableMessageFactoryProvider; import org.apache.ignite.plugin.extensions.communication.MessageFactory; -import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; /** */ -public class ZkMessageFactory implements MessageFactoryProvider { +public class ZkMessageFactory extends AbstractMarshallableMessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - factory.register(400, ZkCommunicationErrorResolveFinishMessage::new, new ZkCommunicationErrorResolveFinishMessageSerializer()); - factory.register(401, ZkCommunicationErrorResolveStartMessage::new, new ZkCommunicationErrorResolveStartMessageSerializer()); - factory.register(402, ZkForceNodeFailMessage::new, new ZkForceNodeFailMessageSerializer()); - factory.register(403, ZkNoServersMessage::new, new ZkNoServersMessageSerializer()); - factory.register(404, ZkDiscoDataBagWrapper::new, new ZkDiscoDataBagWrapperSerializer()); + register(factory, ZkCommunicationErrorResolveFinishMessage.class, (short)400, dfltMarsh); + register(factory, ZkCommunicationErrorResolveStartMessage.class, (short)401, dfltMarsh); + register(factory, ZkForceNodeFailMessage.class, (short)402, dfltMarsh); + register(factory, ZkNoServersMessage.class, (short)403, dfltMarsh); + register(factory, ZkDiscoDataBagWrapper.class, (short)404, dfltMarsh); } } From a1c828c0e85fe7065e309b4cad154d05a7d75650 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 03:08:29 +0300 Subject: [PATCH 191/215] WIP --- .../query/calcite/message/QueryStartRequest.java | 4 ++-- .../internal/MessageDeploymentGenerator.java | 2 +- .../apache/ignite/internal/MessageGenerator.java | 2 +- .../internal/MessageMarshallerGenerator.java | 2 +- .../apache/ignite/internal/MessageProcessor.java | 4 ++-- .../internal/MessageSerializerGenerator.java | 14 +++++++------- .../ignite/internal/CoreMessagesProvider.java | 4 ++-- .../org/apache/ignite/internal/TxEntriesInfo.java | 2 +- .../cache/transactions/IgniteTxEntry.java | 6 +++--- .../tcp/DiscoveryUnmarshalVulnerabilityTest.java | 2 +- .../zk/internal/DiscoveryMessageParser.java | 4 ++-- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java index 12157a9c41be9..00309571662e2 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java @@ -39,7 +39,7 @@ public class QueryStartRequest implements MarshallableMessage, ExecutionContextA @Order(1) UUID qryId; - /** Sequential local counter; see {@link #qryId} for the cluster-wide UUID. */ + /** */ @Order(2) long originatingQryId; @@ -70,7 +70,7 @@ public class QueryStartRequest implements MarshallableMessage, ExecutionContextA @Order(8) long timeout; - /** Transaction entries to mix in during query processing, or {@code null} if not inside a tx. */ + /** */ @Order(9) @Nullable Collection qryTxEntries; diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java index 2b8814181ee39..379786d8cc7b8 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java @@ -76,7 +76,7 @@ public class MessageDeploymentGenerator extends MessageGenerator { /** */ private boolean needsCctx; - /** @param env Annotation processing environment. */ + /** */ MessageDeploymentGenerator(ProcessingEnvironment env) { super(env); diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java index 2da9806a29f92..86c630159b317 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java @@ -75,7 +75,7 @@ public abstract class MessageGenerator { /** */ int indent; - /** @param env Annotation processing environment. */ + /** */ MessageGenerator(ProcessingEnvironment env) { this.env = env; } diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index b77f6abbb7640..9127f69f80a26 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -83,7 +83,7 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** Enclosed fields of the currently processed type. Computed once per {@link #generateBody} call. */ private Map enclosed; - /** @param env Annotation processing environment. */ + /** */ MessageMarshallerGenerator(ProcessingEnvironment env) { super(env); diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java index 85da3b1fd33df..d47542313d450 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java @@ -101,7 +101,7 @@ public class MessageProcessor extends AbstractProcessor { "org.apache.ignite.spi.communication.tcp.TestDelayMessage" }; - /** Tracks enum-to-mapper bindings to detect inconsistent mapper usage across messages. */ + /** */ private final Map> enumMappersInUse = new HashMap<>(); /** Processes all classes implementing the {@code Message} interface and generates corresponding serializer code. */ @@ -232,7 +232,7 @@ private List orderedFields(TypeElement type) { return result; } - /** Recursively collects ordered fields from {@code type} and all its superclasses, one list per level. */ + /** */ private List> hierarchicalOrderedFields(TypeElement type) { Element superType = processingEnv.getTypeUtils().asElement(type.getSuperclass()); diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 7a5b43a749e2d..0c85e82cd1cda 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -50,7 +50,7 @@ public class MessageSerializerGenerator extends MessageGenerator { /** */ private static final String RETURN_FALSE_STMT = "return false;"; - /** FQN of the default enum mapper used when no custom mapper is specified. */ + /** */ static final String DLFT_ENUM_MAPPER_CLS = "org.apache.ignite.plugin.extensions.communication.mappers.DefaultEnumMapper"; /** */ @@ -66,7 +66,7 @@ public class MessageSerializerGenerator extends MessageGenerator { /** Enum-mapper field declarations emitted at the top of the generated {@code *Serializer} class. */ private final Set fields = new java.util.TreeSet<>(); - /** @param env Annotation processing environment. */ + /** */ MessageSerializerGenerator(ProcessingEnvironment env) { super(env); } @@ -116,7 +116,7 @@ public class MessageSerializerGenerator extends MessageGenerator { } } - /** Writes a no-arg constructor stub to the generated serializer class. */ + /** */ private void writeConstructor(Writer writer, String serClsName) throws IOException { ++indent; @@ -584,7 +584,7 @@ else if (enumType(env, type)) { throw new IllegalArgumentException("Unsupported type kind: " + type.getKind()); } - /** @return the field name of the item-type descriptor constant for {@code field}'s collection element type. */ + /** */ private String messageCollectionItemTypes(VariableElement field, TypeMirror type) throws Exception { String desc = messageCollectionItemTypeDescriptor(type); String descName = field.getSimpleName() + "CollDesc"; @@ -595,7 +595,7 @@ private String messageCollectionItemTypes(VariableElement field, TypeMirror type return descName; } - /** @return constructor expression for the {@code MessageCollectionItemType} descriptor of {@code type}. */ + /** */ private String messageCollectionItemTypeDescriptor(TypeMirror type) throws Exception { imports.add("org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType"); @@ -827,7 +827,7 @@ private void writeClassFields(Writer writer) throws IOException { indent = 0; } - /** @return {@code true} if {@code type} corresponds to the class named {@code typeStr}. */ + /** */ private boolean sameType(TypeMirror type, String typeStr) { return env.getTypeUtils().isSameType(type, type(typeStr)); } @@ -844,7 +844,7 @@ public static boolean enumType(ProcessingEnvironment env, TypeMirror type) { return element != null && element.getKind() == ElementKind.ENUM; } - /** Converts e.g. {@code "BYTE"} to {@code "Byte"}: uppercases first char, lowercases the rest. */ + /** Converts string "BYTE" to string "Byte", with first capital latter. */ private String capitalizeOnlyFirst(String input) { return input.substring(0, 1).toUpperCase() + input.substring(1).toLowerCase(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java b/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java index 2d771a1795c7d..69f977c28a82c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java @@ -298,7 +298,7 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryStatusCheckMessage; import org.jetbrains.annotations.Nullable; -/** Registers all built-in core messages into {@link MessageFactory}. */ +/** */ public class CoreMessagesProvider extends AbstractMarshallableMessageFactoryProvider { /** Node ID message type. */ public static final short NODE_ID_MSG_TYPE = 11500; @@ -309,7 +309,7 @@ public class CoreMessagesProvider extends AbstractMarshallableMessageFactoryProv /** Handshake wait message type. */ public static final short HANDSHAKE_WAIT_MSG_TYPE = HANDSHAKE_MSG_TYPE + 1; - /** Upper bound on message type IDs allocated by this provider; used to detect range exhaustion. */ + /** */ public static final short MAX_MESSAGE_ID = 15_000; /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java index 2f48500fc950d..c4d4ec69175d4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/TxEntriesInfo.java @@ -32,7 +32,7 @@ public final class TxEntriesInfo extends IgniteDiagnosticRequest.DiagnosticBaseI @Order(0) int cacheId; - /** Keys to look up lock/entry diagnostic information for. */ + /** */ @Order(1) Collection keys; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index ddb0a7f47f124..6a90694ab45ad 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -71,10 +71,10 @@ public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, /** Dummy version for any existing entry read in SERIALIZABLE transaction. */ public static final GridCacheVersion SER_READ_NOT_EMPTY_VER = new GridCacheVersion(0, 0, 1); - /** Dummy version for an updated entry read in GET operation. */ + /** */ public static final GridCacheVersion GET_ENTRY_INVALID_VER_UPDATED = new GridCacheVersion(0, 0, 2); - /** Dummy version for an entry read after a GET operation. */ + /** */ public static final GridCacheVersion GET_ENTRY_INVALID_VER_AFTER_GET = new GridCacheVersion(0, 0, 3); /** Skip store flag bit mask. */ @@ -209,7 +209,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, MarshallableMessage, /** Partition update counter. */ private long partUpdateCntr; - /** Version read in SERIALIZABLE transaction to track conflicts. */ + /** */ @Order(12) GridCacheVersion serReadVer; diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index 29ee98d32c552..2647625a8499b 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -255,7 +255,7 @@ private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOE } } - /** Lazily-initialized {@link MessageSerializer} wrapper resolved from the plugin provider. */ + /** */ private static class MessageSerializerWrapper implements MessageSerializer { /** */ private final AbstractMarshallableMessageFactoryProvider provider; diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index 817571c2e3c76..e39883b3e4b47 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -87,7 +87,7 @@ public T unmarshalZip(byte[] bytes) { } } - /** Serializes {@code m} (type prefix + payload) into {@code out}. */ + /** */ private void serializeMessage(Message m, OutputStream out) throws IOException { DirectMessageWriter msgWriter = new DirectMessageWriter(msgFactory); ByteBuffer msgBuf = ByteBuffer.allocate(MSG_BUFFER_SIZE); @@ -113,7 +113,7 @@ private void serializeMessage(Message m, OutputStream out) throws IOException { while (!finished); } - /** Deserializes a message (type prefix + payload) from {@code in}. */ + /** */ private T deserializeMessage(InputStream in) throws IOException { DirectMessageReader msgReader = new DirectMessageReader(msgFactory, null); ByteBuffer msgBuf = ByteBuffer.allocate(MSG_BUFFER_SIZE); From 98c3175a7c630607c6d5fa206085384ad47742a3 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 03:26:49 +0300 Subject: [PATCH 192/215] WIP --- .../test/resources/codegen/NioFieldOnNonMessageMessage.java | 3 --- .../src/test/resources/codegen/TestMarshallableMessage.java | 2 -- 2 files changed, 5 deletions(-) diff --git a/modules/core/src/test/resources/codegen/NioFieldOnNonMessageMessage.java b/modules/core/src/test/resources/codegen/NioFieldOnNonMessageMessage.java index 40df58fafac65..a8ac50154d9df 100644 --- a/modules/core/src/test/resources/codegen/NioFieldOnNonMessageMessage.java +++ b/modules/core/src/test/resources/codegen/NioFieldOnNonMessageMessage.java @@ -19,14 +19,11 @@ import org.apache.ignite.plugin.extensions.communication.Message; -/** */ public class NioFieldOnNonMessageMessage implements Message { - /** */ @NioField @Order(0) int id; - /** */ public short directType() { return 0; } diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessage.java b/modules/core/src/test/resources/codegen/TestMarshallableMessage.java index 12b5ef75ee04d..641a379cf2c7d 100644 --- a/modules/core/src/test/resources/codegen/TestMarshallableMessage.java +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessage.java @@ -34,12 +34,10 @@ public class TestMarshallableMessage implements MarshallableMessage { @Order(2) byte[] cstDataBytes; - /** {@inheritDoc} */ @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { cstDataBytes = U.marshal(marsh, cstData); } - /** {@inheritDoc} */ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { cstData = U.unmarshal(marsh, cstDataBytes, clsLdr); } From 031d3d89959cd4db70749b1387037f710f942d5b Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 03:38:07 +0300 Subject: [PATCH 193/215] WIP --- .../internal/MessageDeploymentGenerator.java | 9 ++++----- .../apache/ignite/internal/MessageGenerator.java | 2 +- .../internal/MessageMarshallerGenerator.java | 14 +++++++------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java index 379786d8cc7b8..cc3d1e26c5639 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java @@ -215,10 +215,10 @@ private boolean hasCustomDeployment(TypeElement type) { /** Returns the line that resolves {@code cctx} from {@code ctx} based on the message type hierarchy. */ private String cctxResolutionLine() { - if (cacheGroupIdMsgMirror != null && assignableFrom(type.asType(), cacheGroupIdMsgMirror)) + if (assignableFrom(type.asType(), cacheGroupIdMsgMirror)) return "GridCacheContext cctx = ctx.cacheContext(msg.groupId());"; - if (cacheIdMsgMirror != null && assignableFrom(type.asType(), cacheIdMsgMirror)) + if (assignableFrom(type.asType(), cacheIdMsgMirror)) return "GridCacheContext cctx = ctx.cacheContext(msg.cacheId());"; throw new IllegalStateException("Cannot resolve cache context for " + type.getQualifiedName() @@ -245,7 +245,7 @@ private List allHierarchyFields(TypeElement te) { if (fieldType.getKind() == TypeKind.ARRAY || fieldType.getKind().isPrimitive()) return null; - if (cacheObjectMirror != null && assignableFrom(fieldType, cacheObjectMirror)) + if (assignableFrom(fieldType, cacheObjectMirror)) return DeployKind.CACHE_OBJECT; if (!(fieldType instanceof DeclaredType)) @@ -257,8 +257,7 @@ private List allHierarchyFields(TypeElement te) { if (!args.isEmpty()) { TypeMirror elemType = erasedType(elementBound(args.get(0))); - if (cacheObjectMirror != null && collectionMirror != null - && assignableFrom(erased, collectionMirror) + if (assignableFrom(erased, collectionMirror) && assignableFrom(elemType, cacheObjectMirror)) return DeployKind.CACHE_OBJECTS; diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java index 86c630159b317..95dd26c08aa6d 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageGenerator.java @@ -191,7 +191,7 @@ String simpleNameWithGeneric(TypeElement te) { /** */ boolean assignableFrom(TypeMirror type, TypeMirror superType) { - return env.getTypeUtils().isAssignable(type, superType); + return superType != null && env.getTypeUtils().isAssignable(type, superType); } /** @return the {@link TypeMirror} for the fully-qualified {@code clazz}, or {@code null} if not on classpath. */ diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 9127f69f80a26..921025907e06a 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -976,37 +976,37 @@ private boolean needsCtxType(TypeMirror t) { /** */ private boolean isMessage(TypeMirror type) { - return messageMirror != null && assignableFrom(type, messageMirror); + return assignableFrom(type, messageMirror); } /** */ private boolean isCacheObject(TypeMirror type) { - return cacheObjectMirror != null && assignableFrom(type, cacheObjectMirror); + return assignableFrom(type, cacheObjectMirror); } /** Returns {@code true} if {@code type} (erased) is assignable to {@code java.util.Map}. */ private boolean isMap(TypeMirror type) { - return mapMirror != null && assignableFrom(erasedType(type), mapMirror); + return assignableFrom(erasedType(type), mapMirror); } /** Returns {@code true} if {@code type} (erased) is assignable to {@code java.util.Collection}. */ private boolean isCollection(TypeMirror type) { - return collectionMirror != null && assignableFrom(erasedType(type), collectionMirror); + return assignableFrom(erasedType(type), collectionMirror); } /** */ private boolean isNonMarshallableMessage(TypeElement te) { - return nonMarshallableMirror != null && assignableFrom(te.asType(), nonMarshallableMirror); + return assignableFrom(te.asType(), nonMarshallableMirror); } /** */ private boolean isCacheIdAwareMessage(TypeElement te) { - return cacheIdAwareMirror != null && assignableFrom(te.asType(), cacheIdAwareMirror); + return assignableFrom(te.asType(), cacheIdAwareMirror); } /** */ private boolean isCacheGroupIdMessage(TypeElement te) { - return cacheGroupIdMsgMirror != null && assignableFrom(te.asType(), cacheGroupIdMsgMirror); + return assignableFrom(te.asType(), cacheGroupIdMsgMirror); } /** */ From 76888447194bfc85bfb976dab9c9d22be5662384 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 03:46:21 +0300 Subject: [PATCH 194/215] WIP --- .../communication/MessageMarshaller.java | 14 ++++++++++---- .../communication/MessageSerializer.java | 10 ++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index e629718cf4b5b..8c957bd4f9ec7 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -87,7 +87,7 @@ default void finishUnmarshalNio(M msg, GridKernalContext kctx) throws IgniteChec */ static void finishUnmarshalNio(MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { - MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); + MessageMarshaller m = resolve(factory, msg); if (m != null) m.finishUnmarshalNio(msg, kctx); @@ -105,7 +105,7 @@ static void finishUnmarshalNio(MessageFactory factory, M msg */ static void prepareMarshal(MessageFactory factory, M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested) throws IgniteCheckedException { - MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); + MessageMarshaller m = resolve(factory, msg); if (m != null) m.prepareMarshal(msg, kctx, nested); @@ -126,7 +126,7 @@ static void finishUnmarshal(MessageFactory factory, M msg, G @Nullable CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { assert !Dedup.ENABLED || Dedup.firstUnmarshal(msg, true) : "Finish-unmarshalled more than once: " + msg.getClass().getName(); - MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); + MessageMarshaller m = resolve(factory, msg); if (m != null) m.finishUnmarshal(msg, kctx, nested, clsLdr); @@ -145,12 +145,18 @@ static void finishUnmarshal(MessageFactory factory, M msg, G throws IgniteCheckedException { assert !Dedup.ENABLED || Dedup.firstUnmarshal(msg, false) : "Finish-unmarshalled more than once: " + msg.getClass().getName(); - MessageMarshaller m = (MessageMarshaller)factory.marshaller(msg.directType()); + MessageMarshaller m = resolve(factory, msg); if (m != null) m.finishUnmarshal(msg, kctx); } + /** @return the marshaller registered for {@code msg}'s direct type, or {@code null} if none. */ + @SuppressWarnings("unchecked") + private static MessageMarshaller resolve(MessageFactory factory, M msg) { + return (MessageMarshaller)factory.marshaller(msg.directType()); + } + /** * Detects a {@link MarshallableMessage} instance being finish-unmarshalled more than once within the same pass * (cache-aware or cache-free) — a class-loader or receive-path bug. The two passes over one message (e.g. the diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java index 46f7a0ea80141..28d6c6a62a053 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java @@ -49,7 +49,7 @@ public interface MessageSerializer { * @return Whether message was fully written. */ static boolean writeTo(MessageFactory factory, M msg, MessageWriter writer) { - return ((MessageSerializer)factory.serializer(msg.directType())).writeTo(msg, writer); + return resolve(factory, msg).writeTo(msg, writer); } /** @@ -62,6 +62,12 @@ static boolean writeTo(MessageFactory factory, M msg, Messag * @return Whether message was fully read. */ static boolean readFrom(MessageFactory factory, M msg, MessageReader reader) { - return ((MessageSerializer)factory.serializer(msg.directType())).readFrom(msg, reader); + return resolve(factory, msg).readFrom(msg, reader); + } + + /** @return the serializer registered for {@code msg}'s direct type. */ + @SuppressWarnings("unchecked") + private static MessageSerializer resolve(MessageFactory factory, M msg) { + return (MessageSerializer)factory.serializer(msg.directType()); } } From ecff3eebf84916888940a28e39acf93e3faaf82c Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 04:14:11 +0300 Subject: [PATCH 195/215] WIP --- .../internal/MessageMarshallerGenerator.java | 1 - .../internal/MessageSerializerGenerator.java | 2 +- .../codegen/MessageProcessorTest.java | 18 +++++ .../codegen/ChildMessageMarshaller.java | 1 - .../codegen/ChildMessageSerializer.java | 2 - ...stomMapperEnumFieldsMessageMarshaller.java | 1 - ...stomMapperEnumFieldsMessageSerializer.java | 2 - ...aultMapperEnumFieldsMessageMarshaller.java | 1 - ...aultMapperEnumFieldsMessageSerializer.java | 2 - .../TestCollectionsMessageMarshaller.java | 1 - .../TestCollectionsMessageSerializer.java | 2 - .../codegen/TestMapMessageMarshaller.java | 1 - .../codegen/TestMapMessageSerializer.java | 2 - .../TestMarshallableMessageMarshaller.java | 1 - .../TestMarshallableMessageSerializer.java | 2 - ...MarshalledCollectionMessageMarshaller.java | 1 - ...MarshalledCollectionMessageSerializer.java | 1 - .../TestMarshalledMapMessageMarshaller.java | 1 - .../TestMarshalledMapMessageSerializer.java | 1 - .../TestMarshalledMessageMarshaller.java | 1 - .../TestMarshalledObjectsMessage.java} | 22 +++--- ...estMarshalledObjectsMessageMarshaller.java | 70 +++++++++++++++++ ...estMarshalledObjectsMessageSerializer.java | 75 +++++++++++++++++++ .../codegen/TestMessageMarshaller.java | 1 - .../codegen/TestMessageSerializer.java | 1 - 25 files changed, 176 insertions(+), 37 deletions(-) rename modules/{codegen/src/main/java/org/apache/ignite/internal/MarshalledSet.java => core/src/test/resources/codegen/TestMarshalledObjectsMessage.java} (63%) create mode 100644 modules/core/src/test/resources/codegen/TestMarshalledObjectsMessageMarshaller.java create mode 100644 modules/core/src/test/resources/codegen/TestMarshalledObjectsMessageSerializer.java diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 921025907e06a..6062575019f9a 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -170,7 +170,6 @@ private void writeConstructor(Writer writer, String marshallerClsName) throws IO writer.write(NL); } - writer.write(NL); writer.write(indentedLine("}")); writer.write(NL + NL); } diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java index 0c85e82cd1cda..3012b08922cd7 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java @@ -123,7 +123,7 @@ private void writeConstructor(Writer writer, String serClsName) throws IOExcepti writer.write(indentedLine(METHOD_JAVADOC)); writer.write(NL); writer.write(indentedLine("public " + serClsName + "() {")); - writer.write(NL + NL); + writer.write(NL); writer.write(indentedLine("}")); writer.write(NL); writer.write(NL); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java index f1fce2ed5cc05..d7026e3bf746c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java @@ -50,6 +50,24 @@ /** */ public class MessageProcessorTest { + /** */ + @Test + public void testMarshalledObjectsMessage() { + Compilation compilation = compile("TestMarshalledObjectsMessage.java"); + + assertThat(compilation).succeeded(); + + assertEquals(2, compilation.generatedSourceFiles().size()); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMarshalledObjectsMessageSerializer") + .hasSourceEquivalentTo(javaFile("TestMarshalledObjectsMessageSerializer.java")); + + assertThat(compilation) + .generatedSourceFile("org.apache.ignite.internal.TestMarshalledObjectsMessageMarshaller") + .hasSourceEquivalentTo(javaFile("TestMarshalledObjectsMessageMarshaller.java")); + } + /** */ @Test public void testProcessorGeneratesSerializer() { diff --git a/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java b/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java index ff153a16120fb..194925906ef6c 100644 --- a/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java @@ -32,7 +32,6 @@ public class ChildMessageMarshaller implements MessageMarshaller { /** */ public ChildMessageMarshaller() { - } /** */ diff --git a/modules/core/src/test/resources/codegen/ChildMessageSerializer.java b/modules/core/src/test/resources/codegen/ChildMessageSerializer.java index d4de3abe02800..6c06862cfeb05 100644 --- a/modules/core/src/test/resources/codegen/ChildMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/ChildMessageSerializer.java @@ -31,7 +31,6 @@ public class ChildMessageSerializer implements MessageSerializer { /** */ public ChildMessageSerializer() { - } /** */ @@ -110,5 +109,4 @@ public ChildMessageSerializer() { return true; } - } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java index b7acb977a6239..ab1080aa2d428 100644 --- a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java @@ -32,7 +32,6 @@ public class CustomMapperEnumFieldsMessageMarshaller implements MessageMarshaller { /** */ public CustomMapperEnumFieldsMessageMarshaller() { - } /** */ diff --git a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageSerializer.java b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageSerializer.java index 7d8e53bf08d4b..6dea5109f8b5f 100644 --- a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageSerializer.java @@ -36,7 +36,6 @@ public class CustomMapperEnumFieldsMessageSerializer implements MessageSerialize /** */ public CustomMapperEnumFieldsMessageSerializer() { - } /** */ @@ -73,5 +72,4 @@ public CustomMapperEnumFieldsMessageSerializer() { return true; } - } diff --git a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java index 81f0c16900c37..59c5c057bf761 100644 --- a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java @@ -32,7 +32,6 @@ public class DefaultMapperEnumFieldsMessageMarshaller implements MessageMarshaller { /** */ public DefaultMapperEnumFieldsMessageMarshaller() { - } /** */ diff --git a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageSerializer.java b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageSerializer.java index 000fea443fb75..7d3859fee4a35 100644 --- a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageSerializer.java @@ -38,7 +38,6 @@ public class DefaultMapperEnumFieldsMessageSerializer implements MessageSerializ /** */ public DefaultMapperEnumFieldsMessageSerializer() { - } /** */ @@ -89,5 +88,4 @@ public DefaultMapperEnumFieldsMessageSerializer() { return true; } - } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java index 09434b2688e76..ad9d99817a5bf 100644 --- a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java @@ -49,7 +49,6 @@ public class TestCollectionsMessageMarshaller implements MessageMarshaller { /** */ public TestCollectionsMessageMarshaller() { - } /** */ diff --git a/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java b/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java index 2aff2a2e686b3..1741e3161433b 100644 --- a/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestCollectionsMessageSerializer.java @@ -86,7 +86,6 @@ public class TestCollectionsMessageSerializer implements MessageSerializer { /** */ public TestMapMessageMarshaller() { - } /** */ diff --git a/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java index 1e43dcb11553b..7cacb98f36858 100644 --- a/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestMapMessageSerializer.java @@ -87,7 +87,6 @@ public class TestMapMessageSerializer implements MessageSerializer { /** */ public TestMarshallableMessageSerializer() { - } /** */ @@ -95,5 +94,4 @@ public TestMarshallableMessageSerializer() { return true; } - } diff --git a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java index 42fb9378e1637..04f6a562773a6 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java @@ -33,7 +33,6 @@ public class TestMarshalledCollectionMessageMarshaller implements MessageMarshaller { /** */ public TestMarshalledCollectionMessageMarshaller() { - } /** */ diff --git a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageSerializer.java index 74612611f526a..2ef81522ecc49 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageSerializer.java @@ -37,7 +37,6 @@ public class TestMarshalledCollectionMessageSerializer implements MessageSeriali /** */ public TestMarshalledCollectionMessageSerializer() { - } /** */ diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java index 58c00c0c025d7..77cd42a13c0fc 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java @@ -35,7 +35,6 @@ public class TestMarshalledMapMessageMarshaller implements MessageMarshaller { /** */ public TestMarshalledMapMessageMarshaller() { - } /** */ diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageSerializer.java index f9bd0bf24e195..4b9b7e7432b90 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageSerializer.java @@ -38,7 +38,6 @@ public class TestMarshalledMapMessageSerializer implements MessageSerializer dataBytes; + + @MarshalledObjects("dataBytes") + Collection data; + + public short directType() { + return 0; + } } diff --git a/modules/core/src/test/resources/codegen/TestMarshalledObjectsMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledObjectsMessageMarshaller.java new file mode 100644 index 0000000000000..eef35eba3e420 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshalledObjectsMessageMarshaller.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import java.util.ArrayList; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.TestMarshalledObjectsMessage; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.extensions.communication.MessageMarshaller; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMarshalledObjectsMessageMarshaller implements MessageMarshaller { + /** */ + private final Marshaller marshaller; + + /** */ + public TestMarshalledObjectsMessageMarshaller(Marshaller marshaller) { + this.marshaller = marshaller; + } + + /** */ + @Override public void prepareMarshal(TestMarshalledObjectsMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + if (msg.data != null && msg.dataBytes == null) { + msg.dataBytes = new ArrayList<>(msg.data.size()); + + for (Object e : msg.data) + msg.dataBytes.add(U.marshal(marshaller, e)); + } + } + + /** */ + @Override public void finishUnmarshal(TestMarshalledObjectsMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + CacheObjectContext ctx = nested; + + if (msg.dataBytes != null) { + msg.data = new ArrayList<>(msg.dataBytes.size()); + + for (byte[] e : msg.dataBytes) + msg.data.add(U.unmarshal(marshaller, e, clsLdr)); + + msg.dataBytes = null; + } + } + + /** */ + @Override public void finishUnmarshal(TestMarshalledObjectsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMarshalledObjectsMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMarshalledObjectsMessageSerializer.java new file mode 100644 index 0000000000000..575c22eafb656 --- /dev/null +++ b/modules/core/src/test/resources/codegen/TestMarshalledObjectsMessageSerializer.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.internal.TestMarshalledObjectsMessage; +import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; +import org.apache.ignite.plugin.extensions.communication.MessageCollectionType; +import org.apache.ignite.plugin.extensions.communication.MessageItemType; +import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageSerializer; +import org.apache.ignite.plugin.extensions.communication.MessageWriter; + +/** + * This class is generated automatically. + * + * @see org.apache.ignite.internal.MessageProcessor + */ +public class TestMarshalledObjectsMessageSerializer implements MessageSerializer { + /** */ + private static final MessageCollectionType dataBytesCollDesc = new MessageCollectionType(new MessageItemType(MessageCollectionItemType.BYTE_ARR), false); + + /** */ + public TestMarshalledObjectsMessageSerializer() { + } + + /** */ + @Override public boolean writeTo(TestMarshalledObjectsMessage msg, MessageWriter writer) { + if (!writer.isHeaderWritten()) { + if (!writer.writeHeader(msg.directType())) + return false; + + writer.onHeaderWritten(); + } + + switch (writer.state()) { + case 0: + if (!writer.writeCollection(msg.dataBytes, dataBytesCollDesc)) + return false; + + writer.incrementState(); + } + + return true; + } + + /** */ + @Override public boolean readFrom(TestMarshalledObjectsMessage msg, MessageReader reader) { + switch (reader.state()) { + case 0: + msg.dataBytes = reader.readCollection(dataBytesCollDesc); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + } + + return true; + } +} \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMessageMarshaller.java index 7acc5a2c9e0e4..3d4a9d5b6b320 100644 --- a/modules/core/src/test/resources/codegen/TestMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMessageMarshaller.java @@ -34,7 +34,6 @@ public class TestMessageMarshaller implements MessageMarshaller { /** */ public TestMessageMarshaller() { - } /** */ diff --git a/modules/core/src/test/resources/codegen/TestMessageSerializer.java b/modules/core/src/test/resources/codegen/TestMessageSerializer.java index f55bcb63a1f7b..ed406e78ff5ce 100644 --- a/modules/core/src/test/resources/codegen/TestMessageSerializer.java +++ b/modules/core/src/test/resources/codegen/TestMessageSerializer.java @@ -41,7 +41,6 @@ public class TestMessageSerializer implements MessageSerializer { /** */ public TestMessageSerializer() { - } /** */ From 507b4052d078da81262e0e9567fb4aae6b72b5b8 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 04:25:18 +0300 Subject: [PATCH 196/215] WIP --- .../internal/MessageMarshallerGenerator.java | 7 ++- .../TestCollectionsMessageMarshaller.java | 30 +++++----- .../codegen/TestMapMessageMarshaller.java | 58 +++++++++---------- ...MarshalledCollectionMessageMarshaller.java | 12 ++-- .../TestMarshalledMapMessageMarshaller.java | 24 ++++---- .../test/resources/codegen/TestMessage.java | 4 +- .../codegen/TestMessageMarshaller.java | 18 +++--- 7 files changed, 79 insertions(+), 74 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 6062575019f9a..48e853071bcc5 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -83,6 +83,9 @@ public class MessageMarshallerGenerator extends MessageGenerator { /** Enclosed fields of the currently processed type. Computed once per {@link #generateBody} call. */ private Map enclosed; + /** Nesting depth of the current marshal for-loop; names loop variables {@code e}, {@code e1}, {@code e2}… */ + private int loopDepth; + /** */ MessageMarshallerGenerator(ProcessingEnvironment env) { super(env); @@ -890,13 +893,15 @@ private List marshallMap(DeclaredType t, String accessor, MarshalMode mo /** Returns empty if {@code elemType} requires no marshalling; otherwise returns a for-each loop over {@code iterable}. */ private List forLoop(String typeName, TypeMirror elemType, String iterable, MarshalMode mode) { - String el = "e" + (indent + 1); + String el = loopDepth == 0 ? "e" : "e" + loopDepth; + loopDepth++; indent++; List inner = codeFor(elemType, el, mode); indent--; + loopDepth--; if (inner.isEmpty()) return List.of(); diff --git a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java index ad9d99817a5bf..404fd1bd64357 100644 --- a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java @@ -56,16 +56,16 @@ public TestCollectionsMessageMarshaller() { CacheObjectContext ctx = nested; if (msg.messageList != null) { - for (GridCacheVersion e4 : (Collection)msg.messageList) { - if (e4 != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e4, kctx, ctx); + for (GridCacheVersion e : (Collection)msg.messageList) { + if (e != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e, kctx, ctx); } } if (msg.cacheObjectSet != null) { - for (CacheObject e4 : (Collection)msg.cacheObjectSet) { - if (e4 != null && ctx != null) - e4.prepareMarshal(ctx); + for (CacheObject e : (Collection)msg.cacheObjectSet) { + if (e != null && ctx != null) + e.prepareMarshal(ctx); } } } @@ -75,16 +75,16 @@ public TestCollectionsMessageMarshaller() { CacheObjectContext ctx = nested; if (msg.messageList != null) { - for (GridCacheVersion e4 : (Collection)msg.messageList) { - if (e4 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx, ctx, clsLdr); + for (GridCacheVersion e : (Collection)msg.messageList) { + if (e != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); } } if (msg.cacheObjectSet != null) { - for (CacheObject e4 : (Collection)msg.cacheObjectSet) { - if (e4 != null && ctx != null) - e4.finishUnmarshal(ctx, clsLdr); + for (CacheObject e : (Collection)msg.cacheObjectSet) { + if (e != null && ctx != null) + e.finishUnmarshal(ctx, clsLdr); } } } @@ -92,9 +92,9 @@ public TestCollectionsMessageMarshaller() { /** */ @Override public void finishUnmarshal(TestCollectionsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.messageList != null) { - for (GridCacheVersion e4 : (Collection)msg.messageList) { - if (e4 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx); + for (GridCacheVersion e : (Collection)msg.messageList) { + if (e != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx); } } } diff --git a/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java index ec0047aa959f1..9fc5d12f6d45b 100644 --- a/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java @@ -59,24 +59,24 @@ public TestMapMessageMarshaller() { CacheObjectContext ctx = nested; if (msg.messageBoxedDoubleMap != null) { - for (GridCacheVersion e4 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { - if (e4 != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e4, kctx, ctx); + for (GridCacheVersion e : ((Collection)msg.messageBoxedDoubleMap.keySet())) { + if (e != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e, kctx, ctx); } } if (msg.gridCacheObjectMap != null) { - for (KeyCacheObject e4 : ((Collection)msg.gridCacheObjectMap.keySet())) { - if (e4 != null && ctx != null) - e4.prepareMarshal(ctx); + for (KeyCacheObject e : ((Collection)msg.gridCacheObjectMap.keySet())) { + if (e != null && ctx != null) + e.prepareMarshal(ctx); } - for (Map e4 : ((Collection)msg.gridCacheObjectMap.values())) { - if (e4 != null) { - for (List e6 : ((Collection)e4.values())) { - if (e6 != null) { - for (CacheObject e8 : (Collection)e6) { - if (e8 != null && ctx != null) - e8.prepareMarshal(ctx); + for (Map e : ((Collection)msg.gridCacheObjectMap.values())) { + if (e != null) { + for (List e1 : ((Collection)e.values())) { + if (e1 != null) { + for (CacheObject e2 : (Collection)e1) { + if (e2 != null && ctx != null) + e2.prepareMarshal(ctx); } } } @@ -90,24 +90,24 @@ public TestMapMessageMarshaller() { CacheObjectContext ctx = nested; if (msg.messageBoxedDoubleMap != null) { - for (GridCacheVersion e4 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { - if (e4 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx, ctx, clsLdr); + for (GridCacheVersion e : ((Collection)msg.messageBoxedDoubleMap.keySet())) { + if (e != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); } } if (msg.gridCacheObjectMap != null) { - for (KeyCacheObject e4 : ((Collection)msg.gridCacheObjectMap.keySet())) { - if (e4 != null && ctx != null) - e4.finishUnmarshal(ctx, clsLdr); + for (KeyCacheObject e : ((Collection)msg.gridCacheObjectMap.keySet())) { + if (e != null && ctx != null) + e.finishUnmarshal(ctx, clsLdr); } - for (Map e4 : ((Collection)msg.gridCacheObjectMap.values())) { - if (e4 != null) { - for (List e6 : ((Collection)e4.values())) { - if (e6 != null) { - for (CacheObject e8 : (Collection)e6) { - if (e8 != null && ctx != null) - e8.finishUnmarshal(ctx, clsLdr); + for (Map e : ((Collection)msg.gridCacheObjectMap.values())) { + if (e != null) { + for (List e1 : ((Collection)e.values())) { + if (e1 != null) { + for (CacheObject e2 : (Collection)e1) { + if (e2 != null && ctx != null) + e2.finishUnmarshal(ctx, clsLdr); } } } @@ -119,9 +119,9 @@ public TestMapMessageMarshaller() { /** */ @Override public void finishUnmarshal(TestMapMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.messageBoxedDoubleMap != null) { - for (GridCacheVersion e4 : ((Collection)msg.messageBoxedDoubleMap.keySet())) { - if (e4 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx); + for (GridCacheVersion e : ((Collection)msg.messageBoxedDoubleMap.keySet())) { + if (e != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx); } } } diff --git a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java index 04f6a562773a6..da9caa7fc4020 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java @@ -43,9 +43,9 @@ public TestMarshalledCollectionMessageMarshaller() { msg.keysArr = msg.keys.toArray(new GridCacheVersion[0]); if (msg.keysArr != null) { - for (GridCacheVersion e4 : msg.keysArr) { - if (e4 != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e4, kctx, ctx); + for (GridCacheVersion e : msg.keysArr) { + if (e != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e, kctx, ctx); } } } @@ -71,9 +71,9 @@ public TestMarshalledCollectionMessageMarshaller() { /** */ @Override public void finishUnmarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.keysArr != null) { - for (GridCacheVersion e4 : msg.keysArr) { - if (e4 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx); + for (GridCacheVersion e : msg.keysArr) { + if (e != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx); } } } diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java index 77cd42a13c0fc..8898cb96ef76d 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java @@ -47,16 +47,16 @@ public TestMarshalledMapMessageMarshaller() { } if (msg.mapKeys != null) { - for (GridCacheVersion e4 : (Collection)msg.mapKeys) { - if (e4 != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e4, kctx, ctx); + for (GridCacheVersion e : (Collection)msg.mapKeys) { + if (e != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e, kctx, ctx); } } if (msg.mapVals != null) { - for (GridCacheVersion e4 : (Collection)msg.mapVals) { - if (e4 != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e4, kctx, ctx); + for (GridCacheVersion e : (Collection)msg.mapVals) { + if (e != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e, kctx, ctx); } } } @@ -92,16 +92,16 @@ public TestMarshalledMapMessageMarshaller() { /** */ @Override public void finishUnmarshal(TestMarshalledMapMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.mapKeys != null) { - for (GridCacheVersion e4 : (Collection)msg.mapKeys) { - if (e4 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx); + for (GridCacheVersion e : (Collection)msg.mapKeys) { + if (e != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx); } } if (msg.mapVals != null) { - for (GridCacheVersion e4 : (Collection)msg.mapVals) { - if (e4 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx); + for (GridCacheVersion e : (Collection)msg.mapVals) { + if (e != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx); } } } diff --git a/modules/core/src/test/resources/codegen/TestMessage.java b/modules/core/src/test/resources/codegen/TestMessage.java index 82ca4788c116a..5f8e5e7377743 100644 --- a/modules/core/src/test/resources/codegen/TestMessage.java +++ b/modules/core/src/test/resources/codegen/TestMessage.java @@ -44,14 +44,14 @@ public class TestMessage implements Message { @Order(4) int[][] intMatrix; - @NioField // test-only: exercises multi-field finishUnmarshalNio generation + @NioField @Order(5) GridCacheVersion ver; @Order(6) GridCacheVersion[] verArr; - @NioField // test-only: second NioField to verify both appear in finishUnmarshalNio + @NioField @Order(15) GridCacheVersion ver2; diff --git a/modules/core/src/test/resources/codegen/TestMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMessageMarshaller.java index 3d4a9d5b6b320..548cd10f346fe 100644 --- a/modules/core/src/test/resources/codegen/TestMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMessageMarshaller.java @@ -44,9 +44,9 @@ public TestMessageMarshaller() { MessageMarshaller.prepareMarshal(kctx.messageFactory(), msg.ver, kctx, ctx); if (msg.verArr != null) { - for (GridCacheVersion e4 : msg.verArr) { - if (e4 != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e4, kctx, ctx); + for (GridCacheVersion e : msg.verArr) { + if (e != null) + MessageMarshaller.prepareMarshal(kctx.messageFactory(), e, kctx, ctx); } } @@ -65,9 +65,9 @@ public TestMessageMarshaller() { CacheObjectContext ctx = nested; if (msg.verArr != null) { - for (GridCacheVersion e4 : msg.verArr) { - if (e4 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx, ctx, clsLdr); + for (GridCacheVersion e : msg.verArr) { + if (e != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); } } @@ -81,9 +81,9 @@ public TestMessageMarshaller() { /** */ @Override public void finishUnmarshal(TestMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.verArr != null) { - for (GridCacheVersion e4 : msg.verArr) { - if (e4 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e4, kctx); + for (GridCacheVersion e : msg.verArr) { + if (e != null) + MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx); } } } From e1cd796f1d21520f904c4fa2e704a9c00090e79f Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 04:45:52 +0300 Subject: [PATCH 197/215] WIP --- .../extensions/communication/Message.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/Message.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/Message.java index 1e4abc845c52c..ebd48deb7761a 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/Message.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/Message.java @@ -32,19 +32,25 @@ public interface Message { /** Registry of message class to direct type mappings, populated during factory initialization. */ Map, Short> REGISTRATIONS = new ConcurrentHashMap<>(); + /** Per-class cache over {@link #REGISTRATIONS}; keeps {@link #directType()} off the hash lookup on the hot path. */ + ClassValue DIRECT_TYPES = new ClassValue<>() { + @Override protected Short computeValue(Class type) { + Short directType = REGISTRATIONS.get(type); + + if (directType == null) + throw new UnknownMessageException(type.asSubclass(Message.class)); + + return directType; + } + }; + /** * Gets message type. * * @return Message type. */ default short directType() { - var clazz = getClass(); - Short type = REGISTRATIONS.get(clazz); - - if (type == null) - throw new UnknownMessageException(clazz); - - return type; + return DIRECT_TYPES.get(getClass()); } /** From 6e3d9ffc4b7bb1157b04b20556aabaed4467241d Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 11:43:00 +0300 Subject: [PATCH 198/215] WIP --- .../ignite/internal/MessageMarshallerGenerator.java | 8 ++++---- .../org/apache/ignite/internal/MessageProcessor.java | 11 ++++++++++- .../codegen/TestMarshalledMapMessageMarshaller.java | 8 ++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 48e853071bcc5..90ad5d28f6da2 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -660,15 +660,15 @@ private List mapFinishCollectionBlock(VariableElement field, VariableEle code.add(indentedLine("%s = U.newHashMap(%s.size());", mapField, keysField)); code.add(EMPTY); - code.add(indentedLine("Iterator keyIter = %s.iterator();", keysField)); - code.add(indentedLine("Iterator valIter = %s.iterator();", valsField)); + code.add(indentedLine("Iterator<%s> keyIter = %s.iterator();", keyCompName, keysField)); + code.add(indentedLine("Iterator<%s> valIter = %s.iterator();", valCompName, valsField)); code.add(EMPTY); code.add(indentedLine("while (keyIter.hasNext()) {")); indent++; - code.add(indentedLine("%s k = (%s)keyIter.next();", keyCompName, keyCompName)); - code.add(indentedLine("%s v = (%s)valIter.next();", valCompName, valCompName)); + code.add(indentedLine("%s k = keyIter.next();", keyCompName)); + code.add(indentedLine("%s v = valIter.next();", valCompName)); List keyUnmarshal = codeFor(keyCompType, "k", MarshalMode.FINISH_CACHE); List valUnmarshal = codeFor(valCompType, "v", MarshalMode.FINISH_CACHE); diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java index d47542313d450..4c648db0aff3e 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java @@ -106,7 +106,16 @@ public class MessageProcessor extends AbstractProcessor { /** Processes all classes implementing the {@code Message} interface and generates corresponding serializer code. */ @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { - TypeMirror msgType = processingEnv.getElementUtils().getTypeElement(MESSAGE_INTERFACE).asType(); + TypeElement msgEl = processingEnv.getElementUtils().getTypeElement(MESSAGE_INTERFACE); + + if (msgEl == null) { + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, + "Cannot resolve " + MESSAGE_INTERFACE + " on the annotation-processing classpath."); + + return false; + } + + TypeMirror msgType = msgEl.asType(); List emptyMsgs = typesToTypeMirrors(EMPTY_MESSAGES); List skipMsgs = typesToTypeMirrors(SKIP_MESSAGES); diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java index 8898cb96ef76d..56644eb35ef09 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java @@ -68,12 +68,12 @@ public TestMarshalledMapMessageMarshaller() { if (msg.mapKeys != null) { msg.theMap = U.newHashMap(msg.mapKeys.size()); - Iterator keyIter = msg.mapKeys.iterator(); - Iterator valIter = msg.mapVals.iterator(); + Iterator keyIter = msg.mapKeys.iterator(); + Iterator valIter = msg.mapVals.iterator(); while (keyIter.hasNext()) { - GridCacheVersion k = (GridCacheVersion)keyIter.next(); - GridCacheVersion v = (GridCacheVersion)valIter.next(); + GridCacheVersion k = keyIter.next(); + GridCacheVersion v = valIter.next(); if (k != null) MessageMarshaller.finishUnmarshal(kctx.messageFactory(), k, kctx, ctx, clsLdr); From 3503d8467826dbe68f0e3b4f9e46c945efa9f267 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 13:00:58 +0300 Subject: [PATCH 199/215] WIP --- ...actMarshallableMessageFactoryProvider.java | 33 +++++++++++-------- .../zk/internal/ZkMessageFactory.java | 10 +++--- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java index 053e2a51f2988..d998eeceebd13 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.plugin; import java.lang.reflect.Constructor; +import java.util.function.Supplier; import org.apache.ignite.IgniteException; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; @@ -65,6 +66,23 @@ protected static void register(MessageFactory factory, Class throw new IgniteException("Failed to register message of type " + cls.getSimpleName(), e); } + register(factory, cls, id, () -> { + try { + return ctor.newInstance(); + } + catch (Exception e) { + throw new IgniteException("Failed to create message of type " + cls.getSimpleName(), e); + } + }, marsh); + } + + /** + * Registers a message with a caller-provided {@code supplier} and its generated serializer, marshaller (if + * marshallable), and deployer (if any). Use this overload when {@code cls} is package-private and so cannot be + * instantiated by reflection from this package — pass an in-package {@code ::new} reference as {@code supplier}. + */ + protected static void register(MessageFactory factory, Class cls, short id, + Supplier supplier, Marshaller marsh) { MessageSerializer serializer = loadGenerated(cls, "Serializer", marsh); MessageMarshaller marshaller = NonMarshallableMessage.class.isAssignableFrom(cls) @@ -73,20 +91,7 @@ protected static void register(MessageFactory factory, Class GridCacheMessageDeployer deployer = loadGenerated(cls, "Deployer", marsh); - factory.register( - id, - () -> { - try { - return ctor.newInstance(); - } - catch (Exception e) { - throw new IgniteException("Failed to create message of type " + cls.getSimpleName(), e); - } - }, - serializer, - marshaller, - deployer - ); + factory.register(id, supplier, serializer, marshaller, deployer); } /** diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java index eed938cf63cfd..80b79da642905 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java @@ -24,10 +24,10 @@ public class ZkMessageFactory extends AbstractMarshallableMessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - register(factory, ZkCommunicationErrorResolveFinishMessage.class, (short)400, dfltMarsh); - register(factory, ZkCommunicationErrorResolveStartMessage.class, (short)401, dfltMarsh); - register(factory, ZkForceNodeFailMessage.class, (short)402, dfltMarsh); - register(factory, ZkNoServersMessage.class, (short)403, dfltMarsh); - register(factory, ZkDiscoDataBagWrapper.class, (short)404, dfltMarsh); + register(factory, ZkCommunicationErrorResolveFinishMessage.class, (short)400, ZkCommunicationErrorResolveFinishMessage::new, dfltMarsh); + register(factory, ZkCommunicationErrorResolveStartMessage.class, (short)401, ZkCommunicationErrorResolveStartMessage::new, dfltMarsh); + register(factory, ZkForceNodeFailMessage.class, (short)402, ZkForceNodeFailMessage::new, dfltMarsh); + register(factory, ZkNoServersMessage.class, (short)403, ZkNoServersMessage::new, dfltMarsh); + register(factory, ZkDiscoDataBagWrapper.class, (short)404, ZkDiscoDataBagWrapper::new, dfltMarsh); } } From 7adece91214485dad515f411c5a58f9f90a7c55b Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 13:45:13 +0300 Subject: [PATCH 200/215] WIP --- .../ignite/spi/discovery/zk/internal/ZkMessageFactory.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java index 80b79da642905..d315981d993c2 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkMessageFactory.java @@ -24,8 +24,10 @@ public class ZkMessageFactory extends AbstractMarshallableMessageFactoryProvider { /** {@inheritDoc} */ @Override public void registerAll(MessageFactory factory) { - register(factory, ZkCommunicationErrorResolveFinishMessage.class, (short)400, ZkCommunicationErrorResolveFinishMessage::new, dfltMarsh); - register(factory, ZkCommunicationErrorResolveStartMessage.class, (short)401, ZkCommunicationErrorResolveStartMessage::new, dfltMarsh); + register(factory, ZkCommunicationErrorResolveFinishMessage.class, (short)400, + ZkCommunicationErrorResolveFinishMessage::new, dfltMarsh); + register(factory, ZkCommunicationErrorResolveStartMessage.class, (short)401, + ZkCommunicationErrorResolveStartMessage::new, dfltMarsh); register(factory, ZkForceNodeFailMessage.class, (short)402, ZkForceNodeFailMessage::new, dfltMarsh); register(factory, ZkNoServersMessage.class, (short)403, ZkNoServersMessage::new, dfltMarsh); register(factory, ZkDiscoDataBagWrapper.class, (short)404, ZkDiscoDataBagWrapper::new, dfltMarsh); From 2d412cf93699ffc57ec71e69e9e82d3bf882208f Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 15:15:37 +0300 Subject: [PATCH 201/215] WIP --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index 406d6e78bb414..3d0862e62d0d7 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -863,7 +863,7 @@ **/.asf.yaml .travis.yml .github/PULL_REQUEST_TEMPLATE.md - .mvn/jvm.config + .mvn/jvm.config idea/ignite_codeStyle.xml **/DEVNOTES*.txt **/NOTICE* From 878278a615cae6030c9168d099c2ffb5007ddd54 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 15:27:03 +0300 Subject: [PATCH 202/215] WIP --- .../idto/IDTOSerializerGenerator.java | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/idto/IDTOSerializerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/idto/IDTOSerializerGenerator.java index d20399a197e11..26cd7ed2bd642 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/idto/IDTOSerializerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/idto/IDTOSerializerGenerator.java @@ -740,7 +740,7 @@ private Collection fields(TypeElement type) { } /** @return FQN of {@code comp}. */ - private String className(TypeMirror comp) { + private static String className(TypeMirror comp) { String n = comp.toString(); int spaceIdx = n.indexOf(' '); @@ -750,22 +750,7 @@ private String className(TypeMirror comp) { int genIdx = n.indexOf('<'); - n = genIdx == -1 ? n : n.substring(0, genIdx); - - // In some JDK versions, annotated types may yield simple names (no package). - // Resolve to FQN via the TypeElement to ensure COLL_IMPL / TYPE_SERDES lookups work. - if (!n.contains(".") && comp instanceof DeclaredType) { - TypeElement elem = (TypeElement)((DeclaredType)comp).asElement(); - - if (elem != null) { - String fqn = elem.getQualifiedName().toString(); - - if (!fqn.isEmpty()) - n = fqn; - } - } - - return n; + return genIdx == -1 ? n : n.substring(0, genIdx); } /** @return Serializer class name. */ From 4d5cdb741121bd0c3a86d696f0d6cb67fb2ef9fa Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 15:53:09 +0300 Subject: [PATCH 203/215] WIP --- .../plugin/extensions/communication/Message.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/Message.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/Message.java index ebd48deb7761a..5f88e10e22510 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/Message.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/Message.java @@ -24,6 +24,21 @@ /** * Base class for all communication messages. + *

+ * Wire fields are declared by annotating instance fields; {@link org.apache.ignite.internal.MessageProcessor} then + * generates the serializer, so implementations should not hand-write {@code writeTo}/{@code readFrom}. Available + * field annotations (see each annotation's javadoc for details): + *

    + *
  • {@link org.apache.ignite.internal.Order @Order} — an ordered wire field (the basic building block);
  • + *
  • {@link org.apache.ignite.internal.Compress @Compress} — compress the field's wire form;
  • + *
  • {@link org.apache.ignite.internal.NioField @NioField} — a low-level NIO field;
  • + *
  • {@link org.apache.ignite.internal.CustomMapper @CustomMapper} — map the field via a custom mapper;
  • + *
  • {@link org.apache.ignite.internal.Marshalled @Marshalled} / + * {@link org.apache.ignite.internal.MarshalledMap @MarshalledMap} / + * {@link org.apache.ignite.internal.MarshalledCollection @MarshalledCollection} / + * {@link org.apache.ignite.internal.MarshalledObjects @MarshalledObjects} — for {@link MarshallableMessage} + * payloads serialized via a {@link org.apache.ignite.marshaller.Marshaller}.
  • + *
*/ public interface Message { /** Direct type size in bytes. */ From 3656926b9a8368a475133d23ae93b6ad8fc05280 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 16:12:42 +0300 Subject: [PATCH 204/215] WIP --- .../managers/communication/GridIoManager.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index cc7f5eb51ad4d..e3fb4bf47eeac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1189,15 +1189,20 @@ private void onChannelOpened0(UUID rmtNodeId, GridIoMessage initMsg, Channel cha byte plc = initMsg.policy(); - // Restore the @NioField topic (as onMessage0 does); otherwise GridIoMessage.topic() is null here. MessageMarshaller.finishUnmarshalNio(ctx.messageFactory(), initMsg, ctx); - MessageMarshaller.finishUnmarshal(ctx.messageFactory(), initMsg, ctx); - pools.poolForPolicy(plc).execute(new Runnable() { @Override public void run() { - processOpenedChannel(initMsg.topic(), rmtNodeId, (SessionChannelMessage)initMsg.message(), - (SocketChannel)channel); + try { + MessageMarshaller.finishUnmarshal(ctx.messageFactory(), initMsg, ctx); + + processOpenedChannel(initMsg.topic(), rmtNodeId, (SessionChannelMessage)initMsg.message(), + (SocketChannel)channel); + } + catch (IgniteCheckedException e) { + U.error(log, "Failed to process channel creation event due to exception " + + "[rmtNodeId=" + rmtNodeId + ", initMsg=" + initMsg + ']', e); + } } }); } From b09b1b53129f6a9786d7eae857da582568139640 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 17:50:18 +0300 Subject: [PATCH 205/215] WIP --- .../processors/cache/CacheObject.java | 4 +- .../internal/binary/BinaryEnumObjectImpl.java | 4 +- .../internal/binary/BinaryObjectImpl.java | 6 +- .../binary/BinaryObjectOffheapImpl.java | 4 +- .../calcite/message/GenericValueMessage.java | 4 +- .../calcite/message/MessageServiceImpl.java | 2 +- .../calcite/message/QueryStartRequest.java | 4 +- .../calcite/metadata/ColocationGroup.java | 4 +- .../internal/MessageDeploymentGenerator.java | 4 +- .../internal/MessageMarshallerGenerator.java | 58 +++++++++---------- .../org/apache/ignite/internal/NioField.java | 2 +- .../ignite/util/CdcResendCommandTest.java | 2 +- .../internal/GridJobExecuteRequest.java | 4 +- .../ignite/internal/GridTopicMessage.java | 4 +- .../managers/communication/ErrorMessage.java | 4 +- .../managers/communication/GridIoManager.java | 20 +++---- .../eventstorage/GridEventStorageMessage.java | 4 +- .../cache/CacheObjectByteArrayImpl.java | 4 +- .../processors/cache/CacheObjectImpl.java | 4 +- .../CacheObjectNotResolvedException.java | 2 +- .../processors/cache/DeployableMessage.java | 2 +- .../processors/cache/GridCacheEntryInfo.java | 4 +- .../processors/cache/GridCacheIoManager.java | 2 +- .../processors/cache/GridCacheMapEntry.java | 4 +- .../processors/cache/GridCacheMessage.java | 2 +- .../cache/GridCacheMessageDeployer.java | 2 +- .../processors/cache/KeyCacheObjectImpl.java | 4 +- .../atomic/GridDhtAtomicUpdateRequest.java | 4 +- .../GridNearAtomicFullUpdateRequest.java | 4 +- ...idNearAtomicSingleUpdateInvokeRequest.java | 4 +- .../GridDhtPartitionsFullMessage.java | 4 +- .../GridDhtPartitionsSingleMessage.java | 4 +- .../CacheContinuousQueryHandler.java | 2 +- .../CacheContinuousQueryManager.java | 6 +- .../cache/transactions/IgniteTxEntry.java | 4 +- .../cache/transactions/IgniteTxManager.java | 2 +- .../processors/cluster/ClusterProcessor.java | 2 +- .../continuous/GridContinuousProcessor.java | 6 +- .../continuous/StartRequestData.java | 4 +- .../datastreamer/DataStreamerImpl.java | 6 +- .../datastreamer/DataStreamerUpdateJob.java | 4 +- .../processors/job/GridJobProcessor.java | 2 +- .../DistributedMetaStorageCasMessage.java | 8 +-- .../DistributedMetaStorageImpl.java | 6 +- .../DistributedMetaStorageUpdateMessage.java | 4 +- .../processors/task/GridTaskWorker.java | 2 +- .../communication/MarshallableMessage.java | 4 +- .../communication/MessageMarshaller.java | 34 +++++------ .../SerializableDataBagItemWrapper.java | 4 +- .../discovery/tcp/TcpDiscoveryIoSession.java | 4 +- .../tcp/internal/TcpDiscoveryNode.java | 4 +- .../TcpDiscoveryAbstractTraceableMessage.java | 4 +- .../ignite/cdc/CdcCacheVersionTest.java | 2 +- .../internal/GridAffinityNoCacheSelfTest.java | 4 +- ... => MarshallerCacheFreeUnmarshalTest.java} | 28 ++++----- .../MessageSerializationArchitectureTest.java | 12 ++-- .../communication/ErrorMessageSelfTest.java | 4 +- .../ClientSlowDiscoveryAbstractTest.java | 2 +- .../IgniteIncompleteCacheObjectSelfTest.java | 4 +- ...shallerCacheClientRequestsMappingTest.java | 4 +- ...IgniteSequentialNodeCrashRecoveryTest.java | 2 +- .../snapshot/IncrementalSnapshotTest.java | 2 +- .../dump/IgniteCacheDumpSelf2Test.java | 2 +- .../IncrementalSnapshotJoiningClientTest.java | 2 +- ...adlockDetectionMessageMarshallingTest.java | 2 +- .../database/CacheFreeListSelfTest.java | 4 +- .../DataStreamerImplSelfTest.java | 2 +- .../schema/IndexWithSameNameTestBase.java | 2 +- .../communication/MessageMarshalOnceTest.java | 14 ++--- ...est.java => MessageUnmarshalOnceTest.java} | 6 +- .../discovery/tcp/BlockTcpDiscoverySpi.java | 2 +- .../DiscoveryUnmarshalVulnerabilityTest.java | 14 ++--- .../spi/discovery/tcp/ExploitMessage.java | 4 +- .../discovery/tcp/TcpDiscoverySelfTest.java | 2 +- .../testsuites/IgniteBasicTestSuite.java | 8 +-- .../codegen/ChildMessageMarshaller.java | 6 +- ...stomMapperEnumFieldsMessageMarshaller.java | 6 +- ...aultMapperEnumFieldsMessageMarshaller.java | 6 +- .../TestCollectionsMessageMarshaller.java | 16 ++--- .../codegen/TestMapMessageMarshaller.java | 20 +++---- .../codegen/TestMarshallableMessage.java | 4 +- ...hallableMessageMarshallableSerializer.java | 8 +-- .../TestMarshallableMessageMarshaller.java | 12 ++-- ...MarshalledCollectionMessageMarshaller.java | 12 ++-- .../TestMarshalledMapMessageMarshaller.java | 18 +++--- .../TestMarshalledMessageMarshaller.java | 6 +- ...estMarshalledObjectsMessageMarshaller.java | 6 +- .../codegen/TestMessageMarshaller.java | 30 +++++----- .../h2/twostep/msg/GridH2CacheObject.java | 4 +- .../zk/internal/DiscoveryMessageParser.java | 4 +- .../internal/ZkDiscoveryCustomEventData.java | 4 +- .../zk/internal/ZookeeperDiscoveryImpl.java | 8 +-- 92 files changed, 297 insertions(+), 297 deletions(-) rename modules/core/src/test/java/org/apache/ignite/internal/codegen/{MarshallerCacheFreeFinishTest.java => MarshallerCacheFreeUnmarshalTest.java} (82%) rename modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/{MessageFinishUnmarshalOnceTest.java => MessageUnmarshalOnceTest.java} (93%) diff --git a/modules/binary/api/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java b/modules/binary/api/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java index 09e7a8d5a0e91..845eb86e17402 100644 --- a/modules/binary/api/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java +++ b/modules/binary/api/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java @@ -120,13 +120,13 @@ public interface CacheObject { * @param ldr Class loader. * @throws IgniteCheckedException If failed. */ - public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException; + public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException; /** * @param ctx Context. * @throws IgniteCheckedException If failed. */ - public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException; + public void marshal(CacheObjectValueContext ctx) throws IgniteCheckedException; /** * @return {@code True} if postWriteHashCode call required, {@code false} otherwise. diff --git a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java index d61cab738b414..2024eef66e521 100644 --- a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java +++ b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java @@ -367,12 +367,12 @@ private T uncachedValue(Class cls) throws BinaryObjectException { } /** {@inheritDoc} */ - @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { + @Override public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { this.ctx = ctx.binaryContext(); } /** {@inheritDoc} */ - @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException { + @Override public void marshal(CacheObjectValueContext ctx) throws IgniteCheckedException { // No-op. } diff --git a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java index 50e85ff230899..7dd2bebdf86af 100644 --- a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java +++ b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java @@ -220,13 +220,13 @@ public BinaryObjectImpl(BinaryContext ctx, byte[] arr, int start) { @Override public CacheObject prepareForCache(CacheObjectValueContext ctx) { BinaryObjectImpl res = detached() ? this : detach(false); - res.prepareMarshal(ctx); + res.marshal(ctx); return res; } /** {@inheritDoc} */ - @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { + @Override public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { assert arr != null || valBytes != null; if (arr == null) @@ -238,7 +238,7 @@ public BinaryObjectImpl(BinaryContext ctx, byte[] arr, int start) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(CacheObjectValueContext ctx) { + @Override public void marshal(CacheObjectValueContext ctx) { assert arr != null || valBytes != null; if (valBytes == null) diff --git a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java index cce4f59dab7fe..e2ac1b89b4e42 100644 --- a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java +++ b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java @@ -453,12 +453,12 @@ else if (fieldOffLen == BinaryUtils.OFFSET_2) } /** {@inheritDoc} */ - @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { + @Override public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ - @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException { + @Override public void marshal(CacheObjectValueContext ctx) throws IgniteCheckedException { throw new UnsupportedOperationException(); } diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java index 8a2ceea7f1965..0b24aae0d40f5 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/GenericValueMessage.java @@ -48,13 +48,13 @@ public Object value() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { if (val != null && serialized == null) serialized = U.marshal(marsh, val); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (serialized != null && val == null) val = U.unmarshal(marsh, serialized, clsLdr); diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java index 4b94456877eb1..0d386f32d957b 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/MessageServiceImpl.java @@ -182,7 +182,7 @@ public FailureProcessor failureProcessor() { /** */ protected void prepareUnmarshal(Message msg) throws IgniteCheckedException { try { - MessageMarshaller.finishUnmarshal(ctx.kernalContext().messageFactory(), msg, ctx.kernalContext(), null, clsLdr); + MessageMarshaller.unmarshal(ctx.kernalContext().messageFactory(), msg, ctx.kernalContext(), null, clsLdr); } catch (Exception e) { failureProcessor().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java index 00309571662e2..e8273b8d20661 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/QueryStartRequest.java @@ -212,13 +212,13 @@ public boolean keepBinaryMode() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { if (paramsBytes == null && params != null) paramsBytes = U.marshal(marsh, params); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (params == null && paramsBytes != null) params = U.unmarshal(marsh, paramsBytes, clsLdr); diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java index 3dd75d35fb6b1..a0fd5eba4519d 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java @@ -314,7 +314,7 @@ public int[] partitions(UUID nodeId) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { if (!F.isEmpty(marshalledAssignments) || assignments == null || primaryAssignment) return; @@ -343,7 +343,7 @@ public int[] partitions(UUID nodeId) { } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (F.isEmpty(marshalledAssignments)) return; diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java index cc3d1e26c5639..cc4328c4dc4f9 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java @@ -40,7 +40,7 @@ * nested {@code GridCacheMessage} (whose deployment is delegated). The strategy is inferred entirely from the field type. * *

A message with deployment logic that cannot be inferred from field types implements {@code DeployableMessage}; - * the generated deployer then also delegates to its {@code prepareDeployment}, mirroring {@code prepareMarshal}. + * the generated deployer then also delegates to its {@code prepareDeployment}, mirroring {@code marshal}. */ public class MessageDeploymentGenerator extends MessageGenerator { /** FQN of GridCacheMessage; hierarchy scan stops here (exclusive). */ @@ -176,7 +176,7 @@ private boolean hasCustomDeployment(TypeElement type) { deploy.addAll(body); - // Delegate the non-inferable part to the message's own prepareDeployment, mirroring msg.prepareMarshal(). + // Delegate the non-inferable part to the message's own prepareDeployment, mirroring msg.marshal(). if (hasCustomDeployment(type)) { if (!body.isEmpty()) deploy.add(EMPTY); diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java index 90ad5d28f6da2..cb8c0c5d25d04 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java @@ -119,8 +119,8 @@ public class MessageMarshallerGenerator extends MessageGenerator { indent = 1; - generatePrepareMarshalMethod(fields); - generateUnmarshallMethods(fields); + generateMarshalMethod(fields); + generateUnmarshalMethods(fields); } /** {@inheritDoc} */ @@ -177,15 +177,15 @@ private void writeConstructor(Writer writer, String marshallerClsName) throws IO writer.write(NL + NL); } - /** Generates the {@code prepareMarshal} method body and appends it to {@link #marshall}. */ - private void generatePrepareMarshalMethod(List orderedFields) { + /** Generates the {@code marshal} method body and appends it to {@link #marshall}. */ + private void generateMarshalMethod(List orderedFields) { imports.add("org.apache.ignite.IgniteCheckedException"); imports.add("org.apache.ignite.internal.GridKernalContext"); imports.add("org.apache.ignite.internal.processors.cache.CacheObjectContext"); marshall.add(indentedLine(METHOD_JAVADOC)); - marshall.add(indentedLine("@Override public void prepareMarshal(" + simpleNameWithGeneric(type) + + marshall.add(indentedLine("@Override public void marshal(" + simpleNameWithGeneric(type) + " msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException {")); indent++; @@ -199,7 +199,7 @@ private void generatePrepareMarshalMethod(List orderedFields) { appendMarshalledPrepare(body); if (marshallable) - appendBlock(body, List.of(indentedLine("msg.prepareMarshal(marshaller);"))); + appendBlock(body, List.of(indentedLine("msg.marshal(marshaller);"))); appendFields(body, orderedFields, MarshalMode.PREPARE); @@ -210,8 +210,8 @@ private void generatePrepareMarshalMethod(List orderedFields) { marshall.add(indentedLine("}")); } - /** Generates all {@code finishUnmarshal} overloads and appends them to {@link #marshall}. */ - private void generateUnmarshallMethods(List orderedFields) { + /** Generates all {@code unmarshal} overloads and appends them to {@link #marshall}. */ + private void generateUnmarshalMethods(List orderedFields) { List nioFields = new ArrayList<>(); List workerFields = new ArrayList<>(); @@ -233,17 +233,17 @@ private void generateUnmarshallMethods(List orderedFields) { String msgParam = simpleNameWithGeneric(type) + " msg, GridKernalContext kctx"; - generateFinishUnmarshalMethod("finishUnmarshal", msgParam + ", CacheObjectContext nested, ClassLoader clsLdr", + generateUnmarshalMethod("unmarshal", msgParam + ", CacheObjectContext nested, ClassLoader clsLdr", workerFields, MarshalMode.FINISH_CACHE); - generateFinishUnmarshalMethod("finishUnmarshal", msgParam, workerFields, MarshalMode.FINISH); + generateUnmarshalMethod("unmarshal", msgParam, workerFields, MarshalMode.FINISH); if (!nioFields.isEmpty()) - generateFinishUnmarshalNioMethod(msgParam, nioFields); + generateUnmarshalNioMethod(msgParam, nioFields); } - /** Generates a single {@code finishUnmarshal} overload for the given {@code mode}. */ - private void generateFinishUnmarshalMethod(String methodName, String params, List fields, MarshalMode mode) { + /** Generates a single {@code unmarshal} overload for the given {@code mode}. */ + private void generateUnmarshalMethod(String methodName, String params, List fields, MarshalMode mode) { marshall.add(EMPTY); marshall.add(indentedLine(METHOD_JAVADOC)); @@ -263,9 +263,9 @@ private void generateFinishUnmarshalMethod(String methodName, String params, Lis if (marshallable) { if (mode == MarshalMode.FINISH_CACHE) - appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, clsLdr);"))); + appendBlock(body, List.of(indentedLine("msg.unmarshal(marshaller, clsLdr);"))); else - appendBlock(body, List.of(indentedLine("msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config()));"))); + appendBlock(body, List.of(indentedLine("msg.unmarshal(marshaller, U.resolveClassLoader(kctx.config()));"))); } appendMarshalledFinish(body, mode); @@ -283,13 +283,13 @@ private void generateFinishUnmarshalMethod(String methodName, String params, Lis marshall.add(indentedLine("}")); } - /** Generates the {@code finishUnmarshalNio} method for NIO-eligible {@code @Message} fields. */ - private void generateFinishUnmarshalNioMethod(String params, List nioFields) { + /** Generates the {@code unmarshalNio} method for NIO-eligible {@code @Message} fields. */ + private void generateUnmarshalNioMethod(String params, List nioFields) { marshall.add(EMPTY); marshall.add(indentedLine(METHOD_JAVADOC)); - marshall.add(indentedLine("@Override public void finishUnmarshalNio(" + params + ") throws IgniteCheckedException {")); + marshall.add(indentedLine("@Override public void unmarshalNio(" + params + ") throws IgniteCheckedException {")); indent++; @@ -313,7 +313,7 @@ private void appendMarshalledFieldsPrepare(List body) { } } - /** Generates the {@code Collection} build-up for a {@code @MarshalledObjects} field in prepareMarshal. */ + /** Generates the {@code Collection} build-up for a {@code @MarshalledObjects} field in marshal. */ private void appendObjectsPrepare(List body, VariableElement field) { MarshalledObjects ann = field.getAnnotation(MarshalledObjects.class); @@ -400,7 +400,7 @@ private void appendMapPrepare(List body, VariableElement field) { appendBlock(body, code); } - /** Generates {@code U.marshal} calls for all {@code @Marshalled} fields in prepareMarshal. */ + /** Generates {@code U.marshal} calls for all {@code @Marshalled} fields in marshal. */ private void appendMarshalledPrepare(List body) { forEachMarshalled((bytesAcc, objAcc) -> { List code = new ArrayList<>(); @@ -417,7 +417,7 @@ private void appendMarshalledPrepare(List body) { }, body); } - /** Generates {@code U.unmarshal} calls for all {@code @Marshalled} fields in finishUnmarshal. */ + /** Generates {@code U.unmarshal} calls for all {@code @Marshalled} fields in unmarshal. */ private void appendMarshalledFinish(List body, MarshalMode mode) { String clsLdr = mode == MarshalMode.FINISH_CACHE ? "clsLdr" : "U.resolveClassLoader(kctx.config())"; @@ -508,7 +508,7 @@ private void appendMarshalledObjectsFinish(List body) { } } - /** Generates the {@code for} loop body: per-element finishUnmarshal + try/catch add into the collection. */ + /** Generates the {@code for} loop body: per-element unmarshal + try/catch add into the collection. */ private List collectionFinishForBlock(VariableElement wireField, String colField, String arrField, String fieldName) { String compName = arrayComponentName(wireField); TypeMirror compType = ((ArrayType)wireField.asType()).getComponentType(); @@ -777,7 +777,7 @@ private List codeFor(TypeMirror t, String accessor, MarshalMode mode) { return List.of(); } - /** Generates a null-guarded {@code MessageMarshaller.prepareMarshal/finishUnmarshal} call. */ + /** Generates a null-guarded {@code MessageMarshaller.marshal/unmarshal} call. */ private List marshallMessage(String accessor, MarshalMode mode) { List code = new ArrayList<>(); @@ -787,13 +787,13 @@ private List marshallMessage(String accessor, MarshalMode mode) { switch (mode) { case PREPARE: - code.add(indentedLine("MessageMarshaller.prepareMarshal(kctx.messageFactory(), %s, kctx, ctx);", accessor)); + code.add(indentedLine("MessageMarshaller.marshal(kctx.messageFactory(), %s, kctx, ctx);", accessor)); break; case FINISH: - code.add(indentedLine("MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx);", accessor)); + code.add(indentedLine("MessageMarshaller.unmarshal(kctx.messageFactory(), %s, kctx);", accessor)); break; case FINISH_CACHE: - code.add(indentedLine("MessageMarshaller.finishUnmarshal(kctx.messageFactory(), %s, kctx, ctx, clsLdr);", accessor)); + code.add(indentedLine("MessageMarshaller.unmarshal(kctx.messageFactory(), %s, kctx, ctx, clsLdr);", accessor)); break; } @@ -802,7 +802,7 @@ private List marshallMessage(String accessor, MarshalMode mode) { return code; } - /** Generates a null-and-ctx-guarded {@code prepareMarshal/finishUnmarshal} call on a {@code CacheObject}. */ + /** Generates a null-and-ctx-guarded {@code marshal/unmarshal} call on a {@code CacheObject}. */ private List marshallCacheObject(String accessor, MarshalMode mode) { if (mode == MarshalMode.FINISH) return List.of(); @@ -814,8 +814,8 @@ private List marshallCacheObject(String accessor, MarshalMode mode) { indent++; code.add(mode == MarshalMode.PREPARE - ? indentedLine("%s.prepareMarshal(ctx);", accessor) - : indentedLine("%s.finishUnmarshal(ctx, clsLdr);", accessor)); + ? indentedLine("%s.marshal(ctx);", accessor) + : indentedLine("%s.unmarshal(ctx, clsLdr);", accessor)); indent--; diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/NioField.java b/modules/codegen/src/main/java/org/apache/ignite/internal/NioField.java index cac0e7e5b3585..610a551d19765 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/NioField.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/NioField.java @@ -23,7 +23,7 @@ import java.lang.annotation.Target; /** - * Marks a {@link Message}-typed {@link Order @Order} field whose {@code finishUnmarshal} runs in the NIO thread + * Marks a {@link Message}-typed {@link Order @Order} field whose {@code unmarshalNio} runs in the NIO thread * rather than being deferred to the worker thread. */ @Retention(RetentionPolicy.CLASS) diff --git a/modules/control-utility/src/test/java/org/apache/ignite/util/CdcResendCommandTest.java b/modules/control-utility/src/test/java/org/apache/ignite/util/CdcResendCommandTest.java index e259864e68b50..4d6512d15f931 100644 --- a/modules/control-utility/src/test/java/org/apache/ignite/util/CdcResendCommandTest.java +++ b/modules/control-utility/src/test/java/org/apache/ignite/util/CdcResendCommandTest.java @@ -161,7 +161,7 @@ public void testResendConflictVersion() throws Exception { // Override data from clusterId=2. KeyCacheObject key = new KeyCacheObjectImpl(0, null, cachex.affinity().partition(0)); CacheObject val = new CacheObjectImpl(1, null); - val.prepareMarshal(cachex.context().cacheObjectContext()); + val.marshal(cachex.context().cacheObjectContext()); GridCacheVersion conflict = new GridCacheVersion(1, 0, 1, (byte)2); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java index 37e23f5b8b9a0..376d05db9db07 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java @@ -451,7 +451,7 @@ public AffinityTopologyVersion topologyVersion() { /** * @param marsh Marshaller. */ - public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + public void marshal(Marshaller marsh) throws IgniteCheckedException { jobBytes = U.marshal(marsh, job); topPredBytes = U.marshal(marsh, topPred); siblingsBytes = U.marshal(marsh, siblings); @@ -463,7 +463,7 @@ public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { * @param marsh Marshaller. * @param ldr Class loader. */ - public void finishUnmarshal(Marshaller marsh, ClassLoader ldr) throws IgniteCheckedException { + public void unmarshal(Marshaller marsh, ClassLoader ldr) throws IgniteCheckedException { assert top != null || topPredBytes != null; assert sesAttrsBytes != null || !sesFullSup; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridTopicMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/GridTopicMessage.java index 5ec7fed797186..35547f804aacd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridTopicMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTopicMessage.java @@ -61,13 +61,13 @@ public static int ordinal(GridTopicMessage msg) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { if (ord < 0 && topic != null) topicBytes = U.marshal(marsh, topic); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (ord < 0 && topicBytes != null) { topic = U.unmarshal(marsh, topicBytes, clsLdr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java index b497e76ae845c..c74922f3d4a07 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java @@ -54,7 +54,7 @@ public ErrorMessage(@Nullable Throwable err) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { if (err == null) return; @@ -67,7 +67,7 @@ public ErrorMessage(@Nullable Throwable err) { } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (errBytes == null) return; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index e3fb4bf47eeac..5b6085686da72 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1189,12 +1189,12 @@ private void onChannelOpened0(UUID rmtNodeId, GridIoMessage initMsg, Channel cha byte plc = initMsg.policy(); - MessageMarshaller.finishUnmarshalNio(ctx.messageFactory(), initMsg, ctx); + MessageMarshaller.unmarshalNio(ctx.messageFactory(), initMsg, ctx); pools.poolForPolicy(plc).execute(new Runnable() { @Override public void run() { try { - MessageMarshaller.finishUnmarshal(ctx.messageFactory(), initMsg, ctx); + MessageMarshaller.unmarshal(ctx.messageFactory(), initMsg, ctx); processOpenedChannel(initMsg.topic(), rmtNodeId, (SessionChannelMessage)initMsg.message(), (SocketChannel)channel); @@ -1224,7 +1224,7 @@ private void onMessage0(UUID nodeId, GridIoMessage msg, IgniteRunnable msgC) thr assert nodeId != null; assert msg != null; - MessageMarshaller.finishUnmarshalNio(ctx.messageFactory(), msg, ctx); + MessageMarshaller.unmarshalNio(ctx.messageFactory(), msg, ctx); Lock busyLock0 = busyLock.readLock(); @@ -1467,19 +1467,19 @@ private void processRegularMessage0(GridIoMessage msg, UUID nodeId) { if (lsnr == null) return; - finishUnmarshalPayload(msg); + unmarshalPayload(msg); invokeListener(msg.policy(), lsnr, nodeId, msg.message(), secSubjId(msg)); } /** */ - private void finishUnmarshalPayload(GridIoMessage msg) { + private void unmarshalPayload(GridIoMessage msg) { // Unmarshalled by GridCacheIoManager with the deployment loader; the loader here can't see its peer classes. if (msg.message() instanceof GridCacheMessage) return; try { - MessageMarshaller.finishUnmarshal(ctx.messageFactory(), msg.message(), ctx); + MessageMarshaller.unmarshal(ctx.messageFactory(), msg.message(), ctx); } catch (IgniteCheckedException e) { throw new IgniteException("Failed to unmarshal message payload", e); @@ -1961,7 +1961,7 @@ private IgniteInternalFuture openChannel( false ); - MessageMarshaller.prepareMarshal(ctx.messageFactory(), ioMsg, ctx, null); + MessageMarshaller.marshal(ctx.messageFactory(), ioMsg, ctx, null); try { return ((TcpCommunicationSpi)(CommunicationSpi)getSpi()).openChannel(node, ioMsg); @@ -2031,7 +2031,7 @@ else if (async) ackC.apply(null); } else { - MessageMarshaller.prepareMarshal(ctx.messageFactory(), ioMsg, ctx, null); + MessageMarshaller.marshal(ctx.messageFactory(), ioMsg, ctx, null); sendMarshalled(node, ioMsg, topic, msg, plc, ackC); } @@ -2083,7 +2083,7 @@ private void sendToMany(Collection nodes, Object topic, M if (ioMsg == null) { ioMsg = createGridIoMessage(topic, msg, plc, ordered, timeout, skipOnTimeout); - MessageMarshaller.prepareMarshal(ctx.messageFactory(), ioMsg, ctx, null); + MessageMarshaller.marshal(ctx.messageFactory(), ioMsg, ctx, null); } sendMarshalled(node, ioMsg, topic, msg, plc, null); @@ -3860,7 +3860,7 @@ void unwind(GridMessageListener lsnr) { MTC.span().addTag(SpanTags.MESSAGE, () -> traceName(fmc.message)); - finishUnmarshalPayload(mc.message); + unmarshalPayload(mc.message); invokeListener(mc.message.policy(), lsnr, nodeId, mc.message.message(), secSubjId(mc.message)); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java index c41856b0fb5d2..022b929519e06 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java @@ -199,13 +199,13 @@ String userVersion() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { if (filter != null) filterBytes = U.marshal(marsh, filter); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader ldr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader ldr) throws IgniteCheckedException { // No-op. } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java index 2119c99b9c1bb..608d6fdc8868b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java @@ -56,7 +56,7 @@ public CacheObjectByteArrayImpl(byte[] val) { } /** {@inheritDoc} */ - @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { + @Override public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { // No-op. } @@ -118,7 +118,7 @@ public CacheObjectByteArrayImpl(byte[] val) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException { + @Override public void marshal(CacheObjectValueContext ctx) throws IgniteCheckedException { // No-op. } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java index fabf36ac20a08..cc4be8e76e5cf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java @@ -105,7 +105,7 @@ else if (ctx.isPeerClassLoadingEnabled()) } /** {@inheritDoc} */ - @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException { + @Override public void marshal(CacheObjectValueContext ctx) throws IgniteCheckedException { assert val != null || valBytes != null; if (valBytes == null) @@ -113,7 +113,7 @@ else if (ctx.isPeerClassLoadingEnabled()) } /** {@inheritDoc} */ - @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { + @Override public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { assert val != null || valBytes != null; if (val == null && ctx.storeValue()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectNotResolvedException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectNotResolvedException.java index e8cb4f32f05ed..09440bf117603 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectNotResolvedException.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectNotResolvedException.java @@ -19,7 +19,7 @@ /** * Thrown by {@link KeyCacheObjectImpl#hashCode()} when the object has not been deserialized yet, - * which happens when the owning cache has been removed before {@code finishUnmarshal} could complete. + * which happens when the owning cache has been removed before {@code unmarshal} could complete. */ public class CacheObjectNotResolvedException extends RuntimeException { /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DeployableMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DeployableMessage.java index 5d4fb9d92faff..dd79f3b87315a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DeployableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DeployableMessage.java @@ -22,7 +22,7 @@ /** * A {@link GridCacheMessage} with custom deployment logic that cannot be inferred from field types (conditional * deployment, non-standard accessors, etc.). The generated {@code *Deployer} calls {@link #prepareDeployment} after - * its inferred field deployment, mirroring how a generated marshaller calls {@code MarshallableMessage#prepareMarshal}. + * its inferred field deployment, mirroring how a generated marshaller calls {@code MarshallableMessage#marshal}. */ public interface DeployableMessage { /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java index 293db4c0241b8..9896ce1bd989a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java @@ -192,7 +192,7 @@ public int marshalledSize(CacheObjectContext ctx) throws IgniteCheckedException } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { if (expireTime == 0) expireTime = -1; else { @@ -204,7 +204,7 @@ public int marshalledSize(CacheObjectContext ctx) throws IgniteCheckedException } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { long remaining = expireTime; expireTime = remaining < 0 ? 0 : U.currentTimeMillis() + remaining; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index 6da49c1f7b7d2..2a7fd2162657b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -1552,7 +1552,7 @@ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) { log.debug("Set P2P context [senderId=" + nodeId + ", msg=" + cacheMsg + ']'); } - MessageMarshaller.finishUnmarshal(cctx.kernalContext().messageFactory(), + MessageMarshaller.unmarshal(cctx.kernalContext().messageFactory(), cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); } catch (IgniteCheckedException e) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java index d2ead2bb39d93..e50b225d1ef93 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java @@ -282,12 +282,12 @@ protected void value(@Nullable CacheObject val) { lockEntry(); try { - key.prepareMarshal(cctx.cacheObjectContext()); + key.marshal(cctx.cacheObjectContext()); kb = key.valueBytes(cctx.cacheObjectContext()); if (val != null) { - val.prepareMarshal(cctx.cacheObjectContext()); + val.marshal(cctx.cacheObjectContext()); vb = val.valueBytes(cctx.cacheObjectContext()); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index e35c1c31add8d..d5d6d94b5848d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -281,7 +281,7 @@ final void prepareInfoDeployment(GridCacheEntryInfo info, CacheObject val = info.value(); if (val != null) { - val.finishUnmarshal(cacheObjCtx, ctx.deploy().globalLoader()); + val.unmarshal(cacheObjCtx, ctx.deploy().globalLoader()); prepareObjectDeployment(val.value(cacheObjCtx, false), ctx); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java index f9767ceda411f..8b5deb9a26d67 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java @@ -97,7 +97,7 @@ static void forceDeploymentInfo(GridCacheMessage msg, GridCacheSharedContext ctx) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java index e656a32892482..721eb3d813994 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java @@ -115,13 +115,13 @@ public KeyCacheObjectImpl(Object val, byte[] valBytes, int part) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException { + @Override public void marshal(CacheObjectValueContext ctx) throws IgniteCheckedException { if (valBytes == null) valBytes = ctx.marshal(val); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { + @Override public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { if (val == null) { assert valBytes != null; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 4b467a68d1041..d9e7abdba6fcb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -475,7 +475,7 @@ else if (conflictVers != null) } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { if (forceTransformBackups) { if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) invokeArgsBytes = Arrays.asList(marshallInvokeArguments(invokeArgs, marsh)); @@ -489,7 +489,7 @@ else if (conflictVers != null) } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (forceTransformBackups) { if (entryProcessors == null) entryProcessors = unmarshalCollection(entryProcessorsBytes, marsh, clsLdr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index 23ba2731d7d05..3f6ae0bfac110 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -351,7 +351,7 @@ else if (conflictVers != null) } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { if (expiryPlc != null && expiryPlcBytes == null) expiryPlcBytes = U.marshal(marsh, new IgniteExternalizableExpiryPolicy(expiryPlc)); @@ -365,7 +365,7 @@ else if (conflictVers != null) } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (expiryPlcBytes != null && expiryPlc == null) expiryPlc = U.unmarshal(marsh, expiryPlcBytes, clsLdr); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index c49917c951488..02a5668ce425b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -172,13 +172,13 @@ public GridNearAtomicSingleUpdateInvokeRequest() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) invokeArgsBytes = Arrays.asList(marshallInvokeArguments(invokeArgs, marsh)); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (invokeArgsBytes != null && invokeArgs == null) invokeArgs = unmarshalInvokeArguments(invokeArgsBytes.toArray(new byte[invokeArgsBytes.size()][]), marsh, clsLdr); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index 49543242acce5..b87878d849ad0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -388,7 +388,7 @@ public void rebalanced(boolean rebalanced) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { if (!F.isEmpty(parts) && locParts == null) locParts = copyPartitionsMap(parts); } @@ -408,7 +408,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (locParts != null && parts == null) { parts = copyPartitionsMap(locParts); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index ff9f2016f3464..2fe5493e19696 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -292,12 +292,12 @@ public void exchangeStartTime(long exchangeStartTime) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { // No-op. } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (dupPartsData != null) { assert parts != null; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java index 131381d3ec1bf..d73e1ea05b3c9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java @@ -1072,7 +1072,7 @@ private void notifyCallback0(UUID nodeId, } } - MessageMarshaller.finishUnmarshal( + MessageMarshaller.unmarshal( cctx.kernalContext().messageFactory(), e, cctx.kernalContext(), null, cctx.deploy().globalLoader()); Collection> evts = handleEvent(ctx, e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java index 1680b9619a2ef..b711e97cccc41 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java @@ -418,11 +418,11 @@ public void onEntryUpdated( oldVal = (CacheObject)cctx.unwrapTemporary(oldVal); if (oldVal != null) - oldVal.finishUnmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader()); + oldVal.unmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader()); } if (newVal != null) - newVal.finishUnmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader()); + newVal.unmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader()); initialized = true; } @@ -484,7 +484,7 @@ public void onEntryExpired(GridCacheEntryEx e, KeyCacheObject key, CacheObject o oldVal = (CacheObject)cctx.unwrapTemporary(oldVal); if (oldVal != null) - oldVal.finishUnmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader()); + oldVal.unmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader()); initialized = true; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index 6a90694ab45ad..0dc1cf07781b1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -1040,7 +1040,7 @@ public void filtersSet(boolean filtersSet) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { boolean transfer = expiryPlc != null && expiryPlc != ctx.expiry(); if (transfer) { @@ -1052,7 +1052,7 @@ public void filtersSet(boolean filtersSet) { } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (filters == null) filters = CU.empty0(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index ec1b3ec7109e2..9e4a88baa7029 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -3504,7 +3504,7 @@ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) { return; try { - MessageMarshaller.finishUnmarshal(cctx.kernalContext().messageFactory(), + MessageMarshaller.unmarshal(cctx.kernalContext().messageFactory(), cacheMsg, cctx.kernalContext(), null, cctx.deploy().globalLoader()); } catch (IgniteCheckedException e) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java index d0449f2d0d326..85678108bd3b3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java @@ -381,7 +381,7 @@ public void initDiagnosticListeners() throws IgniteCheckedException { IgniteDiagnosticRequest infoReq = (IgniteDiagnosticRequest)msg; try { - MessageMarshaller.finishUnmarshal(ctx.messageFactory(), infoReq, ctx, null, U.gridClassLoader()); + MessageMarshaller.unmarshal(ctx.messageFactory(), infoReq, ctx, null, U.gridClassLoader()); } catch (IgniteCheckedException e) { U.error(diagnosticLog, "Failed to ummarshall diagnostic request [msg=" + infoReq + "]", e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java index 7291e631c2f31..efc65d8d35431 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java @@ -975,7 +975,7 @@ private AbstractContinuousMessage createStartMessage(UUID routineId, reqData.deploymentInfo(dep); } - reqData.prepareMarshal(ctx); + reqData.marshal(ctx); if (!immutableDiscoCustomMsg) { StartRoutineDiscoveryMessage msg = new StartRoutineDiscoveryMessage(routineId, reqData, Mode.MUTABLE); @@ -1342,7 +1342,7 @@ private void processStartRequestMutable(ClusterNode node, StartRoutineDiscoveryM IgniteCheckedException err = null; try { - data.finishUnmarshal(ctx, node.id()); + data.unmarshal(ctx, node.id()); } catch (IgniteCheckedException e) { U.error(log, "Failed to unmarshal start request data [nodeId=" + node.id() + @@ -1484,7 +1484,7 @@ private void processStartRequestImmutable(final AffinityTopologyVersion topVer, Exception err = null; try { - reqData.finishUnmarshal(ctx, snd.id()); + reqData.unmarshal(ctx, snd.id()); } catch (IgniteCheckedException e) { err = e; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java index 99c39201500af..9571c231bbf9a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java @@ -171,7 +171,7 @@ public void autoUnsubscribe(boolean autoUnsubscribe) { } /** */ - public void prepareMarshal(GridKernalContext ctx) throws IgniteCheckedException { + public void marshal(GridKernalContext ctx) throws IgniteCheckedException { if (hnd != null) { if (ctx.config().isPeerClassLoadingEnabled()) { // Handle peer deployment for other handler-specific objects. @@ -186,7 +186,7 @@ public void prepareMarshal(GridKernalContext ctx) throws IgniteCheckedException } /** */ - public void finishUnmarshal(GridKernalContext ctx, UUID sndId) throws IgniteCheckedException { + public void unmarshal(GridKernalContext ctx, UUID sndId) throws IgniteCheckedException { if (ctx.config().isPeerClassLoadingEnabled() && clsName != null) { GridDeployment dep = ctx.deploy().getGlobalDeployment(depInfo.deployMode(), clsName, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java index 1b795b2faf84a..9a030b8e3354f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java @@ -1931,12 +1931,12 @@ private void submit( else { try { for (DataStreamerEntry e : entries) { - e.getKey().prepareMarshal(cacheObjCtx); + e.getKey().marshal(cacheObjCtx); CacheObject val = e.getValue(); if (val != null) - val.prepareMarshal(cacheObjCtx); + val.marshal(cacheObjCtx); } if (updaterBytes == null) { @@ -2253,7 +2253,7 @@ protected static class IsolatedUpdater implements StreamReceiver { final GridCacheContext cctx = cache.context(); for (DataStreamerEntry e : col) { - e.getKey().finishUnmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader()); + e.getKey().unmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader()); CacheObject val = e.getValue(); if (val != null) { checkSecurityPermission(SecurityPermission.CACHE_PUT); - val.finishUnmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader()); + val.unmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader()); } else checkSecurityPermission(SecurityPermission.CACHE_REMOVE); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java index 3e584ed0e4842..ec0096383bf2b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java @@ -1250,7 +1250,7 @@ public void processJobExecuteRequest(ClusterNode node, final GridJobExecuteReque try { if (!loc) - req.finishUnmarshal(marsh, U.resolveClassLoader(dep.classLoader(), ctx.config())); + req.unmarshal(marsh, U.resolveClassLoader(dep.classLoader(), ctx.config())); // Note that we unmarshal session/job attributes here with proper class loader. GridTaskSessionImpl taskSes = ctx.session().createTaskSession( diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageCasMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageCasMessage.java index d40661bbadcad..95f3717fb5b63 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageCasMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageCasMessage.java @@ -75,16 +75,16 @@ public boolean matches() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { - super.prepareMarshal(marsh); + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { + super.marshal(marsh); if (expVal != null && expValBytes == null) expValBytes = U.marshal(marsh, expVal); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh) throws IgniteCheckedException { - super.finishUnmarshal(marsh); + @Override public void unmarshal(Marshaller marsh) throws IgniteCheckedException { + super.unmarshal(marsh); if (expValBytes != null && expVal == null) expVal = U.unmarshal(marsh, expValBytes, U.gridClassLoader()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageImpl.java index ad9022f2e9747..990a26d9b2386 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageImpl.java @@ -1018,7 +1018,7 @@ private GridFutureAdapter startWrite(String key, @Nullable Serializable val) DistributedMetaStorageUpdateMessage msg = new DistributedMetaStorageUpdateMessage(reqId, key, val); - msg.prepareMarshal(marshaller); + msg.marshal(marshaller); ctx.discovery().sendCustomEvent(msg); @@ -1039,7 +1039,7 @@ private GridFutureAdapter startCas(String key, @Nullable Serializable e DistributedMetaStorageCasMessage msg = new DistributedMetaStorageCasMessage(reqId, key, expVal, newVal); - msg.prepareMarshal(marshaller); + msg.marshal(marshaller); ctx.discovery().sendCustomEvent(msg); @@ -1281,7 +1281,7 @@ private void completeCas( Serializable oldVal = bridge.read(msg.key()); - msg.finishUnmarshal(marshaller); + msg.unmarshal(marshaller); if (!Objects.deepEquals(oldVal, msg.expectedValue())) { msg.setMatches(false); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageUpdateMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageUpdateMessage.java index b836fec1032d6..07e645795c6e7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageUpdateMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageUpdateMessage.java @@ -84,13 +84,13 @@ public byte[] valueBytes() { } /** @param marsh Marshaller. */ - public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + public void marshal(Marshaller marsh) throws IgniteCheckedException { if (val != null && valBytes == null) valBytes = U.marshal(marsh, val); } /** @param marsh Marshaller. */ - public void finishUnmarshal(Marshaller marsh) throws IgniteCheckedException { + public void unmarshal(Marshaller marsh) throws IgniteCheckedException { // No-op. } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java index d21de03723432..fe419cefaf637 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java @@ -1416,7 +1416,7 @@ private void sendRequest(ComputeJobResult res) { if (loc) ctx.job().processJobExecuteRequest(ctx.discovery().localNode(), req); else { - req.prepareMarshal(marsh); + req.marshal(marsh); byte plc; diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java index d15d50b625f9d..5b6a36a3cc9f7 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java @@ -23,11 +23,11 @@ /** A {@link Message} requiring a custom marshal/unmarshal step via {@link Marshaller}. */ public interface MarshallableMessage extends Message { /** @param marsh Marshaller for pre-marshalling. */ - public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException; + public void marshal(Marshaller marsh) throws IgniteCheckedException; /** * @param marsh Marshaller for post-unmarshalling. * @param clsLdr Class loader for unmarshalling. */ - public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException; + public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException; } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index 8c957bd4f9ec7..73e2c6a1fc853 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -29,7 +29,7 @@ import org.jetbrains.annotations.Nullable; /** - * Handles {@code prepareMarshal}/{@code finishUnmarshal} for a {@link Message} type that requires custom serialization. + * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that requires custom serialization. * * @param Message type. */ @@ -42,7 +42,7 @@ public interface MessageMarshaller { * @param nested Cache object context, or {@code null} if not applicable. * @throws IgniteCheckedException If marshalling failed. */ - public void prepareMarshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested) + public void marshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested) throws IgniteCheckedException; /** @@ -54,7 +54,7 @@ public void prepareMarshal(M msg, GridKernalContext kctx, @Nullable CacheObjectC * @param clsLdr Class loader for unmarshalling. * @throws IgniteCheckedException If unmarshalling failed. */ - public void finishUnmarshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested, ClassLoader clsLdr) + public void unmarshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException; /** @@ -64,7 +64,7 @@ public void finishUnmarshal(M msg, GridKernalContext kctx, @Nullable CacheObject * @param kctx Kernal context. * @throws IgniteCheckedException If unmarshalling failed. */ - public void finishUnmarshal(M msg, GridKernalContext kctx) throws IgniteCheckedException; + public void unmarshal(M msg, GridKernalContext kctx) throws IgniteCheckedException; /** * Unmarshals only {@code @NioField}-annotated fields in the NIO/IO thread. No-op by default. @@ -73,11 +73,11 @@ public void finishUnmarshal(M msg, GridKernalContext kctx, @Nullable CacheObject * @param kctx Kernal context. * @throws IgniteCheckedException If unmarshalling failed. */ - default void finishUnmarshalNio(M msg, GridKernalContext kctx) throws IgniteCheckedException { + default void unmarshalNio(M msg, GridKernalContext kctx) throws IgniteCheckedException { } /** - * Null-safe {@code finishUnmarshalNio} — skips when no marshaller is registered. + * Null-safe {@code unmarshalNio} — skips when no marshaller is registered. * * @param Message type. * @param factory Message factory. @@ -85,16 +85,16 @@ default void finishUnmarshalNio(M msg, GridKernalContext kctx) throws IgniteChec * @param kctx Kernal context. * @throws IgniteCheckedException If unmarshalling failed. */ - static void finishUnmarshalNio(MessageFactory factory, M msg, GridKernalContext kctx) + static void unmarshalNio(MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { MessageMarshaller m = resolve(factory, msg); if (m != null) - m.finishUnmarshalNio(msg, kctx); + m.unmarshalNio(msg, kctx); } /** - * Null-safe {@code prepareMarshal} — skips when no marshaller is registered. + * Null-safe {@code marshal} — skips when no marshaller is registered. * * @param Message type. * @param factory Message factory. @@ -103,16 +103,16 @@ static void finishUnmarshalNio(MessageFactory factory, M msg * @param nested Cache object context, or {@code null} if not applicable. * @throws IgniteCheckedException If marshalling failed. */ - static void prepareMarshal(MessageFactory factory, M msg, GridKernalContext kctx, + static void marshal(MessageFactory factory, M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested) throws IgniteCheckedException { MessageMarshaller m = resolve(factory, msg); if (m != null) - m.prepareMarshal(msg, kctx, nested); + m.marshal(msg, kctx, nested); } /** - * Null-safe {@code finishUnmarshal} — skips when no marshaller is registered. + * Null-safe {@code unmarshal} — skips when no marshaller is registered. * * @param Message type. * @param factory Message factory. @@ -122,18 +122,18 @@ static void prepareMarshal(MessageFactory factory, M msg, Gr * @param clsLdr Class loader for unmarshalling. * @throws IgniteCheckedException If unmarshalling failed. */ - static void finishUnmarshal(MessageFactory factory, M msg, GridKernalContext kctx, + static void unmarshal(MessageFactory factory, M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { assert !Dedup.ENABLED || Dedup.firstUnmarshal(msg, true) : "Finish-unmarshalled more than once: " + msg.getClass().getName(); MessageMarshaller m = resolve(factory, msg); if (m != null) - m.finishUnmarshal(msg, kctx, nested, clsLdr); + m.unmarshal(msg, kctx, nested, clsLdr); } /** - * Null-safe {@code finishUnmarshal} (cache-free) — skips when no marshaller is registered. + * Null-safe {@code unmarshal} (cache-free) — skips when no marshaller is registered. * * @param Message type. * @param factory Message factory. @@ -141,14 +141,14 @@ static void finishUnmarshal(MessageFactory factory, M msg, G * @param kctx Kernal context. * @throws IgniteCheckedException If unmarshalling failed. */ - static void finishUnmarshal(MessageFactory factory, M msg, GridKernalContext kctx) + static void unmarshal(MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { assert !Dedup.ENABLED || Dedup.firstUnmarshal(msg, false) : "Finish-unmarshalled more than once: " + msg.getClass().getName(); MessageMarshaller m = resolve(factory, msg); if (m != null) - m.finishUnmarshal(msg, kctx); + m.unmarshal(msg, kctx); } /** @return the marshaller registered for {@code msg}'s direct type, or {@code null} if none. */ diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/SerializableDataBagItemWrapper.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/SerializableDataBagItemWrapper.java index f688c6b91b651..1ca007e1f7c56 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/SerializableDataBagItemWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/SerializableDataBagItemWrapper.java @@ -76,13 +76,13 @@ private T unwrap() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { if (data != null) dataBytes = U.marshal(marsh, data); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (dataBytes != null) { try { data = U.unmarshal(marsh, dataBytes, clsLdr); diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java index 75b3886989a50..4cd1def04c961 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java @@ -197,7 +197,7 @@ T readMessage() throws IgniteCheckedException, IOException { } while (!finished); - MessageMarshaller.finishUnmarshal(spi.messageFactory(), msg, ((IgniteEx)spi.ignite()).context()); + MessageMarshaller.unmarshal(spi.messageFactory(), msg, ((IgniteEx)spi.ignite()).context()); return (T)msg; } @@ -241,7 +241,7 @@ public Socket socket() { * @throws IOException If serialization fails. */ void serializeMessage(Message m, OutputStream out) throws IOException, IgniteCheckedException { - MessageMarshaller.prepareMarshal(spi.messageFactory(), m, ((IgniteEx)spi.ignite()).context(), null); + MessageMarshaller.marshal(spi.messageFactory(), m, ((IgniteEx)spi.ignite()).context(), null); msgWriter.reset(); msgWriter.setBuffer(msgBuf); diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java index 636c96cacaf2d..a3bf5a7220c15 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java @@ -223,12 +223,12 @@ public TcpDiscoveryNode(UUID id, } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { metricsMsg = new NodeMetricsMessage(metrics); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (metricsMsg != null) metrics = new ClusterMetricsSnapshot(metricsMsg); diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractTraceableMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractTraceableMessage.java index 2df35f55ce64a..75db3d55485f3 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractTraceableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractTraceableMessage.java @@ -83,12 +83,12 @@ public Object readResolve() { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { spanContainerBytes = spanContainer == null ? null : spanContainer.serializedSpanBytes(); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { if (spanContainerBytes != null) spanContainer.serializedSpanBytes(spanContainerBytes); } diff --git a/modules/core/src/test/java/org/apache/ignite/cdc/CdcCacheVersionTest.java b/modules/core/src/test/java/org/apache/ignite/cdc/CdcCacheVersionTest.java index aa33d3859b330..1d42ed57ece25 100644 --- a/modules/core/src/test/java/org/apache/ignite/cdc/CdcCacheVersionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cdc/CdcCacheVersionTest.java @@ -416,7 +416,7 @@ private void addConflictData( KeyCacheObject key = new KeyCacheObjectImpl(i, null, intCache.affinity().partition(i)); CacheObject val = new CacheObjectImpl(createUser(i), null); - val.prepareMarshal(intCache.context().cacheObjectContext()); + val.marshal(intCache.context().cacheObjectContext()); drMap.put(key, new GridCacheDrInfo(val, new GridCacheVersion(1, i, 1, OTHER_CLUSTER_ID))); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java index 5d914886a46dc..cff11ed735ec3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java @@ -284,13 +284,13 @@ private TestCacheObject(Object val) { } /** {@inheritDoc} */ - @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) + @Override public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ - @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException { + @Override public void marshal(CacheObjectValueContext ctx) throws IgniteCheckedException { throw new UnsupportedOperationException(); } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MarshallerCacheFreeFinishTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MarshallerCacheFreeUnmarshalTest.java similarity index 82% rename from modules/core/src/test/java/org/apache/ignite/internal/codegen/MarshallerCacheFreeFinishTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/codegen/MarshallerCacheFreeUnmarshalTest.java index 858163384d487..99d6073aa9dfc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MarshallerCacheFreeFinishTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MarshallerCacheFreeUnmarshalTest.java @@ -47,31 +47,31 @@ * mutation is the one thing that must not run in both passes, and the generator keeps it in the cache-aware pass only. * *

That is exactly what this rule checks — purely the mutating side effect, not the fields: the cache-free - * {@code finishUnmarshal(msg, kctx)} overload of every generated marshaller must not call {@link Collection#add} or + * {@code unmarshal(msg, kctx)} overload of every generated marshaller must not call {@link Collection#add} or * {@link Map#put}. Assignments are left unchecked (they can't break); a generator regression that moved an append into * the cache-free pass — a real double-add the runtime check can't see, since it allows both passes — fails here. */ -public class MarshallerCacheFreeFinishTest { +public class MarshallerCacheFreeUnmarshalTest { /** - * The two-arg, cache-free {@code finishUnmarshal} overload. The cache-aware overload takes a cache context and a - * class loader (four args); {@code finishUnmarshalNio} shares the two-arg shape, so the name is matched too. + * The two-arg, cache-free {@code unmarshal} overload. The cache-aware overload takes a cache context and a + * class loader (four args); {@code unmarshalNio} shares the two-arg shape, so the name is matched too. */ - private static final DescribedPredicate CACHE_FREE_FINISH = - new DescribedPredicate<>("cache-free finishUnmarshal(msg, kctx)") { + private static final DescribedPredicate CACHE_FREE_UNMARSHAL = + new DescribedPredicate<>("cache-free unmarshal(msg, kctx)") { @Override public boolean test(JavaCodeUnit unit) { List params = unit.getRawParameterTypes(); - return "finishUnmarshal".equals(unit.getName()) + return "unmarshal".equals(unit.getName()) && params.size() == 2 && params.get(1).isEquivalentTo(GridKernalContext.class); } }; - /** A {@link Collection#add} or {@link Map#put} append made from within the cache-free {@code finishUnmarshal}. */ - private static final DescribedPredicate CACHE_FREE_FINISH_APPEND = - new DescribedPredicate<>("Collection.add / Map.put from the cache-free finishUnmarshal pass") { + /** A {@link Collection#add} or {@link Map#put} append made from within the cache-free {@code unmarshal}. */ + private static final DescribedPredicate CACHE_FREE_UNMARSHAL_APPEND = + new DescribedPredicate<>("Collection.add / Map.put from the cache-free unmarshal pass") { @Override public boolean test(JavaMethodCall call) { - if (!CACHE_FREE_FINISH.test(call.getOrigin())) + if (!CACHE_FREE_UNMARSHAL.test(call.getOrigin())) return false; JavaClass owner = call.getTarget().getOwner(); @@ -93,16 +93,16 @@ public static void importClasses() { .importPackages("org.apache.ignite"); } - /** The cache-free {@code finishUnmarshal} overload must not append to collections/maps; those are cache-pass only. */ + /** The cache-free {@code unmarshal} overload must not append to collections/maps; those are cache-pass only. */ @Test public void cacheFreeFinishDoesNotAppendToCollections() { ArchRule rule = noClasses() .that() .areAssignableTo(MessageMarshaller.class) .should() - .callMethodWhere(CACHE_FREE_FINISH_APPEND) + .callMethodWhere(CACHE_FREE_UNMARSHAL_APPEND) .because("@MarshalledCollection/@MarshalledMap appends are non-idempotent and run only in the cache-aware " + - "finishUnmarshal pass; an append in the cache-free pass would double-add when both passes run, which " + + "unmarshal pass; an append in the cache-free pass would double-add when both passes run, which " + "the mode-aware unmarshal-once check (MessageMarshaller.Dedup) permits and cannot catch."); rule.check(classes); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java index bf868bc8fa312..fa0f4b5773234 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java @@ -47,8 +47,8 @@ *

  • {@link MessageSerializer#readFrom(org.apache.ignite.plugin.extensions.communication.MessageFactory, * org.apache.ignite.plugin.extensions.communication.Message, * org.apache.ignite.plugin.extensions.communication.MessageReader)}
  • - *
  • {@link MessageMarshaller#prepareMarshal}
  • - *
  • {@link MessageMarshaller#finishUnmarshal}
  • + *
  • {@link MessageMarshaller#marshal}
  • + *
  • {@link MessageMarshaller#unmarshal}
  • *
  • static {@code GridCacheMessageDeployer.prepareDeployment(factory, msg, ctx)}
  • * * @@ -107,12 +107,12 @@ public void serializerInstanceMethodsOnlyCalledFromImplementations() { } /** - * Instance methods of {@link MessageMarshaller} ({@code prepareMarshal}, {@code finishUnmarshal}) must + * Instance methods of {@link MessageMarshaller} ({@code marshal}, {@code unmarshal}) must * only be called from within classes that themselves implement {@link MessageMarshaller} — i.e. generated * marshallers and hand-written wrappers that delegate to the underlying marshaller. * * Everyone else must use the static - * {@link MessageMarshaller#prepareMarshal} and {@link MessageMarshaller#finishUnmarshal} methods. + * {@link MessageMarshaller#marshal} and {@link MessageMarshaller#unmarshal} methods. */ @Test public void marshallerInstanceMethodsOnlyCalledFromImplementations() { @@ -124,8 +124,8 @@ public void marshallerInstanceMethodsOnlyCalledFromImplementations() { .callMethodWhere(TO_INSTANCE_METHOD .and(target(HasOwner.Predicates.With.owner(assignableTo(MessageMarshaller.class)))) ) - .because("Use static MessageMarshaller.prepareMarshal(factory, ...) and " + - "MessageMarshaller.finishUnmarshal(factory, ...) instead of calling instance methods directly."); + .because("Use static MessageMarshaller.marshal(factory, ...) and " + + "MessageMarshaller.unmarshal(factory, ...) instead of calling instance methods directly."); rule.check(classes); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/ErrorMessageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/ErrorMessageSelfTest.java index b3ff36de94b8a..72ed44eacb6a2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/ErrorMessageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/ErrorMessageSelfTest.java @@ -40,7 +40,7 @@ public void testDirectAndInsverseConversion() throws IgniteCheckedException { assertSame(e, msg0.error()); - msg0.prepareMarshal(jdk()); + msg0.marshal(jdk()); byte[] errBytes = msg0.errBytes; @@ -49,7 +49,7 @@ public void testDirectAndInsverseConversion() throws IgniteCheckedException { ErrorMessage msg1 = new ErrorMessage(); msg1.errBytes = errBytes; - msg1.finishUnmarshal(jdk(), U.gridClassLoader()); + msg1.unmarshal(jdk(), U.gridClassLoader()); Throwable t = msg1.error(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClientSlowDiscoveryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClientSlowDiscoveryAbstractTest.java index fd6c6f9e4befd..4cb06c7fb441a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClientSlowDiscoveryAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClientSlowDiscoveryAbstractTest.java @@ -93,7 +93,7 @@ static class CustomMessageInterceptingDiscoverySpi extends TcpDiscoverySpi { TcpDiscoveryCustomEventMessage cm = (TcpDiscoveryCustomEventMessage)msg; try { - cm.finishUnmarshal(marshaller(), U.resolveClassLoader(ignite().configuration())); + cm.unmarshal(marshaller(), U.resolveClassLoader(ignite().configuration())); assertNotNull(cm.message()); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java index 0e8f4676f0c73..f280524648a01 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java @@ -149,13 +149,13 @@ private TestCacheObject(final byte type) { } /** {@inheritDoc} */ - @Override public void finishUnmarshal(final CacheObjectValueContext ctx, final ClassLoader ldr) + @Override public void unmarshal(final CacheObjectValueContext ctx, final ClassLoader ldr) throws IgniteCheckedException { // No-op } /** {@inheritDoc} */ - @Override public void prepareMarshal(final CacheObjectValueContext ctx) throws IgniteCheckedException { + @Override public void marshal(final CacheObjectValueContext ctx) throws IgniteCheckedException { // No-op } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheClientRequestsMappingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheClientRequestsMappingTest.java index fe4a0eeb70809..03cfabc9729d6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheClientRequestsMappingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheClientRequestsMappingTest.java @@ -163,7 +163,7 @@ private void doTestMarshallingBinaryMappingsLoadedFromClient(boolean receiveMeta try { TcpDiscoveryCustomEventMessage evtMsg = (TcpDiscoveryCustomEventMessage)msg; - evtMsg.finishUnmarshal(marshaller(), U.gridClassLoader()); + evtMsg.unmarshal(marshaller(), U.gridClassLoader()); DiscoveryCustomMessage delegate = U.unwrapCustomMessage(evtMsg.message()); @@ -239,7 +239,7 @@ public void testBinaryMetaDelayedForComputeJobResult() throws Exception { try { TcpDiscoveryCustomEventMessage evtMsg = (TcpDiscoveryCustomEventMessage)msg; - evtMsg.finishUnmarshal(marshaller(), U.gridClassLoader()); + evtMsg.unmarshal(marshaller(), U.gridClassLoader()); DiscoveryCustomMessage delegate = U.unwrapCustomMessage(evtMsg.message()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteSequentialNodeCrashRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteSequentialNodeCrashRecoveryTest.java index e404873a8ccad..57139ce4c5bc5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteSequentialNodeCrashRecoveryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteSequentialNodeCrashRecoveryTest.java @@ -357,7 +357,7 @@ private DiscoveryCustomMessage extractCustomMessage(TcpDiscoveryCustomEventMessa DiscoveryCustomMessage msgObj = null; try { - msg.finishUnmarshal(marshaller(), U.gridClassLoader()); + msg.unmarshal(marshaller(), U.gridClassLoader()); msgObj = (DiscoveryCustomMessage)msg.message(); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java index 1028299f7bf91..36bbaee3883a6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotTest.java @@ -432,7 +432,7 @@ public void testStagesFail() throws Exception { ErrorMessage em = new ErrorMessage(new IgniteException("Test exception.")); try { - em.prepareMarshal(jdk()); + em.marshal(jdk()); } catch (IgniteCheckedException e) { throw new RuntimeException(e); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java index 782b67148becc..d025cbb48f195 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java @@ -1031,7 +1031,7 @@ public void testDumpEntryConflictVersion() throws Exception { KeyCacheObject key = new KeyCacheObjectImpl(i, null, intCache.affinity().partition(i)); CacheObject val = new CacheObjectImpl(i, null); - val.prepareMarshal(intCache.context().cacheObjectContext()); + val.marshal(intCache.context().cacheObjectContext()); drMap.put(key, new GridCacheDrInfo(val, new GridCacheVersion(topVer, i, nodeOrder, dataCenterId))); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotJoiningClientTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotJoiningClientTest.java index fd42dc16fbf41..3930051c86dcc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotJoiningClientTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotJoiningClientTest.java @@ -246,7 +246,7 @@ private static class CoordinatorBlockingDiscoverySpi extends TcpDiscoverySpi { TcpDiscoveryCustomEventMessage m = (TcpDiscoveryCustomEventMessage)msg; try { - m.finishUnmarshal(marshaller(), U.resolveClassLoader(ignite().configuration())); + m.unmarshal(marshaller(), U.resolveClassLoader(ignite().configuration())); if (U.unwrapCustomMessage(m.message()) instanceof InitMessage) rcvStartSnpReq.countDown(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java index 0e18a0ab82d96..2c03037017baf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java @@ -67,7 +67,7 @@ public void testMessageUnmarshallWithoutCacheContext() throws Exception { @Override public void onMessage(UUID nodeId, Object msg, byte plc) { if (msg instanceof TxLocksResponse) { try { - MessageMarshaller.finishUnmarshal(clientCtx.kernalContext().messageFactory(), (TxLocksResponse)msg, + MessageMarshaller.unmarshal(clientCtx.kernalContext().messageFactory(), (TxLocksResponse)msg, clientCtx.kernalContext(), null, clientCtx.deploy().globalLoader()); res.set(true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/CacheFreeListSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/CacheFreeListSelfTest.java index d714f666aac9a..97987aad4c45f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/CacheFreeListSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/CacheFreeListSelfTest.java @@ -725,13 +725,13 @@ private TestCacheObject(int size) { } /** {@inheritDoc} */ - @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) + @Override public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { assert false; } /** {@inheritDoc} */ - @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException { + @Override public void marshal(CacheObjectValueContext ctx) throws IgniteCheckedException { assert false; } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java index 4d10e412a0634..6cb74d0483bf2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java @@ -716,7 +716,7 @@ private static class StaleTopologyCommunicationSpi extends TcpCommunicationSpi { ); try { - MessageMarshaller.prepareMarshal(((IgniteEx)ignite).context().messageFactory(), + MessageMarshaller.marshal(((IgniteEx)ignite).context().messageFactory(), msg, ((IgniteEx)ignite).context(), null); } catch (IgniteCheckedException e) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/query/schema/IndexWithSameNameTestBase.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/query/schema/IndexWithSameNameTestBase.java index e37cee61fc560..efaaae6793ba2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/query/schema/IndexWithSameNameTestBase.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/query/schema/IndexWithSameNameTestBase.java @@ -313,7 +313,7 @@ public static class SchemaFinishListeningTcpDiscoverySpi extends TcpDiscoverySpi try { TcpDiscoveryCustomEventMessage evtMsg = (TcpDiscoveryCustomEventMessage)msg; - evtMsg.finishUnmarshal(marshaller(), U.gridClassLoader()); + evtMsg.unmarshal(marshaller(), U.gridClassLoader()); DiscoveryCustomMessage discoCustomMsg = U.unwrapCustomMessage(evtMsg.message()); diff --git a/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageMarshalOnceTest.java b/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageMarshalOnceTest.java index de35455fe7b6c..fae5f22136b8e 100644 --- a/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageMarshalOnceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageMarshalOnceTest.java @@ -38,8 +38,8 @@ * Verifies the marshal-once-before-fan-out contract of the collection {@code send}: a message broadcast to N remote * nodes is marshalled exactly once (prepared before the fan-out and reused for every destination), not once per * destination. A counting marshaller is registered for a test message; broadcasting it to {@link #RMT_CNT} remote nodes - * must produce {@code RMT_CNT} sends but a single {@code prepareMarshal}. Counting the sends keeps the check honest (a - * lone send would also marshal once). The unmarshal-once counterpart lives in {@link MessageFinishUnmarshalOnceTest}. + * must produce {@code RMT_CNT} sends but a single {@code marshal}. Counting the sends keeps the check honest (a + * lone send would also marshal once). The unmarshal-once counterpart lives in {@link MessageUnmarshalOnceTest}. */ public class MessageMarshalOnceTest extends GridCommonAbstractTest { /** Direct type for the test message, past the core range. */ @@ -48,7 +48,7 @@ public class MessageMarshalOnceTest extends GridCommonAbstractTest { /** Number of remote destinations to broadcast to (a single marshal must serve all of them). */ private static final int RMT_CNT = 4; - /** Counts {@code prepareMarshal} invocations of {@link MarshalOnceCheckMessage} across the JVM. */ + /** Counts {@code marshal} invocations of {@link MarshalOnceCheckMessage} across the JVM. */ private static final AtomicInteger MARSHAL_CNT = new AtomicInteger(); /** {@inheritDoc} */ @@ -128,21 +128,21 @@ private static class Serializer implements MessageSerializer { /** {@inheritDoc} */ - @Override public void prepareMarshal(MarshalOnceCheckMessage msg, GridKernalContext kctx, CacheObjectContext nested) { + @Override public void marshal(MarshalOnceCheckMessage msg, GridKernalContext kctx, CacheObjectContext nested) { MARSHAL_CNT.incrementAndGet(); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(MarshalOnceCheckMessage msg, GridKernalContext kctx, CacheObjectContext nested, + @Override public void unmarshal(MarshalOnceCheckMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) { // No-op. } /** {@inheritDoc} */ - @Override public void finishUnmarshal(MarshalOnceCheckMessage msg, GridKernalContext kctx) { + @Override public void unmarshal(MarshalOnceCheckMessage msg, GridKernalContext kctx) { // No-op. } } diff --git a/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageFinishUnmarshalOnceTest.java b/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageUnmarshalOnceTest.java similarity index 93% rename from modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageFinishUnmarshalOnceTest.java rename to modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageUnmarshalOnceTest.java index fca0a92e8e3ca..996746c1a35f0 100644 --- a/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageFinishUnmarshalOnceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/plugin/extensions/communication/MessageUnmarshalOnceTest.java @@ -28,7 +28,7 @@ * silently turn off and pass every test vacuously. The actual coverage (no real receive path unmarshals an instance * twice in the same pass) comes from running the check across the whole suite via {@code GridAbstractTest}. */ -public class MessageFinishUnmarshalOnceTest extends GridCommonAbstractTest { +public class MessageUnmarshalOnceTest extends GridCommonAbstractTest { /** The suite-wide guard must be on, so a silently-disabled check cannot pass every test without verifying anything. */ @Test public void testCheckEnabled() { @@ -59,12 +59,12 @@ public void testBothPassesAllowed() { /** Minimal {@link MarshallableMessage}; only its identity matters to the check. */ private static class NoopMarshallableMessage implements MarshallableMessage { /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) { + @Override public void marshal(Marshaller marsh) { // No-op. } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) { // No-op. } } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/BlockTcpDiscoverySpi.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/BlockTcpDiscoverySpi.java index 00ed5f205abd4..3c0445f0f94a8 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/BlockTcpDiscoverySpi.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/BlockTcpDiscoverySpi.java @@ -54,7 +54,7 @@ private synchronized void apply(ClusterNode addr, TcpDiscoveryAbstractMessage ms TcpDiscoveryCustomEventMessage cm = (TcpDiscoveryCustomEventMessage)msg; try { - cm.finishUnmarshal(marshaller(), U.gridClassLoader()); + cm.unmarshal(marshaller(), U.gridClassLoader()); assertNotNull(cm.message()); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index 2647625a8499b..59eedeb1ec757 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -238,7 +238,7 @@ private byte[] serializedMessage() throws IgniteCheckedException { ExploitMessage msg = new ExploitMessage(new Exploit()); - MessageMarshaller.prepareMarshal(msgFactory, msg, grid().context(), null); + MessageMarshaller.marshal(msgFactory, msg, grid().context(), null); writer.writeMessage(msg); @@ -309,26 +309,26 @@ private MessageMarshallerWrapper(AbstractMarshallableMessageFactoryProvider prov } /** {@inheritDoc} */ - @Override public void prepareMarshal(ExploitMessage msg, GridKernalContext kctx, CacheObjectContext nested) + @Override public void marshal(ExploitMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { initIfNecessary(); - marsh.prepareMarshal(msg, kctx, nested); + marsh.marshal(msg, kctx, nested); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(ExploitMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) + @Override public void unmarshal(ExploitMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { initIfNecessary(); - marsh.finishUnmarshal(msg, kctx, nested, clsLdr); + marsh.unmarshal(msg, kctx, nested, clsLdr); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(ExploitMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + @Override public void unmarshal(ExploitMessage msg, GridKernalContext kctx) throws IgniteCheckedException { initIfNecessary(); - marsh.finishUnmarshal(msg, kctx); + marsh.unmarshal(msg, kctx); } /** */ diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ExploitMessage.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ExploitMessage.java index d4074b58fdb45..5223f0997f82e 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ExploitMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ExploitMessage.java @@ -41,12 +41,12 @@ public ExploitMessage(Exploit exploit) { } /** {@inheritDoc} */ - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { exploitBytes = marsh.marshal(exploit); } /** {@inheritDoc} */ - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { exploit = marsh.unmarshal(exploitBytes, clsLdr); } } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java index 4920d029538a6..ac7901471fcba 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java @@ -2647,7 +2647,7 @@ private static class TestCustomerEventAckSpi extends TcpDiscoverySpi { try { TcpDiscoveryCustomEventMessage evtMsg = (TcpDiscoveryCustomEventMessage)msg; - evtMsg.finishUnmarshal(marshaller(), U.gridClassLoader()); + evtMsg.unmarshal(marshaller(), U.gridClassLoader()); DiscoveryCustomMessage custMsg = U.unwrapCustomMessage(evtMsg.message()); diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java index b249da56d1711..74c49232da99c 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java @@ -36,7 +36,7 @@ import org.apache.ignite.internal.IgniteSlowClientDetectionSelfTest; import org.apache.ignite.internal.TransactionsMXBeanImplTest; import org.apache.ignite.internal.codegen.IgniteDataTransferObjectProcessorTest; -import org.apache.ignite.internal.codegen.MarshallerCacheFreeFinishTest; +import org.apache.ignite.internal.codegen.MarshallerCacheFreeUnmarshalTest; import org.apache.ignite.internal.codegen.MessageProcessorTest; import org.apache.ignite.internal.codegen.MessageSerializationArchitectureTest; import org.apache.ignite.internal.managers.communication.CompressedMessageTest; @@ -73,7 +73,7 @@ import org.apache.ignite.messaging.GridMessagingSelfTest; import org.apache.ignite.messaging.IgniteMessagingSendAsyncTest; import org.apache.ignite.messaging.IgniteMessagingWithClientTest; -import org.apache.ignite.plugin.extensions.communication.MessageFinishUnmarshalOnceTest; +import org.apache.ignite.plugin.extensions.communication.MessageUnmarshalOnceTest; import org.apache.ignite.plugin.extensions.communication.MessageMarshalOnceTest; import org.apache.ignite.spi.GridSpiLocalHostInjectionTest; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTestSelfTest; @@ -156,8 +156,8 @@ MessageProcessorTest.class, MessageMarshalOnceTest.class, - MessageFinishUnmarshalOnceTest.class, - MarshallerCacheFreeFinishTest.class, + MessageUnmarshalOnceTest.class, + MarshallerCacheFreeUnmarshalTest.class, MessageSerializationArchitectureTest.class, ErrorMessageSelfTest.class, DefaultEnumMapperTest.class, diff --git a/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java b/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java index 194925906ef6c..c9dbf11137bac 100644 --- a/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/ChildMessageMarshaller.java @@ -35,14 +35,14 @@ public ChildMessageMarshaller() { } /** */ - @Override public void prepareMarshal(ChildMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + @Override public void marshal(ChildMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { } /** */ - @Override public void finishUnmarshal(ChildMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(ChildMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { } /** */ - @Override public void finishUnmarshal(ChildMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + @Override public void unmarshal(ChildMessage msg, GridKernalContext kctx) throws IgniteCheckedException { } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java index ab1080aa2d428..0b04c22489ab0 100644 --- a/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/CustomMapperEnumFieldsMessageMarshaller.java @@ -35,14 +35,14 @@ public CustomMapperEnumFieldsMessageMarshaller() { } /** */ - @Override public void prepareMarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + @Override public void marshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { } /** */ - @Override public void finishUnmarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { } /** */ - @Override public void finishUnmarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + @Override public void unmarshal(CustomMapperEnumFieldsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java index 59c5c057bf761..21df8e0eb8de0 100644 --- a/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/DefaultMapperEnumFieldsMessageMarshaller.java @@ -35,14 +35,14 @@ public DefaultMapperEnumFieldsMessageMarshaller() { } /** */ - @Override public void prepareMarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + @Override public void marshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { } /** */ - @Override public void finishUnmarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { } /** */ - @Override public void finishUnmarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + @Override public void unmarshal(DefaultMapperEnumFieldsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java index 404fd1bd64357..cfb651719d1fb 100644 --- a/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestCollectionsMessageMarshaller.java @@ -52,49 +52,49 @@ public TestCollectionsMessageMarshaller() { } /** */ - @Override public void prepareMarshal(TestCollectionsMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + @Override public void marshal(TestCollectionsMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { CacheObjectContext ctx = nested; if (msg.messageList != null) { for (GridCacheVersion e : (Collection)msg.messageList) { if (e != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e, kctx, ctx); + MessageMarshaller.marshal(kctx.messageFactory(), e, kctx, ctx); } } if (msg.cacheObjectSet != null) { for (CacheObject e : (Collection)msg.cacheObjectSet) { if (e != null && ctx != null) - e.prepareMarshal(ctx); + e.marshal(ctx); } } } /** */ - @Override public void finishUnmarshal(TestCollectionsMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(TestCollectionsMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { CacheObjectContext ctx = nested; if (msg.messageList != null) { for (GridCacheVersion e : (Collection)msg.messageList) { if (e != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); + MessageMarshaller.unmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); } } if (msg.cacheObjectSet != null) { for (CacheObject e : (Collection)msg.cacheObjectSet) { if (e != null && ctx != null) - e.finishUnmarshal(ctx, clsLdr); + e.unmarshal(ctx, clsLdr); } } } /** */ - @Override public void finishUnmarshal(TestCollectionsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + @Override public void unmarshal(TestCollectionsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.messageList != null) { for (GridCacheVersion e : (Collection)msg.messageList) { if (e != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx); + MessageMarshaller.unmarshal(kctx.messageFactory(), e, kctx); } } } diff --git a/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java index 9fc5d12f6d45b..23902ee640919 100644 --- a/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMapMessageMarshaller.java @@ -55,20 +55,20 @@ public TestMapMessageMarshaller() { } /** */ - @Override public void prepareMarshal(TestMapMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + @Override public void marshal(TestMapMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { CacheObjectContext ctx = nested; if (msg.messageBoxedDoubleMap != null) { for (GridCacheVersion e : ((Collection)msg.messageBoxedDoubleMap.keySet())) { if (e != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e, kctx, ctx); + MessageMarshaller.marshal(kctx.messageFactory(), e, kctx, ctx); } } if (msg.gridCacheObjectMap != null) { for (KeyCacheObject e : ((Collection)msg.gridCacheObjectMap.keySet())) { if (e != null && ctx != null) - e.prepareMarshal(ctx); + e.marshal(ctx); } for (Map e : ((Collection)msg.gridCacheObjectMap.values())) { if (e != null) { @@ -76,7 +76,7 @@ public TestMapMessageMarshaller() { if (e1 != null) { for (CacheObject e2 : (Collection)e1) { if (e2 != null && ctx != null) - e2.prepareMarshal(ctx); + e2.marshal(ctx); } } } @@ -86,20 +86,20 @@ public TestMapMessageMarshaller() { } /** */ - @Override public void finishUnmarshal(TestMapMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(TestMapMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { CacheObjectContext ctx = nested; if (msg.messageBoxedDoubleMap != null) { for (GridCacheVersion e : ((Collection)msg.messageBoxedDoubleMap.keySet())) { if (e != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); + MessageMarshaller.unmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); } } if (msg.gridCacheObjectMap != null) { for (KeyCacheObject e : ((Collection)msg.gridCacheObjectMap.keySet())) { if (e != null && ctx != null) - e.finishUnmarshal(ctx, clsLdr); + e.unmarshal(ctx, clsLdr); } for (Map e : ((Collection)msg.gridCacheObjectMap.values())) { if (e != null) { @@ -107,7 +107,7 @@ public TestMapMessageMarshaller() { if (e1 != null) { for (CacheObject e2 : (Collection)e1) { if (e2 != null && ctx != null) - e2.finishUnmarshal(ctx, clsLdr); + e2.unmarshal(ctx, clsLdr); } } } @@ -117,11 +117,11 @@ public TestMapMessageMarshaller() { } /** */ - @Override public void finishUnmarshal(TestMapMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + @Override public void unmarshal(TestMapMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.messageBoxedDoubleMap != null) { for (GridCacheVersion e : ((Collection)msg.messageBoxedDoubleMap.keySet())) { if (e != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx); + MessageMarshaller.unmarshal(kctx.messageFactory(), e, kctx); } } } diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessage.java b/modules/core/src/test/resources/codegen/TestMarshallableMessage.java index 641a379cf2c7d..a4e660cd9ba3e 100644 --- a/modules/core/src/test/resources/codegen/TestMarshallableMessage.java +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessage.java @@ -34,11 +34,11 @@ public class TestMarshallableMessage implements MarshallableMessage { @Order(2) byte[] cstDataBytes; - @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { + @Override public void marshal(Marshaller marsh) throws IgniteCheckedException { cstDataBytes = U.marshal(marsh, cstData); } - @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { cstData = U.unmarshal(marsh, cstDataBytes, clsLdr); } diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java index 5e914a3d6e52c..2388d68370079 100644 --- a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java @@ -108,16 +108,16 @@ public TestMarshallableMessageMarshallableSerializer(Marshaller marshaller, Clas } /** */ - @Override public void prepareMarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + @Override public void marshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { GridCacheContext ctx = nested; - msg.prepareMarshal(marshaller); + msg.marshal(marshaller); } /** */ - @Override public void finishUnmarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { + @Override public void unmarshal(TestMarshallableMessage msg, GridKernalContext kctx, GridCacheContext nested) throws IgniteCheckedException { GridCacheContext ctx = nested; - msg.finishUnmarshal(marshaller, clsLdr); + msg.unmarshal(marshaller, clsLdr); } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java index 393615d9fe43b..5fd6f7cbd5954 100644 --- a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshaller.java @@ -40,17 +40,17 @@ public TestMarshallableMessageMarshaller(Marshaller marshaller) { } /** */ - @Override public void prepareMarshal(TestMarshallableMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { - msg.prepareMarshal(marshaller); + @Override public void marshal(TestMarshallableMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + msg.marshal(marshaller); } /** */ - @Override public void finishUnmarshal(TestMarshallableMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { - msg.finishUnmarshal(marshaller, clsLdr); + @Override public void unmarshal(TestMarshallableMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + msg.unmarshal(marshaller, clsLdr); } /** */ - @Override public void finishUnmarshal(TestMarshallableMessage msg, GridKernalContext kctx) throws IgniteCheckedException { - msg.finishUnmarshal(marshaller, U.resolveClassLoader(kctx.config())); + @Override public void unmarshal(TestMarshallableMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + msg.unmarshal(marshaller, U.resolveClassLoader(kctx.config())); } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java index da9caa7fc4020..dd7c484948318 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledCollectionMessageMarshaller.java @@ -36,7 +36,7 @@ public TestMarshalledCollectionMessageMarshaller() { } /** */ - @Override public void prepareMarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + @Override public void marshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { CacheObjectContext ctx = nested; if (msg.keys != null && msg.keysArr == null) @@ -45,13 +45,13 @@ public TestMarshalledCollectionMessageMarshaller() { if (msg.keysArr != null) { for (GridCacheVersion e : msg.keysArr) { if (e != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e, kctx, ctx); + MessageMarshaller.marshal(kctx.messageFactory(), e, kctx, ctx); } } } /** */ - @Override public void finishUnmarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { CacheObjectContext ctx = nested; if (msg.keysArr != null) { @@ -59,7 +59,7 @@ public TestMarshalledCollectionMessageMarshaller() { for (GridCacheVersion e : msg.keysArr) { if (e != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); + MessageMarshaller.unmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); msg.keys.add(e); } @@ -69,11 +69,11 @@ public TestMarshalledCollectionMessageMarshaller() { } /** */ - @Override public void finishUnmarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + @Override public void unmarshal(TestMarshalledCollectionMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.keysArr != null) { for (GridCacheVersion e : msg.keysArr) { if (e != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx); + MessageMarshaller.unmarshal(kctx.messageFactory(), e, kctx); } } } diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java index 56644eb35ef09..4c86a66302003 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledMapMessageMarshaller.java @@ -38,7 +38,7 @@ public TestMarshalledMapMessageMarshaller() { } /** */ - @Override public void prepareMarshal(TestMarshalledMapMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + @Override public void marshal(TestMarshalledMapMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { CacheObjectContext ctx = nested; if (msg.theMap != null && msg.mapKeys == null) { @@ -49,20 +49,20 @@ public TestMarshalledMapMessageMarshaller() { if (msg.mapKeys != null) { for (GridCacheVersion e : (Collection)msg.mapKeys) { if (e != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e, kctx, ctx); + MessageMarshaller.marshal(kctx.messageFactory(), e, kctx, ctx); } } if (msg.mapVals != null) { for (GridCacheVersion e : (Collection)msg.mapVals) { if (e != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e, kctx, ctx); + MessageMarshaller.marshal(kctx.messageFactory(), e, kctx, ctx); } } } /** */ - @Override public void finishUnmarshal(TestMarshalledMapMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(TestMarshalledMapMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { CacheObjectContext ctx = nested; if (msg.mapKeys != null) { @@ -76,10 +76,10 @@ public TestMarshalledMapMessageMarshaller() { GridCacheVersion v = valIter.next(); if (k != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), k, kctx, ctx, clsLdr); + MessageMarshaller.unmarshal(kctx.messageFactory(), k, kctx, ctx, clsLdr); if (v != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), v, kctx, ctx, clsLdr); + MessageMarshaller.unmarshal(kctx.messageFactory(), v, kctx, ctx, clsLdr); msg.theMap.put(k, v); } @@ -90,18 +90,18 @@ public TestMarshalledMapMessageMarshaller() { } /** */ - @Override public void finishUnmarshal(TestMarshalledMapMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + @Override public void unmarshal(TestMarshalledMapMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.mapKeys != null) { for (GridCacheVersion e : (Collection)msg.mapKeys) { if (e != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx); + MessageMarshaller.unmarshal(kctx.messageFactory(), e, kctx); } } if (msg.mapVals != null) { for (GridCacheVersion e : (Collection)msg.mapVals) { if (e != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx); + MessageMarshaller.unmarshal(kctx.messageFactory(), e, kctx); } } } diff --git a/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java index 80948fb904597..e43a98e37c372 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledMessageMarshaller.java @@ -40,19 +40,19 @@ public TestMarshalledMessageMarshaller(Marshaller marshaller) { } /** */ - @Override public void prepareMarshal(TestMarshalledMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + @Override public void marshal(TestMarshalledMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { if (msg.data != null && msg.dataBytes == null) msg.dataBytes = U.marshal(marshaller, msg.data); } /** */ - @Override public void finishUnmarshal(TestMarshalledMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(TestMarshalledMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { if (msg.dataBytes != null) msg.data = U.unmarshal(marshaller, msg.dataBytes, clsLdr); } /** */ - @Override public void finishUnmarshal(TestMarshalledMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + @Override public void unmarshal(TestMarshalledMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.dataBytes != null) msg.data = U.unmarshal(marshaller, msg.dataBytes, U.resolveClassLoader(kctx.config())); } diff --git a/modules/core/src/test/resources/codegen/TestMarshalledObjectsMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMarshalledObjectsMessageMarshaller.java index eef35eba3e420..42f9e58a47235 100644 --- a/modules/core/src/test/resources/codegen/TestMarshalledObjectsMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMarshalledObjectsMessageMarshaller.java @@ -41,7 +41,7 @@ public TestMarshalledObjectsMessageMarshaller(Marshaller marshaller) { } /** */ - @Override public void prepareMarshal(TestMarshalledObjectsMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + @Override public void marshal(TestMarshalledObjectsMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { if (msg.data != null && msg.dataBytes == null) { msg.dataBytes = new ArrayList<>(msg.data.size()); @@ -51,7 +51,7 @@ public TestMarshalledObjectsMessageMarshaller(Marshaller marshaller) { } /** */ - @Override public void finishUnmarshal(TestMarshalledObjectsMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(TestMarshalledObjectsMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { CacheObjectContext ctx = nested; if (msg.dataBytes != null) { @@ -65,6 +65,6 @@ public TestMarshalledObjectsMessageMarshaller(Marshaller marshaller) { } /** */ - @Override public void finishUnmarshal(TestMarshalledObjectsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + @Override public void unmarshal(TestMarshalledObjectsMessage msg, GridKernalContext kctx) throws IgniteCheckedException { } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestMessageMarshaller.java b/modules/core/src/test/resources/codegen/TestMessageMarshaller.java index 548cd10f346fe..6cb8f05a7004e 100644 --- a/modules/core/src/test/resources/codegen/TestMessageMarshaller.java +++ b/modules/core/src/test/resources/codegen/TestMessageMarshaller.java @@ -37,63 +37,63 @@ public TestMessageMarshaller() { } /** */ - @Override public void prepareMarshal(TestMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { + @Override public void marshal(TestMessage msg, GridKernalContext kctx, CacheObjectContext nested) throws IgniteCheckedException { CacheObjectContext ctx = nested; if (msg.ver != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), msg.ver, kctx, ctx); + MessageMarshaller.marshal(kctx.messageFactory(), msg.ver, kctx, ctx); if (msg.verArr != null) { for (GridCacheVersion e : msg.verArr) { if (e != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), e, kctx, ctx); + MessageMarshaller.marshal(kctx.messageFactory(), e, kctx, ctx); } } if (msg.keyCacheObject != null && ctx != null) - msg.keyCacheObject.prepareMarshal(ctx); + msg.keyCacheObject.marshal(ctx); if (msg.cacheObject != null && ctx != null) - msg.cacheObject.prepareMarshal(ctx); + msg.cacheObject.marshal(ctx); if (msg.ver2 != null) - MessageMarshaller.prepareMarshal(kctx.messageFactory(), msg.ver2, kctx, ctx); + MessageMarshaller.marshal(kctx.messageFactory(), msg.ver2, kctx, ctx); } /** */ - @Override public void finishUnmarshal(TestMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { + @Override public void unmarshal(TestMessage msg, GridKernalContext kctx, CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { CacheObjectContext ctx = nested; if (msg.verArr != null) { for (GridCacheVersion e : msg.verArr) { if (e != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); + MessageMarshaller.unmarshal(kctx.messageFactory(), e, kctx, ctx, clsLdr); } } if (msg.keyCacheObject != null && ctx != null) - msg.keyCacheObject.finishUnmarshal(ctx, clsLdr); + msg.keyCacheObject.unmarshal(ctx, clsLdr); if (msg.cacheObject != null && ctx != null) - msg.cacheObject.finishUnmarshal(ctx, clsLdr); + msg.cacheObject.unmarshal(ctx, clsLdr); } /** */ - @Override public void finishUnmarshal(TestMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + @Override public void unmarshal(TestMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.verArr != null) { for (GridCacheVersion e : msg.verArr) { if (e != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), e, kctx); + MessageMarshaller.unmarshal(kctx.messageFactory(), e, kctx); } } } /** */ - @Override public void finishUnmarshalNio(TestMessage msg, GridKernalContext kctx) throws IgniteCheckedException { + @Override public void unmarshalNio(TestMessage msg, GridKernalContext kctx) throws IgniteCheckedException { if (msg.ver != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), msg.ver, kctx); + MessageMarshaller.unmarshal(kctx.messageFactory(), msg.ver, kctx); if (msg.ver2 != null) - MessageMarshaller.finishUnmarshal(kctx.messageFactory(), msg.ver2, kctx); + MessageMarshaller.unmarshal(kctx.messageFactory(), msg.ver2, kctx); } } \ No newline at end of file diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java index 559f96bccad5c..92640ed4b75a4 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java @@ -47,14 +47,14 @@ public GridH2CacheObject() { public GridH2CacheObject(GridH2ValueCacheObject v) throws IgniteCheckedException { obj = v.getCacheObject(); - obj.prepareMarshal(v.valueContext()); + obj.marshal(v.valueContext()); } /** {@inheritDoc} */ @Override public Value value(GridKernalContext ctx) throws IgniteCheckedException { CacheObjectValueContext valCtx = ctx.query().objectContext(); - obj.finishUnmarshal(valCtx, ctx.cache().context().deploy().globalLoader()); + obj.unmarshal(valCtx, ctx.cache().context().deploy().globalLoader()); return new GridH2ValueCacheObject(obj, valCtx); } diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java index e39883b3e4b47..7e15d3c5ffbbd 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java @@ -95,7 +95,7 @@ private void serializeMessage(Message m, OutputStream out) throws IOException { msgWriter.setBuffer(msgBuf); try { - MessageMarshaller.prepareMarshal(msgFactory, m, ((IgniteEx)spi.ignite()).context(), null); + MessageMarshaller.marshal(msgFactory, m, ((IgniteEx)spi.ignite()).context(), null); } catch (IgniteCheckedException e) { throw new IgniteSpiException("Failed to marshal discovery message", e); @@ -142,7 +142,7 @@ private T deserializeMessage(InputStream in) throws IOExcept while (!finished); try { - MessageMarshaller.finishUnmarshal(msgFactory, msg, ((IgniteEx)spi.ignite()).context()); + MessageMarshaller.unmarshal(msgFactory, msg, ((IgniteEx)spi.ignite()).context()); } catch (IgniteCheckedException e) { throw new IgniteSpiException("Failed to unmarshal discovery message", e); diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkDiscoveryCustomEventData.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkDiscoveryCustomEventData.java index e606f384fcf0f..52161d34c8471 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkDiscoveryCustomEventData.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZkDiscoveryCustomEventData.java @@ -71,13 +71,13 @@ class ZkDiscoveryCustomEventData extends ZkDiscoveryEventData { } /** */ - public void prepareMarshal(DiscoveryMessageParser parser) { + public void marshal(DiscoveryMessageParser parser) { if (resolvedMsg != null) msgBytes = parser.marshalZip(resolvedMsg); } /** */ - public void finishUnmarshal(DiscoveryMessageParser parser) { + public void unmarshal(DiscoveryMessageParser parser) { if (msgBytes != null) resolvedMsg = parser.unmarshalZip(msgBytes); } diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java index ae988d404f9dd..a040e4b79018a 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java @@ -1490,7 +1490,7 @@ private void generateNoServersEvent(ZkDiscoveryEventsData evtsData, Stat evtsSta new ZkNoServersMessage(), null); - evtData.prepareMarshal(msgParser); + evtData.marshal(msgParser); Collection nodesToAck = Collections.emptyList(); @@ -1520,7 +1520,7 @@ private void previousCoordinatorCleanup(ZkDiscoveryEventsData lastEvts) throws E if (evtData instanceof ZkDiscoveryCustomEventData) { ZkDiscoveryCustomEventData evtData0 = (ZkDiscoveryCustomEventData)evtData; - evtData0.finishUnmarshal(msgParser); + evtData0.unmarshal(msgParser); // It is possible previous coordinator failed before finished cleanup. if (evtData0.resolvedMsg instanceof ZkCommunicationErrorResolveFinishMessage) { @@ -2750,7 +2750,7 @@ private void processNewEvents(final ZkDiscoveryEventsData evtsData) throws Excep if (evtData0.ackEvent() && evtData0.topologyVersion() < locNode.order()) break; - evtData0.finishUnmarshal(msgParser); + evtData0.unmarshal(msgParser); if (rtState.crd) assert evtData0.resolvedMsg != null : evtData0; @@ -3451,7 +3451,7 @@ private void onCommunicationErrorResolveStatusReceived(final ZkRuntimeState rtSt msg, null); - evtData.prepareMarshal(msgParser); + evtData.marshal(msgParser); evtsData.addEvent(rtState.top.nodesByOrder.values(), evtData); From 6cc12af0256226817867b9a801fedf9e10e2728e Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 17:54:10 +0300 Subject: [PATCH 206/215] WIP --- .../managers/communication/IgniteMessageFactoryImpl.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java index 814c7a67ec204..734e60ac4cf3a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java @@ -149,11 +149,7 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] factories) { return supplier.get(); } - /** - * @param directType Message direct type. - * @return Message serializer. - * @throws IgniteException If there are no any message factory for given {@code directType}. - */ + /** {@inheritDoc} */ @Override public MessageSerializer serializer(short directType) { MessageSerializer serializer = msgSerializers[directTypeToIndex(directType)]; From d558a0c9ed17ecdd102f4e5681be4994a45633c2 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 17:57:41 +0300 Subject: [PATCH 207/215] WIP --- .../extensions/communication/MessageMarshaller.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index 73e2c6a1fc853..173c105ebfa6c 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -40,7 +40,6 @@ public interface MessageMarshaller { * @param msg Message to marshal. * @param kctx Kernal context. * @param nested Cache object context, or {@code null} if not applicable. - * @throws IgniteCheckedException If marshalling failed. */ public void marshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested) throws IgniteCheckedException; @@ -52,7 +51,6 @@ public void marshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext * @param kctx Kernal context. * @param nested Cache object context, or {@code null} if not applicable. * @param clsLdr Class loader for unmarshalling. - * @throws IgniteCheckedException If unmarshalling failed. */ public void unmarshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException; @@ -62,7 +60,6 @@ public void unmarshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContex * * @param msg Message to unmarshal. * @param kctx Kernal context. - * @throws IgniteCheckedException If unmarshalling failed. */ public void unmarshal(M msg, GridKernalContext kctx) throws IgniteCheckedException; @@ -71,7 +68,6 @@ public void unmarshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContex * * @param msg Message to unmarshal. * @param kctx Kernal context. - * @throws IgniteCheckedException If unmarshalling failed. */ default void unmarshalNio(M msg, GridKernalContext kctx) throws IgniteCheckedException { } @@ -83,7 +79,6 @@ default void unmarshalNio(M msg, GridKernalContext kctx) throws IgniteCheckedExc * @param factory Message factory. * @param msg Message to unmarshal. * @param kctx Kernal context. - * @throws IgniteCheckedException If unmarshalling failed. */ static void unmarshalNio(MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { @@ -101,7 +96,6 @@ static void unmarshalNio(MessageFactory factory, M msg, Grid * @param msg Message to marshal. * @param kctx Kernal context. * @param nested Cache object context, or {@code null} if not applicable. - * @throws IgniteCheckedException If marshalling failed. */ static void marshal(MessageFactory factory, M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested) throws IgniteCheckedException { @@ -120,7 +114,6 @@ static void marshal(MessageFactory factory, M msg, GridKerna * @param kctx Kernal context. * @param nested Cache object context, or {@code null} if not applicable. * @param clsLdr Class loader for unmarshalling. - * @throws IgniteCheckedException If unmarshalling failed. */ static void unmarshal(MessageFactory factory, M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested, ClassLoader clsLdr) throws IgniteCheckedException { @@ -139,7 +132,6 @@ static void unmarshal(MessageFactory factory, M msg, GridKer * @param factory Message factory. * @param msg Message to unmarshal. * @param kctx Kernal context. - * @throws IgniteCheckedException If unmarshalling failed. */ static void unmarshal(MessageFactory factory, M msg, GridKernalContext kctx) throws IgniteCheckedException { From 9b22ac2c6274e619f8cdb451c6f4a04ddf1a9ae1 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 18:08:28 +0300 Subject: [PATCH 208/215] WIP --- .../communication/MessageFactory.java | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java index 3f3a6b6ed86c4..da92fb1940184 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java @@ -26,40 +26,6 @@ * Message factory for all communication messages registered using {@link #register(short, Supplier, MessageSerializer)} method call. */ public interface MessageFactory { - /** - * Register message factory with given direct type. All messages must be registered during construction - * of class which implements this interface. Any invocation of this method after initialization is done must - * throw {@link IllegalStateException} exception. - * - * @param directType Direct type. - * @param supplier Message factory. - * @throws IgniteException In case of attempt to register message with direct type which is already registered. - * @throws IllegalStateException On any invocation of this method when class which implements this interface - * is alredy constructed. - * @deprecated Use {@link #register(short, Supplier, MessageSerializer)} instead. - */ - @Deprecated(forRemoval = true) - default void register(short directType, Supplier supplier) throws IgniteException { - throw new UnsupportedOperationException(); - } - - /** - * Register message factory with given direct type. All messages must be registered during construction - * of class which implements this interface. Any invocation of this method after initialization is done must - * throw {@link IllegalStateException} exception. - * - * @param directType Direct type. - * @param supplier Message factory. - * @throws IgniteException In case of attempt to register message with direct type which is already registered. - * @throws IllegalStateException On any invocation of this method when class which implements this interface - * is alredy constructed. - * @deprecated Use {@link #register(int, Supplier, MessageSerializer)} instead. - */ - @Deprecated(forRemoval = true) - default void register(int directType, Supplier supplier) throws IgniteException { - register((short)directType, supplier); - } - /** * Register message factory with given direct type. All messages must be registered during construction * of class which implements this interface. Any invocation of this method after initialization is done must From 2c0cf955ee809c330ad6fdae91d36141889fe3c0 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 18:19:21 +0300 Subject: [PATCH 209/215] WIP --- .../communication/IgniteMessageFactoryImpl.java | 11 ----------- .../extensions/communication/MessageFactory.java | 12 ++++++------ .../java/org/apache/ignite/spi/IgniteSpiAdapter.java | 9 +++------ .../tcp/internal/GridNioServerWrapper.java | 7 ++++--- .../DirectByteBufferStreamImplByteOrderSelfTest.java | 9 +++------ 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java index 734e60ac4cf3a..6f52d1220fb38 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java @@ -78,17 +78,6 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] factories) { initialized = true; } - /** {@inheritDoc} */ - @Override public void register(short directType, Supplier supplier, MessageSerializer serializer) throws IgniteException { - register(directType, supplier, serializer, null); - } - - /** {@inheritDoc} */ - @Override public void register(short directType, Supplier supplier, MessageSerializer serializer, - @Nullable MessageMarshaller marshaller) throws IgniteException { - register(directType, supplier, serializer, marshaller, null); - } - /** * Registers a message type with a serializer, an optional marshaller, and an optional deployer. * diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java index da92fb1940184..5c8e863a1030d 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java @@ -38,7 +38,9 @@ public interface MessageFactory { * @throws IllegalStateException On any invocation of this method when class which implements this interface * is alredy constructed. */ - public void register(short directType, Supplier supplier, MessageSerializer serializer) throws IgniteException; + default void register(short directType, Supplier supplier, MessageSerializer serializer) throws IgniteException { + register(directType, supplier, serializer, null, null); + } /** * Register message factory with given direct type and serializer. The direct type is also registered @@ -80,7 +82,7 @@ default void register(int directType, Supplier supplier, MessageSeriali */ default void register(short directType, Supplier supplier, MessageSerializer serializer, @Nullable MessageMarshaller marshaller) throws IgniteException { - register(directType, supplier, serializer); + register(directType, supplier, serializer, marshaller, null); } /** @@ -94,10 +96,8 @@ default void register(short directType, Supplier supplier, MessageSeria * @param deployer Message deployer, or {@code null} for messages without deployable fields. * @throws IgniteException In case of attempt to register message with direct type which is already registered. */ - default void register(short directType, Supplier supplier, MessageSerializer serializer, - @Nullable MessageMarshaller marshaller, @Nullable GridCacheMessageDeployer deployer) throws IgniteException { - register(directType, supplier, serializer, marshaller); - } + public void register(short directType, Supplier supplier, MessageSerializer serializer, + @Nullable MessageMarshaller marshaller, @Nullable GridCacheMessageDeployer deployer) throws IgniteException; /** * Returns {@code MessageSerializer} for provided type. diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java index 1d51119aa6fb3..552d5681bbf29 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java @@ -40,6 +40,7 @@ import org.apache.ignite.internal.IgniteNodeAttributes; import org.apache.ignite.internal.managers.communication.GridMessageListener; import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.timeout.GridSpiTimeoutObject; import org.apache.ignite.internal.util.IgniteExceptionRegistry; import org.apache.ignite.internal.util.typedef.internal.SB; @@ -756,12 +757,8 @@ private class GridDummySpiContext implements IgniteSpiContext { if (msgFactory0 == null) { msgFactory0 = new MessageFactory() { - @Override public void register(short directType, Supplier supplier) throws IgniteException { - throw new IgniteException("Failed to register message, node is not started."); - } - - @Override public void register(short directType, Supplier supplier, - MessageSerializer serializer) throws IgniteException { + @Override public void register(short directType, Supplier supplier, MessageSerializer serializer, + @Nullable MessageMarshaller marshaller, @Nullable GridCacheMessageDeployer deployer) throws IgniteException { throw new IgniteException("Failed to register message, node is not started."); } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java index 765bd01b85308..0a28e0c565499 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java @@ -55,6 +55,7 @@ import org.apache.ignite.internal.direct.DirectMessageWriter; import org.apache.ignite.internal.managers.GridManager; import org.apache.ignite.internal.managers.tracing.GridTracingManager; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.metric.GridMetricManager; import org.apache.ignite.internal.processors.tracing.Tracing; import org.apache.ignite.internal.util.GridConcurrentFactory; @@ -815,9 +816,9 @@ public GridNioServer resetNioServer() throws IgniteCheckedException { MessageFactory msgFactory = new MessageFactory() { private MessageFactory impl; - @Override public void register(short directType, Supplier supplier, - MessageSerializer serializer) throws IgniteException { - get().register(directType, supplier, serializer); + @Override public void register(short directType, Supplier supplier, MessageSerializer serializer, + @Nullable MessageMarshaller marshaller, @Nullable GridCacheMessageDeployer deployer) throws IgniteException { + get().register(directType, supplier, serializer, marshaller, deployer); } @Nullable @Override public Message create(short type) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStreamImplByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStreamImplByteOrderSelfTest.java index f07d995357df8..44e2b7cfb2fdf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStreamImplByteOrderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStreamImplByteOrderSelfTest.java @@ -25,6 +25,7 @@ import java.util.function.Supplier; import org.apache.commons.lang3.StringUtils; import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.plugin.extensions.communication.Message; @@ -88,12 +89,8 @@ public void setUp() throws Exception { */ private static DirectByteBufferStream createStream(ByteBuffer buff) { DirectByteBufferStream stream = new DirectByteBufferStream(new MessageFactory() { - @Override public void register(short directType, Supplier supplier) throws IgniteException { - throw new UnsupportedOperationException(); - } - - @Override public void register(short directType, Supplier supplier, - MessageSerializer serializer) throws IgniteException { + @Override public void register(short directType, Supplier supplier, MessageSerializer serializer, + @Nullable MessageMarshaller marshaller, @Nullable GridCacheMessageDeployer deployer) throws IgniteException { throw new UnsupportedOperationException(); } From dc709a9f136e1ead8368f2d614ada5be74a334cb Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 18:50:48 +0300 Subject: [PATCH 210/215] WIP --- .../internal/MessageDeploymentGenerator.java | 20 +++---- .../internal/GridEventConsumeHandler.java | 2 +- .../processors/cache/DeployableMessage.java | 4 +- .../processors/cache/GridCacheDeployable.java | 4 +- .../cache/GridCacheDeploymentManager.java | 4 +- .../processors/cache/GridCacheIoManager.java | 2 +- .../processors/cache/GridCacheMessage.java | 56 ++++++++--------- .../cache/GridCacheMessageDeployer.java | 60 +++++++++---------- .../distributed/dht/GridDhtLockResponse.java | 4 +- .../dht/GridDhtTxPrepareRequest.java | 4 +- .../atomic/GridDhtAtomicUpdateRequest.java | 8 +-- .../GridNearAtomicFullUpdateRequest.java | 6 +- ...idNearAtomicSingleUpdateInvokeRequest.java | 6 +- .../atomic/GridNearAtomicUpdateResponse.java | 4 +- .../GridDhtPartitionSupplyMessage.java | 2 +- .../GridDhtPartitionsExchangeFuture.java | 2 +- .../near/GridNearSingleGetResponse.java | 4 +- .../cache/query/GridCacheQueryRequest.java | 12 ++-- .../cache/query/GridCacheQueryResponse.java | 8 +-- .../continuous/CacheContinuousQueryEntry.java | 2 +- .../cache/transactions/IgniteTxManager.java | 4 +- .../communication/MarshallableMessage.java | 4 +- .../communication/MessageMarshaller.java | 6 +- .../codegen/MessageProcessorTest.java | 2 +- .../MessageSerializationArchitectureTest.java | 8 +-- ...adlockDetectionMessageMarshallingTest.java | 2 +- .../p2p/ClassLoadingProblemExceptionTest.java | 2 +- .../codegen/TestCacheIdMessageDeployer.java | 10 ++-- .../codegen/TestDeployableMessage.java | 2 +- .../TestDeployableMessageDeployer.java | 6 +- .../TestNestedDeployMessageDeployer.java | 4 +- 31 files changed, 132 insertions(+), 132 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java index cc4328c4dc4f9..b09d900f5c0bd 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java @@ -40,7 +40,7 @@ * nested {@code GridCacheMessage} (whose deployment is delegated). The strategy is inferred entirely from the field type. * *

    A message with deployment logic that cannot be inferred from field types implements {@code DeployableMessage}; - * the generated deployer then also delegates to its {@code prepareDeployment}, mirroring {@code marshal}. + * the generated deployer then also delegates to its {@code deploy}, mirroring {@code marshal}. */ public class MessageDeploymentGenerator extends MessageGenerator { /** FQN of GridCacheMessage; hierarchy scan stops here (exclusive). */ @@ -70,7 +70,7 @@ public class MessageDeploymentGenerator extends MessageGenerator { /** */ private final TypeMirror iterableMirror; - /** Accumulated source lines for the generated {@code prepareDeployment} method. */ + /** Accumulated source lines for the generated {@code deploy} method. */ private final List deploy = new ArrayList<>(); /** */ @@ -113,7 +113,7 @@ public class MessageDeploymentGenerator extends MessageGenerator { return true; } - /** @return {@code true} if {@code type} implements {@code DeployableMessage} (has hand-written {@code prepareDeployment}). */ + /** @return {@code true} if {@code type} implements {@code DeployableMessage} (has hand-written {@code deploy}). */ private boolean hasCustomDeployment(TypeElement type) { return deployableMessageMirror != null && assignableFrom(type.asType(), deployableMessageMirror); } @@ -124,7 +124,7 @@ private boolean hasCustomDeployment(TypeElement type) { deploy.add(indentedLine(METHOD_JAVADOC)); deploy.add(indentedLine( - "@Override public void prepareDeployment(%s msg, GridCacheSharedContext ctx) throws IgniteCheckedException {", + "@Override public void deploy(%s msg, GridCacheSharedContext ctx) throws IgniteCheckedException {", simpleNameWithGeneric(type))); indent++; @@ -142,23 +142,23 @@ private boolean hasCustomDeployment(TypeElement type) { switch (kind) { case CACHE_OBJECT: needsCctx = true; - stmt = "GridCacheMessageDeployer.prepareCacheObject(msg, %s, cctx);"; + stmt = "GridCacheMessageDeployer.deployCacheObject(msg, %s, cctx);"; break; case CACHE_OBJECTS: needsCctx = true; - stmt = "GridCacheMessageDeployer.prepareCacheObjects(msg, %s, cctx);"; + stmt = "GridCacheMessageDeployer.deployCacheObjects(msg, %s, cctx);"; break; case TX_ENTRIES: - stmt = "GridCacheMessageDeployer.prepareTxEntries(msg, %s, ctx);"; + stmt = "GridCacheMessageDeployer.deployTxEntries(msg, %s, ctx);"; break; case NESTED: - stmt = "GridCacheMessageDeployer.prepareDeployment(ctx.kernalContext().messageFactory(), %s, ctx);"; + stmt = "GridCacheMessageDeployer.deploy(ctx.kernalContext().messageFactory(), %s, ctx);"; break; @@ -176,12 +176,12 @@ private boolean hasCustomDeployment(TypeElement type) { deploy.addAll(body); - // Delegate the non-inferable part to the message's own prepareDeployment, mirroring msg.marshal(). + // Delegate the non-inferable part to the message's own deploy, mirroring msg.marshal(). if (hasCustomDeployment(type)) { if (!body.isEmpty()) deploy.add(EMPTY); - deploy.add(indentedLine("msg.prepareDeployment(ctx);")); + deploy.add(indentedLine("msg.deploy(ctx);")); } indent--; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java index 354284e03ed0f..cad29b7b12909 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java @@ -563,7 +563,7 @@ void p2pUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr) throws IgniteChec } /** {@inheritDoc} */ - @Override public void prepareDeployment(GridDeploymentInfo depInfo) { + @Override public void deploy(GridDeploymentInfo depInfo) { assert evt instanceof CacheEvent; this.depInfo = depInfo; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DeployableMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DeployableMessage.java index dd79f3b87315a..a9848ab3e104e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DeployableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DeployableMessage.java @@ -21,7 +21,7 @@ /** * A {@link GridCacheMessage} with custom deployment logic that cannot be inferred from field types (conditional - * deployment, non-standard accessors, etc.). The generated {@code *Deployer} calls {@link #prepareDeployment} after + * deployment, non-standard accessors, etc.). The generated {@code *Deployer} calls {@link #deploy} after * its inferred field deployment, mirroring how a generated marshaller calls {@code MarshallableMessage#marshal}. */ public interface DeployableMessage { @@ -31,5 +31,5 @@ public interface DeployableMessage { * @param ctx Cache shared context. * @throws IgniteCheckedException If failed. */ - void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException; + void deploy(GridCacheSharedContext ctx) throws IgniteCheckedException; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeployable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeployable.java index 9d8f289bbe1c1..ffd5953a2f7e1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeployable.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeployable.java @@ -24,11 +24,11 @@ */ public interface GridCacheDeployable { /** - * Prepare deployment information. + * Applies the given deployment information. * * @param depInfo Deployment information. */ - public void prepareDeployment(GridDeploymentInfo depInfo); + public void deploy(GridDeploymentInfo depInfo); /** * @return Deployment bean. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java index 29abdca600257..125fe4ce94743 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java @@ -411,7 +411,7 @@ public void prepare(GridCacheDeployable deployable) throws IgnitePeerToPeerClass checkDeploymentIsCorrect(dep, deployable, true); if (dep != null) - deployable.prepareDeployment(dep); + deployable.deploy(dep); if (log.isDebugEnabled()) log.debug("Prepared grid cache deployable [dep=" + dep + ", deployable=" + deployable + ']'); @@ -449,7 +449,7 @@ private void checkDeploymentIsCorrect(GridDeploymentInfoBean deployment, GridCac assert depEnabled; // Do not return info if mode is CONTINUOUS. - // In this case deployment info will be set by GridCacheMessage.prepareObject(). + // In this case deployment info will be set by GridCacheMessage.deployObject(). if (cctx.gridConfig().getDeploymentMode() == CONTINUOUS) return null; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index 2a7fd2162657b..d47de55d1462b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -1096,7 +1096,7 @@ private boolean onSend(GridCacheMessage msg, @Nullable UUID destNodeId) throws I msg.messageId(idGen.incrementAndGet()); if (destNodeId == null || !cctx.localNodeId().equals(destNodeId)) { - GridCacheMessageDeployer.prepareDeployment(cctx.kernalContext().messageFactory(), msg, cctx); + GridCacheMessageDeployer.deploy(cctx.kernalContext().messageFactory(), msg, cctx); if (msg instanceof GridCacheDeployable && msg.addDeploymentInfo()) cctx.deploy().prepare((GridCacheDeployable)msg); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index d5d6d94b5848d..3fae5981c861d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -199,27 +199,27 @@ 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. */ - final void prepareObjectDeployment(@Nullable Object o, GridCacheContext ctx) throws IgniteCheckedException { - prepareObjectDeployment(o, ctx.shared()); + final void deployObject(@Nullable Object o, GridCacheContext ctx) throws IgniteCheckedException { + deployObject(o, ctx.shared()); } /** - * @param o Object to prepare for marshalling. + * @param o Object to deploy. * @param ctx Context. * @throws IgniteCheckedException If failed. */ - final void prepareObjectDeployment(@Nullable Object o, GridCacheSharedContext ctx) throws IgniteCheckedException { + final void deployObject(@Nullable Object o, GridCacheSharedContext ctx) throws IgniteCheckedException { assert addDepInfo || forceAddDepInfo; if (!skipPrepare && o != null) { GridDeploymentInfo d = ctx.deploy().globalDeploymentInfo(); if (d != null) { - prepareDeployment(d); + deploy(d); // Global deployment has been injected. skipPrepare = true; @@ -232,16 +232,16 @@ final void prepareObjectDeployment(@Nullable Object o, GridCacheSharedContext ct ClassLoader ldr = U.detectClassLoader(cls); if (ldr instanceof GridDeploymentInfo) - prepareDeployment((GridDeploymentInfo)ldr); + deploy((GridDeploymentInfo)ldr); } } } /** * @param depInfo Deployment to set. - * @see GridCacheDeployable#prepareDeployment(GridDeploymentInfo) + * @see GridCacheDeployable#deploy(GridDeploymentInfo) */ - public final void prepareDeployment(GridDeploymentInfo depInfo) { + public final void deploy(GridDeploymentInfo depInfo) { if (depInfo != this.depInfo) { if (this.depInfo != null && depInfo instanceof GridDeployment) // Make sure not to replace remote deployment with local. @@ -267,7 +267,7 @@ public GridDeploymentInfoBean deployInfo() { * @param cacheObjCtx Cache object context. * @throws IgniteCheckedException If failed. */ - final void prepareInfoDeployment(GridCacheEntryInfo info, + final void deployInfo(GridCacheEntryInfo info, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx ) throws IgniteCheckedException { @@ -276,14 +276,14 @@ final void prepareInfoDeployment(GridCacheEntryInfo info, if (info != null) { if (addDepInfo) { if (info.key() != null) - prepareObjectDeployment(info.key().value(cacheObjCtx, false), ctx); + deployObject(info.key().value(cacheObjCtx, false), ctx); CacheObject val = info.value(); if (val != null) { val.unmarshal(cacheObjCtx, ctx.deploy().globalLoader()); - prepareObjectDeployment(val.value(cacheObjCtx, false), ctx); + deployObject(val.value(cacheObjCtx, false), ctx); } } } @@ -294,13 +294,13 @@ final void prepareInfoDeployment(GridCacheEntryInfo info, * @param ctx Context. * @throws IgniteCheckedException If failed. */ - final void prepareInfosDeployment(Iterable infos, GridCacheSharedContext ctx, + final void deployInfos(Iterable infos, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx) throws IgniteCheckedException { assert ctx != null; if (infos != null) for (GridCacheEntryInfo e : infos) - prepareInfoDeployment(e, ctx, cacheObjCtx); + deployInfo(e, ctx, cacheObjCtx); } /** @@ -308,7 +308,7 @@ final void prepareInfosDeployment(Iterable infos, * @param ctx Context. * @throws IgniteCheckedException If failed. */ - final void prepareTxDeployment(Iterable txEntries, GridCacheSharedContext ctx) + final void deployTx(Iterable txEntries, GridCacheSharedContext ctx) throws IgniteCheckedException { assert ctx != null; @@ -320,14 +320,14 @@ final void prepareTxDeployment(Iterable txEntries, GridCacheShare if (addDepInfo) { if (e.key() != null) - prepareObjectDeployment(e.key().value(cctx.cacheObjectContext(), false), ctx); + deployObject(e.key().value(cctx.cacheObjectContext(), false), ctx); if (e.value() != null) - prepareObjectDeployment(e.value().value(cctx.cacheObjectContext(), false), ctx); + deployObject(e.value().value(cctx.cacheObjectContext(), false), ctx); if (e.entryProcessors() != null) { for (T2, Object[]> entProc : e.entryProcessors()) - prepareObjectDeployment(entProc.get1(), ctx); + deployObject(entProc.get1(), ctx); } } else if (p2pEnabled && e.entryProcessors() != null) { @@ -335,7 +335,7 @@ else if (p2pEnabled && e.entryProcessors() != null) { forceAddDepInfo = true; for (T2, Object[]> entProc : e.entryProcessors()) - prepareObjectDeployment(entProc.get1(), ctx); + deployObject(entProc.get1(), ctx); } } } @@ -369,7 +369,7 @@ else if (p2pEnabled && e.entryProcessors() != null) { * @param ctx Context. * @throws IgniteCheckedException If failed. */ - final void prepareInvokeArgumentsDeployment(@Nullable Object[] args, GridCacheContext ctx) + final void deployInvokeArguments(@Nullable Object[] args, GridCacheContext ctx) throws IgniteCheckedException { assert ctx != null; @@ -380,7 +380,7 @@ final void prepareInvokeArgumentsDeployment(@Nullable Object[] args, GridCacheCo Object arg = args[i]; if (addDepInfo) - prepareObjectDeployment(arg, ctx.shared()); + deployObject(arg, ctx.shared()); } } @@ -424,19 +424,19 @@ final void prepareInvokeArgumentsDeployment(@Nullable Object[] args, GridCacheCo } /** - * Prepares each element of {@code col} for deployment, calling {@link #prepareObjectDeployment} on each item. + * Deploys each element of {@code col} via {@link #deployObject} on each item. * * @param col Collection to marshal. * @param ctx Context. * @throws IgniteCheckedException If failed. */ - final void prepareCollectionDeployment(@Nullable Collection col, + final void deployCollection(@Nullable Collection col, GridCacheContext ctx) throws IgniteCheckedException { assert ctx != null; for (Object o : col) { if (addDepInfo) - prepareObjectDeployment(o, ctx.shared()); + deployObject(o, ctx.shared()); } } @@ -445,10 +445,10 @@ final void prepareCollectionDeployment(@Nullable Collection col, * @param ctx Context. * @throws IgniteCheckedException If failed. */ - final void prepareCacheObjectDeployment(CacheObject obj, GridCacheContext ctx) throws IgniteCheckedException { + final void deployCacheObject(CacheObject obj, GridCacheContext ctx) throws IgniteCheckedException { if (obj != null) { if (addDepInfo) - prepareObjectDeployment(obj.value(ctx.cacheObjectContext(), false), ctx.shared()); + deployObject(obj.value(ctx.cacheObjectContext(), false), ctx.shared()); } } @@ -457,7 +457,7 @@ final void prepareCacheObjectDeployment(CacheObject obj, GridCacheContext ctx) t * @param ctx Cache context. * @throws IgniteCheckedException If failed. */ - final void prepareCacheObjectsDeployment(@Nullable Collection col, + final void deployCacheObjects(@Nullable Collection col, GridCacheContext ctx) throws IgniteCheckedException { if (col == null) return; @@ -465,7 +465,7 @@ final void prepareCacheObjectsDeployment(@Nullable CollectionDeployer} implements {@link #prepareDeployment} to deploy the message's - * fields. The {@code static} methods are the facade through which all non-generated code (custom {@code prepareDeployment} + * Per-message deployer. A generated {@code Deployer} implements {@link #deploy} to deploy the message's + * fields. The {@code static} methods are the facade through which all non-generated code (custom {@code deploy} * in messages, message-building code) reaches {@link GridCacheMessage}'s package-private deployment helpers — so that, as * with marshalling, deployment internals are never touched directly from outside the {@code cache} package. */ public interface GridCacheMessageDeployer { /** Prepares deployment info for all deployable fields of {@code msg}. */ - void prepareDeployment(M msg, GridCacheSharedContext ctx) throws IgniteCheckedException; + void deploy(M msg, GridCacheSharedContext ctx) throws IgniteCheckedException; - /** Bridge to {@link GridCacheMessage#prepareObjectDeployment}; no-op when the cache context is absent. */ - static void prepareObject(GridCacheMessage msg, @Nullable Object o, @Nullable GridCacheContext cctx) + /** Bridge to {@link GridCacheMessage#deployObject}; no-op when the cache context is absent. */ + static void deployObject(GridCacheMessage msg, @Nullable Object o, @Nullable GridCacheContext cctx) throws IgniteCheckedException { if (cctx != null) - msg.prepareObjectDeployment(o, cctx); + msg.deployObject(o, cctx); } - /** Bridge to {@link GridCacheMessage#prepareCacheObjectDeployment}; no-op when the cache context is absent. */ - static void prepareCacheObject(GridCacheMessage msg, @Nullable CacheObject obj, @Nullable GridCacheContext cctx) + /** Bridge to {@link GridCacheMessage#deployCacheObject}; no-op when the cache context is absent. */ + static void deployCacheObject(GridCacheMessage msg, @Nullable CacheObject obj, @Nullable GridCacheContext cctx) throws IgniteCheckedException { if (cctx != null) - msg.prepareCacheObjectDeployment(obj, cctx); + msg.deployCacheObject(obj, cctx); } - /** Bridge to {@link GridCacheMessage#prepareCacheObjectsDeployment}; no-op when the cache context is absent. */ - static void prepareCacheObjects(GridCacheMessage msg, @Nullable Collection col, + /** Bridge to {@link GridCacheMessage#deployCacheObjects}; no-op when the cache context is absent. */ + static void deployCacheObjects(GridCacheMessage msg, @Nullable Collection col, @Nullable GridCacheContext cctx) throws IgniteCheckedException { if (cctx != null) - msg.prepareCacheObjectsDeployment(col, cctx); + msg.deployCacheObjects(col, cctx); } - /** Bridge to {@link GridCacheMessage#prepareCollectionDeployment}; no-op when the cache context is absent. */ - static void prepareCollection(GridCacheMessage msg, @Nullable Collection col, @Nullable GridCacheContext cctx) + /** Bridge to {@link GridCacheMessage#deployCollection}; no-op when the cache context is absent. */ + static void deployCollection(GridCacheMessage msg, @Nullable Collection col, @Nullable GridCacheContext cctx) throws IgniteCheckedException { if (cctx != null) - msg.prepareCollectionDeployment(col, cctx); + msg.deployCollection(col, cctx); } - /** Bridge to {@link GridCacheMessage#prepareInvokeArgumentsDeployment}; no-op when the cache context is absent. */ - static void prepareInvokeArguments(GridCacheMessage msg, @Nullable Object[] args, @Nullable GridCacheContext cctx) + /** Bridge to {@link GridCacheMessage#deployInvokeArguments}; no-op when the cache context is absent. */ + static void deployInvokeArguments(GridCacheMessage msg, @Nullable Object[] args, @Nullable GridCacheContext cctx) throws IgniteCheckedException { if (cctx != null) - msg.prepareInvokeArgumentsDeployment(args, cctx); + msg.deployInvokeArguments(args, cctx); } - /** Bridge to {@link GridCacheMessage#prepareInfosDeployment}; no-op when the cache context is absent. */ - static void prepareInfos(GridCacheMessage msg, @Nullable Iterable infos, + /** Bridge to {@link GridCacheMessage#deployInfos}; no-op when the cache context is absent. */ + static void deployInfos(GridCacheMessage msg, @Nullable Iterable infos, @Nullable GridCacheContext cctx) throws IgniteCheckedException { if (cctx != null) - msg.prepareInfosDeployment(infos, cctx.shared(), cctx.cacheObjectContext()); + msg.deployInfos(infos, cctx.shared(), cctx.cacheObjectContext()); } - /** Bridge to {@link GridCacheMessage#prepareInfoDeployment}. */ - static void prepareInfo(GridCacheMessage msg, GridCacheEntryInfo info, GridCacheSharedContext ctx, + /** Bridge to {@link GridCacheMessage#deployInfo}. */ + static void deployInfo(GridCacheMessage msg, GridCacheEntryInfo info, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx) throws IgniteCheckedException { - msg.prepareInfoDeployment(info, ctx, cacheObjCtx); + msg.deployInfo(info, ctx, cacheObjCtx); } - /** Bridge to {@link GridCacheMessage#prepareTxDeployment} for generated deployers. */ - static void prepareTxEntries(GridCacheMessage msg, @Nullable Iterable entries, GridCacheSharedContext ctx) + /** Bridge to {@link GridCacheMessage#deployTx} for generated deployers. */ + static void deployTxEntries(GridCacheMessage msg, @Nullable Iterable entries, GridCacheSharedContext ctx) throws IgniteCheckedException { - msg.prepareTxDeployment(entries, ctx); + msg.deployTx(entries, ctx); } /** Forces deployment info on {@code msg} when peer-class-loading is enabled. */ @@ -94,13 +94,13 @@ static void forceDeploymentInfo(GridCacheMessage msg, GridCacheSharedContext ctx) + static void deploy(MessageFactory factory, @Nullable GridCacheMessage msg, GridCacheSharedContext ctx) throws IgniteCheckedException { if (msg == null) return; @@ -108,6 +108,6 @@ static void prepareDeployment(MessageFactory factory, @Nullable GridCacheMessage GridCacheMessageDeployer deployer = factory.deployer(msg.directType()); if (deployer != null) - deployer.prepareDeployment(msg, ctx); + deployer.deploy(msg, ctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index f480c2c2643fb..d5a378e0176c5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -126,11 +126,11 @@ public Collection preloadEntries() { } /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + @Override public void deploy(GridCacheSharedContext ctx) throws IgniteCheckedException { if (preloadEntries != null) { GridCacheContext cctx = ctx.cacheContext(cacheId); - GridCacheMessageDeployer.prepareInfos(this, preloadEntries, cctx); + GridCacheMessageDeployer.deployInfos(this, preloadEntries, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index aeecb7c098713..1ff52590a11c0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -307,13 +307,13 @@ public boolean skipCompletedVersion() { } /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + @Override public void deploy(GridCacheSharedContext ctx) throws IgniteCheckedException { if (owned != null && ownedKeys == null) { for (IgniteTxKey key : owned.keySet()) { GridCacheContext cctx = ctx.cacheContext(key.cacheId()); if (addDepInfo) - GridCacheMessageDeployer.prepareObject(this, key, cctx); + GridCacheMessageDeployer.deployObject(this, key, cctx); } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index d9e7abdba6fcb..1b7625cbb5120 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -503,20 +503,20 @@ else if (conflictVers != null) } /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + @Override public void deploy(GridCacheSharedContext ctx) throws IgniteCheckedException { if (forceTransformBackups) { GridCacheContext cctx = ctx.cacheContext(cacheId); GridCacheMessageDeployer.forceDeploymentInfo(this, ctx); if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) - GridCacheMessageDeployer.prepareInvokeArguments(this, invokeArgs, cctx); + GridCacheMessageDeployer.deployInvokeArguments(this, invokeArgs, cctx); if (entryProcessorsBytes == null) - GridCacheMessageDeployer.prepareCollection(this, entryProcessors, cctx); + GridCacheMessageDeployer.deployCollection(this, entryProcessors, cctx); if (nearEntryProcessorsBytes == null) - GridCacheMessageDeployer.prepareCollection(this, nearEntryProcessors, cctx); + GridCacheMessageDeployer.deployCollection(this, nearEntryProcessors, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index 3f6ae0bfac110..8681b3fe2b746 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -379,7 +379,7 @@ else if (conflictVers != null) } /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + @Override public void deploy(GridCacheSharedContext ctx) throws IgniteCheckedException { if (filter != null && filter.length == 0) filter = null; @@ -389,10 +389,10 @@ else if (conflictVers != null) GridCacheMessageDeployer.forceDeploymentInfo(this, ctx); if (entryProcessorsBytes == null) - GridCacheMessageDeployer.prepareCollection(this, entryProcessors, cctx); + GridCacheMessageDeployer.deployCollection(this, entryProcessors, cctx); if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) - GridCacheMessageDeployer.prepareInvokeArguments(this, invokeArgs, cctx); + GridCacheMessageDeployer.deployInvokeArguments(this, invokeArgs, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index 02a5668ce425b..23c427705e541 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -184,18 +184,18 @@ public GridNearAtomicSingleUpdateInvokeRequest() { } /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + @Override public void deploy(GridCacheSharedContext ctx) throws IgniteCheckedException { GridCacheContext cctx = ctx.cacheContext(cacheId); GridCacheMessageDeployer.forceDeploymentInfo(this, ctx); if (entryProc != null && entryProcBytes == null) { if (addDepInfo) - GridCacheMessageDeployer.prepareObject(this, entryProc, cctx); + GridCacheMessageDeployer.deployObject(this, entryProc, cctx); } if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) - GridCacheMessageDeployer.prepareInvokeArguments(this, invokeArgs, cctx); + GridCacheMessageDeployer.deployInvokeArguments(this, invokeArgs, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index b7c39b8657c9c..bf024ce8ebf3a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -376,11 +376,11 @@ public void partition(int partId) { } /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + @Override public void deploy(GridCacheSharedContext ctx) throws IgniteCheckedException { if (nearUpdates != null) { GridCacheContext cctx = ctx.cacheContext(cacheId); - GridCacheMessageDeployer.prepareCacheObjects(this, nearUpdates.nearValues(), cctx); + GridCacheMessageDeployer.deployCacheObjects(this, nearUpdates.nearValues(), cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index a63a5551103f8..fbd619662e087 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -215,7 +215,7 @@ void addEntry0(int p, boolean historical, GridCacheEntryInfo info, GridCacheShar assert info.value() != null || historical : info; // Need to call this method to initialize info properly. - GridCacheMessageDeployer.prepareInfo(this, info, ctx, cacheObjCtx); + GridCacheMessageDeployer.deployInfo(this, info, ctx, cacheObjCtx); msgSize += info.marshalledSize(cacheObjCtx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java index 4d06b0566ff1e..fb79d83c23ce4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java @@ -3877,7 +3877,7 @@ else if (exchCtx.events().hasServerLeft()) else if (forceAffReassignment) msg.idealAffinityDiff(idealAffDiff); - GridCacheMessageDeployer.prepareDeployment(cctx.kernalContext().messageFactory(), msg, cctx); + GridCacheMessageDeployer.deploy(cctx.kernalContext().messageFactory(), msg, cctx); timeBag.finishGlobalStage("Full message preparing"); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java index b12470b2b201c..48cc9fad23c0d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java @@ -146,11 +146,11 @@ public long futureId() { } /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + @Override public void deploy(GridCacheSharedContext ctx) throws IgniteCheckedException { if (res instanceof CacheObject) { GridCacheContext cctx = ctx.cacheContext(cacheId); - GridCacheMessageDeployer.prepareCacheObject(this, (CacheObject)res, cctx); + GridCacheMessageDeployer.deployCacheObject(this, (CacheObject)res, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 46503ecb7f8d3..0f42e326ffe27 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -587,34 +587,34 @@ public Collection skipKeys() { } /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + @Override public void deploy(GridCacheSharedContext ctx) throws IgniteCheckedException { GridCacheContext cctx = ctx.cacheContext(cacheId); if (keyValFilter != null && keyValFilterBytes == null) { if (addDepInfo) - GridCacheMessageDeployer.prepareObject(this, keyValFilter, cctx); + GridCacheMessageDeployer.deployObject(this, keyValFilter, cctx); } if (rdc != null && rdcBytes == null) { if (addDepInfo) - GridCacheMessageDeployer.prepareObject(this, rdc, cctx); + GridCacheMessageDeployer.deployObject(this, rdc, cctx); } if (trans != null && transBytes == null) { if (addDepInfo) - GridCacheMessageDeployer.prepareObject(this, trans, cctx); + GridCacheMessageDeployer.deployObject(this, trans, cctx); } if (!F.isEmpty(args) && argsBytes == null) { if (addDepInfo) { for (Object arg : args) - GridCacheMessageDeployer.prepareObject(this, arg, cctx); + GridCacheMessageDeployer.deployObject(this, arg, cctx); } } if (idxQryDesc != null && idxQryDescBytes == null) { if (addDepInfo) - GridCacheMessageDeployer.prepareObject(this, idxQryDesc, cctx); + GridCacheMessageDeployer.deployObject(this, idxQryDesc, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index b51881fb2e665..7f55a6a5e7fe1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -159,19 +159,19 @@ public boolean fields() { } /** {@inheritDoc} */ - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + @Override public void deploy(GridCacheSharedContext ctx) throws IgniteCheckedException { GridCacheContext cctx = ctx.cacheContext(cacheId); if (dataBytes == null && data != null) - GridCacheMessageDeployer.prepareCollection(this, data, cctx); + GridCacheMessageDeployer.deployCollection(this, data, cctx); if (addDepInfo && !F.isEmpty(data)) { for (Object o : data) { if (o instanceof Map.Entry) { Map.Entry e = (Map.Entry)o; - GridCacheMessageDeployer.prepareObject(this, e.getKey(), cctx); - GridCacheMessageDeployer.prepareObject(this, e.getValue(), cctx); + GridCacheMessageDeployer.deployObject(this, e.getKey(), cctx); + GridCacheMessageDeployer.deployObject(this, e.getValue(), cctx); } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java index 2cd35df578da5..ffe67490e0282 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java @@ -307,7 +307,7 @@ CacheObject oldValue() { } /** {@inheritDoc} */ - @Override public void prepareDeployment(GridDeploymentInfo depInfo) { + @Override public void deploy(GridDeploymentInfo depInfo) { this.depInfo = depInfo; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 9e4a88baa7029..4047b69ad39ac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -2434,7 +2434,7 @@ void txLocksInfo(UUID nodeId, TxDeadlockFuture fut, Set txKeys) { try { if (!cctx.localNodeId().equals(nodeId)) - GridCacheMessageDeployer.prepareDeployment(cctx.kernalContext().messageFactory(), req, cctx); + GridCacheMessageDeployer.deploy(cctx.kernalContext().messageFactory(), req, cctx); cctx.gridIO().sendToGridTopic(node, TOPIC_TX, req, SYSTEM_POOL); } @@ -3419,7 +3419,7 @@ private class DeadlockDetectionListener implements GridMessageListener { try { if (!cctx.localNodeId().equals(nodeId)) - GridCacheMessageDeployer.prepareDeployment(cctx.kernalContext().messageFactory(), res, cctx); + GridCacheMessageDeployer.deploy(cctx.kernalContext().messageFactory(), res, cctx); cctx.gridIO().sendToGridTopic(nodeId, TOPIC_TX, res, SYSTEM_POOL); } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java index 5b6a36a3cc9f7..06f84b11d9cd4 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java @@ -22,11 +22,11 @@ /** A {@link Message} requiring a custom marshal/unmarshal step via {@link Marshaller}. */ public interface MarshallableMessage extends Message { - /** @param marsh Marshaller for pre-marshalling. */ + /** @param marsh Marshaller for marshalling. */ public void marshal(Marshaller marsh) throws IgniteCheckedException; /** - * @param marsh Marshaller for post-unmarshalling. + * @param marsh Marshaller for unmarshalling. * @param clsLdr Class loader for unmarshalling. */ public void unmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException; diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java index 173c105ebfa6c..ecbc908fd2c07 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java @@ -35,7 +35,7 @@ */ public interface MessageMarshaller { /** - * Pre-marshals the message on the user thread before sending. + * Marshals the message on the user thread before sending. * * @param msg Message to marshal. * @param kctx Kernal context. @@ -45,7 +45,7 @@ public void marshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext throws IgniteCheckedException; /** - * Post-unmarshals the message with full cache context and class loader. + * Unmarshals the message with full cache context and class loader. * * @param msg Message to unmarshal. * @param kctx Kernal context. @@ -56,7 +56,7 @@ public void unmarshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContex throws IgniteCheckedException; /** - * Post-unmarshals message fields that do not require a cache context. + * Unmarshals message fields that do not require a cache context. * * @param msg Message to unmarshal. * @param kctx Kernal context. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java index d7026e3bf746c..42491d1e0c043 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java @@ -489,7 +489,7 @@ public void testDeployerGeneration() { .hasSourceEquivalentTo(javaFile("TestCacheIdMessageDeployer.java")); } - /** Verifies a {@code DeployableMessage}'s generated deployer delegates to its custom {@code prepareDeployment}. */ + /** Verifies a {@code DeployableMessage}'s generated deployer delegates to its custom {@code deploy}. */ @Test public void testDeployerDelegatesToCustomDeployment() { Compilation compilation = compile("TestDeployableMessage.java"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java index fa0f4b5773234..ae75825969587 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageSerializationArchitectureTest.java @@ -49,7 +49,7 @@ * org.apache.ignite.plugin.extensions.communication.MessageReader)} *

  • {@link MessageMarshaller#marshal}
  • *
  • {@link MessageMarshaller#unmarshal}
  • - *
  • static {@code GridCacheMessageDeployer.prepareDeployment(factory, msg, ctx)}
  • + *
  • static {@code GridCacheMessageDeployer.deploy(factory, msg, ctx)}
  • * * *

    The rules key on whether the called method is {@code static}, not on its name — so any instance method added @@ -131,10 +131,10 @@ public void marshallerInstanceMethodsOnlyCalledFromImplementations() { } /** - * Instance method of {@link GridCacheMessageDeployer} ({@code prepareDeployment}) must only be called from + * Instance method of {@link GridCacheMessageDeployer} ({@code deploy}) must only be called from * within classes that themselves implement {@link GridCacheMessageDeployer} — i.e. generated deployers. * - * Everyone else must use the static {@code GridCacheMessageDeployer.prepareDeployment(factory, msg, ctx)} facade. + * Everyone else must use the static {@code GridCacheMessageDeployer.deploy(factory, msg, ctx)} facade. */ @Test public void deployerInstanceMethodOnlyCalledFromImplementations() { @@ -146,7 +146,7 @@ public void deployerInstanceMethodOnlyCalledFromImplementations() { .callMethodWhere(TO_INSTANCE_METHOD .and(target(HasOwner.Predicates.With.owner(assignableTo(GridCacheMessageDeployer.class)))) ) - .because("Use static GridCacheMessageDeployer.prepareDeployment(factory, msg, ctx) instead of " + + .because("Use static GridCacheMessageDeployer.deploy(factory, msg, ctx) instead of " + "calling the instance method directly."); rule.check(classes); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java index 2c03037017baf..fb5e18b568896 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java @@ -89,7 +89,7 @@ public void testMessageUnmarshallWithoutCacheContext() throws Exception { TxLocksResponse msg = new TxLocksResponse(); msg.addKey(cctx.txKey(key)); - GridCacheMessageDeployer.prepareDeployment(cctx.kernalContext().messageFactory(), msg, cctx.shared()); + GridCacheMessageDeployer.deploy(cctx.kernalContext().messageFactory(), msg, cctx.shared()); ((IgniteKernal)ignite).context().cache().context().gridIO().sendToCustomTopic( ((IgniteKernal)client).localNode(), TOPIC, msg, GridIoPolicy.PUBLIC_POOL); diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExceptionTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExceptionTest.java index b93d56d9ab355..1af74a63c3340 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExceptionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExceptionTest.java @@ -197,7 +197,7 @@ private class TestCommunicationSpi extends TcpCommunicationSpi { GridCacheQueryRequest qryReq = (GridCacheQueryRequest)m; if (qryReq.deployInfo() != null) { - qryReq.prepareDeployment(new GridDeploymentInfoBean( + qryReq.deploy(new GridDeploymentInfoBean( IgniteUuid.fromUuid(UUID.randomUUID()), qryReq.deployInfo().userVersion(), qryReq.deployInfo().deployMode(), diff --git a/modules/core/src/test/resources/codegen/TestCacheIdMessageDeployer.java b/modules/core/src/test/resources/codegen/TestCacheIdMessageDeployer.java index a2311bd1bf72d..4a6e71a328ccd 100644 --- a/modules/core/src/test/resources/codegen/TestCacheIdMessageDeployer.java +++ b/modules/core/src/test/resources/codegen/TestCacheIdMessageDeployer.java @@ -30,15 +30,15 @@ */ public class TestCacheIdMessageDeployer implements GridCacheMessageDeployer { /** */ - @Override public void prepareDeployment(TestCacheIdMessage msg, GridCacheSharedContext ctx) throws IgniteCheckedException { + @Override public void deploy(TestCacheIdMessage msg, GridCacheSharedContext ctx) throws IgniteCheckedException { GridCacheContext cctx = ctx.cacheContext(msg.cacheId()); - GridCacheMessageDeployer.prepareCacheObject(msg, msg.key, cctx); + GridCacheMessageDeployer.deployCacheObject(msg, msg.key, cctx); - GridCacheMessageDeployer.prepareCacheObject(msg, msg.val, cctx); + GridCacheMessageDeployer.deployCacheObject(msg, msg.val, cctx); - GridCacheMessageDeployer.prepareCacheObjects(msg, msg.keys, cctx); + GridCacheMessageDeployer.deployCacheObjects(msg, msg.keys, cctx); - GridCacheMessageDeployer.prepareTxEntries(msg, msg.writes, ctx); + GridCacheMessageDeployer.deployTxEntries(msg, msg.writes, ctx); } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestDeployableMessage.java b/modules/core/src/test/resources/codegen/TestDeployableMessage.java index de1667b8dba91..99f946c2b8423 100644 --- a/modules/core/src/test/resources/codegen/TestDeployableMessage.java +++ b/modules/core/src/test/resources/codegen/TestDeployableMessage.java @@ -35,7 +35,7 @@ public short directType() { return true; } - @Override public void prepareDeployment(GridCacheSharedContext ctx) throws IgniteCheckedException { + @Override public void deploy(GridCacheSharedContext ctx) throws IgniteCheckedException { // Custom deployment that cannot be inferred from field types. } } diff --git a/modules/core/src/test/resources/codegen/TestDeployableMessageDeployer.java b/modules/core/src/test/resources/codegen/TestDeployableMessageDeployer.java index 20a54907a2843..f41636bac01ae 100644 --- a/modules/core/src/test/resources/codegen/TestDeployableMessageDeployer.java +++ b/modules/core/src/test/resources/codegen/TestDeployableMessageDeployer.java @@ -30,11 +30,11 @@ */ public class TestDeployableMessageDeployer implements GridCacheMessageDeployer { /** */ - @Override public void prepareDeployment(TestDeployableMessage msg, GridCacheSharedContext ctx) throws IgniteCheckedException { + @Override public void deploy(TestDeployableMessage msg, GridCacheSharedContext ctx) throws IgniteCheckedException { GridCacheContext cctx = ctx.cacheContext(msg.cacheId()); - GridCacheMessageDeployer.prepareCacheObject(msg, msg.key, cctx); + GridCacheMessageDeployer.deployCacheObject(msg, msg.key, cctx); - msg.prepareDeployment(ctx); + msg.deploy(ctx); } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestNestedDeployMessageDeployer.java b/modules/core/src/test/resources/codegen/TestNestedDeployMessageDeployer.java index b0a063b437cdc..3f75e24b49d46 100644 --- a/modules/core/src/test/resources/codegen/TestNestedDeployMessageDeployer.java +++ b/modules/core/src/test/resources/codegen/TestNestedDeployMessageDeployer.java @@ -29,7 +29,7 @@ */ public class TestNestedDeployMessageDeployer implements GridCacheMessageDeployer { /** */ - @Override public void prepareDeployment(TestNestedDeployMessage msg, GridCacheSharedContext ctx) throws IgniteCheckedException { - GridCacheMessageDeployer.prepareDeployment(ctx.kernalContext().messageFactory(), msg.nested, ctx); + @Override public void deploy(TestNestedDeployMessage msg, GridCacheSharedContext ctx) throws IgniteCheckedException { + GridCacheMessageDeployer.deploy(ctx.kernalContext().messageFactory(), msg.nested, ctx); } } \ No newline at end of file From 7f6ccf95ae8572b1b8942d60a35afc1548d3adfb Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 19:09:10 +0300 Subject: [PATCH 211/215] WIP --- .../internal/MessageDeploymentGenerator.java | 6 +- .../processors/cache/GridCacheMessage.java | 49 ++++++++----- .../cache/GridCacheMessageDeployer.java | 72 ++----------------- .../distributed/dht/GridDhtLockResponse.java | 3 +- .../dht/GridDhtTxPrepareRequest.java | 3 +- .../atomic/GridDhtAtomicUpdateRequest.java | 9 ++- .../GridNearAtomicFullUpdateRequest.java | 7 +- ...idNearAtomicSingleUpdateInvokeRequest.java | 7 +- .../atomic/GridNearAtomicUpdateResponse.java | 3 +- .../GridDhtPartitionSupplyMessage.java | 3 +- .../near/GridNearSingleGetResponse.java | 3 +- .../cache/query/GridCacheQueryRequest.java | 11 ++- .../cache/query/GridCacheQueryResponse.java | 7 +- .../codegen/TestCacheIdMessageDeployer.java | 8 +-- .../TestDeployableMessageDeployer.java | 2 +- 15 files changed, 66 insertions(+), 127 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java index b09d900f5c0bd..82df6bd13b1f0 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageDeploymentGenerator.java @@ -142,18 +142,18 @@ private boolean hasCustomDeployment(TypeElement type) { switch (kind) { case CACHE_OBJECT: needsCctx = true; - stmt = "GridCacheMessageDeployer.deployCacheObject(msg, %s, cctx);"; + stmt = "msg.deployCacheObject(%s, cctx);"; break; case CACHE_OBJECTS: needsCctx = true; - stmt = "GridCacheMessageDeployer.deployCacheObjects(msg, %s, cctx);"; + stmt = "msg.deployCacheObjects(%s, cctx);"; break; case TX_ENTRIES: - stmt = "GridCacheMessageDeployer.deployTxEntries(msg, %s, ctx);"; + stmt = "msg.deployTx(%s, ctx);"; break; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index 3fae5981c861d..bff5af40d9174 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -203,8 +203,9 @@ public void lastAffinityChangedTopologyVersion(AffinityTopologyVersion topVer) { * @param ctx Context. * @throws IgniteCheckedException If failed. */ - final void deployObject(@Nullable Object o, GridCacheContext ctx) throws IgniteCheckedException { - deployObject(o, ctx.shared()); + public final void deployObject(@Nullable Object o, @Nullable GridCacheContext ctx) throws IgniteCheckedException { + if (ctx != null) + deployObject(o, ctx.shared()); } /** @@ -237,6 +238,12 @@ final void deployObject(@Nullable Object o, GridCacheSharedContext ctx) throws I } } + /** Forces deployment info to be added when peer-class-loading is enabled. */ + public final void forceDeploymentInfo(GridCacheSharedContext ctx) { + if (!addDepInfo && ctx.deploymentEnabled()) + addDepInfo = true; + } + /** * @param depInfo Deployment to set. * @see GridCacheDeployable#deploy(GridDeploymentInfo) @@ -267,7 +274,7 @@ public GridDeploymentInfoBean deployInfo() { * @param cacheObjCtx Cache object context. * @throws IgniteCheckedException If failed. */ - final void deployInfo(GridCacheEntryInfo info, + public final void deployInfo(GridCacheEntryInfo info, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx ) throws IgniteCheckedException { @@ -289,6 +296,13 @@ final void deployInfo(GridCacheEntryInfo info, } } + /** 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 infos, @Nullable GridCacheContext cctx) + throws IgniteCheckedException { + if (cctx != null) + deployInfos(infos, cctx.shared(), cctx.cacheObjectContext()); + } + /** * @param infos Entries to marshal. * @param ctx Context. @@ -308,7 +322,7 @@ final void deployInfos(Iterable infos, GridCacheSh * @param ctx Context. * @throws IgniteCheckedException If failed. */ - final void deployTx(Iterable txEntries, GridCacheSharedContext ctx) + public final void deployTx(Iterable txEntries, GridCacheSharedContext ctx) throws IgniteCheckedException { assert ctx != null; @@ -369,11 +383,9 @@ else if (p2pEnabled && e.entryProcessors() != null) { * @param ctx Context. * @throws IgniteCheckedException If failed. */ - final void deployInvokeArguments(@Nullable Object[] args, GridCacheContext ctx) + public final void deployInvokeArguments(@Nullable Object[] args, @Nullable GridCacheContext ctx) throws IgniteCheckedException { - assert ctx != null; - - if (args == null) + if (ctx == null || args == null) return; for (int i = 0; i < args.length; i++) { @@ -430,9 +442,10 @@ final void deployInvokeArguments(@Nullable Object[] args, GridCacheContext ctx) * @param ctx Context. * @throws IgniteCheckedException If failed. */ - final void deployCollection(@Nullable Collection col, - GridCacheContext ctx) throws IgniteCheckedException { - assert ctx != null; + public final void deployCollection(@Nullable Collection col, + @Nullable GridCacheContext ctx) throws IgniteCheckedException { + if (ctx == null || col == null) + return; for (Object o : col) { if (addDepInfo) @@ -445,11 +458,9 @@ final void deployCollection(@Nullable Collection col, * @param ctx Context. * @throws IgniteCheckedException If failed. */ - final void deployCacheObject(CacheObject obj, GridCacheContext ctx) throws IgniteCheckedException { - if (obj != null) { - if (addDepInfo) - deployObject(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()); } /** @@ -457,9 +468,9 @@ final void deployCacheObject(CacheObject obj, GridCacheContext ctx) throws Ignit * @param ctx Cache context. * @throws IgniteCheckedException If failed. */ - final void deployCacheObjects(@Nullable Collection col, - GridCacheContext ctx) throws IgniteCheckedException { - if (col == null) + public final void deployCacheObjects(@Nullable Collection col, + @Nullable GridCacheContext ctx) throws IgniteCheckedException { + if (col == null || ctx == null) return; for (CacheObject obj : col) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java index b2d6e9383879c..570802a198675 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java @@ -17,82 +17,20 @@ package org.apache.ignite.internal.processors.cache; -import java.util.Collection; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.jetbrains.annotations.Nullable; /** - * Per-message deployer. A generated {@code Deployer} implements {@link #deploy} to deploy the message's - * fields. The {@code static} methods are the facade through which all non-generated code (custom {@code deploy} - * in messages, message-building code) reaches {@link GridCacheMessage}'s package-private deployment helpers — so that, as - * with marshalling, deployment internals are never touched directly from outside the {@code cache} package. + * Per-message deployer. A generated {@code Deployer} implements {@link #deploy(GridCacheMessage, GridCacheSharedContext)} + * to deploy the message's fields (via {@code GridCacheMessage}'s public {@code deploy*} methods). The static + * {@link #deploy(MessageFactory, GridCacheMessage, GridCacheSharedContext)} is the factory-resolving entry point, + * mirroring the static {@code MessageMarshaller#marshal}. */ public interface GridCacheMessageDeployer { - /** Prepares deployment info for all deployable fields of {@code msg}. */ + /** Deploys all deployable fields of {@code msg}. */ void deploy(M msg, GridCacheSharedContext ctx) throws IgniteCheckedException; - /** Bridge to {@link GridCacheMessage#deployObject}; no-op when the cache context is absent. */ - static void deployObject(GridCacheMessage msg, @Nullable Object o, @Nullable GridCacheContext cctx) - throws IgniteCheckedException { - if (cctx != null) - msg.deployObject(o, cctx); - } - - /** Bridge to {@link GridCacheMessage#deployCacheObject}; no-op when the cache context is absent. */ - static void deployCacheObject(GridCacheMessage msg, @Nullable CacheObject obj, @Nullable GridCacheContext cctx) - throws IgniteCheckedException { - if (cctx != null) - msg.deployCacheObject(obj, cctx); - } - - /** Bridge to {@link GridCacheMessage#deployCacheObjects}; no-op when the cache context is absent. */ - static void deployCacheObjects(GridCacheMessage msg, @Nullable Collection col, - @Nullable GridCacheContext cctx) throws IgniteCheckedException { - if (cctx != null) - msg.deployCacheObjects(col, cctx); - } - - /** Bridge to {@link GridCacheMessage#deployCollection}; no-op when the cache context is absent. */ - static void deployCollection(GridCacheMessage msg, @Nullable Collection col, @Nullable GridCacheContext cctx) - throws IgniteCheckedException { - if (cctx != null) - msg.deployCollection(col, cctx); - } - - /** Bridge to {@link GridCacheMessage#deployInvokeArguments}; no-op when the cache context is absent. */ - static void deployInvokeArguments(GridCacheMessage msg, @Nullable Object[] args, @Nullable GridCacheContext cctx) - throws IgniteCheckedException { - if (cctx != null) - msg.deployInvokeArguments(args, cctx); - } - - /** Bridge to {@link GridCacheMessage#deployInfos}; no-op when the cache context is absent. */ - static void deployInfos(GridCacheMessage msg, @Nullable Iterable infos, - @Nullable GridCacheContext cctx) throws IgniteCheckedException { - if (cctx != null) - msg.deployInfos(infos, cctx.shared(), cctx.cacheObjectContext()); - } - - /** Bridge to {@link GridCacheMessage#deployInfo}. */ - static void deployInfo(GridCacheMessage msg, GridCacheEntryInfo info, GridCacheSharedContext ctx, - CacheObjectContext cacheObjCtx) throws IgniteCheckedException { - msg.deployInfo(info, ctx, cacheObjCtx); - } - - /** Bridge to {@link GridCacheMessage#deployTx} for generated deployers. */ - static void deployTxEntries(GridCacheMessage msg, @Nullable Iterable entries, GridCacheSharedContext ctx) - throws IgniteCheckedException { - msg.deployTx(entries, ctx); - } - - /** Forces deployment info on {@code msg} when peer-class-loading is enabled. */ - static void forceDeploymentInfo(GridCacheMessage msg, GridCacheSharedContext ctx) { - if (!msg.addDepInfo && ctx.deploymentEnabled()) - msg.addDepInfo = true; - } - /** * Deploys {@code msg} through its factory-registered deployer (a no-op when {@code msg} is * {@code null} — e.g. an absent nested message — or the message has no registered deployer). Single entry point diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index d5a378e0176c5..cf0b9b0680113 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -26,7 +26,6 @@ import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; -import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockResponse; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -130,7 +129,7 @@ public Collection preloadEntries() { if (preloadEntries != null) { GridCacheContext cctx = ctx.cacheContext(cacheId); - GridCacheMessageDeployer.deployInfos(this, preloadEntries, cctx); + deployInfos(preloadEntries, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 1ff52590a11c0..2efa19a6677e3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -28,7 +28,6 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareRequest; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; @@ -313,7 +312,7 @@ public boolean skipCompletedVersion() { GridCacheContext cctx = ctx.cacheContext(key.cacheId()); if (addDepInfo) - GridCacheMessageDeployer.deployObject(this, key, cctx); + deployObject(key, cctx); } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 1b7625cbb5120..4e800386a1161 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -28,7 +28,6 @@ import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; @@ -507,16 +506,16 @@ else if (conflictVers != null) if (forceTransformBackups) { GridCacheContext cctx = ctx.cacheContext(cacheId); - GridCacheMessageDeployer.forceDeploymentInfo(this, ctx); + forceDeploymentInfo(ctx); if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) - GridCacheMessageDeployer.deployInvokeArguments(this, invokeArgs, cctx); + deployInvokeArguments(invokeArgs, cctx); if (entryProcessorsBytes == null) - GridCacheMessageDeployer.deployCollection(this, entryProcessors, cctx); + deployCollection(entryProcessors, cctx); if (nearEntryProcessorsBytes == null) - GridCacheMessageDeployer.deployCollection(this, nearEntryProcessors, cctx); + deployCollection(nearEntryProcessors, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index 8681b3fe2b746..2ad20466f7c16 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -31,7 +31,6 @@ import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; @@ -386,13 +385,13 @@ else if (conflictVers != null) if (operation() == TRANSFORM) { GridCacheContext cctx = ctx.cacheContext(cacheId); - GridCacheMessageDeployer.forceDeploymentInfo(this, ctx); + forceDeploymentInfo(ctx); if (entryProcessorsBytes == null) - GridCacheMessageDeployer.deployCollection(this, entryProcessors, cctx); + deployCollection(entryProcessors, cctx); if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) - GridCacheMessageDeployer.deployInvokeArguments(this, invokeArgs, cctx); + deployInvokeArguments(invokeArgs, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index 23c427705e541..bf6ee8069f67d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -30,7 +30,6 @@ import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.DeployableMessage; import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; @@ -187,15 +186,15 @@ public GridNearAtomicSingleUpdateInvokeRequest() { @Override public void deploy(GridCacheSharedContext ctx) throws IgniteCheckedException { GridCacheContext cctx = ctx.cacheContext(cacheId); - GridCacheMessageDeployer.forceDeploymentInfo(this, ctx); + forceDeploymentInfo(ctx); if (entryProc != null && entryProcBytes == null) { if (addDepInfo) - GridCacheMessageDeployer.deployObject(this, entryProc, cctx); + deployObject(entryProc, cctx); } if (!F.isEmpty(invokeArgs) && invokeArgsBytes == null) - GridCacheMessageDeployer.deployInvokeArguments(this, invokeArgs, cctx); + deployInvokeArguments(invokeArgs, cctx); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index bf024ce8ebf3a..066ba444f0fe6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -29,7 +29,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; -import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheReturn; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; @@ -380,7 +379,7 @@ public void partition(int partId) { if (nearUpdates != null) { GridCacheContext cctx = ctx.cacheContext(cacheId); - GridCacheMessageDeployer.deployCacheObjects(this, nearUpdates.nearValues(), cctx); + deployCacheObjects(nearUpdates.nearValues(), cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index fbd619662e087..8b85ce7913a6a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -31,7 +31,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; import org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage; -import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; @@ -215,7 +214,7 @@ void addEntry0(int p, boolean historical, GridCacheEntryInfo info, GridCacheShar assert info.value() != null || historical : info; // Need to call this method to initialize info properly. - GridCacheMessageDeployer.deployInfo(this, info, ctx, cacheObjCtx); + deployInfo(info, ctx, cacheObjCtx); msgSize += info.marshalledSize(cacheObjCtx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java index 48cc9fad23c0d..fcccd4494aca2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java @@ -26,7 +26,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; -import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.plugin.extensions.communication.Message; @@ -150,7 +149,7 @@ public long futureId() { if (res instanceof CacheObject) { GridCacheContext cctx = ctx.cacheContext(cacheId); - GridCacheMessageDeployer.deployCacheObject(this, (CacheObject)res, cctx); + deployCacheObject((CacheObject)res, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 0f42e326ffe27..05bbe0016a5d6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -26,7 +26,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; -import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -592,29 +591,29 @@ public Collection skipKeys() { if (keyValFilter != null && keyValFilterBytes == null) { if (addDepInfo) - GridCacheMessageDeployer.deployObject(this, keyValFilter, cctx); + deployObject(keyValFilter, cctx); } if (rdc != null && rdcBytes == null) { if (addDepInfo) - GridCacheMessageDeployer.deployObject(this, rdc, cctx); + deployObject(rdc, cctx); } if (trans != null && transBytes == null) { if (addDepInfo) - GridCacheMessageDeployer.deployObject(this, trans, cctx); + deployObject(trans, cctx); } if (!F.isEmpty(args) && argsBytes == null) { if (addDepInfo) { for (Object arg : args) - GridCacheMessageDeployer.deployObject(this, arg, cctx); + deployObject(arg, cctx); } } if (idxQryDesc != null && idxQryDescBytes == null) { if (addDepInfo) - GridCacheMessageDeployer.deployObject(this, idxQryDesc, cctx); + deployObject(idxQryDesc, cctx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index 7f55a6a5e7fe1..03b517e476931 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -28,7 +28,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheDeployable; import org.apache.ignite.internal.processors.cache.GridCacheIdMessage; -import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; @@ -163,15 +162,15 @@ public boolean fields() { GridCacheContext cctx = ctx.cacheContext(cacheId); if (dataBytes == null && data != null) - GridCacheMessageDeployer.deployCollection(this, data, cctx); + deployCollection(data, cctx); if (addDepInfo && !F.isEmpty(data)) { for (Object o : data) { if (o instanceof Map.Entry) { Map.Entry e = (Map.Entry)o; - GridCacheMessageDeployer.deployObject(this, e.getKey(), cctx); - GridCacheMessageDeployer.deployObject(this, e.getValue(), cctx); + deployObject(e.getKey(), cctx); + deployObject(e.getValue(), cctx); } } } diff --git a/modules/core/src/test/resources/codegen/TestCacheIdMessageDeployer.java b/modules/core/src/test/resources/codegen/TestCacheIdMessageDeployer.java index 4a6e71a328ccd..00200f0d59c18 100644 --- a/modules/core/src/test/resources/codegen/TestCacheIdMessageDeployer.java +++ b/modules/core/src/test/resources/codegen/TestCacheIdMessageDeployer.java @@ -33,12 +33,12 @@ public class TestCacheIdMessageDeployer implements GridCacheMessageDeployer ctx) throws IgniteCheckedException { GridCacheContext cctx = ctx.cacheContext(msg.cacheId()); - GridCacheMessageDeployer.deployCacheObject(msg, msg.key, cctx); + msg.deployCacheObject(msg.key, cctx); - GridCacheMessageDeployer.deployCacheObject(msg, msg.val, cctx); + msg.deployCacheObject(msg.val, cctx); - GridCacheMessageDeployer.deployCacheObjects(msg, msg.keys, cctx); + msg.deployCacheObjects(msg.keys, cctx); - GridCacheMessageDeployer.deployTxEntries(msg, msg.writes, ctx); + msg.deployTx(msg.writes, ctx); } } \ No newline at end of file diff --git a/modules/core/src/test/resources/codegen/TestDeployableMessageDeployer.java b/modules/core/src/test/resources/codegen/TestDeployableMessageDeployer.java index f41636bac01ae..f4705cafac8eb 100644 --- a/modules/core/src/test/resources/codegen/TestDeployableMessageDeployer.java +++ b/modules/core/src/test/resources/codegen/TestDeployableMessageDeployer.java @@ -33,7 +33,7 @@ public class TestDeployableMessageDeployer implements GridCacheMessageDeployer ctx) throws IgniteCheckedException { GridCacheContext cctx = ctx.cacheContext(msg.cacheId()); - GridCacheMessageDeployer.deployCacheObject(msg, msg.key, cctx); + msg.deployCacheObject(msg.key, cctx); msg.deploy(ctx); } From 0288131d7dd3c0b57d8ed27066dd2cf1f2fe9cc9 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 19:18:06 +0300 Subject: [PATCH 212/215] WIP --- .../internal/processors/cache/query/GridCacheQueryRequest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 05bbe0016a5d6..3f21d760df663 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -36,7 +36,6 @@ import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgniteReducer; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.INDEX; @@ -46,7 +45,7 @@ /** * Query request. */ -public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, Message, DeployableMessage { +public class GridCacheQueryRequest extends GridCacheIdMessage implements GridCacheDeployable, DeployableMessage { /** */ private static final int FLAG_DATA_PAGE_SCAN_DFLT = 0b00; From 780001bd2c78d32c081a7018ad05cdb9e7a8372d Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 20:24:25 +0300 Subject: [PATCH 213/215] WIP --- .../cache/distributed/near/GridNearTxRemote.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java index d67accfd6bedc..6023dbd144c27 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java @@ -209,9 +209,14 @@ public Collection evicted() { */ public void addEntries(ClassLoader ldr, Iterable entries) throws IgniteCheckedException { for (IgniteTxEntry entry : entries) { - entry.initializeContext(cctx, topVer, true); + try { + entry.initializeContext(cctx, topVer, true); - addEntry(entry); + addEntry(entry); + } + catch (CacheInvalidStateException e) { + // Cache was destroyed. + } } } From 6d09b4a8dbbbed43270f1cc960cff9263e21982d Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 20:51:48 +0300 Subject: [PATCH 214/215] WIP --- .../java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java index 74c49232da99c..605d06f9d48ac 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java @@ -73,8 +73,8 @@ import org.apache.ignite.messaging.GridMessagingSelfTest; import org.apache.ignite.messaging.IgniteMessagingSendAsyncTest; import org.apache.ignite.messaging.IgniteMessagingWithClientTest; -import org.apache.ignite.plugin.extensions.communication.MessageUnmarshalOnceTest; import org.apache.ignite.plugin.extensions.communication.MessageMarshalOnceTest; +import org.apache.ignite.plugin.extensions.communication.MessageUnmarshalOnceTest; import org.apache.ignite.spi.GridSpiLocalHostInjectionTest; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTestSelfTest; import org.apache.ignite.testframework.junits.multijvm.JavaVersionCommandParserTest; From e4ef03b125270262e33f7ba261f632718a3b7ea2 Mon Sep 17 00:00:00 2001 From: Anton Vinogradov Date: Tue, 30 Jun 2026 21:29:38 +0300 Subject: [PATCH 215/215] WIP --- .../processors/cache/IgniteCacheOffheapManagerImpl.java | 5 ++++- .../cache/binary/MetadataUpdateProposedMessage.java | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java index b39ec316b314a..c97aefd68213f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java @@ -1003,7 +1003,10 @@ private long allocateForTree() throws IgniteCheckedException { info.expireTime(), info.cacheId(), grp.storeCacheIdInDataPage())); } catch (IllegalStateException th) { - assert ctx.cacheContext(info.cacheId()) == null; // Ignoring removed cache entries. + if (ctx.cacheContext(info.cacheId()) != null) + throw th; // Not a removed-cache race — propagate. + + // Ignoring removed cache entries. } if (batch.size() == PRELOAD_SIZE_UNDER_CHECKPOINT_LOCK || !infos.hasNext()) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java index 16fcca485ec0f..cdef7dbb27e8f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java @@ -183,6 +183,10 @@ public BinaryMetadata metadata() { /** @param metadata Metadata. */ public void metadata(BinaryMetadata metadata) { this.metadata = metadata; + + // Invalidate the cached marshalled form so a re-marshal (e.g. coordinator re-propagating merged metadata) + // picks up the new value instead of keeping the stale bytes under the marshal-once guard. + this.metadataBytes = null; } /** */