Class ExtractionPluginClient
- All Implemented Interfaces:
AutoCloseable,BaseExtractionPlugin,RemoteExtractionPlugin
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
ConstructorsConstructorDescriptionExtractionPluginClient(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), but with a pluginId parameter for routing. -
Method Summary
Modifier and TypeMethodDescriptionprotected ExtractionPluginGrpcAdapteradapter(ClientTrace trace, ClientDataContext dataContext, TraceSearcher searcher) Returns an adapter that translates gRPC protocol messages to clean API calls.voidclose()static ObjectcreateTransformerArgument(String type, String value) deserializeJsonArguments(TransformerLabel label, Map<String, String> arguments) Returns the API version of the Remote Extraction Plugin.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.protected RpcTransformerResponseinvokeTransformer(RpcTransformerRequest request) Invoke a transformer with a given request.booleanChecks that the API implemented by the remote plugin is compatible with the currently loaded (runtime) Extraction Plugin SDK version.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.transform(TransformerLabel label, Map<String, String> stringMap) Calls a transformer method of a remote extraction plugin.voidvalidateTransformerRequest(TransformerLabel label, Map<String, TransformerArgument> arguments) Validates if a transformer request given a transformer label and specific arguments is correct.
-
Constructor Details
-
ExtractionPluginClient
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
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
Same asExtractionPluginClient(String, int), but with atargetstring instead.- Parameters:
target- endpoint where the extraction plugin server is running
-
ExtractionPluginClient
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
Same asExtractionPluginClient(String, RetryPolicy), 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 Details
-
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
Returns the API version of the Remote Extraction Plugin.- Returns:
- API version
-
pluginInfo
- Specified by:
pluginInfoin interfaceBaseExtractionPlugin
-
process
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
-
validateTransformerRequest
public void validateTransformerRequest(TransformerLabel label, Map<String, TransformerArgument> arguments) throws IllegalArgumentExceptionValidates if a transformer request given a transformer label and specific arguments is correct.- Parameters:
label- The transformer label specifying the transformer method that is to be called.arguments- The actual arguments that the transformer method is to be invoked with.- Throws:
IllegalArgumentException- Any validation errors describing how the current label and arguments are not compliant.
-
transform
Description copied from interface:RemoteExtractionPluginCalls a transformer method of a remote extraction plugin.- Specified by:
transformin interfaceRemoteExtractionPlugin- Parameters:
label- Describes the name, parameters and return type of the transformer method that we want to invoke.stringMap- The actual arguments we want to pass to the method. Specified as a name and value pair.- Returns:
- Returns a value that was produced by the transformer method.
-
deserializeJsonArguments
public Map<String,TransformerArgument> deserializeJsonArguments(TransformerLabel label, Map<String, String> arguments) -
createTransformerArgument
-
invokeTransformer
Invoke a transformer with a given request. This method is isolated such that it can be easily used for mocking.- Parameters:
request- The transformer request containing the transformer name and arguments we want to invoke it with.- Returns:
- The returned response from the transformer.
-
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
- Specified by:
closein interfaceAutoCloseable- Throws:
InterruptedException
-