anton-vinogradov commented on code in PR #13095: URL: https://github.com/apache/ignite/pull/13095#discussion_r3579154282
########## modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java: ########## @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.plugin.extensions.communication; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.managers.communication.IgniteMessageFactory; +import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +/** + * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that requires custom serialization. Review Comment: Fixed. ########## modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java: ########## @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.plugin.extensions.communication; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.managers.communication.IgniteMessageFactory; +import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +/** + * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that requires custom serialization. + * + * @param <M> Message type. Review Comment: Fixed — "A message this marshaller handles." ########## modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java: ########## @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.plugin.extensions.communication; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.managers.communication.IgniteMessageFactory; +import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +/** + * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that requires custom serialization. + * + * @param <M> Message type. + */ +public interface MessageMarshaller<M extends Message> { + /** + * Marshals the message on the user thread before sending. + * + * @param msg Message to marshal. + * @param kctx Kernal context. + * @param nested Cache object context, or {@code null} if not applicable. + */ + public void marshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested) Review Comment: Renamed to `cacheObjCtx` — through the interface, the generator emission and the goldens; the role ("context of the enclosing message, null at the top level") stayed in the `@param` javadoc. ########## modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java: ########## @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.plugin.extensions.communication; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.managers.communication.IgniteMessageFactory; +import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +/** + * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that requires custom serialization. Review Comment: Kept the single-L verb — searching the code settles it: Ignite's own public `Marshaller#marshal(Object)` and `U.marshal(...)` use it master-wide, and the JDK precedent is the same (`javax.xml.bind.Marshaller#marshal`). A double-L verb here would diverge from the very API this interface delegates to. ########## modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java: ########## @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.plugin.extensions.communication; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.managers.communication.IgniteMessageFactory; +import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +/** + * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that requires custom serialization. + * + * @param <M> Message type. + */ +public interface MessageMarshaller<M extends Message> { + /** + * Marshals the message on the user thread before sending. + * + * @param msg Message to marshal. Review Comment: Same as above — the codebase canon is the single-L verb. ########## modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java: ########## @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.plugin.extensions.communication; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.managers.communication.IgniteMessageFactory; +import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +/** + * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that requires custom serialization. + * + * @param <M> Message type. + */ +public interface MessageMarshaller<M extends Message> { + /** + * Marshals the message on the user thread before sending. + * + * @param msg Message to marshal. + * @param kctx Kernal context. + * @param nested Cache object context, or {@code null} if not applicable. + */ + public void marshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested) Review Comment: Same as above. ########## modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java: ########## @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.plugin.extensions.communication; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.managers.communication.IgniteMessageFactory; +import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +/** + * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that requires custom serialization. + * + * @param <M> Message type. + */ +public interface MessageMarshaller<M extends Message> { + /** + * Marshals the message on the user thread before sending. + * + * @param msg Message to marshal. + * @param kctx Kernal context. + * @param nested Cache object context, or {@code null} if not applicable. + */ + public void marshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested) + throws IgniteCheckedException; + + /** + * Unmarshals the message with full cache context and class loader. Review Comment: Same as above. ########## modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageMarshaller.java: ########## @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.plugin.extensions.communication; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.managers.communication.IgniteMessageFactory; +import org.apache.ignite.internal.managers.communication.MessageUnmarshalDedup; +import org.apache.ignite.internal.processors.cache.CacheObjectContext; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +/** + * Handles {@code marshal}/{@code unmarshal} for a {@link Message} type that requires custom serialization. + * + * @param <M> Message type. + */ +public interface MessageMarshaller<M extends Message> { + /** + * Marshals the message on the user thread before sending. + * + * @param msg Message to marshal. + * @param kctx Kernal context. + * @param nested Cache object context, or {@code null} if not applicable. + */ + public void marshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested) + throws IgniteCheckedException; + + /** + * Unmarshals the message with full cache context and class loader. + * + * @param msg Message to unmarshal. + * @param kctx Kernal context. + * @param nested Cache object context, or {@code null} if not applicable. + * @param clsLdr Class loader for unmarshalling. + */ + public void unmarshal(M msg, GridKernalContext kctx, @Nullable CacheObjectContext nested, ClassLoader clsLdr) + throws IgniteCheckedException; + + /** + * Unmarshals the message without a cache context, using the configuration class loader — the cache-free receive + * path (e.g. the generic {@code GridIoManager} pass). Delegates to the cache-aware overload with a {@code null} + * context, so per-message marshallers need only implement the cache-aware method. + * + * @param msg Message to unmarshal. + * @param kctx Kernal context. + */ + default void unmarshal(M msg, GridKernalContext kctx) throws IgniteCheckedException { + unmarshal(msg, kctx, null, U.resolveClassLoader(kctx.config())); + } + + /** + * Unmarshals only {@code @NioField}-annotated fields in the NIO/IO thread. No-op by default. + * + * @param msg Message to unmarshal. + * @param kctx Kernal context. + */ + default void unmarshalNio(M msg, GridKernalContext kctx) throws IgniteCheckedException { + } + + /** + * Null-safe {@code unmarshalNio} — skips when no marshaller is registered. + * + * @param <M> Message type. + * @param factory Message factory. + * @param msg Message to unmarshal. + * @param kctx Kernal context. + */ + static <M extends Message> void unmarshalNio(MessageFactory factory, M msg, GridKernalContext kctx) Review Comment: It is — but dropping it doesn't compile: the statics `unmarshal(M, GridKernalContext)` and `unmarshalNio(M, GridKernalContext)` would collide with the same-signature instance defaults of this very interface. It also keeps the family shape aligned: `MessageSerializer.writeTo(factory, …)` and `GridCacheMessageDeployer.deploy(factory, …)` need the explicit factory (there is no kctx there). -- 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]
