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,org.apache.flink.util.AutoCloseableAsync
- Direct Known Subclasses:
AbstractJobManagerFileHandler,AbstractRestHandler,AbstractTaskManagerFileHandler
public abstract class AbstractHandler<T extends RestfulGateway,R extends RequestBody,M extends MessageParameters> extends LeaderRetrievalHandler<T> implements org.apache.flink.util.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.Loggerlogprotected static org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapperMAPPER-
Fields inherited from class org.apache.flink.runtime.rest.handler.LeaderRetrievalHandler
leaderRetriever, logger, responseHeaders, timeout
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractHandler(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()protected CompletableFuture<Void>closeHandlerAsync()protected voidrespondAsLeader(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
-
-
-
-
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:
respondAsLeaderin classLeaderRetrievalHandler<T extends RestfulGateway>
-
closeAsync
public final CompletableFuture<Void> closeAsync()
- Specified by:
closeAsyncin interfaceorg.apache.flink.util.AutoCloseableAsync
-
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
-
-