Skip to content
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

Closed

Conversation

tillrohrmann
Copy link
Contributor

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

  • Introduce LegacyRestHandler interface to be implemented by the old REST handler
  • Implement LegacyRestHandlerAdapter which allows the LegacyRestHandler to be executed by the RestServerEndpoint
  • Port the ClusterOverviewHandler to the LegacyRestHandler interface

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

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (no)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (no)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (no)

Documentation

  • Does this pull request introduce a new feature? (no)
  • If yes, how is the feature documented? (not applicable)

@tillrohrmann tillrohrmann force-pushed the createLegacyHandlerAdapter branch 5 times, most recently from 5eb55a2 to 3bae198 Compare September 6, 2017 11:40

} catch (Throwable throwable) {
logger.warn("Error occurred while processing web request.", throwable);
HandlerUtils.sendErrorResponse(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation is off

Copy link
Contributor Author

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 {
Copy link
Contributor

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)

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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();
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@tzulitai tzulitai left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: bu -> be?

Copy link
Contributor Author

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.
Copy link
Contributor

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

Copy link
Contributor Author

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";
Copy link
Contributor

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

Copy link
Contributor Author

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.

@tillrohrmann
Copy link
Contributor Author

Thanks for your review @tzulitai. I will address your comments and then merge this PR.

@tillrohrmann tillrohrmann force-pushed the createLegacyHandlerAdapter branch 2 times, most recently from ae7f59f to 1991c9e Compare September 20, 2017 09:20
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants