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 gateway
R - type of the incoming request
M - 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

    Fields
    Modifier and Type
    Field
    Description
    protected final org.slf4j.Logger
     
    protected static final org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper
     

    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

    Modifier and Type
    Method
    Description
     
     
    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 given HandlerRequest.

    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

    Methods 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

  • Method Details

    • respondAsLeader

      protected void respondAsLeader(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx, RoutedRequest routedRequest, T gateway)
      Specified by:
      respondAsLeader in class LeaderRetrievalHandler<T extends RestfulGateway>
    • closeAsync

      public final CompletableFuture<Void> closeAsync()
      Specified by:
      closeAsync in interface org.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 given HandlerRequest.
      Parameters:
      ctx - channel handler context to write the response
      httpRequest - original http request
      handlerRequest - typed handler request
      gateway - leader gateway
      Returns:
      Future which is completed once the request has been processed
      Throws:
      RestHandlerException - if an exception occurred while responding