Package org.apache.hadoop.hbase.wal
Class WALKeyImpl
java.lang.Object
org.apache.hadoop.hbase.wal.WALKeyImpl
- All Implemented Interfaces:
Comparable<WALKey>,SequenceId,WALKey
Default implementation of Key for an Entry in the WAL. For internal use only though Replication
needs to have access. The log intermingles edits to many tables and rows, so each log entry
identifies the appropriate table and row. Within a table and row, they're also sorted.
Some Transactional edits (START, COMMIT, ABORT) will not have an associated row.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe first element in the list is the cluster id on which the change has originatedstatic final WALKeyImplprivate byte[]private MultiVersionConcurrencyControlprivate longprivate longprivate longUsed during WAL replay; the sequenceId of the edit when it came into the system.private NavigableMap<byte[],Integer> private longSequenceId for this edit.private TableNameSet in a way visible to multiple threads; e.g.private longTime at which this edit was written.Fields inherited from interface org.apache.hadoop.hbase.regionserver.SequenceId
NO_SEQUENCE_IDFields inherited from interface org.apache.hadoop.hbase.wal.WALKey
EMPTY_UUIDS -
Constructor Summary
ConstructorsConstructorDescriptionWALKeyImpl(byte[] encodedRegionName, TableName tablename, long now) WALKeyImpl(byte[] encodedRegionName, TableName tablename, long logSeqNum, long nonceGroup, long nonce, MultiVersionConcurrencyControl mvcc) Create the log key for writing to somewhere.WALKeyImpl(byte[] encodedRegionName, TableName tablename, long logSeqNum, long now, List<UUID> clusterIds, long nonceGroup, long nonce, MultiVersionConcurrencyControl mvcc) Create the log key for writing to somewhere.WALKeyImpl(byte[] encodedRegionName, TableName tablename, long logSeqNum, long now, List<UUID> clusterIds, long nonceGroup, long nonce, MultiVersionConcurrencyControl mvcc, NavigableMap<byte[], Integer> replicationScope) Create the log key for writing to somewhere.WALKeyImpl(byte[] encodedRegionName, TableName tablename, long logSeqNum, long now, UUID clusterId) WALKeyImpl(byte[] encodedRegionName, TableName tablename, long logSeqNum, long now, UUID clusterId, MultiVersionConcurrencyControl mvcc) WALKeyImpl(byte[] encodedRegionName, TableName tablename, long now, List<UUID> clusterIds, long nonceGroup, long nonce, MultiVersionConcurrencyControl mvcc) Create the log key for writing to somewhere.WALKeyImpl(byte[] encodedRegionName, TableName tablename, long now, List<UUID> clusterIds, long nonceGroup, long nonce, MultiVersionConcurrencyControl mvcc, NavigableMap<byte[], Integer> replicationScope) Create the log key for writing to somewhere.WALKeyImpl(byte[] encodedRegionName, TableName tablename, long now, List<UUID> clusterIds, long nonceGroup, long nonce, MultiVersionConcurrencyControl mvcc, NavigableMap<byte[], Integer> replicationScope, Map<String, byte[]> extendedAttributes) WALKeyImpl(byte[] encodedRegionName, TableName tablename, long now, NavigableMap<byte[], Integer> replicationScope) WALKeyImpl(byte[] encodedRegionName, TableName tablename, long now, MultiVersionConcurrencyControl mvcc) WALKeyImpl(byte[] encodedRegionName, TableName tablename, long now, MultiVersionConcurrencyControl mvcc, NavigableMap<byte[], Integer> replicationScope) WALKeyImpl(byte[] encodedRegionName, TableName tablename, long now, MultiVersionConcurrencyControl mvcc, NavigableMap<byte[], Integer> replicationScope, Map<String, byte[]> extendedAttributes) WALKeyImpl(NavigableMap<byte[], Integer> replicationScope) WALKeyImpl(WALKeyImpl key, Map<String, byte[]> extendedAttributes) Copy constructor that takes in an existing WALKeyImpl plus some extended attributes.WALKeyImpl(WALKey key, List<UUID> clusterIds, MultiVersionConcurrencyControl mvcc, NavigableMap<byte[], Integer> replicationScopes, Map<String, byte[]> extendedAttributes) Copy constructor that takes in an existing WALKey, the extra WALKeyImpl fields that the parent interface is missing, plus some extended attributes. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClusterId(UUID clusterId) Marks that the cluster with the given clusterId has consumed the changevoidaddExtendedAttribute(String attributeKey, byte[] attributeValue) Add a named String value to this WALKey to be persisted into the WALvoidintbooleanlongorg.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALKey.BuildergetBuilder(WALCellCodec.ByteStringCompressor compressor) Returns the set of cluster Ids that have consumed the changebyte[]Returns encoded region namebyte[]getExtendedAttribute(String attributeKey) Return a named String value injected into the WALKey during processing, such as by a coprocessorReturns a map of all extended attributes injected into this WAL key.getMvcc()longgetNonce()Returns The noncelongReturns The nonce grouplongReturn a positive long if current WALKeyImpl is created from a replay edit; a replay edit is an edit that came in when replaying WALs of a crashed server.NavigableMap<byte[],Integer> longSequenceId is only available post WAL-assign.Returns table nameUse it to complete mvcc transaction.longReturns the write timeinthashCode()protected voidinit(byte[] encodedRegionName, TableName tablename, long logSeqNum, long now, List<UUID> clusterIds, long nonceGroup, long nonce, MultiVersionConcurrencyControl mvcc, NavigableMap<byte[], Integer> replicationScope, Map<String, byte[]> extendedAttributes) (package private) voidinternEncodedRegionName(byte[] encodedRegionName) Drop this instance's region name byte array and instead hold a reference to the provided region name.(package private) voidinternTableName(TableName tablename) Drop this instance's tablename byte array and instead hold a reference to the provided tablename.voidreadFieldsFromPb(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALKey walKey, WALCellCodec.ByteStringUncompressor uncompressor) voidsetOrigLogSeqNum(long sequenceId) Used to set original sequenceId for WALKeyImpl during WAL replayprivate voidsetReplicationScope(NavigableMap<byte[], Integer> replicationScope) protected voidsetSequenceId(long sequenceId) voidtoString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.hbase.wal.WALKey
toStringMap
-
Field Details
-
EMPTY_WALKEYIMPL
-
encodedRegionName
-
tablename
-
sequenceId
SequenceId for this edit. Set post-construction at write-to-WAL time. Until then it is NO_SEQUENCE_ID. Change it so multiple threads can read it -- e.g. access is synchronized. -
origLogSeqNum
Used during WAL replay; the sequenceId of the edit when it came into the system. -
writeTime
Time at which this edit was written. -
clusterIds
The first element in the list is the cluster id on which the change has originated -
replicationScope
-
nonceGroup
-
nonce
-
mvcc
-
writeEntry
Set in a way visible to multiple threads; e.g. synchronized getter/setters. -
extendedAttributes
-
-
Constructor Details
-
WALKeyImpl
public WALKeyImpl() -
WALKeyImpl
@Private public WALKeyImpl(byte[] encodedRegionName, TableName tablename, long logSeqNum, long now, UUID clusterId) -
WALKeyImpl
@Private public WALKeyImpl(byte[] encodedRegionName, TableName tablename, long logSeqNum, long now, UUID clusterId, MultiVersionConcurrencyControl mvcc) -
WALKeyImpl
-
WALKeyImpl
public WALKeyImpl(byte[] encodedRegionName, TableName tablename, long now, MultiVersionConcurrencyControl mvcc) -
WALKeyImpl
Copy constructor that takes in an existing WALKeyImpl plus some extended attributes. Intended for coprocessors to add annotations to a system-generated WALKey for persistence to the WAL.- Parameters:
key- Key to be copied into this new keyextendedAttributes- Extra attributes to copy into the new key
-
WALKeyImpl
public WALKeyImpl(byte[] encodedRegionName, TableName tablename, long logSeqNum, long now, List<UUID> clusterIds, long nonceGroup, long nonce, MultiVersionConcurrencyControl mvcc) Create the log key for writing to somewhere. We maintain the tablename mainly for debugging purposes. A regionName is always a sub-table object.Used by log splitting and snapshots.
- Parameters:
encodedRegionName- Encoded name of the region as returned byHRegionInfo#getEncodedNameAsBytes().tablename- - name of tablelogSeqNum- - log sequence numbernow- Time at which this edit was written.clusterIds- the clusters that have consumed the change(used in Replication)
-
WALKeyImpl
public WALKeyImpl(byte[] encodedRegionName, TableName tablename, long now, List<UUID> clusterIds, long nonceGroup, long nonce, MultiVersionConcurrencyControl mvcc) Create the log key for writing to somewhere. We maintain the tablename mainly for debugging purposes. A regionName is always a sub-table object.- Parameters:
encodedRegionName- Encoded name of the region as returned byHRegionInfo#getEncodedNameAsBytes().tablename- the tablenamenow- Time at which this edit was written.clusterIds- the clusters that have consumed the change(used in Replication) * * @param mvcc mvcc control used to generate sequence numbers and control read/write points
-
WALKeyImpl
public WALKeyImpl(byte[] encodedRegionName, TableName tablename, long logSeqNum, long nonceGroup, long nonce, MultiVersionConcurrencyControl mvcc) Create the log key for writing to somewhere. We maintain the tablename mainly for debugging purposes. A regionName is always a sub-table object.- Parameters:
encodedRegionName- Encoded name of the region as returned byHRegionInfo#getEncodedNameAsBytes().
-
-
Method Details
-
getMvcc
-
getWriteEntry
Use it to complete mvcc transaction. This WALKeyImpl was part of (the transaction is started when you call append; see the comment on FSHLog#append). To complete callMultiVersionConcurrencyControl.complete(MultiVersionConcurrencyControl.WriteEntry)orMultiVersionConcurrencyControl.complete(MultiVersionConcurrencyControl.WriteEntry)- Returns:
- A WriteEntry gotten from local WAL subsystem.
- See Also:
-
setWriteEntry
-
setSequenceId
-
getEncodedRegionName
Returns encoded region name- Specified by:
getEncodedRegionNamein interfaceWALKey
-
getTableName
Returns table name- Specified by:
getTableNamein interfaceWALKey
-
setOrigLogSeqNum
Used to set original sequenceId for WALKeyImpl during WAL replay -
getOrigLogSeqNum
Return a positive long if current WALKeyImpl is created from a replay edit; a replay edit is an edit that came in when replaying WALs of a crashed server.- Specified by:
getOrigLogSeqNumin interfaceWALKey- Returns:
- original sequence number of the WALEdit
-
getSequenceId
SequenceId is only available post WAL-assign. Calls before this will get you aSequenceId.NO_SEQUENCE_ID. See the comment on FSHLog#append and #getWriteNumber in this method for more on when this sequenceId comes available.- Specified by:
getSequenceIdin interfaceSequenceId- Returns:
- long the new assigned sequence number
-
getWriteTime
Returns the write time- Specified by:
getWriteTimein interfaceWALKey
-
getReplicationScopes
-
getNonceGroup
Returns The nonce group- Specified by:
getNonceGroupin interfaceWALKey
-
getNonce
Returns The nonce -
clearReplicationScope
-
addClusterId
Marks that the cluster with the given clusterId has consumed the change -
getClusterIds
Returns the set of cluster Ids that have consumed the change -
getOriginatingClusterId
- Specified by:
getOriginatingClusterIdin interfaceWALKey- Returns:
- the cluster id on which the change has originated. It there is no such cluster, it returns DEFAULT_CLUSTER_ID (cases where replication is not enabled)
-
addExtendedAttribute
Description copied from interface:WALKeyAdd a named String value to this WALKey to be persisted into the WAL- Specified by:
addExtendedAttributein interfaceWALKey- Parameters:
attributeKey- Name of the attributeattributeValue- Value of the attribute
-
getExtendedAttribute
Description copied from interface:WALKeyReturn a named String value injected into the WALKey during processing, such as by a coprocessor- Specified by:
getExtendedAttributein interfaceWALKey- Parameters:
attributeKey- The key of a key / value pair
-
getExtendedAttributes
Description copied from interface:WALKeyReturns a map of all extended attributes injected into this WAL key.- Specified by:
getExtendedAttributesin interfaceWALKey
-
toString
-
equals
-
hashCode
-
compareTo
- Specified by:
compareToin interfaceComparable<WALKey>
-
internTableName
Drop this instance's tablename byte array and instead hold a reference to the provided tablename. This is not meant to be a general purpose setter - it's only used to collapse references to conserve memory. -
internEncodedRegionName
Drop this instance's region name byte array and instead hold a reference to the provided region name. This is not meant to be a general purpose setter - it's only used to collapse references to conserve memory. -
getBuilder
public org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALKey.Builder getBuilder(WALCellCodec.ByteStringCompressor compressor) throws IOException - Throws:
IOException
-
readFieldsFromPb
public void readFieldsFromPb(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALKey walKey, WALCellCodec.ByteStringUncompressor uncompressor) throws IOException - Throws:
IOException
-
estimatedSerializedSizeOf
- Specified by:
estimatedSerializedSizeOfin interfaceWALKey
-