Package org.apache.hadoop.ipc.internal
Class ShadedProtobufHelper
java.lang.Object
org.apache.hadoop.ipc.internal.ShadedProtobufHelper
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.hadoop.thirdparty.protobuf.ByteStringgetByteString(byte[] bytes) Get the byte string of a non-null byte array.static org.apache.hadoop.thirdparty.protobuf.ByteStringgetFixedByteString(String key) Get the ByteString for frequently used fixed and small set strings.static org.apache.hadoop.thirdparty.protobuf.ByteStringgetFixedByteString(Text key) Get the ByteString for frequently used fixed and small set strings.static IOExceptiongetRemoteException(org.apache.hadoop.thirdparty.protobuf.ServiceException se) Return the IOException thrown by the remote server wrapped in ServiceException as cause.static <T> Tipc(ShadedProtobufHelper.IpcCall<T> call) Evaluate a protobuf call, converting any ServiceException to an IOException.static org.apache.hadoop.security.proto.SecurityProtos.TokenProtoprotoFromToken(Token<?> tok) Create aTokenProtoinstance 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.
-
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
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
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 aTokenProtoinstance 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
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
-