Class ExtractionPluginServer

  • All Implemented Interfaces:
    AutoCloseable

    public final class ExtractionPluginServer
    extends Object
    implements AutoCloseable
    gRPC Server for Extraction Plugins.
    Author:
    Netherlands Forensic Institute
    • 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
        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 served
        plugin - 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 served
        numberOfWorkers - the size of the underlying threadpool, which is equal to the number of concurrent workers
        plugin - 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
        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 served
        service - 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 served
        numberOfWorkers - the size of the underlying threadpool, which is equal to the number of concurrent workers
        service - the service to server
        Returns:
        a server instance
        Throws:
        Exception - if the service cannot be served
      • close

        public void close()
        Stop serving requests and shutdown resources.
        Specified by:
        close in interface AutoCloseable