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 classRestServerEndpoint.RestHandlerUrlComparatorComparator 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()StringgetRestBaseUrl()Returns the base URL of the REST server endpoint.intgetRestPort()Port of the running rest service.InetSocketAddressgetServerAddress()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.voidstart()Starts this REST server endpoint.protected abstract voidstartInternal()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:
IOExceptionorg.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 ExceptionStarts this REST server endpoint.- Throws:
Exception- if we cannot start the RestServerEndpoint
-
startInternal
protected abstract void startInternal() throws ExceptionHook 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:RestServicePort of the running rest service.- Specified by:
getRestPortin interfaceRestService- Returns:
- port of the rest service if running; otherwise -1
-
closeAsync
public CompletableFuture<Void> closeAsync()
- Specified by:
closeAsyncin 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.
-
-