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


##########
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;
+
+/** Marker interface: no {@link MessageMarshaller} is generated for 
implementing classes. */
+public interface NonMarshallableMessage extends Message {

Review Comment:
   Should we use an annotation instead of an empty interface. Empty interface 
is a bad, outdated practice to me.



##########
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 {

Review Comment:
   Is it so necessary to bring one more annotation? Can we use `Marshalled`?



##########
modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/CacheIdAware.java:
##########
@@ -0,0 +1,24 @@
+/*
+ * 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;
+
+/** Implemented by messages that carry a cache ID identifying the target 
cache. */

Review Comment:
   Suggestion: let's describe its purpose.



##########
modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java:
##########
@@ -45,8 +49,15 @@ public class DiscoveryMessageParser {
     private final MessageFactory msgFactory;
 
     /** */
-    public DiscoveryMessageParser(MessageFactory msgFactory) {
+    private final ZookeeperDiscoverySpi spi;

Review Comment:
   Suggestion: let's store GridKernalContext instead



##########
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 {

Review Comment:
   Same question as for `MarshalledCollection`



##########
modules/commons/src/main/java/org/apache/ignite/plugin/extensions/communication/Message.java:
##########
@@ -32,19 +47,25 @@ public interface Message {
     /** Registry of message class to direct type mappings, populated during 
factory initialization. */
     Map<Class<?>, Short> REGISTRATIONS = new ConcurrentHashMap<>();
 
+    /** Per-class cache over {@link #REGISTRATIONS}; keeps {@link 
#directType()} off the hash lookup on the hot path. */

Review Comment:
   Can we clarify what is `the hot path?`



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java:
##########
@@ -184,25 +183,17 @@ 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;

Review Comment:
   We do not zero the marshalled bytes usually. Should either do not do it or 
do it everywhere



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotVerifyResult.java:
##########
@@ -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<>();

Review Comment:
   Initial array size?



##########
modules/codegen/src/main/java/org/apache/ignite/internal/MarshalledObjects.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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<byte[]>} 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.
+ *
+ * <p>An unmarshalled {@code Map.Entry} element (a query result row) gets its 
{@code KeyCacheObject} key resolved with
+ * the message's cache object context: such a key arrives bytes-only and 
forbids lazy resolution.
+ */
+@Retention(RetentionPolicy.CLASS)
+@Target(ElementType.FIELD)
+public @interface MarshalledObjects {

Review Comment:
   Can we consider using `Marshalled` also for not-message fields?



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotVerifyResult.java:
##########
@@ -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));
+            }

Review Comment:
   No need the brackets



##########
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()}. */

Review Comment:
   Same as in `Marshalled`



##########
modules/codegen/src/main/java/org/apache/ignite/internal/NioField.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.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marks a {@code Message}-typed {@link Order} field that is unmarshalled 
early — on the NIO (read) thread —

Review Comment:
   Let's simplify `{@code Message}-typed {@link Order}` to be human readable. 
In the other places too. Allows field serialization at NIO/Socket processing in 
its thread`



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IncrementalSnapshotVerifyResult.java:
##########
@@ -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);

Review Comment:
   Why changed?



##########
modules/codegen/src/main/java/org/apache/ignite/internal/NioField.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.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marks a {@code Message}-typed {@link Order} field that is unmarshalled 
early — on the NIO (read) thread —
+ * instead of being deferred to the worker thread with the rest of the 
message. Used for routing headers such as
+ * the topic, which must be read before the message can be dispatched to a 
pool.
+ */
+@Retention(RetentionPolicy.CLASS)
+@Target(ElementType.FIELD)
+public @interface NioField {

Review Comment:
   Can it be used with Sockets? Should we use a name meaning network/io-close 
serialization?



##########
modules/commons/src/main/java/org/apache/ignite/plugin/extensions/communication/Message.java:
##########
@@ -24,6 +24,21 @@
 
 /**
  * Base class for all communication messages.
+ * <p>

Review Comment:
   Let's fix `all communication messages`. Discovery uses them too.



##########
modules/commons/src/main/java/org/apache/ignite/plugin/extensions/communication/Message.java:
##########
@@ -24,6 +24,21 @@
 
 /**
  * Base class for all communication messages.
+ * <p>
+ * Wire fields are declared by annotating instance fields; {@link 
org.apache.ignite.internal.MessageProcessor} then

Review Comment:
   Try to search for `wire` in the code. Isn't popular. Can we rewite? 



-- 
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