Class AbstractRestHandler<T extends RestfulGateway,R extends RequestBody,P extends ResponseBody,M extends MessageParameters>
- java.lang.Object
-
- org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerAdapter
-
- org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter
-
- org.apache.flink.shaded.netty4.io.netty.channel.SimpleChannelInboundHandler<RoutedRequest>
-
- org.apache.flink.runtime.rest.handler.LeaderRetrievalHandler<T>
-
- org.apache.flink.runtime.rest.handler.AbstractHandler<T,R,M>
-
- org.apache.flink.runtime.rest.handler.AbstractRestHandler<T,R,P,M>
-
- Type Parameters:
R
- type of incoming requestsP
- type of outgoing responses
- All Implemented Interfaces:
AutoCloseable
,org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler
,org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler
,AutoCloseableAsync
- Direct Known Subclasses:
AbstractAggregatingMetricsHandler
,AbstractAsynchronousOperationHandlers.StatusHandler
,AbstractAsynchronousOperationHandlers.TriggerHandler
,AbstractCheckpointStatsHandler
,AbstractExecutionGraphHandler
,AbstractMetricsHandler
,AbstractResourceManagerHandler
,CheckpointHandlers.CheckpointStatusHandler
,CheckpointHandlers.CheckpointTriggerHandler
,ClientCoordinationHandler
,ClusterConfigHandler
,ClusterOverviewHandler
,DashboardConfigHandler
,JarDeleteHandler
,JarListHandler
,JarPlanHandler
,JarRunHandler
,JarUploadHandler
,JobCancellationHandler
,JobClientHeartbeatHandler
,JobExecutionResultHandler
,JobIdsHandler
,JobManagerEnvironmentHandler
,JobManagerJobConfigurationHandler
,JobManagerJobEnvironmentHandler
,JobManagerLogListHandler
,JobManagerProfilingHandler
,JobManagerProfilingListHandler
,JobManagerThreadDumpHandler
,JobResourceRequirementsHandler
,JobResourceRequirementsUpdateHandler
,JobsOverviewHandler
,JobStatusHandler
,JobSubmitHandler
,JobVertexBackPressureHandler
,SavepointHandlers.SavepointStatusHandler
,SavepointHandlers.SavepointTriggerHandler
,SavepointHandlers.StopWithSavepointHandler
,ShutdownHandler
@Sharable public abstract class AbstractRestHandler<T extends RestfulGateway,R extends RequestBody,P extends ResponseBody,M extends MessageParameters> extends AbstractHandler<T,R,M>
Super class for netty-based handlers that work withRequestBody
s andResponseBody
s.Subclasses must be thread-safe.
-
-
Field Summary
-
Fields inherited from class org.apache.flink.runtime.rest.handler.AbstractHandler
log, MAPPER
-
Fields inherited from class org.apache.flink.runtime.rest.handler.LeaderRetrievalHandler
leaderRetriever, logger, responseHeaders, timeout
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractRestHandler(GatewayRetriever<? extends T> leaderRetriever, Duration timeout, Map<String,String> responseHeaders, MessageHeaders<R,P,M> messageHeaders)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description MessageHeaders<R,P,M>
getMessageHeaders()
protected abstract CompletableFuture<P>
handleRequest(HandlerRequest<R> request, T gateway)
This method is called for every incoming request and returns aCompletableFuture
containing a the response.protected CompletableFuture<Void>
respondToRequest(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx, org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest httpRequest, HandlerRequest<R> handlerRequest, T gateway)
Respond to the givenHandlerRequest
.-
Methods inherited from class org.apache.flink.runtime.rest.handler.AbstractHandler
closeAsync, closeHandlerAsync, respondAsLeader
-
Methods inherited from class org.apache.flink.runtime.rest.handler.LeaderRetrievalHandler
channelRead0, getTimeout
-
Methods inherited from class org.apache.flink.shaded.netty4.io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelRead
-
Methods inherited from class org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
-
Methods inherited from class org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.util.AutoCloseableAsync
close
-
-
-
-
Constructor Detail
-
AbstractRestHandler
protected AbstractRestHandler(GatewayRetriever<? extends T> leaderRetriever, Duration timeout, Map<String,String> responseHeaders, MessageHeaders<R,P,M> messageHeaders)
-
-
Method Detail
-
getMessageHeaders
public MessageHeaders<R,P,M> getMessageHeaders()
-
respondToRequest
protected CompletableFuture<Void> respondToRequest(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx, org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest httpRequest, HandlerRequest<R> handlerRequest, T gateway)
Description copied from class:AbstractHandler
Respond to the givenHandlerRequest
.- Specified by:
respondToRequest
in classAbstractHandler<T extends RestfulGateway,R extends RequestBody,M extends MessageParameters>
- Parameters:
ctx
- channel handler context to write the responsehttpRequest
- original http requesthandlerRequest
- typed handler requestgateway
- leader gateway- Returns:
- Future which is completed once the request has been processed
-
handleRequest
protected abstract CompletableFuture<P> handleRequest(@Nonnull HandlerRequest<R> request, @Nonnull T gateway) throws RestHandlerException
This method is called for every incoming request and returns aCompletableFuture
containing a the response.Implementations may decide whether to throw
RestHandlerException
s or fail the returnedCompletableFuture
with aRestHandlerException
.Failing the future with another exception type or throwing unchecked exceptions is regarded as an implementation error as it does not allow us to provide a meaningful HTTP status code. In this case a
HttpResponseStatus.INTERNAL_SERVER_ERROR
will be returned.- Parameters:
request
- request that should be handledgateway
- leader gateway- Returns:
- future containing a handler response
- Throws:
RestHandlerException
- if the handling failed
-
-