GitHub user EronWright opened a pull request:
https://github.com/apache/flink/pull/4767
[FLINK-7738] [flip-6] Create WebSocket handler (server, client)
## What is the purpose of the change
Introduces WebSocket support for the FLIP-6 REST server and client.
The basic idea is to use the normal REST handler to initiate a websocket
upgrade. In this way, the normal request parsing logic may be used. For
example, a REST method of `/jobs/:jobid/subscribe` may be developed using a
normal REST handler. The handler responds such that the server initiates the
upgrade procedure rather than producing a normal REST response. A new type of
handler based on `AbstractWebSocketMessageHandler` is then installed into the
pipeline for subsequent interaction.
Netty's `ChannelGroup` is leveraged to act as an event bus to easily
dispatch a message to one or more channels based on a routing key. In the
above example, the routing key might be `jobid`, meaning that a given channel
is listening to events related to a certain job. It is expected that a
concrete subclass of `RestServerEndpoint` create one or more
`KeyedChannelRouter` instances as needed for its handlers, and then write
messages as it sees fit.
The client was similarly adapted to open a `WebSocket` with associated
listeners. Consider the work to be a stop-gap pending further discussion.
The `RestEndpointITCase` test was enhanced with an end-to-end
demonstration. A separate unit test for `AbstractRestHandler` was also
introduced.
## Brief change log
- Introduce `AbstractWebSocketMessageHandler` to handle inbound and
outbound websocket messages.
- Introduce `WebSocketUpgradeResponseBody` as a special REST response that
triggers a websocket upgrade.
- Update `AbstractRestHandler` to handle websocket upgrades.
- Introduce `KeyedChannelRouter` to route websocket messages to interested
channels.
- Update `RestClient` with a new method, `sendWebSocketRequest`.
- Introduce `WebSocket` and `WebSocketListener`.
- Update `RestEndpointITCase` with end-to-end websocket test.
## Verifying this change
This change added tests and can be verified as follows:
- `AbstractRestHandlerTest`
- `RestEndpointITCase`
- `AbstractWebSocketMessageHandlerTest`
## 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
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/EronWright/flink FLINK-7738-2
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/4767.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #4767
----
commit f56168846731ab4205a2b04a42285e0b3a3f1972
Author: Wright, Eron <[email protected]>
Date: 2017-10-04T00:26:56Z
[FLINK-7738] [flip-6] Create WebSocket handler (server, client)
----
---