Class ProtobufWrapperLegacy

java.lang.Object
org.apache.hadoop.ipc.RpcWritable
org.apache.hadoop.ipc.ProtobufWrapperLegacy
All Implemented Interfaces:
Writable

@Private public class ProtobufWrapperLegacy extends RpcWritable
A RpcWritable wrapper for unshaded protobuf messages. This class isolates unshaded protobuf classes from the rest of the RPC codebase, so it can operate without needing that on the classpath at runtime. The classes are needed at compile time; and if unshaded protobuf messages are to be marshalled, they will need to be on the classpath then. That is implicit: it is impossible to pass in a class which is a protobuf message unless that condition is met.
  • Constructor Details

    • ProtobufWrapperLegacy

      public ProtobufWrapperLegacy(Object message)
      Construct. The type of the parameter is Object so as to keep the casting internal to this class.
      Parameters:
      message - message to wrap.
      Throws:
      IllegalArgumentException - if the class is not a protobuf message.
  • Method Details

    • getMessage

      public com.google.protobuf.Message getMessage()
    • writeTo

      public void writeTo(ResponseBuffer out) throws IOException
      Throws:
      IOException
    • readFrom

      protected <T> T readFrom(ByteBuffer bb) throws IOException
      Throws:
      IOException
    • isUnshadedProtobufMessage

      public static boolean isUnshadedProtobufMessage(Object payload)
      Is a message an unshaded protobuf message?
      Parameters:
      payload - payload
      Returns:
      true if protobuf.jar is on the classpath and the payload is a Message