You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "valepakh (via GitHub)" <gi...@apache.org> on 2023/02/22 14:51:17 UTC

[GitHub] [ignite-3] valepakh opened a new pull request, #1710: IGNITE-18708 ItGeneratedRestClientTest.updateTheSameNodeConfiguration() is flaky

valepakh opened a new pull request, #1710:
URL: https://github.com/apache/ignite-3/pull/1710

   https://issues.apache.org/jira/browse/IGNITE-18708
   
   The flakiness was caused by the JdbcUrlRegistryImpl not stopping after some CLI tests and spamming node configuration API from another thread so the static `Configuration.getDefaultApiClient()` was used from different threads leading to calls to different nodes than intended.


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] valepakh commented on a diff in pull request #1710: IGNITE-18708 ItGeneratedRestClientTest.updateTheSameNodeConfiguration() is flaky

Posted by "valepakh (via GitHub)" <gi...@apache.org>.
valepakh commented on code in PR #1710:
URL: https://github.com/apache/ignite-3/pull/1710#discussion_r1116007326


##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/logger/CliLoggers.java:
##########
@@ -59,6 +61,10 @@ public static IgniteLogger forName(String name) {
         return Loggers.forName(name, loggerFactory);
     }
 
+    public static void addApiClient(ApiClient client) {
+        httpLoggers.add(new HttpLogging(client));

Review Comment:
   I guess you're right. I can use similar map from path to logger here as in the client factory.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] valepakh commented on a diff in pull request #1710: IGNITE-18708 ItGeneratedRestClientTest.updateTheSameNodeConfiguration() is flaky

Posted by "valepakh (via GitHub)" <gi...@apache.org>.
valepakh commented on code in PR #1710:
URL: https://github.com/apache/ignite-3/pull/1710#discussion_r1115971594


##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/core/ApiClientFactory.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.cli.core;
+
+import jakarta.inject.Singleton;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.ignite.internal.cli.logger.CliLoggers;
+import org.apache.ignite.rest.client.invoker.ApiClient;
+
+/**
+ * This class holds the map from URLs to {@link ApiClient}.
+ */
+@Singleton
+public class ApiClientFactory {
+    private final Map<String, ApiClient> clients = new ConcurrentHashMap<>();
+
+    /**
+     * Gets {@link ApiClient} for the base path.
+     *
+     * @param path Base path.
+     * @return created API client.
+     */
+    public ApiClient getClient(String path) {
+        ApiClient apiClient = clients.computeIfAbsent(path, s -> new ApiClient().setBasePath(s));
+        CliLoggers.addApiClient(apiClient);

Review Comment:
   It could be done but I don't want to introduce side effects to it. I don't think you can be sure whether it's called in the thread-safe manner or not.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] PakhomovAlexander merged pull request #1710: IGNITE-18708 ItGeneratedRestClientTest.updateTheSameNodeConfiguration() is flaky

Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander merged PR #1710:
URL: https://github.com/apache/ignite-3/pull/1710


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] Flaugh24 commented on a diff in pull request #1710: IGNITE-18708 ItGeneratedRestClientTest.updateTheSameNodeConfiguration() is flaky

Posted by "Flaugh24 (via GitHub)" <gi...@apache.org>.
Flaugh24 commented on code in PR #1710:
URL: https://github.com/apache/ignite-3/pull/1710#discussion_r1115464878


##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/core/ApiClientFactory.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.cli.core;
+
+import jakarta.inject.Singleton;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.internal.cli.logger.CliLoggers;
+import org.apache.ignite.rest.client.invoker.ApiClient;
+
+/**
+ * This class holds the map from URLs to {@link ApiClient}.
+ */
+@Singleton
+public class ApiClientFactory {
+    private final Map<String, ApiClient> clients = new HashMap<>();
+
+    /**
+     * Gets {@link ApiClient} for the base path.
+     *
+     * @param path Base path.
+     * @return created API client.
+     */
+    public ApiClient getClient(String path) {

Review Comment:
   What about synchronization? I think it would be better to rewrite it using https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html#computeIfAbsent-K-java.util.function.Function-



##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/core/ApiClientFactory.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.cli.core;
+
+import jakarta.inject.Singleton;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.internal.cli.logger.CliLoggers;
+import org.apache.ignite.rest.client.invoker.ApiClient;
+
+/**
+ * This class holds the map from URLs to {@link ApiClient}.
+ */
+@Singleton
+public class ApiClientFactory {
+    private final Map<String, ApiClient> clients = new HashMap<>();

Review Comment:
   I suppose it should be ConcurrentHashMap



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] Flaugh24 commented on a diff in pull request #1710: IGNITE-18708 ItGeneratedRestClientTest.updateTheSameNodeConfiguration() is flaky

Posted by "Flaugh24 (via GitHub)" <gi...@apache.org>.
Flaugh24 commented on code in PR #1710:
URL: https://github.com/apache/ignite-3/pull/1710#discussion_r1115965745


##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/core/ApiClientFactory.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.cli.core;
+
+import jakarta.inject.Singleton;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.ignite.internal.cli.logger.CliLoggers;
+import org.apache.ignite.rest.client.invoker.ApiClient;
+
+/**
+ * This class holds the map from URLs to {@link ApiClient}.
+ */
+@Singleton
+public class ApiClientFactory {
+    private final Map<String, ApiClient> clients = new ConcurrentHashMap<>();
+
+    /**
+     * Gets {@link ApiClient} for the base path.
+     *
+     * @param path Base path.
+     * @return created API client.
+     */
+    public ApiClient getClient(String path) {
+        ApiClient apiClient = clients.computeIfAbsent(path, s -> new ApiClient().setBasePath(s));
+        CliLoggers.addApiClient(apiClient);

Review Comment:
   Do we really need to do that each time when we call getClient()? 
   I think it could be inside computeIfAbsent()



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] PakhomovAlexander commented on a diff in pull request #1710: IGNITE-18708 ItGeneratedRestClientTest.updateTheSameNodeConfiguration() is flaky

Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander commented on code in PR #1710:
URL: https://github.com/apache/ignite-3/pull/1710#discussion_r1116001293


##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/logger/CliLoggers.java:
##########
@@ -59,6 +61,10 @@ public static IgniteLogger forName(String name) {
         return Loggers.forName(name, loggerFactory);
     }
 
+    public static void addApiClient(ApiClient client) {
+        httpLoggers.add(new HttpLogging(client));

Review Comment:
   `HttpLogging` does not define `equals` and `hashCode`. So, I think the method `addApiClient ` is not idempotent. I suppose we will add client loggers each time we create a client. Could you confirm that using `--verbose` flag does not duplicate the HTTP logging in this case?



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] PakhomovAlexander commented on a diff in pull request #1710: IGNITE-18708 ItGeneratedRestClientTest.updateTheSameNodeConfiguration() is flaky

Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander commented on code in PR #1710:
URL: https://github.com/apache/ignite-3/pull/1710#discussion_r1116013632


##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/logger/CliLoggers.java:
##########
@@ -59,6 +61,10 @@ public static IgniteLogger forName(String name) {
         return Loggers.forName(name, loggerFactory);
     }
 
+    public static void addApiClient(ApiClient client) {
+        httpLoggers.add(new HttpLogging(client));

Review Comment:
   Or just define `hashcode` and `equals` that use URL as a reference.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org