Package org.apache.flink.runtime.rest
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RestServerEndpoint.RestHandlerUrlComparator
Comparator for Rest URLs.
-
Constructor Summary
Constructors Constructor Description RestServerEndpoint(org.apache.flink.configuration.Configuration configuration)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CompletableFuture<Void>
closeAsync()
String
getRestBaseUrl()
Returns the base URL of the REST server endpoint.int
getRestPort()
Port of the running rest service.InetSocketAddress
getServerAddress()
Returns the address on which this endpoint is accepting requests.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 ofstart()
to setup all handlers that the REST server endpoint implementation requires.protected CompletableFuture<Void>
shutDownInternal()
Stops this REST server endpoint.void
start()
Starts this REST server endpoint.protected abstract void
startInternal()
Hook to start sub class specific services.
-
-
-
Constructor Detail
-
RestServerEndpoint
public RestServerEndpoint(org.apache.flink.configuration.Configuration configuration) throws IOException, org.apache.flink.util.ConfigurationException
- Throws:
IOException
org.apache.flink.util.ConfigurationException
-
-
Method Detail
-
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 ofstart()
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 interfaceRestService
- Returns:
- port of the rest service if running; otherwise -1
-
closeAsync
public CompletableFuture<Void> closeAsync()
- Specified by:
closeAsync
in interfaceorg.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.
-
-