Class ExtractionPluginClient
- java.lang.Object
-
- org.hansken.plugin.extraction.runtime.grpc.client.ExtractionPluginClient
-
- All Implemented Interfaces:
AutoCloseable,BaseExtractionPlugin,RemoteExtractionPlugin
public class ExtractionPluginClient extends Object implements RemoteExtractionPlugin, AutoCloseable
Client to connect to a running Extraction Plugin (server).This client acts as a proxy between the clean API and an extraction plugin implementation that is served by a remote gRPC server.
- Author:
- Netherlands Forensic Institute
-
-
Constructor Summary
Constructors Constructor Description ExtractionPluginClient(String target)Same asExtractionPluginClient(String, int), but with atargetstring instead.ExtractionPluginClient(String host, int port)Constructor for the Extraction Plugin client.ExtractionPluginClient(String host, int port, RetryPolicy retryPolicy)SeeExtractionPluginClient(String, int), but with aRetryPolicy.ExtractionPluginClient(String target, RetryPolicy retryPolicy)Same asExtractionPluginClient(String, RetryPolicy), but with atargetstring instead.ExtractionPluginClient(String target, RetryPolicy retryPolicy, String pluginId)Same asExtractionPluginClient(String, RetryPolicy, String), but with a pluginId parameter for routing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ExtractionPluginGrpcAdapteradapter(ClientTrace trace, ClientDataContext dataContext, TraceSearcher searcher)Returns an adapter that translates gRPC protocol messages to clean API calls.voidclose()StringgetPluginApiVersion()Returns the API version of the Remote Extraction Plugin.StringgetTarget()Gets the client's connection target, a String which consists of a host and port.protected ProtocolHandlerhandler(ClientTrace trace, ClientDataContext dataContext, TraceSearcher searcher, ReplyStream stream)Returns a handler for orchestrating the processing of a trace over gRPC.booleanisCompatible()Checks that the API implemented by the remote plugin is compatible with the currently loaded (runtime) Extraction Plugin SDK version.PluginInfopluginInfo()voidprocess(ClientTrace trace, ClientDataContext dataContext)SeeExtractionPlugin.process(Trace, DataContext), but requires a special type ofTrace.voidprocessDeferred(ClientTrace trace, ClientDataContext dataContext, TraceSearcher searcher)SeeExtractionPlugin.process(Trace, DataContext), but requires a special type ofTrace.
-
-
-
Constructor Detail
-
ExtractionPluginClient
public ExtractionPluginClient(String host, int port)
Constructor for the Extraction Plugin client.During construction of this client object no actual connection is created, so if the server is not available on the provided host and port, no exception is thrown. Instead, an exception will be thrown each time a new info or process-method is invoked. In case the client has to fail early it should invoke pluginInfo() directly after constructing the client.
There is no retry policy configured, for this, use
ExtractionPluginClient(String, int, RetryPolicy).- Parameters:
host- Host where the extraction plugin server is runningport- Port where the extraction plugin server is running on
-
ExtractionPluginClient
public ExtractionPluginClient(String host, int port, RetryPolicy retryPolicy)
SeeExtractionPluginClient(String, int), but with aRetryPolicy.- Parameters:
host- host where the extraction plugin server is runningport- port where the extraction plugin server is runningretryPolicy- the retry configuration policy to use, ornullif no policy should be used
-
ExtractionPluginClient
public ExtractionPluginClient(String target)
Same asExtractionPluginClient(String, int), but with atargetstring instead.- Parameters:
target- endpoint where the extraction plugin server is running
-
ExtractionPluginClient
public ExtractionPluginClient(String target, RetryPolicy retryPolicy)
Same asExtractionPluginClient(String, RetryPolicy), but with atargetstring instead.- Parameters:
target- endpoint where the extraction plugin server is runningretryPolicy- the retry configuration policy to use, ornullif no policy should be used
-
ExtractionPluginClient
public ExtractionPluginClient(String target, RetryPolicy retryPolicy, String pluginId)
Same asExtractionPluginClient(String, RetryPolicy, String), but with a pluginId parameter for routing.- Parameters:
target- endpoint where the extraction plugin server is runningretryPolicy- the retry configuration policy to use, ornullif no policy should be usedpluginId- the id of the plugin, which is set in the header, for routing purposes
-
-
Method Detail
-
isCompatible
public boolean isCompatible()
Description copied from interface:RemoteExtractionPluginChecks that the API implemented by the remote plugin is compatible with the currently loaded (runtime) Extraction Plugin SDK version.- Specified by:
isCompatiblein interfaceRemoteExtractionPlugin- Returns:
- true if compatible, false otherwise
-
getPluginApiVersion
public String getPluginApiVersion()
Returns the API version of the Remote Extraction Plugin.- Returns:
- API version
-
pluginInfo
public PluginInfo pluginInfo()
- Specified by:
pluginInfoin interfaceBaseExtractionPlugin
-
process
public void process(ClientTrace trace, ClientDataContext dataContext) throws IOException
Description copied from interface:RemoteExtractionPluginSeeExtractionPlugin.process(Trace, DataContext), but requires a special type ofTrace.- Specified by:
processin interfaceRemoteExtractionPlugin- Parameters:
trace- the trace to processdataContext- data context of this trace extraction- Throws:
IOException- when an I/O error occurs
-
processDeferred
public void processDeferred(ClientTrace trace, ClientDataContext dataContext, TraceSearcher searcher) throws IOException
Description copied from interface:RemoteExtractionPluginSeeExtractionPlugin.process(Trace, DataContext), but requires a special type ofTrace.- Specified by:
processDeferredin interfaceRemoteExtractionPlugin- Parameters:
trace- the trace to processdataContext- data context of this trace extractionsearcher- the trace searcher- Throws:
IOException- when an I/O error occurs
-
getTarget
public String getTarget()
Gets the client's connection target, a String which consists of a host and port. For example: localhost:8999.- Returns:
- a host and port combined into an authority string
-
handler
protected ProtocolHandler handler(ClientTrace trace, ClientDataContext dataContext, TraceSearcher searcher, ReplyStream stream)
Returns a handler for orchestrating the processing of a trace over gRPC.This method is exposed as protected method so we can hook into this object using unit tests.
- Parameters:
trace- the trace to processdataContext- the data context to processsearcher- the trace searcherstream- the outbound communication stream- Returns:
- a gRPC handler
-
adapter
protected ExtractionPluginGrpcAdapter adapter(ClientTrace trace, ClientDataContext dataContext, TraceSearcher searcher)
Returns an adapter that translates gRPC protocol messages to clean API calls.This method is exposed as protected method so we can hook into this object using unit tests.
- Parameters:
trace- the trace on which to make the API callsdataContext- the data context on which to make the API callssearcher- the searcher on which to make the API calls- Returns:
- gRPC adapter object
-
close
public void close() throws InterruptedException- Specified by:
closein interfaceAutoCloseable- Throws:
InterruptedException
-
-