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 with
RequestBody.
Subclasses must be thread-safe
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler
org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.slf4j.Loggerprotected static final org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapperFields inherited from class org.apache.flink.runtime.rest.handler.LeaderRetrievalHandler
leaderRetriever, logger, responseHeaders, timeout -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractHandler(GatewayRetriever<? extends T> leaderRetriever, Duration timeout, Map<String, String> responseHeaders, UntypedResponseMessageHeaders<R, M> untypedResponseMessageHeaders) -
Method Summary
Modifier and TypeMethodDescriptionfinal CompletableFuture<Void>protected CompletableFuture<Void>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, getTimeoutMethods inherited from class org.apache.flink.shaded.netty4.io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.flink.util.AutoCloseableAsync
closeMethods inherited from interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
log
protected final org.slf4j.Logger log -
MAPPER
protected static final org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper MAPPER
-
-
Constructor Details
-
AbstractHandler
protected AbstractHandler(@Nonnull GatewayRetriever<? extends T> leaderRetriever, @Nonnull Duration timeout, @Nonnull Map<String, String> responseHeaders, @Nonnull UntypedResponseMessageHeaders<R, M> untypedResponseMessageHeaders)
-
-
Method Details
-
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
- Specified by:
closeAsyncin interfaceorg.apache.flink.util.AutoCloseableAsync
-
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
-