Package org.yamcs.http
Class HttpServer
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractService
-
- org.yamcs.AbstractYamcsService
-
- org.yamcs.http.HttpServer
-
- All Implemented Interfaces:
com.google.common.util.concurrent.Service
,YamcsService
public class HttpServer extends AbstractYamcsService
Server-wide HTTP server based on Netty that provides a number of Yamcs web services:- REST API
- WebSocket API
- Static file serving
-
-
Field Summary
Fields Modifier and Type Field Description static String
TYPE_URL_PREFIX
static org.yamcs.api.HttpRoute
WEBSOCKET_ROUTE
-
Fields inherited from class org.yamcs.AbstractYamcsService
config, log, serviceName, yamcsInstance
-
-
Constructor Summary
Constructors Constructor Description HttpServer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addApi(org.yamcs.api.Api<Context> api)
void
addHandler(String pathSegment, Supplier<Handler> handlerSupplier)
void
addStaticRoot(Path staticRoot)
void
closeChannel(String id)
protected void
doStart()
protected void
doStop()
List<Binding>
getBindings()
List<io.netty.channel.Channel>
getClientChannels()
String
getContextPath()
io.netty.handler.codec.http.cors.CorsConfig
getCorsConfig()
com.google.protobuf.util.JsonFormat.Parser
getJsonParser()
com.google.protobuf.util.JsonFormat.Printer
getJsonPrinter()
com.codahale.metrics.MetricRegistry
getMetricRegistry()
ProtobufRegistry
getProtobufRegistry()
List<Route>
getRoutes()
Spec
getSpec()
Returns the valid configuration options for this service.TokenStore
getTokenStore()
List<Topic>
getTopics()
void
init(String yamcsInstance, String serviceName, YConfiguration config)
Initialize this service.void
startServer()
-
Methods inherited from class org.yamcs.AbstractYamcsService
getConfig, getYamcsInstance
-
Methods inherited from class com.google.common.util.concurrent.AbstractService
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, failureCause, isRunning, notifyFailed, notifyStarted, notifyStopped, startAsync, state, stopAsync, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.common.util.concurrent.Service
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, failureCause, isRunning, startAsync, state, stopAsync
-
Methods inherited from interface org.yamcs.YamcsService
init
-
-
-
-
Field Detail
-
WEBSOCKET_ROUTE
public static final org.yamcs.api.HttpRoute WEBSOCKET_ROUTE
-
TYPE_URL_PREFIX
public static final String TYPE_URL_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSpec
public Spec getSpec()
Description copied from interface:YamcsService
Returns the valid configuration options for this service.- Returns:
- the argument specification, or null if the args should not be validated.
-
init
public void init(String yamcsInstance, String serviceName, YConfiguration config) throws InitException
Description copied from interface:YamcsService
Initialize this service. This is called before the service is started. All operations should finish fast.- Specified by:
init
in interfaceYamcsService
- Overrides:
init
in classAbstractYamcsService
- Parameters:
yamcsInstance
- The yamcs instance, or null if this is a global service.serviceName
- The service name.config
- The configured arguments for this service. IfYamcsService.getSpec()
is implemented then this contains the arguments after being validated (including any defaults).- Throws:
InitException
- When something goes wrong during the execution of this method.
-
addStaticRoot
public void addStaticRoot(Path staticRoot)
-
addApi
public void addApi(org.yamcs.api.Api<Context> api)
-
doStart
protected void doStart()
- Specified by:
doStart
in classcom.google.common.util.concurrent.AbstractService
-
startServer
public void startServer() throws InterruptedException, SSLException, CertificateException, IOException
-
getTokenStore
public TokenStore getTokenStore()
-
getContextPath
public String getContextPath()
-
getProtobufRegistry
public ProtobufRegistry getProtobufRegistry()
-
getJsonParser
public com.google.protobuf.util.JsonFormat.Parser getJsonParser()
-
getJsonPrinter
public com.google.protobuf.util.JsonFormat.Printer getJsonPrinter()
-
getCorsConfig
public io.netty.handler.codec.http.cors.CorsConfig getCorsConfig()
-
getMetricRegistry
public com.codahale.metrics.MetricRegistry getMetricRegistry()
-
getClientChannels
public List<io.netty.channel.Channel> getClientChannels()
-
closeChannel
public void closeChannel(String id)
-
doStop
protected void doStop()
- Specified by:
doStop
in classcom.google.common.util.concurrent.AbstractService
-
-