Class AbstractHandler<T extends RestfulGateway,R extends RequestBody,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>
-
- Type Parameters:
T
- type of the leader gatewayR
- type of the incoming requestM
- type of the message parameters
- 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:
AbstractJobManagerFileHandler
,AbstractRestHandler
,AbstractSqlGatewayRestHandler
,AbstractTaskManagerFileHandler
public abstract class AbstractHandler<T extends RestfulGateway,R extends RequestBody,M extends MessageParameters> extends LeaderRetrievalHandler<T> implements AutoCloseableAsync
Super class for netty-based handlers that work withRequestBody
.Subclasses must be thread-safe
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
log
protected static org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper
MAPPER
-
Fields inherited from class org.apache.flink.runtime.rest.handler.LeaderRetrievalHandler
leaderRetriever, logger, responseHeaders, timeout
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractHandler(GatewayRetriever<? extends T> leaderRetriever, Duration timeout, Map<String,String> responseHeaders, UntypedResponseMessageHeaders<R,M> untypedResponseMessageHeaders)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CompletableFuture<Void>
closeAsync()
Trigger the closing of the resource and return the corresponding close future.protected CompletableFuture<Void>
closeHandlerAsync()
protected void
respondAsLeader(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx, RoutedRequest routedRequest, T gateway)
protected abstract 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.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
-
AbstractHandler
protected AbstractHandler(@Nonnull GatewayRetriever<? extends T> leaderRetriever, @Nonnull Duration timeout, @Nonnull Map<String,String> responseHeaders, @Nonnull UntypedResponseMessageHeaders<R,M> untypedResponseMessageHeaders)
-
-
Method Detail
-
respondAsLeader
protected void respondAsLeader(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx, RoutedRequest routedRequest, T gateway)
- Specified by:
respondAsLeader
in classLeaderRetrievalHandler<T extends RestfulGateway>
-
closeAsync
public final CompletableFuture<Void> closeAsync()
Description copied from interface:AutoCloseableAsync
Trigger the closing of the resource and return the corresponding close future.- Specified by:
closeAsync
in interfaceAutoCloseableAsync
- Returns:
- Future which is completed once the resource has been closed
-
closeHandlerAsync
protected CompletableFuture<Void> closeHandlerAsync()
-
respondToRequest
protected abstract 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) throws RestHandlerException
Respond to the givenHandlerRequest
.- 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
- Throws:
RestHandlerException
- if an exception occurred while responding
-
-