Package alluxio.grpc

Class DataMessageMarshaller<T>

    • Constructor Summary

      Constructors 
      Constructor Description
      DataMessageMarshaller​(io.grpc.MethodDescriptor.Marshaller<T> originalMarshaller)
      Creates a data marshaller.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the repository and all its buffers.
      abstract T combineData​(DataMessage<T,​DataBuffer> message)
      Combines the data buffer into the message.
      protected abstract T deserialize​(io.grpc.internal.ReadableBuffer buffer)
      Deserialize data buffer to the message.
      void offerBuffer​(DataBuffer buffer, T message)
      Stores a buffer in the repository.
      T parse​(java.io.InputStream message)  
      DataBuffer pollBuffer​(T message)
      Retrieves and removes a buffer from the store.
      protected abstract io.netty.buffer.ByteBuf[] serialize​(T message)
      Serialize the message to buffers.
      java.io.InputStream stream​(T message)  
      • Methods inherited from class java.lang.Object

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

      • DataMessageMarshaller

        public DataMessageMarshaller​(io.grpc.MethodDescriptor.Marshaller<T> originalMarshaller)
        Creates a data marshaller.
        Parameters:
        originalMarshaller - the original marshaller for the message
    • Method Detail

      • stream

        public java.io.InputStream stream​(T message)
        Specified by:
        stream in interface io.grpc.MethodDescriptor.Marshaller<T>
      • parse

        public T parse​(java.io.InputStream message)
        Specified by:
        parse in interface io.grpc.MethodDescriptor.Marshaller<T>
      • close

        public void close()
        Description copied from interface: BufferRepository
        Closes the repository and all its buffers.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface BufferRepository<T,​DataBuffer>
        Specified by:
        close in interface java.io.Closeable
      • pollBuffer

        public DataBuffer pollBuffer​(T message)
        Description copied from interface: BufferRepository
        Retrieves and removes a buffer from the store.
        Specified by:
        pollBuffer in interface BufferRepository<T,​DataBuffer>
        Parameters:
        message - the message that associated with the buffer
        Returns:
        the buffer, or null if the buffer is not found
      • combineData

        public abstract T combineData​(@Nullable
                                      DataMessage<T,​DataBuffer> message)
        Combines the data buffer into the message.
        Parameters:
        message - the message to be combined
        Returns:
        the message with the combined buffer
      • serialize

        protected abstract io.netty.buffer.ByteBuf[] serialize​(T message)
                                                        throws java.io.IOException
        Serialize the message to buffers.
        Parameters:
        message - the message to be serialized
        Returns:
        an array of ByteBufs containing the serialized message
        Throws:
        java.io.IOException - if the marshaller fails to serialize the message
      • deserialize

        protected abstract T deserialize​(io.grpc.internal.ReadableBuffer buffer)
                                  throws java.io.IOException
        Deserialize data buffer to the message.
        Parameters:
        buffer - the buffer that contains the message data
        Returns:
        the deserialized message
        Throws:
        java.io.IOException - if the marshaller fails to deserialize the data