Class Pack
- java.lang.Object
-
- org.hansken.plugin.extraction.runtime.grpc.common.Pack
-
-
Field Summary
Fields Modifier and Type Field Description static intFIRST_BYTES_SIZEAmount of bytes initially sent with the RpcRandomAccessDataMeta (for performance reasons).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static io.grpc.StatusRuntimeExceptionasStatusRuntimeException(io.grpc.Status.Code statusCode, Throwable t)Wrap athrowablein a status exception which can be used to signal an error on gRPC stream.static RpcAuthorauthor(Author author)static RpcMaturitymaturityLevel(MaturityLevel maturity)Convert givenMaturityLevelto theirRpcMaturitycounterpart.static RpcRandomAccessDataMetametaOfData(String dataType, RandomAccessData data)Convert givenRandomAccessDatato theirRpcRandomAccessDataMetacounterpart.static RpcDataContextmetaOfDataContext(DataContext context)Convert givenDataContextto theirRpcDataContextcounterpart.static RpcPluginIdentifierpluginId(PluginId id)static RpcPluginInfopluginInfo(PluginInfo info)Convert givenPluginInfoto theirRpcPluginInfocounterpart.static RpcPluginTypepluginType(PluginType type)Convert givenPluginTypeto theirRpcPluginTypecounterpart.static com.google.protobuf.Messageprimitive(Object object)Convert given object to their RPC primitive message counterpart (see PrimitiveMessages proto definitions), based on the runtime type.static RpcTracePropertyproperty(String name, Object value)static RpcRandomAccessDataMetarandomAccessDataMeta(String dataType, ImmutableTrace trace)Pack given dataType and trace into an RPC message.static RpcReadreadParameters(long position, int count, String traceUid, String type)Create anRpcReadmessage from given position and size.static RpcSearchRequestsearchRequest(String query, int count, TraceSearcher.SearchScope scope)Create aRpcSearchRequestmessage from given query and count.static RpcSearchResultsearchResult(SearchResult result)Create aRpcSearchResultfrom a givenSearchResult.static RpcSearchTracesearchTrace(SearchTrace trace)Convert givenSearchTraceto theirRpcSearchTracecounterpart.static RpcTracetrace(String id, ImmutableTrace trace)static RpcEnrichTracetraceEnrichment(String id, Set<String> types, Map<String,Object> properties, List<Trace.Tracelet> tracelets, Map<String,List<DataTransformation>> transformations)Create aRpcEnrichTracemessage which contains given set of types and properties to send to the client and used to enrich the currently processed trace with.
-
-
-
Field Detail
-
FIRST_BYTES_SIZE
public static final int FIRST_BYTES_SIZE
Amount of bytes initially sent with the RpcRandomAccessDataMeta (for performance reasons). It is useless to make it greater than the cache size.- See Also:
- Constant Field Values
-
-
Method Detail
-
trace
public static RpcTrace trace(String id, ImmutableTrace trace)
- Parameters:
id- the id of the tracetrace- the trace to convert- Returns:
- the converted trace
- Throws:
IllegalArgumentException- if the trace contains properties which are not of an expected primitive type
-
searchTrace
public static RpcSearchTrace searchTrace(SearchTrace trace)
Convert givenSearchTraceto theirRpcSearchTracecounterpart.- Parameters:
trace- the search trace to convert- Returns:
- the converted trace
- Throws:
IllegalArgumentException- if the trace contains properties which are not of an expected primitive type
-
property
public static RpcTraceProperty property(String name, Object value)
-
primitive
public static com.google.protobuf.Message primitive(Object object)
Convert given object to their RPC primitive message counterpart (see PrimitiveMessages proto definitions), based on the runtime type. If the type is a genericListorMap, the elements, keys and values must all be of the same type.- Parameters:
object- the object to convert- Returns:
- the converted object
- Throws:
IllegalArgumentException- if the type of the object is not supported, or if not all elements of a collection (like) object are of the same type, or if any of these elements is null
-
metaOfDataContext
public static RpcDataContext metaOfDataContext(DataContext context)
Convert givenDataContextto theirRpcDataContextcounterpart. Only the metadata of the data sequence will be packed, seemetaOfData(String, RandomAccessData).- Parameters:
context- the context to convert- Returns:
- the converted context
-
metaOfData
public static RpcRandomAccessDataMeta metaOfData(String dataType, RandomAccessData data)
Convert givenRandomAccessDatato theirRpcRandomAccessDataMetacounterpart. This does not copy the entire data contained in the sequence, only thesizeand the first 1MB if available.- Parameters:
dataType- the dataType of the sequencedata- the data sequence to convert- Returns:
- the converted data sequence
-
randomAccessDataMeta
public static RpcRandomAccessDataMeta randomAccessDataMeta(String dataType, ImmutableTrace trace)
Pack given dataType and trace into an RPC message. Note that this message does not include any data.- Parameters:
dataType- type of the datatrace- trace used to infer size of the data- Returns:
- RpcRandomAccessDataMeta message
-
pluginInfo
public static RpcPluginInfo pluginInfo(PluginInfo info)
Convert givenPluginInfoto theirRpcPluginInfocounterpart.- Parameters:
info- the info to convert- Returns:
- the converted info
-
pluginId
public static RpcPluginIdentifier pluginId(PluginId id)
-
author
public static RpcAuthor author(Author author)
- Parameters:
author- the author to convert- Returns:
- the converted author
-
maturityLevel
public static RpcMaturity maturityLevel(MaturityLevel maturity)
Convert givenMaturityLevelto theirRpcMaturitycounterpart.- Parameters:
maturity- the maturity to convert- Returns:
- the converted maturity
- Throws:
IllegalArgumentException- when the given maturity is not mappable
-
pluginType
public static RpcPluginType pluginType(PluginType type)
Convert givenPluginTypeto theirRpcPluginTypecounterpart.- Parameters:
type- the type to convert- Returns:
- the converted type
- Throws:
IllegalArgumentException- when the given type is not mappable
-
readParameters
public static RpcRead readParameters(long position, int count, String traceUid, String type)
Create anRpcReadmessage from given position and size.- Parameters:
position- the position to read atcount- the amount of bytes to readtraceUid- the uid of the trace to read fromtype- the type of the data stream to read- Returns:
- the created message
-
searchRequest
public static RpcSearchRequest searchRequest(String query, int count, TraceSearcher.SearchScope scope)
Create aRpcSearchRequestmessage from given query and count.- Parameters:
query- string to querycount- maximum number of results returnedscope- scope to limit the search to (image or project)- Returns:
- the created message
-
traceEnrichment
public static RpcEnrichTrace traceEnrichment(String id, Set<String> types, Map<String,Object> properties, List<Trace.Tracelet> tracelets, Map<String,List<DataTransformation>> transformations)
Create aRpcEnrichTracemessage which contains given set of types and properties to send to the client and used to enrich the currently processed trace with.- Parameters:
id- the id of the trace to enrichtypes- the types to addproperties- the properties to addtracelets- the tracelets to addtransformations- the transformations to add- Returns:
- the created message
-
searchResult
public static RpcSearchResult searchResult(SearchResult result)
Create aRpcSearchResultfrom a givenSearchResult.- Parameters:
result- the search result containing searched traces- Returns:
- the created RpcSearchResult
-
asStatusRuntimeException
public static io.grpc.StatusRuntimeException asStatusRuntimeException(io.grpc.Status.Code statusCode, Throwable t)Wrap athrowablein a status exception which can be used to signal an error on gRPC stream.- Parameters:
statusCode- the error codet- the error cause- Returns:
- a status exception which can be signaled on the gRPC stream
-
-