Class ShadedProtobufHelper

java.lang.Object
org.apache.hadoop.ipc.internal.ShadedProtobufHelper

@Private @Unstable public final class ShadedProtobufHelper extends Object
Helper methods for protobuf related RPC implementation using the hadoop org.apache.hadoop.thirdparty.protobuf shaded version. This is absolutely private to hadoop-* modules.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.hadoop.thirdparty.protobuf.ByteString
    getByteString(byte[] bytes)
    Get the byte string of a non-null byte array.
    static org.apache.hadoop.thirdparty.protobuf.ByteString
    Get the ByteString for frequently used fixed and small set strings.
    static org.apache.hadoop.thirdparty.protobuf.ByteString
    Get the ByteString for frequently used fixed and small set strings.
    getRemoteException(org.apache.hadoop.thirdparty.protobuf.ServiceException se)
    Return the IOException thrown by the remote server wrapped in ServiceException as cause.
    static <T> T
    Evaluate a protobuf call, converting any ServiceException to an IOException.
    static org.apache.hadoop.security.proto.SecurityProtos.TokenProto
    Create a TokenProto instance from a hadoop token.
    static Token<? extends TokenIdentifier>
    tokenFromProto(org.apache.hadoop.security.proto.SecurityProtos.TokenProto tokenProto)
    Create a hadoop token from a protobuf token.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getRemoteException

      @Private @Unstable public static IOException getRemoteException(org.apache.hadoop.thirdparty.protobuf.ServiceException se)
      Return the IOException thrown by the remote server wrapped in ServiceException as cause. The signature of this method changes with updates to the hadoop-thirdparty shaded protobuf library.
      Parameters:
      se - ServiceException that wraps IO exception thrown by the server
      Returns:
      Exception wrapped in ServiceException or a new IOException that wraps the unexpected ServiceException.
    • getFixedByteString

      public static org.apache.hadoop.thirdparty.protobuf.ByteString getFixedByteString(Text key)
      Get the ByteString for frequently used fixed and small set strings.
      Parameters:
      key - Hadoop Writable Text string
      Returns:
      the ByteString for frequently used fixed and small set strings.
    • getFixedByteString

      public static org.apache.hadoop.thirdparty.protobuf.ByteString getFixedByteString(String key)
      Get the ByteString for frequently used fixed and small set strings.
      Parameters:
      key - string
      Returns:
      ByteString for frequently used fixed and small set strings.
    • getByteString

      public static org.apache.hadoop.thirdparty.protobuf.ByteString getByteString(byte[] bytes)
      Get the byte string of a non-null byte array. If the array is 0 bytes long, return a singleton to reduce object allocation.
      Parameters:
      bytes - bytes to convert.
      Returns:
      the protobuf byte string representation of the array.
    • tokenFromProto

      public static Token<? extends TokenIdentifier> tokenFromProto(org.apache.hadoop.security.proto.SecurityProtos.TokenProto tokenProto)
      Create a hadoop token from a protobuf token.
      Parameters:
      tokenProto - token
      Returns:
      a new token
    • protoFromToken

      public static org.apache.hadoop.security.proto.SecurityProtos.TokenProto protoFromToken(Token<?> tok)
      Create a TokenProto instance from a hadoop token. This builds and caches the fields (identifier, password, kind, service) but not renewer or any payload.
      Parameters:
      tok - token
      Returns:
      a marshallable protobuf class.
    • ipc

      public static <T> T ipc(ShadedProtobufHelper.IpcCall<T> call) throws IOException
      Evaluate a protobuf call, converting any ServiceException to an IOException.
      Type Parameters:
      T - type of the result
      Parameters:
      call - invocation to make
      Returns:
      the result of the call
      Throws:
      IOException - any translated protobuf exception