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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic class -
Constructor Summary
ConstructorsConstructorDescriptionBlockTokenIdentifier(String userId, String bpid, long blockId, EnumSet<BlockTokenIdentifier.AccessMode> modes, org.apache.hadoop.fs.StorageType[] storageTypes, String[] storageIds, boolean useProto) -
Method Summary
Modifier and TypeMethodDescriptionbooleanlongbyte[]getBytes()longbyte[]intgetKeyId()org.apache.hadoop.io.TextgetKind()String[]org.apache.hadoop.fs.StorageType[]org.apache.hadoop.security.UserGroupInformationgetUser()inthashCode()voidreadFields(DataInput in) readFields peeks at the first byte of the DataInput and determines if it was written using WritableUtils ("Legacy") or Protobuf.voidsetExpiryDate(long expiryDate) voidsetHandshakeMsg(byte[] bytes) voidsetKeyId(int keyId) toString()voidwrite(DataOutput out) Methods inherited from class org.apache.hadoop.security.token.TokenIdentifier
getTrackingId
-
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:
getKindin classorg.apache.hadoop.security.token.TokenIdentifier
-
getUser
public org.apache.hadoop.security.UserGroupInformation getUser()- Specified by:
getUserin classorg.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
-
getBlockPoolId
-
getBlockId
public long getBlockId() -
getAccessModes
-
getStorageTypes
public org.apache.hadoop.fs.StorageType[] getStorageTypes() -
getStorageIds
-
getHandshakeMsg
public byte[] getHandshakeMsg() -
setHandshakeMsg
public void setHandshakeMsg(byte[] bytes) -
toString
-
equals
-
hashCode
public int hashCode() -
readFields
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 asfield_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-DataInputto deserialize this object from.- Throws:
IOException
-
write
- Throws:
IOException
-
getBytes
public byte[] getBytes()- Overrides:
getBytesin classorg.apache.hadoop.security.token.TokenIdentifier
-