Package alluxio.grpc
Class GrpcSerializationUtils
- java.lang.Object
-
- alluxio.grpc.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
-
Constructor Summary
Constructors Constructor Description GrpcSerializationUtils()
-
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.
-
-
-
Method Detail
-
makeTag
public static int makeTag(int fieldNumber, int wireType)
Makes a gRPC tag for a field.- Parameters:
fieldNumber
- field numberwireType
- 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 addedstream
- 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 interceptmarshallers
- a map that specifies which marshaller to use for each method- Returns:
- the new service definition
-
-