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
Modifier and TypeFieldDescriptionThe first element in the list is the cluster id on which the change has originatedstatic final WALKeyImpl
private byte[]
private MultiVersionConcurrencyControl
private long
private long
private long
Used during WAL replay; the sequenceId of the edit when it came into the system.private NavigableMap<byte[],
Integer> private long
SequenceId for this edit.private TableName
Set in a way visible to multiple threads; e.g.private long
Time at which this edit was written.Fields inherited from interface org.apache.hadoop.hbase.regionserver.SequenceId
NO_SEQUENCE_ID
Fields inherited from interface org.apache.hadoop.hbase.wal.WALKey
EMPTY_UUIDS
-
Constructor Summary
ConstructorDescriptionWALKeyImpl
(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 TypeMethodDescriptionvoid
addClusterId
(UUID clusterId) Marks that the cluster with the given clusterId has consumed the changevoid
addExtendedAttribute
(String attributeKey, byte[] attributeValue) Add a named String value to this WALKey to be persisted into the WALvoid
int
boolean
long
org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALKey.Builder
getBuilder
(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()
long
getNonce()
Returns The noncelong
Returns The nonce grouplong
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.NavigableMap<byte[],
Integer> long
SequenceId is only available post WAL-assign.Returns table nameUse it to complete mvcc transaction.long
Returns the write timeint
hashCode()
protected void
init
(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) void
internEncodedRegionName
(byte[] encodedRegionName) Drop this instance's region name byte array and instead hold a reference to the provided region name.(package private) void
internTableName
(TableName tablename) Drop this instance's tablename byte array and instead hold a reference to the provided tablename.void
readFieldsFromPb
(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALKey walKey, WALCellCodec.ByteStringUncompressor uncompressor) void
setOrigLogSeqNum
(long sequenceId) Used to set original sequenceId for WALKeyImpl during WAL replayprivate void
setReplicationScope
(NavigableMap<byte[], Integer> replicationScope) protected void
setSequenceId
(long sequenceId) void
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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:
getEncodedRegionName
in interfaceWALKey
-
getTableName
Returns table name- Specified by:
getTableName
in 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:
getOrigLogSeqNum
in 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:
getSequenceId
in interfaceSequenceId
- Returns:
- long the new assigned sequence number
-
getWriteTime
Returns the write time- Specified by:
getWriteTime
in interfaceWALKey
-
getReplicationScopes
-
getNonceGroup
Returns The nonce group- Specified by:
getNonceGroup
in 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:
getOriginatingClusterId
in 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:WALKey
Add a named String value to this WALKey to be persisted into the WAL- Specified by:
addExtendedAttribute
in interfaceWALKey
- Parameters:
attributeKey
- Name of the attributeattributeValue
- Value of the attribute
-
getExtendedAttribute
Description copied from interface:WALKey
Return a named String value injected into the WALKey during processing, such as by a coprocessor- Specified by:
getExtendedAttribute
in interfaceWALKey
- Parameters:
attributeKey
- The key of a key / value pair
-
getExtendedAttributes
Description copied from interface:WALKey
Returns a map of all extended attributes injected into this WAL key.- Specified by:
getExtendedAttributes
in interfaceWALKey
-
toString
-
equals
-
hashCode
-
compareTo
- Specified by:
compareTo
in 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:
estimatedSerializedSizeOf
in interfaceWALKey
-