Class Pack


  • public final class Pack
    extends Object
    Utility class to convert from native Java or plugin API data structures to their gRPC message counterparts. For the other way around, see Unpack.
    • 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)
        Convert given Trace to their RpcTrace counterpart.
        Parameters:
        id - the id of the trace
        trace - the trace to convert
        Returns:
        the converted trace
        Throws:
        IllegalArgumentException - if the trace contains properties which are not of an expected primitive type
      • 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 generic List or Map, 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
      • 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 data
        trace - trace used to infer size of the data
        Returns:
        RpcRandomAccessDataMeta message
      • author

        public static RpcAuthor author​(Author author)
        Convert given Author to their RpcAuthor counterpart.
        Parameters:
        author - the author to convert
        Returns:
        the converted author
      • readParameters

        public static RpcRead readParameters​(long position,
                                             int count,
                                             String traceUid,
                                             String type)
        Create an RpcRead message from given position and size.
        Parameters:
        position - the position to read at
        count - the amount of bytes to read
        traceUid - the uid of the trace to read from
        type - 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 a RpcSearchRequest message from given query and count.
        Parameters:
        query - string to query
        count - maximum number of results returned
        scope - 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 a RpcEnrichTrace message 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 enrich
        types - the types to add
        properties - the properties to add
        tracelets - the tracelets to add
        transformations - the transformations to add
        Returns:
        the created message
      • asStatusRuntimeException

        public static io.grpc.StatusRuntimeException asStatusRuntimeException​(io.grpc.Status.Code statusCode,
                                                                              Throwable t)
        Wrap a throwable in a status exception which can be used to signal an error on gRPC stream.
        Parameters:
        statusCode - the error code
        t - the error cause
        Returns:
        a status exception which can be signaled on the gRPC stream