valepakh commented on code in PR #1267:
URL: https://github.com/apache/ignite-3/pull/1267#discussion_r1007704600


##########
modules/api/src/main/java/org/apache/ignite/network/NodeMetadata.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.network;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Arasdasda.
+ */
+public class NodeMetadata {
+    private static final int VERSION = 1;
+    private final int restPort;
+
+    public NodeMetadata(int restPort) {
+        this.restPort = restPort;
+    }
+
+    public int restPort() {
+        return restPort;
+    }
+
+    /**
+     * Deserializes {@link NodeMetadata} from {@link ByteBuffer}.
+     *
+     * @return {@link NodeMetadata}

Review Comment:
   or null if something goes wrong?



##########
modules/api/src/test/java/org/apache/ignite/network/NodeMetadataTest.java:
##########
@@ -15,8 +15,28 @@
  * limitations under the License.
  */
 
-/**
- * Configuration schemas for Rest component.
- */
+package org.apache.ignite.network;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import java.nio.ByteBuffer;
+import org.junit.jupiter.api.Test;
+
+class NodeMetadataTest {
+
+    @Test
+    void testToByteBufferAndFromByteBuffer() {
+        NodeMetadata metadata = new NodeMetadata(10000);
+        ByteBuffer buffer = metadata.toByteBuffer();
+        NodeMetadata fromByteBuffer = NodeMetadata.fromByteBuffer(buffer);
+        assertEquals(metadata, fromByteBuffer);
+    }
 
-package org.apache.ignite.internal.rest.configuration;
+    @Test
+    void testFromByteBufferWithWrongContent() {
+        ByteBuffer buffer = ByteBuffer.allocate(8);
+        NodeMetadata fromByteBuffer = NodeMetadata.fromByteBuffer(buffer);
+        assertNull(fromByteBuffer);
+    }
+}

Review Comment:
   Please add a line break at the end of the file, it can be done in IDEA 
settings -> Editor -> General -> Ensure every saved file ends with a line break.



##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/call/connect/ConnectCall.java:
##########
@@ -61,7 +68,7 @@ public CallOutput<String> execute(ConnectCallInput input) {
             
stateConfigProvider.get().setProperty(ConfigConstants.LAST_CONNECTED_URL, 
nodeUrl);
             session.setJdbcUrl(constructJdbcUrl(configuration, nodeUrl));
             session.setConnectedToNode(true);
-

Review Comment:
   Please keep the line breaks intact, they are helpful for readability. There 
are some more missing line breaks in other files.



##########
modules/api/src/main/java/org/apache/ignite/network/NodeMetadata.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.network;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Arasdasda.

Review Comment:
   ???



##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/connect/ConnectCommand.java:
##########
@@ -39,17 +45,37 @@ public class ConnectCommand extends BaseCommand implements 
Runnable {
     @Parameters(description = NODE_URL_DESC, descriptionKey = CLUSTER_URL_KEY, 
converter = UrlConverter.class)
     private URL nodeUrl;
 
+    /** Node name option. */
+    @Option(names = {NODE_NAME_OPTION_SHORT, NODE_NAME_OPTION}, description = 
NODE_NAME_DESC)

Review Comment:
   Maybe we can combine these into the single parameter and detect whether this 
is a node name or a node URL?



##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/core/repl/completer/DynamicCompleterFactory.java:
##########
@@ -34,16 +35,18 @@ public class DynamicCompleterFactory {
     private final NodeConfigShowCall nodeConfigShowCall;
     private final ClusterConfigShowCall clusterConfigShowCall;
     private final NodeUrlProvider urlProvider;
+    private final NodeNameRegistry nodeNameRegistry;
 
     /** Default constructor. */
     public DynamicCompleterFactory(
             NodeConfigShowCall nodeConfigShowCall,
             ClusterConfigShowCall clusterConfigShowCall,
-            NodeUrlProvider urlProvider) {
+            NodeUrlProvider urlProvider, NodeNameRegistry nodeNameRegistry) {

Review Comment:
   ```suggestion
               NodeUrlProvider urlProvider,
               NodeNameRegistry nodeNameRegistry) {
   ```



##########
modules/api/src/main/java/org/apache/ignite/network/NodeMetadata.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.network;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Arasdasda.
+ */
+public class NodeMetadata {
+    private static final int VERSION = 1;
+    private final int restPort;
+
+    public NodeMetadata(int restPort) {
+        this.restPort = restPort;
+    }
+
+    public int restPort() {
+        return restPort;
+    }
+
+    /**
+     * Deserializes {@link NodeMetadata} from {@link ByteBuffer}.
+     *
+     * @return {@link NodeMetadata}
+     */
+    public static NodeMetadata fromByteBuffer(ByteBuffer metadata) {
+        try {
+            int version = readInt(metadata, 0);

Review Comment:
   Why not `metadata.getInt(0)`?



##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/call/connect/DisconnectCall.java:
##########
@@ -34,9 +35,12 @@
 public class DisconnectCall implements Call<EmptyCallInput, String> {
     @Inject
     private final Session session;
+    @Inject

Review Comment:
   Micronaut injects the constructor arguments automatically so there's no need 
to annotate the fields.



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