Class RestServerEndpoint

java.lang.Object
org.apache.flink.runtime.rest.RestServerEndpoint
All Implemented Interfaces:
AutoCloseable, RestService, org.apache.flink.util.AutoCloseableAsync
Direct Known Subclasses:
WebMonitorEndpoint

public abstract class RestServerEndpoint extends Object implements RestService
An abstract class for netty-based REST server endpoints.
  • Field Details

    • log

      protected final org.slf4j.Logger log
    • uploadDir

      protected final Path uploadDir
    • responseHeaders

      protected final Map<String,String> responseHeaders
  • Constructor Details

    • RestServerEndpoint

      public RestServerEndpoint(org.apache.flink.configuration.Configuration configuration) throws IOException, org.apache.flink.util.ConfigurationException
      Throws:
      IOException
      org.apache.flink.util.ConfigurationException
  • Method Details

    • initializeHandlers

      protected abstract List<org.apache.flink.api.java.tuple.Tuple2<RestHandlerSpecification,org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler>> initializeHandlers(CompletableFuture<String> localAddressFuture)
      This method is called at the beginning of start() to setup all handlers that the REST server endpoint implementation requires.
      Parameters:
      localAddressFuture - future rest address of the RestServerEndpoint
      Returns:
      Collection of AbstractRestHandler which are added to the server endpoint
    • start

      public final void start() throws Exception
      Starts this REST server endpoint.
      Throws:
      Exception - if we cannot start the RestServerEndpoint
    • startInternal

      protected abstract void startInternal() throws Exception
      Hook to start sub class specific services.
      Throws:
      Exception - if an error occurred
    • getServerAddress

      @Nullable public InetSocketAddress getServerAddress()
      Returns the address on which this endpoint is accepting requests.
      Returns:
      address on which this endpoint is accepting requests or null if none
    • getRestBaseUrl

      public String getRestBaseUrl()
      Returns the base URL of the REST server endpoint.
      Returns:
      REST base URL of this endpoint
    • getRestPort

      public int getRestPort()
      Description copied from interface: RestService
      Port of the running rest service.
      Specified by:
      getRestPort in interface RestService
      Returns:
      port of the rest service if running; otherwise -1
    • closeAsync

      public CompletableFuture<Void> closeAsync()
      Specified by:
      closeAsync in interface org.apache.flink.util.AutoCloseableAsync
    • shutDownInternal

      protected CompletableFuture<Void> shutDownInternal()
      Stops this REST server endpoint.
      Returns:
      Future which is completed once the shut down has been finished.