Class ExtractionPluginServer
- java.lang.Object
-
- org.hansken.plugin.extraction.runtime.grpc.server.ExtractionPluginServer
-
- All Implemented Interfaces:
AutoCloseable
public final class ExtractionPluginServer extends Object implements AutoCloseable
gRPC Server for Extraction Plugins.- Author:
- Netherlands Forensic Institute
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_NUM_WORKERSNumber of simultaneous workers.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()Stop serving requests and shutdown resources.intgetListeningPort()Returns the local port the rpc-server is listening on.static ExtractionPluginServerserve(int port, int numberOfWorkers, io.grpc.BindableService service)Start a server with a custom service implementation.static ExtractionPluginServerserve(int port, int numberOfWorkers, Supplier<BaseExtractionPlugin> plugin)Starts a Extraction Plugin server, and returns the server instance.static ExtractionPluginServerserve(int port, io.grpc.BindableService service)Deprecated.useserve(int, int, io.grpc.BindableService)insteadstatic ExtractionPluginServerserve(int port, Supplier<BaseExtractionPlugin> plugin)Deprecated.useserve(int, int, java.util.function.Supplier)insteadstatic ExtractionPluginServerserve(ExtractionPluginServer server)
-
-
-
Field Detail
-
DEFAULT_NUM_WORKERS
public static final int DEFAULT_NUM_WORKERS
Number of simultaneous workers.- See Also:
- Constant Field Values
-
-
Method Detail
-
getListeningPort
public int getListeningPort()
Returns the local port the rpc-server is listening on.- Returns:
- The local port the rpc-server is listening on.
-
serve
@Deprecated public static ExtractionPluginServer serve(int port, Supplier<BaseExtractionPlugin> plugin) throws Exception
Deprecated.useserve(int, int, java.util.function.Supplier)insteadStarts a Extraction Plugin server, and returns the server instance. This method starts the server in a separate thread.
Use this method to start a new extraction plugin server instance, e.g.serve(8111, SimplePlugin::new);- Parameters:
port- port on which the extraction plugin is servedplugin- supplier that provides a new instance of the plugin- Returns:
- a GRPC server instance serving the plugin
- Throws:
Exception- if the plugin can not be served
-
serve
public static ExtractionPluginServer serve(int port, int numberOfWorkers, Supplier<BaseExtractionPlugin> plugin) throws Exception
Starts a Extraction Plugin server, and returns the server instance. This method starts the server in a separate thread.
Use this method to start a new extraction plugin server instance, e.g.serve(8111, SimplePlugin::new);- Parameters:
port- port on which the extraction plugin is servednumberOfWorkers- the size of the underlying threadpool, which is equal to the number of concurrent workersplugin- supplier that provides a new instance of the plugin- Returns:
- a GRPC server instance serving the plugin
- Throws:
Exception- if the plugin can not be served
-
serve
@Deprecated public static ExtractionPluginServer serve(int port, io.grpc.BindableService service) throws Exception
Deprecated.useserve(int, int, io.grpc.BindableService)insteadStart a server with a custom service implementation.Note: this can be used to inject a custom service. This is generally only useful for testing, so that custom service behaviour can be mocked.
- Parameters:
port- on which the service is to be servedservice- the service to server- Returns:
- a server instance
- Throws:
Exception- if the service cannot be served
-
serve
public static ExtractionPluginServer serve(int port, int numberOfWorkers, io.grpc.BindableService service) throws Exception
Start a server with a custom service implementation.Note: this can be used to inject a custom service. This is generally only useful for testing, so that custom service behaviour can be mocked.
- Parameters:
port- on which the service is to be servednumberOfWorkers- the size of the underlying threadpool, which is equal to the number of concurrent workersservice- the service to server- Returns:
- a server instance
- Throws:
Exception- if the service cannot be served
-
serve
public static ExtractionPluginServer serve(ExtractionPluginServer server) throws Exception
- Throws:
Exception
-
close
public void close()
Stop serving requests and shutdown resources.- Specified by:
closein interfaceAutoCloseable
-
-