Class BlockTokenIdentifier

java.lang.Object
org.apache.hadoop.security.token.TokenIdentifier
org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier
All Implemented Interfaces:
org.apache.hadoop.io.Writable

@Private public class BlockTokenIdentifier extends org.apache.hadoop.security.token.TokenIdentifier
  • Constructor Details

    • BlockTokenIdentifier

      public BlockTokenIdentifier()
    • BlockTokenIdentifier

      public BlockTokenIdentifier(String userId, String bpid, long blockId, EnumSet<BlockTokenIdentifier.AccessMode> modes, org.apache.hadoop.fs.StorageType[] storageTypes, String[] storageIds, boolean useProto)
  • Method Details

    • getKind

      public org.apache.hadoop.io.Text getKind()
      Specified by:
      getKind in class org.apache.hadoop.security.token.TokenIdentifier
    • getUser

      public org.apache.hadoop.security.UserGroupInformation getUser()
      Specified by:
      getUser in class org.apache.hadoop.security.token.TokenIdentifier
    • getExpiryDate

      public long getExpiryDate()
    • setExpiryDate

      public void setExpiryDate(long expiryDate)
    • getKeyId

      public int getKeyId()
    • setKeyId

      public void setKeyId(int keyId)
    • getUserId

      public String getUserId()
    • getBlockPoolId

      public String getBlockPoolId()
    • getBlockId

      public long getBlockId()
    • getAccessModes

      public EnumSet<BlockTokenIdentifier.AccessMode> getAccessModes()
    • getStorageTypes

      public org.apache.hadoop.fs.StorageType[] getStorageTypes()
    • getStorageIds

      public String[] getStorageIds()
    • getHandshakeMsg

      public byte[] getHandshakeMsg()
    • setHandshakeMsg

      public void setHandshakeMsg(byte[] bytes)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • readFields

      public void readFields(DataInput in) throws IOException
      readFields peeks at the first byte of the DataInput and determines if it was written using WritableUtils ("Legacy") or Protobuf. We can do this because we know the first field is the Expiry date. In the case of the legacy buffer, the expiry date is a VInt, so the size (which should always be >1) is encoded in the first byte - which is always negative due to this encoding. However, there are sometimes null BlockTokenIdentifier written so we also need to handle the case there the first byte is also 0. In the case of protobuf, the first byte is a type tag for the expiry date which is written as field_number << 3 | wire_type. So as long as the field_number is less than 16, but also positive, then we know we have a Protobuf.
      Parameters:
      in - DataInput to deserialize this object from.
      Throws:
      IOException
    • write

      public void write(DataOutput out) throws IOException
      Throws:
      IOException
    • getBytes

      public byte[] getBytes()
      Overrides:
      getBytes in class org.apache.hadoop.security.token.TokenIdentifier