Package alluxio.grpc

Class GrpcSerializationUtils


  • public class GrpcSerializationUtils
    extends java.lang.Object
    Utilities for gRPC message serialization.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static io.grpc.CallOptions.Key<io.grpc.MethodDescriptor> OVERRIDDEN_METHOD_DESCRIPTOR  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean addBuffersToStream​(io.netty.buffer.ByteBuf[] buffers, java.io.OutputStream stream)
      Add the given buffers directly to the gRPC output stream.
      static io.grpc.internal.ReadableBuffer getBufferFromStream​(java.io.InputStream stream)
      Gets a buffer directly from a gRPC input stream.
      static io.netty.buffer.ByteBuf getByteBufFromReadableBuffer​(io.grpc.internal.ReadableBuffer buffer)
      Gets a Netty buffer directly from a gRPC ReadableBuffer.
      static int makeTag​(int fieldNumber, int wireType)
      Makes a gRPC tag for a field.
      static io.grpc.ServerServiceDefinition overrideMethods​(io.grpc.ServerServiceDefinition service, java.util.Map<io.grpc.MethodDescriptor,​io.grpc.MethodDescriptor> marshallers)
      Creates a service definition that uses custom marshallers.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • OVERRIDDEN_METHOD_DESCRIPTOR

        public static final io.grpc.CallOptions.Key<io.grpc.MethodDescriptor> OVERRIDDEN_METHOD_DESCRIPTOR
    • Constructor Detail

      • GrpcSerializationUtils

        public GrpcSerializationUtils()
    • Method Detail

      • makeTag

        public static int makeTag​(int fieldNumber,
                                  int wireType)
        Makes a gRPC tag for a field.
        Parameters:
        fieldNumber - field number
        wireType - wire type of the field
        Returns:
        the gRPC tag
      • getBufferFromStream

        public static io.grpc.internal.ReadableBuffer getBufferFromStream​(java.io.InputStream stream)
        Gets a buffer directly from a gRPC input stream.
        Parameters:
        stream - the input stream
        Returns:
        the raw data buffer
      • getByteBufFromReadableBuffer

        public static io.netty.buffer.ByteBuf getByteBufFromReadableBuffer​(io.grpc.internal.ReadableBuffer buffer)
        Gets a Netty buffer directly from a gRPC ReadableBuffer.
        Parameters:
        buffer - the input buffer
        Returns:
        the raw ByteBuf, or null if the ByteBuf cannot be extracted
      • addBuffersToStream

        public static boolean addBuffersToStream​(io.netty.buffer.ByteBuf[] buffers,
                                                 java.io.OutputStream stream)
        Add the given buffers directly to the gRPC output stream.
        Parameters:
        buffers - the buffers to be added
        stream - the output stream
        Returns:
        whether the buffers are added successfully
      • overrideMethods

        public static io.grpc.ServerServiceDefinition overrideMethods​(io.grpc.ServerServiceDefinition service,
                                                                      java.util.Map<io.grpc.MethodDescriptor,​io.grpc.MethodDescriptor> marshallers)
        Creates a service definition that uses custom marshallers.
        Parameters:
        service - the service to intercept
        marshallers - a map that specifies which marshaller to use for each method
        Returns:
        the new service definition