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
[FLINK-7534] Create LegacyRestHandlerAdapter for old REST handlers #4603
[FLINK-7534] Create LegacyRestHandlerAdapter for old REST handlers #4603
Conversation
e809638
to
7e3d861
Compare
5eb55a2
to
3bae198
Compare
|
||
} catch (Throwable throwable) { | ||
logger.warn("Error occurred while processing web request.", throwable); | ||
HandlerUtils.sendErrorResponse( |
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.
indentation is off
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.
Good catch.
/** | ||
* Status overview message including the current flink version and commit id. | ||
*/ | ||
public class StatusOverviewWithVersion extends StatusOverview implements ResponseBody { |
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.
I suggest to add a test to verify that a given Request-/ResponseBody can be mapped to JSON and back again. An example can be found here: https://github.com/zentol/flink/blob/7072/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/JobSubmitRequestBodyResponseTest.java
(We can probably create a simple test base for this)
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.
Good point. I'll add it.
/** | ||
* Request for Flink's legacy REST handler. | ||
*/ | ||
public class LegacyRequest implements RequestBody { |
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.
Let's rename this to EmptyRequestBody
, similar to EmptyMessageParameters
.
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.
Good idea.
|
||
CompletableFuture<R> handleRequest(HandlerRequest<LegacyRequest, M> request, T gateway); | ||
|
||
String[] getPaths(); |
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.
I don't think we'll need this anymore, as this should be subsumed by the message headers.
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.
True, I will remove it.
3bae198
to
f8ef066
Compare
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.
Changes on f8ef066 look good to me. Only some very minor typo nitpicks.
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Interface which Flink's legacy REST handler have to implement in order to bu usable |
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.
typo: bu -> be?
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.
good catch.
import java.util.Objects; | ||
|
||
/** | ||
* Status overview message including the current flink version and commit id. |
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: Capital F for Flink
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.
good catch
|
||
@Override | ||
public String getTargetRestEndpointURL() { | ||
return "/overview"; |
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.
Maybe we should make ClusterOverviewHandler#CLUSTER_OVERVIEW_REST_PATH
public and reuse that
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.
Will move CLUSTER_OVERVIEW_REST_PATH
to ClusterOverviewHeaders
and reference it from ClusterOverviewHandler
.
Thanks for your review @tzulitai. I will address your comments and then merge this PR. |
ae7f59f
to
1991c9e
Compare
Introduce LegacyRestHandler interface which the old REST handler have to implement in order to make them usable for the RestServerEndpoint in combination with the LegacyRestHandlerAdapter. The LegacyRestHandlerAdapter extends the AbstractRestHandler and runs the LegacyRestHandler implementation. As an example, this commit ports the ClusterOverviewHandler to the new interface. The Dispatcher side still has to be properly implemented.
1991c9e
to
d794ac0
Compare
What is the purpose of the change
Introduce LegacyRestHandler interface which the old REST handler have to implement
in order to make them usable for the RestServerEndpoint in combination with the
LegacyRestHandlerAdapter. The LegacyRestHandlerAdapter extends the AbstractRestHandler
and runs the LegacyRestHandler implementation.
As an example, this commit ports the ClusterOverviewHandler to the new interface. The
Dispatcher side still has to be properly implemented.
Brief change log
LegacyRestHandler
interface to be implemented by the old REST handlerLegacyRestHandlerAdapter
which allows theLegacyRestHandler
to be executed by theRestServerEndpoint
ClusterOverviewHandler
to theLegacyRestHandler
interfaceVerifying this change
This change has been manually verified by starting the
DispatcherRestEndpoint
and opening the web frontend in a browser.Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation