Class FederationProtocolPBTranslator<P extends org.apache.hadoop.thirdparty.protobuf.GeneratedMessageV3,B extends org.apache.hadoop.thirdparty.protobuf.Message.Builder,T extends org.apache.hadoop.thirdparty.protobuf.MessageOrBuilder>
java.lang.Object
org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.FederationProtocolPBTranslator<P,B,T>
public class FederationProtocolPBTranslator<P extends org.apache.hadoop.thirdparty.protobuf.GeneratedMessageV3,B extends org.apache.hadoop.thirdparty.protobuf.Message.Builder,T extends org.apache.hadoop.thirdparty.protobuf.MessageOrBuilder>
extends Object
Helper class for setting/getting data elements in an object backed by a
protobuf implementation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Get the serialized proto object.Create or return the cached protobuf builder for this translator.Returns an interface to access data stored within this object.voidreadInstance(String base64String) Read instance from base64 data.voidsetProto(org.apache.hadoop.thirdparty.protobuf.Message p) Called if this translator is to be created from an existing protobuf byte stream.
-
Constructor Details
-
FederationProtocolPBTranslator
-
-
Method Details
-
setProto
public void setProto(org.apache.hadoop.thirdparty.protobuf.Message p) throws IllegalArgumentException Called if this translator is to be created from an existing protobuf byte stream.- Parameters:
p- The existing proto object to use to initialize the translator.- Throws:
IllegalArgumentException- If the given proto message is not instance of the class of the proto handler this translator holds.
-
getBuilder
Create or return the cached protobuf builder for this translator.- Returns:
- cached Builder instance
-
build
Get the serialized proto object. If the translator was created from a byte stream, returns the initial byte stream. Otherwise, creates a new byte stream from the cached builder.- Returns:
- Protobuf message object
-
getProtoOrBuilder
Returns an interface to access data stored within this object. The object may have been initialized either via a builder or by an existing protobuf byte stream.- Returns:
- MessageOrBuilder protobuf interface for the requested class.
-
readInstance
Read instance from base64 data.- Parameters:
base64String- String containing Base64 data.- Throws:
IOException- If the protobuf message build fails.
-