Vladsz83 commented on code in PR #13095:
URL: https://github.com/apache/ignite/pull/13095#discussion_r3558658052


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Per-message deployer. A generated {@code <Msg>Deployer} implements {@link 
#deploy(GridCacheMessage, GridCacheSharedContext)}

Review Comment:
   `<Msg>Deployer` -> `<Message>Deployer` ?
   
   `generated {@code <Msg>Deployer} implements {@link #deploy(GridCacheMessage, 
GridCacheSharedContext)}` indeed it does



##########
modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java:
##########
@@ -15,20 +15,19 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.internal;
+package org.apache.ignite.plugin.extensions.communication;

Review Comment:
   Do we really need this as a public API.



##########
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 #deploy} after
+ * its inferred field deployment, mirroring how a generated marshaller calls 
{@code MarshallableMessage#marshal}.
+ */
+public interface DeployableMessage {

Review Comment:
   Many various `deployable` / `deploy` naming while their's logic is a bit 
different. We might rename `DeployableMessage` -> 
`CustomDeployableGridCacheMessage` or `CustomDeployableMessage`



##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java:
##########
@@ -69,15 +79,38 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] 
factories) {
         initialized = true;
     }
 
-    /** {@inheritDoc} */
-    @Override public void register(short directType, Supplier<Message> 
supplier, MessageSerializer serializer) throws IgniteException {
+    /**
+     * Registers a message type with a serializer, an optional marshaller, and 
an optional deployer.

Review Comment:
   `message type ` -> message?



##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java:
##########
@@ -132,6 +163,16 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] 
factories) {
         return serializer;
     }
 
+    /** {@inheritDoc} */
+    @Override public @Nullable MessageMarshaller marshaller(short directType) {

Review Comment:
   `MessageSerializer` -> `MessageSerializer<Message>` or `MessageSerializer<? 
extends Message>` ? In he other places too.



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Per-message deployer. A generated {@code <Msg>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<M extends GridCacheMessage> {
+    /** Deploys all deployable fields of {@code msg}. */
+    void deploy(M msg, GridCacheSharedContext<?, ?> ctx) throws 
IgniteCheckedException;
+
+    /**
+     * Deploys {@code msg} through its factory-registered deployer (a no-op 
when {@code msg} is

Review Comment:
   `factory-registered` what factory?



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Per-message deployer. A generated {@code <Msg>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<M extends GridCacheMessage> {
+    /** Deploys all deployable fields of {@code msg}. */
+    void deploy(M msg, GridCacheSharedContext<?, ?> ctx) throws 
IgniteCheckedException;
+
+    /**
+     * 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
+     * for message deployment: called both by message-sending code and by a 
generated deployer delegating to a nested
+     * message. Mirrors the static {@code MessageMarshaller#marshal}.
+     */
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    static void deploy(MessageFactory factory, @Nullable GridCacheMessage msg, 
GridCacheSharedContext<?, ?> ctx)

Review Comment:
   `@Nullable` looks wierd here. What we register then?



##########
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 #deploy} after
+ * its inferred field deployment, mirroring how a generated marshaller calls 
{@code MarshallableMessage#marshal}.
+ */
+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 deploy(GridCacheSharedContext<?, ?> ctx) throws 
IgniteCheckedException;

Review Comment:
   The same: might be like `customDeploy()`



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java:
##########


Review Comment:
   Suggestion: let's add `@see DeployableMessage`



##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java:
##########
@@ -42,6 +45,13 @@ 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);
+
+    /** 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;

Review Comment:
   Might be final btw.



##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java:
##########
@@ -20,16 +20,19 @@
 import java.lang.reflect.Array;
 import java.util.function.Supplier;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.processors.cache.DeployableMessage;
+import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer;
+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;
+import org.apache.ignite.plugin.extensions.communication.MessageMarshaller;
 import org.apache.ignite.plugin.extensions.communication.MessageSerializer;
 import org.jetbrains.annotations.Nullable;
 
 /**
  * Message factory implementation which is responsible for instantiation of 
all communication messages.

Review Comment:
   Let's say it is not only Communication.



##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactory.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.managers.communication;
+
+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.MessageMarshaller;
+import org.apache.ignite.plugin.extensions.communication.MessageSerializer;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Internal extension of {@link MessageFactory} that also registers and 
resolves the marshal and deployment
+ * companions of a message. Kept out of the public factory interface: 
marshallers and deployers are bound to
+ * kernal and cache internals ({@code GridKernalContext}, {@code 
GridCacheSharedContext}) the public SPI module
+ * must not depend on.
+ *
+ * @see MessageMarshaller
+ * @see GridCacheMessageDeployer
+ */
+public interface IgniteMessageFactory extends MessageFactory {
+    /** {@inheritDoc} */
+    @Override default void register(short directType, Supplier<Message> 
supplier, MessageSerializer serializer)
+        throws IgniteException {
+        register(directType, supplier, serializer, null, null);
+    }
+
+    /**
+     * 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<Message> supplier, 
MessageSerializer serializer,
+        @Nullable MessageMarshaller marshaller) throws IgniteException {
+        register(directType, supplier, serializer, marshaller, null);
+    }
+
+    /**
+     * 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.
+     */
+    public void register(short directType, Supplier<Message> supplier, 
MessageSerializer serializer,

Review Comment:
   Ca we use `MessageSerializer` parametrized like `MessageSerializer<Message>` 
or `MessageSerializer<? extends Message`? Around `IgniteMessageFactory` and 
`MessageFactory`



##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactory.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.managers.communication;
+
+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.MessageMarshaller;
+import org.apache.ignite.plugin.extensions.communication.MessageSerializer;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Internal extension of {@link MessageFactory} that also registers and 
resolves the marshal and deployment
+ * companions of a message. Kept out of the public factory interface: 
marshallers and deployers are bound to
+ * kernal and cache internals ({@code GridKernalContext}, {@code 
GridCacheSharedContext}) the public SPI module
+ * must not depend on.
+ *
+ * @see MessageMarshaller
+ * @see GridCacheMessageDeployer
+ */
+public interface IgniteMessageFactory extends MessageFactory {
+    /** {@inheritDoc} */
+    @Override default void register(short directType, Supplier<Message> 
supplier, MessageSerializer serializer)
+        throws IgniteException {
+        register(directType, supplier, serializer, null, null);
+    }
+
+    /**
+     * 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.

Review Comment:
   Message id/message type? In other places too.



##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactory.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.managers.communication;
+
+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.MessageMarshaller;
+import org.apache.ignite.plugin.extensions.communication.MessageSerializer;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Internal extension of {@link MessageFactory} that also registers and 
resolves the marshal and deployment
+ * companions of a message. Kept out of the public factory interface: 
marshallers and deployers are bound to
+ * kernal and cache internals ({@code GridKernalContext}, {@code 
GridCacheSharedContext}) the public SPI module
+ * must not depend on.
+ *
+ * @see MessageMarshaller
+ * @see GridCacheMessageDeployer
+ */
+public interface IgniteMessageFactory extends MessageFactory {
+    /** {@inheritDoc} */
+    @Override default void register(short directType, Supplier<Message> 
supplier, MessageSerializer serializer)
+        throws IgniteException {
+        register(directType, supplier, serializer, null, null);
+    }
+
+    /**
+     * Register message factory with given direct type, serializer, and 
marshaller. All messages must be registered
+     * during construction of class which implements this interface.

Review Comment:
   `of class` -> `a/the class`? The others too 



##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java:
##########
@@ -69,15 +79,38 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] 
factories) {
         initialized = true;
     }
 
-    /** {@inheritDoc} */
-    @Override public void register(short directType, Supplier<Message> 
supplier, MessageSerializer serializer) throws IgniteException {
+    /**
+     * 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.

Review Comment:
   NonMarshallableMessage -> {@link NonMarshallableMessage}?



##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java:
##########


Review Comment:
   Doesn't throw actually.



##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java:
##########
@@ -69,15 +79,38 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] 
factories) {
         initialized = true;
     }
 
-    /** {@inheritDoc} */
-    @Override public void register(short directType, Supplier<Message> 
supplier, MessageSerializer serializer) throws IgniteException {
+    /**
+     * 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<Message> 
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.");
         }
 
         try {
-            supplier.get().registerAsDirectType(directType);
+            Message msg = supplier.get();
+
+            if (marshaller == null && msg instanceof MarshallableMessage) {
+                throw new IgniteException("Message implements 
MarshallableMessage but is registered without" +
+                    " a marshaller, so it would be sent unmarshalled 
[directType=" + directType +

Review Comment:
   Suggestion: 'so it would be sent unmarshalled ' -> to smth. like `Failed to 
register` or 'Unallowed to register without...'. Same for below, 
`DeployableMessage`.



##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java:
##########
@@ -42,6 +45,13 @@ 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);

Review Comment:
   `MessageSerializer[]` -> `MessageSerializer<Message>[]`? 
`MessageMarshaller[]` and `GridCacheMessageDeployer` too.



##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java:
##########
@@ -132,6 +163,16 @@ public IgniteMessageFactoryImpl(MessageFactoryProvider[] 
factories) {
         return serializer;
     }
 
+    /** {@inheritDoc} */
+    @Override public @Nullable MessageMarshaller marshaller(short directType) {
+        return msgMarshallers[directTypeToIndex(directType)];
+    }
+
+    /** {@inheritDoc} */
+    @Override public @Nullable GridCacheMessageDeployer deployer(short 
directType) {

Review Comment:
   Suggestion: everywhere around `directType` -> `msgType` or `msgId` or 
`msgTypeId`



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Per-message deployer. A generated {@code <Msg>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,

Review Comment:
   `factory-resolving` what factory?



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Per-message deployer. A generated {@code <Msg>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<M extends GridCacheMessage> {
+    /** Deploys all deployable fields of {@code msg}. */
+    void deploy(M msg, GridCacheSharedContext<?, ?> ctx) throws 
IgniteCheckedException;
+
+    /**
+     * 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
+     * for message deployment: called both by message-sending code and by a 
generated deployer delegating to a nested
+     * message. Mirrors the static {@code MessageMarshaller#marshal}.
+     */
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    static void deploy(MessageFactory factory, @Nullable GridCacheMessage msg, 
GridCacheSharedContext<?, ?> ctx)
+        throws IgniteCheckedException {
+        if (msg == null)
+            return;
+
+        // Deployment info is collected only when peer class loading may need 
it; skip the field scans otherwise.
+        if (!msg.addDeploymentInfo() && !ctx.deploymentEnabled())
+            return;
+
+        GridCacheMessageDeployer deployer = 
((IgniteMessageFactory)factory).deployer(msg.directType());

Review Comment:
   Should we check `assert deployer != null`? Why we call this method if there 
is no deployer? 



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Per-message deployer. A generated {@code <Msg>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<M extends GridCacheMessage> {
+    /** Deploys all deployable fields of {@code msg}. */
+    void deploy(M msg, GridCacheSharedContext<?, ?> ctx) throws 
IgniteCheckedException;
+
+    /**
+     * 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
+     * for message deployment: called both by message-sending code and by a 
generated deployer delegating to a nested
+     * message. Mirrors the static {@code MessageMarshaller#marshal}.
+     */
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    static void deploy(MessageFactory factory, @Nullable GridCacheMessage msg, 
GridCacheSharedContext<?, ?> ctx)
+        throws IgniteCheckedException {
+        if (msg == null)
+            return;
+
+        // Deployment info is collected only when peer class loading may need 
it; skip the field scans otherwise.
+        if (!msg.addDeploymentInfo() && !ctx.deploymentEnabled())

Review Comment:
   ```suggestion
           if (!ctx.deploymentEnabled() || !msg.addDeploymentInfo())
   ```



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessageDeployer.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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;
+import org.apache.ignite.internal.managers.communication.IgniteMessageFactory;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Per-message deployer. A generated {@code <Msg>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<M extends GridCacheMessage> {
+    /** Deploys all deployable fields of {@code msg}. */
+    void deploy(M msg, GridCacheSharedContext<?, ?> ctx) throws 
IgniteCheckedException;
+
+    /**
+     * 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

Review Comment:
   Suggestion: let's simplify, shorten



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to