Class ProtoMessage


  • public final class ProtoMessage
    extends java.lang.Object
    A simple wrapper around the MessageLite class in Protobuf for a few messages defined and generated in Alluxio. In other parts of Alluxio code base that are outside of this module, use this class to replace MessageLite when it must reference MessageLite as a base class of different generated messages. This class is intended to be used internally only. For any new proto message added here, consider adding a test in alluxio.worker.netty.CodecTest.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProtoMessage​(alluxio.proto.dataserver.Protocol.AsyncCacheRequest request)  
      ProtoMessage​(alluxio.proto.dataserver.Protocol.Heartbeat heartbeat)  
      ProtoMessage​(alluxio.proto.dataserver.Protocol.LocalBlockCloseRequest request)  
      ProtoMessage​(alluxio.proto.dataserver.Protocol.LocalBlockCompleteRequest request)  
      ProtoMessage​(alluxio.proto.dataserver.Protocol.LocalBlockCreateRequest request)  
      ProtoMessage​(alluxio.proto.dataserver.Protocol.LocalBlockCreateResponse response)  
      ProtoMessage​(alluxio.proto.dataserver.Protocol.LocalBlockOpenRequest request)  
      ProtoMessage​(alluxio.proto.dataserver.Protocol.LocalBlockOpenResponse response)  
      ProtoMessage​(alluxio.proto.dataserver.Protocol.ReadRequest readRequest)  
      ProtoMessage​(alluxio.proto.dataserver.Protocol.ReadResponse response)  
      ProtoMessage​(alluxio.proto.dataserver.Protocol.Response response)  
      ProtoMessage​(alluxio.proto.dataserver.Protocol.WriteRequest writeRequest)  
    • Constructor Detail

      • ProtoMessage

        public ProtoMessage​(alluxio.proto.dataserver.Protocol.ReadRequest readRequest)
        Parameters:
        readRequest - the read request
      • ProtoMessage

        public ProtoMessage​(alluxio.proto.dataserver.Protocol.WriteRequest writeRequest)
        Parameters:
        writeRequest - the write request
      • ProtoMessage

        public ProtoMessage​(alluxio.proto.dataserver.Protocol.Response response)
        Parameters:
        response - the response
      • ProtoMessage

        public ProtoMessage​(alluxio.proto.dataserver.Protocol.ReadResponse response)
        Parameters:
        response - the read response
      • ProtoMessage

        public ProtoMessage​(alluxio.proto.dataserver.Protocol.LocalBlockOpenRequest request)
        Parameters:
        request - the local block open request
      • ProtoMessage

        public ProtoMessage​(alluxio.proto.dataserver.Protocol.LocalBlockOpenResponse response)
        Parameters:
        response - the local block open response
      • ProtoMessage

        public ProtoMessage​(alluxio.proto.dataserver.Protocol.LocalBlockCloseRequest request)
        Parameters:
        request - the local block close request
      • ProtoMessage

        public ProtoMessage​(alluxio.proto.dataserver.Protocol.LocalBlockCreateRequest request)
        Parameters:
        request - the local block create request
      • ProtoMessage

        public ProtoMessage​(alluxio.proto.dataserver.Protocol.LocalBlockCreateResponse response)
        Parameters:
        response - the local block create response
      • ProtoMessage

        public ProtoMessage​(alluxio.proto.dataserver.Protocol.LocalBlockCompleteRequest request)
        Parameters:
        request - the local block complete request
      • ProtoMessage

        public ProtoMessage​(alluxio.proto.dataserver.Protocol.AsyncCacheRequest request)
        Parameters:
        request - the async cache request
      • ProtoMessage

        public ProtoMessage​(alluxio.proto.dataserver.Protocol.Heartbeat heartbeat)
        Parameters:
        heartbeat - the heartbeat
    • Method Detail

      • asReadRequest

        public alluxio.proto.dataserver.Protocol.ReadRequest asReadRequest()
        Gets the read request or throws runtime exception if mMessage is not of type Protocol.ReadRequest.
        Returns:
        the read request
      • isReadRequest

        public boolean isReadRequest()
        Returns:
        true if mMessage is of type Protocol.ReadRequest
      • asWriteRequest

        public alluxio.proto.dataserver.Protocol.WriteRequest asWriteRequest()
        Gets the write request or throws runtime exception if mMessage is not of type Protocol.WriteRequest.
        Returns:
        the write request
      • isWriteRequest

        public boolean isWriteRequest()
        Returns:
        true if mMessage is of type Protocol.WriteRequest
      • asResponse

        public alluxio.proto.dataserver.Protocol.Response asResponse()
        Gets the response or throws runtime exception if mMessage is not of type Protocol.Response.
        Returns:
        the response
      • isResponse

        public boolean isResponse()
        Returns:
        true if mMessage is of type Protocol.Response
      • asReadResponse

        public alluxio.proto.dataserver.Protocol.ReadResponse asReadResponse()
        Gets the read response or throws runtime exception if mMessage is not of type Protocol.ReadResponse.
        Returns:
        the read response
      • isReadResponse

        public boolean isReadResponse()
        Returns:
        true if mMessage is of type Protocol.ReadResponse
      • asLocalBlockOpenRequest

        public alluxio.proto.dataserver.Protocol.LocalBlockOpenRequest asLocalBlockOpenRequest()
        Gets the local block open request or throws runtime exception if mMessage is not of type Protocol.LocalBlockOpenRequest.
        Returns:
        the Protocol.LocalBlockOpenRequest
      • isLocalBlockOpenRequest

        public boolean isLocalBlockOpenRequest()
        Returns:
        true if mMessage is of type Protocol.LocalBlockOpenRequest
      • asLocalBlockOpenResponse

        public alluxio.proto.dataserver.Protocol.LocalBlockOpenResponse asLocalBlockOpenResponse()
        Gets the local block open response or throws runtime exception if mMessage is not of type Protocol.LocalBlockOpenResponse.
        Returns:
        the Protocol.LocalBlockOpenResponse
      • isLocalBlockOpenResponse

        public boolean isLocalBlockOpenResponse()
        Returns:
        true if mMessage is of type Protocol.LocalBlockOpenResponse
      • asLocalBlockCloseRequest

        public alluxio.proto.dataserver.Protocol.LocalBlockCloseRequest asLocalBlockCloseRequest()
        Gets the local block close request or throws runtime exception if mMessage is not of type Protocol.LocalBlockCloseRequest.
        Returns:
        the Protocol.LocalBlockCloseRequest
      • isLocalBlockCloseRequest

        public boolean isLocalBlockCloseRequest()
        Returns:
        true if mMessage is of type Protocol.LocalBlockCloseRequest
      • asLocalBlockCreateRequest

        public alluxio.proto.dataserver.Protocol.LocalBlockCreateRequest asLocalBlockCreateRequest()
        Returns:
        the Protocol.LocalBlockCreateRequest
      • isLocalBlockCreateRequest

        public boolean isLocalBlockCreateRequest()
        Returns:
        true if mMessage is of type Protocol.LocalBlockCreateRequest
      • asLocalBlockCreateResponse

        public alluxio.proto.dataserver.Protocol.LocalBlockCreateResponse asLocalBlockCreateResponse()
        Returns:
        the Protocol.LocalBlockCreateResponse
      • isLocalBlockCreateResponse

        public boolean isLocalBlockCreateResponse()
        Returns:
        true if mMessage is of type Protocol.LocalBlockCreateResponse
      • asLocalBlockCompleteRequest

        public alluxio.proto.dataserver.Protocol.LocalBlockCompleteRequest asLocalBlockCompleteRequest()
        Returns:
        the Protocol.LocalBlockCompleteRequest
      • isLocalBlockCompleteRequest

        public boolean isLocalBlockCompleteRequest()
        Returns:
        true if mMessage is of type Protocol.LocalBlockCompleteRequest
      • asAsyncCacheRequest

        public alluxio.proto.dataserver.Protocol.AsyncCacheRequest asAsyncCacheRequest()
        Returns:
        an AsyncCacheRequest object if the message is of the same type
      • isAsyncCacheRequest

        public boolean isAsyncCacheRequest()
        Returns:
        true if the message is of type AsyncCacheRequest
      • isHeartbeat

        public boolean isHeartbeat()
        Returns:
        true if the message is of type Protocol.Heartbeat
      • toByteArray

        public byte[] toByteArray()
        Returns:
        the serialized message as byte array
      • parseFrom

        public static ProtoMessage parseFrom​(byte[] serialized,
                                             ProtoMessage prototype)
        Parses proto message from bytes given a prototype.
        Parameters:
        serialized - the serialized message
        prototype - the prototype of the message to return which is usually constructed via new ProtoMessage(SomeProtoType.getDefaultInstance())
        Returns:
        the proto message
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object