-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-16093: Fix spurious REST-related warnings on Connect startup #15149
Changes from all commits
e0ac9ff
51f7627
eeebab0
7c4ccc8
0713736
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,18 +41,11 @@ public class HerderRequestHandler { | |
|
||
private final RestClient restClient; | ||
|
||
private volatile long requestTimeoutMs; | ||
private final RestRequestTimeout requestTimeout; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The field There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This field is final, it wouldn't make sense to mark it volatile. The underlying mutable value that it returns from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't intend to mark the final field as volatile. I wanted to know why the field was marked as volatile in the old PR since you had made the change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, gotcha. The intent was to make it thread-safe since it's likely that writes and reads to/of that value will take place on different threads. |
||
|
||
public HerderRequestHandler(RestClient restClient, long requestTimeoutMs) { | ||
public HerderRequestHandler(RestClient restClient, RestRequestTimeout requestTimeout) { | ||
this.restClient = restClient; | ||
this.requestTimeoutMs = requestTimeoutMs; | ||
} | ||
|
||
public void requestTimeoutMs(long requestTimeoutMs) { | ||
if (requestTimeoutMs < 1) { | ||
throw new IllegalArgumentException("REST request timeout must be positive"); | ||
} | ||
Comment on lines
-52
to
-54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if this validation was needed in the past as well, but now I don't see it being present. Do you think it's needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed it for two reasons:
|
||
this.requestTimeoutMs = requestTimeoutMs; | ||
this.requestTimeout = requestTimeout; | ||
} | ||
|
||
/** | ||
|
@@ -64,7 +57,7 @@ public void requestTimeoutMs(long requestTimeoutMs) { | |
*/ | ||
public <T> T completeRequest(FutureCallback<T> cb) throws Throwable { | ||
try { | ||
return cb.get(requestTimeoutMs, TimeUnit.MILLISECONDS); | ||
return cb.get(requestTimeout.timeoutMs(), TimeUnit.MILLISECONDS); | ||
} catch (ExecutionException e) { | ||
throw e.getCause(); | ||
} catch (StagedTimeoutException e) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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.kafka.connect.runtime.rest; | ||
|
||
public interface RestRequestTimeout { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Mark this interface as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could see some benefit to this, but it's also not a blocker. It's also debatable, since this interface may change in the future and we don't want to imply that it can only have exactly one abstract method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. Makes sense. |
||
|
||
/** | ||
* @return the current timeout that should be used for REST requests, in milliseconds | ||
*/ | ||
long timeoutMs(); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We could probably move the class definition to the bottom so that all
configureXXXResources
method are togetherThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true, but not a blocker.