FederationProtocolPBTranslator (Apache Hadoop HDFS-RBF 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb, class: FederationProtocolPBTranslator

Package org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb

# 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
  Constructor
  Description
  `FederationProtocolPBTranslator(Class<P> protoType)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `P`
  `build()`
  Get the serialized proto object.
  `B`
  `getBuilder()`
  Create or return the cached protobuf builder for this translator.
  `T`
  `getProtoOrBuilder()`
  Returns an interface to access data stored within this object.
  `void`
  `readInstance(String base64String)`
  Read instance from base64 data.
  `void`
  `setProto(org.apache.hadoop.thirdparty.protobuf.Message p)`
  Called if this translator is to be created from an existing protobuf byte stream.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### FederationProtocolPBTranslator

    public FederationProtocolPBTranslator(Class<P> protoType)

- ## 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

    public B getBuilder()
    Create or return the cached protobuf builder for this translator.
    Returns:
      cached Builder instance

  - ### build

    public P 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

    public T 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

    public void readInstance(String base64String) throws IOException
    Read instance from base64 data.
    Parameters:
      `base64String` - String containing Base64 data.
    Throws:
      `IOException` - If the protobuf message build fails.