[GitHub] [kafka] gharris1727 commented on a diff in pull request #12828: KAFKA-14346: Remove hard-to-mock RestClient calls

2022-11-17 Thread GitBox


gharris1727 commented on code in PR #12828:
URL: https://github.com/apache/kafka/pull/12828#discussion_r1025464638


##
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java:
##
@@ -43,10 +43,38 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeoutException;
 
-public class RestClient {
+public class RestClient implements AutoCloseable {

Review Comment:
   I wasn't able to verify the thread-safety of the HttpClient in all versions 
of Jetty, so I think i'll be leaving the existing pattern of 
one-restclient-per-request in place.



-- 
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: jira-unsubscr...@kafka.apache.org

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



[GitHub] [kafka] gharris1727 commented on a diff in pull request #12828: KAFKA-14346: Remove hard-to-mock RestClient calls

2022-11-16 Thread GitBox


gharris1727 commented on code in PR #12828:
URL: https://github.com/apache/kafka/pull/12828#discussion_r1024441937


##
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java:
##
@@ -43,10 +43,38 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeoutException;
 
-public class RestClient {
+public class RestClient implements AutoCloseable {
 private static final Logger log = 
LoggerFactory.getLogger(RestClient.class);
 private static final ObjectMapper JSON_SERDE = new ObjectMapper();
 
+private final HttpClient client;
+public RestClient(WorkerConfig config) {
+client = new 
HttpClient(SSLUtils.createClientSideSslContextFactory(config));

Review Comment:
   It's even better now: It actually works!
   
   Also it tests all phases of the roll from a non-SSL to SSL cluster.



-- 
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: jira-unsubscr...@kafka.apache.org

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



[GitHub] [kafka] gharris1727 commented on a diff in pull request #12828: KAFKA-14346: Remove hard-to-mock RestClient calls

2022-11-15 Thread GitBox


gharris1727 commented on code in PR #12828:
URL: https://github.com/apache/kafka/pull/12828#discussion_r1023397678


##
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java:
##
@@ -43,10 +43,38 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeoutException;
 
-public class RestClient {
+public class RestClient implements AutoCloseable {

Review Comment:
   Yes I looked through the mutability paths for this class and believe it to 
be thread safe, and added a comment to that effect.



-- 
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: jira-unsubscr...@kafka.apache.org

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



[GitHub] [kafka] gharris1727 commented on a diff in pull request #12828: KAFKA-14346: Remove hard-to-mock RestClient calls

2022-11-15 Thread GitBox


gharris1727 commented on code in PR #12828:
URL: https://github.com/apache/kafka/pull/12828#discussion_r1023397291


##
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java:
##
@@ -43,10 +43,38 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeoutException;
 
-public class RestClient {
+public class RestClient implements AutoCloseable {
 private static final Logger log = 
LoggerFactory.getLogger(RestClient.class);
 private static final ObjectMapper JSON_SERDE = new ObjectMapper();
 
+private final HttpClient client;
+public RestClient(WorkerConfig config) {
+client = new 
HttpClient(SSLUtils.createClientSideSslContextFactory(config));

Review Comment:
   I've added a new test class that verifies that HTTP/HTTPS forwarding works 
when SSL is enabled/disabled on leader and follower. Let me know if this 
provide confidence that this was a lateral refactor.



-- 
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: jira-unsubscr...@kafka.apache.org

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



[GitHub] [kafka] gharris1727 commented on a diff in pull request #12828: KAFKA-14346: Remove hard-to-mock RestClient calls

2022-11-11 Thread GitBox


gharris1727 commented on code in PR #12828:
URL: https://github.com/apache/kafka/pull/12828#discussion_r1020535510


##
connect/runtime/src/main/java/org/apache/kafka/connect/cli/ConnectDistributed.java:
##
@@ -138,7 +141,7 @@ public Connect startConnect(Map 
workerProps) {
 // herder is stopped. This is easier than having to track and own the 
lifecycle ourselves.
 DistributedHerder herder = new DistributedHerder(config, time, worker,
 kafkaClusterId, statusBackingStore, configBackingStore,
-advertisedUrl.toString(), connectorClientConfigOverridePolicy, 
sharedAdmin);
+advertisedUrl.toString(), restClient, 
connectorClientConfigOverridePolicy, sharedAdmin, restClient);

Review Comment:
   I was trying to follow the same pattern as the sharedAdmin, but I see that 
the situation isn't exactly analogous. The sharedAdmin isn't directly used by 
the DistributedHerder, while the restClient is.
   
   Another way to think about it is that we are passing the object _without the 
responsibility to close it_ to the RestServer and the DistributedHerder, while 
we are explicitly passing the responsibility to close it as a lambda.
   
   I'm fine with either implementation, and if you think it's more natural to 
explicitly close it, i'll make the change.



-- 
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: jira-unsubscr...@kafka.apache.org

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