Class WALEdit
- All Implemented Interfaces:
HeapSize
A particular WALEdit 'type' is the 'meta' type used to mark key operational events in the WAL
such as compaction, flush, or region open. These meta types do not traverse hbase memstores. They
are edits made by the hbase system rather than edit data submitted by clients. They only show in
the WAL. These 'Meta' types have not been formally specified (or made into an explicit class
type). They evolved organically. HBASE-8457 suggests codifying a WALEdit 'type' by adding a type
field to WALEdit that gets serialized into the WAL. TODO. Would have to work on the
consumption-side. Reading WALs on replay we seem to consume a Cell-at-a-time rather than by
WALEdit. We are already in the below going out of our way to figure particular types -- e.g. if a
compaction, replay, or close meta Marker -- during normal processing so would make sense to do
this. Current system is an awkward marking of Cell columnfamily as METAFAMILY
and then
setting qualifier based off meta edit type. For replay-time where we read Cell-at-a-time, there
are utility methods below for figuring meta type. See also
createBulkLoadEvent(RegionInfo, WALProtos.BulkLoadDescriptor)
, etc., for where we create
meta WALEdit instances.
WALEdit will accumulate a Set of all column family names referenced by the Cells
add(Cell)
'd. This is an optimization. Usually when loading a WALEdit, we have the column
family name to-hand.. just shove it into the WALEdit if available. Doing this, we can save on a
parse of each Cell to figure column family down the line when we go to add the WALEdit to the WAL
file. See the hand-off in FSWALEntry Constructor.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final byte[]
private ArrayList<ExtendedCell>
static final byte[]
Deprecated.Since 2.3.0.private Set<byte[]>
All the Cell families incells
.static final byte[]
Deprecated.Since 2.3.0.static final byte[]
static final byte[]
Deprecated.Since 2.3.0.static final byte[]
Deprecated.Since 2.3.0.private static final byte[]
We use this define figuring if we are carrying a close event.private static final byte[]
private static final String
private static final String
Qualifier for region event meta 'Marker' WALEdits start with theREGION_EVENT_PREFIX
prefix ('HBASE::REGION_EVENT::').private final boolean
static final byte[]
PeriodicallyReplicationMarkerChore
will create marker edits with family asMETAFAMILY
andREPLICATION_MARKER
as qualifier and an empty value. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) WALEdit
add
(List<ExtendedCell> cells) void
This is just for keeping compatibility for CPs, in HBase you should call the belowaddMap(Map)
directly to avoid casting.(package private) WALEdit
add
(ExtendedCell cell) (package private) WALEdit
add
(ExtendedCell cell, byte[] family) private WALEdit
addCell
(ExtendedCell cell) private void
addFamily
(byte[] family) (package private) void
addMap
(Map<byte[], List<ExtendedCell>> familyMap) Append the given map of family-> edits to a WALEdit data structure.static WALEdit
createBulkLoadEvent
(RegionInfo hri, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.BulkLoadDescriptor bulkLoadDescriptor) Create a bulk loader WALEditstatic WALEdit
createCompaction
(RegionInfo hri, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor c) Returns A Marker WALEdit that hasc
serialized as its valuestatic WALEdit
createFlushWALEdit
(RegionInfo hri, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor f) static byte[]
createRegionEventDescriptorQualifier
(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor.EventType t) static WALEdit
createRegionEventWALEdit
(byte[] rowForRegion, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor regionEventDesc) static WALEdit
createRegionEventWALEdit
(RegionInfo hri, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor regionEventDesc) static WALEdit
createReplicationMarkerEdit
(byte[] rowKey, long timestamp) Creates a replication tracker edit withMETAFAMILY
family andREPLICATION_MARKER
qualifier and has null value.long
static org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.BulkLoadDescriptor
getBulkLoadDescriptor
(Cell cell) Deserialized and returns a BulkLoadDescriptor from the passed in CellgetCells()
static org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor
getCompaction
(Cell kv) Deserialized and returns a CompactionDescriptor is the KeyValue contains one.(package private) List<ExtendedCell>
Set<byte[]>
For use by FSWALEntry ONLY.static org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor
getFlushDescriptor
(Cell cell) private Set<byte[]>
static org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor
getRegionEventDescriptor
(Cell cell) static byte[]
long
heapSize()
Return the approximate 'exclusive deep size' of implementing object.static boolean
isCompactionMarker
(Cell cell) Returns true if the given cell is a serializedWALProtos.CompactionDescriptor
boolean
isEmpty()
boolean
static boolean
isMetaEditFamily
(byte[] f) Deprecated.Since 2.3.0.static boolean
isMetaEditFamily
(Cell cell) Replaying WALs can read Cell-at-a-time so need this method in those cases.boolean
Public so can be accessed from regionserver.wal package.boolean
isReplay()
static boolean
Checks whether this edit is a replication marker edit.int
readFromCells
(Codec.Decoder cellDecoder, int expectedCount) Reads WALEdit from cells.(package private) void
This is just for keeping compatibility for CPs, in HBase you should call the belowsetExtendedCells(ArrayList)
directly to avoid casting.(package private) void
setExtendedCells
(ArrayList<ExtendedCell> cells) This is not thread safe.int
size()
toString()
-
Field Details
-
METAFAMILY
-
METAROW
Deprecated.Since 2.3.0. Not used. -
COMPACTION
Deprecated.Since 2.3.0. Make it protected, internal-use only. UseisCompactionMarker(Cell)
-
FLUSH
Deprecated.Since 2.3.0. Make it protected, internal-use only. -
REGION_EVENT_STR
Qualifier for region event meta 'Marker' WALEdits start with theREGION_EVENT_PREFIX
prefix ('HBASE::REGION_EVENT::'). After the prefix, we note the type of the event which we get from the RegionEventDescriptor protobuf instance type (A RegionEventDescriptor protobuf instance is written as the meta Marker Cell value). Adding a type suffix means we do not have to deserialize the protobuf to figure out what type of event this is.. .just read the qualifier suffix. For example, a close region event descriptor will have a qualifier of HBASE::REGION_EVENT::REGION_CLOSE. See WAL.proto and the EventType in RegionEventDescriptor protos for all possible event types.- See Also:
-
REGION_EVENT_PREFIX_STR
- See Also:
-
REGION_EVENT_PREFIX
-
REGION_EVENT
Deprecated.Since 2.3.0. Remove. Not for external use. Not used. -
REGION_EVENT_CLOSE
We use this define figuring if we are carrying a close event. -
BULK_LOAD
-
REPLICATION_MARKER
PeriodicallyReplicationMarkerChore
will create marker edits with family asMETAFAMILY
andREPLICATION_MARKER
as qualifier and an empty value. org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceWALReader will populate the Replication Marker edit with region_server_name, wal_name and wal_offset encoded inWALProtos.ReplicationMarkerDescriptor
object.Replication
will change the REPLICATION_SCOPE for this edit to GLOBAL so that it can replicate. On the sink cluster,ReplicationSink
will convert the ReplicationMarkerDescriptor into a Put mutation to REPLICATION_SINK_TRACKER_TABLE_NAME_STR table. -
replay
-
cells
-
families
-
-
Constructor Details
-
WALEdit
public WALEdit() -
WALEdit
Deprecated.since 2.0.1 and will be removed in 4.0.0. UseWALEdit(int, boolean)
instead.- See Also:
-
WALEdit
Deprecated.since 2.0.1 and will be removed in 4.0.0. UseWALEdit(int, boolean)
instead.- See Also:
-
WALEdit
- Parameters:
cellCount
- Pass so can pre-size the WALEdit. Optimization.
-
WALEdit
Create a new WALEdit from a existingWALEdit
.
-
-
Method Details
-
getOrCreateFamilies
-
getFamilies
For use by FSWALEntry ONLY. An optimization.- Returns:
- All families in
getCells()
; may be null.
-
isMetaEditFamily
Deprecated.Since 2.3.0. Do not expose. Make protected.- Returns:
- True is
f
isMETAFAMILY
-
isMetaEditFamily
Replaying WALs can read Cell-at-a-time so need this method in those cases. -
isMetaEdit
- Returns:
- True if this is a meta edit; has one edit only and its columnfamily is
METAFAMILY
.
-
isReplay
- Returns:
- True when current WALEdit is created by log replay. Replication skips WALEdits from replay.
-
add
-
add
-
add
-
add
-
add
-
isEmpty
-
size
-
getCells
-
getExtendedCells
-
setCells
This is just for keeping compatibility for CPs, in HBase you should call the belowsetExtendedCells(ArrayList)
directly to avoid casting. -
setExtendedCells
This is not thread safe. This will change the WALEdit and shouldn't be used unless you are sure that nothing else depends on the contents being immutable.- Parameters:
cells
- the list of cells that this WALEdit now contains.
-
readFromCells
Reads WALEdit from cells.- Parameters:
cellDecoder
- Cell decoder.expectedCount
- Expected cell count.- Returns:
- Number of KVs read.
- Throws:
IOException
-
heapSize
Description copied from interface:HeapSize
Return the approximate 'exclusive deep size' of implementing object. Includes count of payload and hosting object sizings. -
estimatedSerializedSizeOf
-
toString
-
createFlushWALEdit
public static WALEdit createFlushWALEdit(RegionInfo hri, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor f) -
getFlushDescriptor
public static org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor getFlushDescriptor(Cell cell) throws IOException - Throws:
IOException
-
createRegionEventWALEdit
public static WALEdit createRegionEventWALEdit(RegionInfo hri, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor regionEventDesc) - Returns:
- A meta Marker WALEdit that has a single Cell whose value is the passed in
regionEventDesc
serialized and whose row is this region, columnfamily isMETAFAMILY
and qualifier isREGION_EVENT_PREFIX
+WALProtos.RegionEventDescriptor.getEventType()
; for example HBASE::REGION_EVENT::REGION_CLOSE.
-
createRegionEventWALEdit
@Private public static WALEdit createRegionEventWALEdit(byte[] rowForRegion, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor regionEventDesc) -
createRegionEventDescriptorQualifier
@Private public static byte[] createRegionEventDescriptorQualifier(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor.EventType t) - Returns:
- Cell qualifier for the passed in RegionEventDescriptor Type; e.g. we'll return something like a byte array with HBASE::REGION_EVENT::REGION_OPEN in it.
-
isRegionCloseMarker
Public so can be accessed from regionserver.wal package.- Returns:
- True if this is a Marker Edit and it is a RegionClose type.
-
getRegionEventDescriptor
public static org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor getRegionEventDescriptor(Cell cell) throws IOException - Returns:
- Returns a RegionEventDescriptor made by deserializing the content of the passed in
cell
, IFF thecell
is a RegionEventDescriptor type WALEdit. - Throws:
IOException
-
createCompaction
public static WALEdit createCompaction(RegionInfo hri, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor c) Returns A Marker WALEdit that hasc
serialized as its value -
getRowForRegion
-
getCompaction
public static org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor getCompaction(Cell kv) throws IOException Deserialized and returns a CompactionDescriptor is the KeyValue contains one.- Parameters:
kv
- the key value- Returns:
- deserialized CompactionDescriptor or null.
- Throws:
IOException
-
isCompactionMarker
Returns true if the given cell is a serializedWALProtos.CompactionDescriptor
- See Also:
-
createBulkLoadEvent
public static WALEdit createBulkLoadEvent(RegionInfo hri, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.BulkLoadDescriptor bulkLoadDescriptor) Create a bulk loader WALEdit- Parameters:
hri
- The RegionInfo for the region in which we are bulk loadingbulkLoadDescriptor
- The descriptor for the Bulk Loader- Returns:
- The WALEdit for the BulkLoad
-
getBulkLoadDescriptor
public static org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.BulkLoadDescriptor getBulkLoadDescriptor(Cell cell) throws IOException Deserialized and returns a BulkLoadDescriptor from the passed in Cell- Parameters:
cell
- the key value- Returns:
- deserialized BulkLoadDescriptor or null.
- Throws:
IOException
-
add
This is just for keeping compatibility for CPs, in HBase you should call the belowaddMap(Map)
directly to avoid casting. -
addMap
Append the given map of family-> edits to a WALEdit data structure. This does not write to the WAL itself. Note that as an optimization, we will stamp the Set of column families into the WALEdit to save on our having to calculate column families subsequently down in the actual WAL writing.- Parameters:
familyMap
- map of family -> edits
-
addFamily
-
addCell
-
createReplicationMarkerEdit
Creates a replication tracker edit withMETAFAMILY
family andREPLICATION_MARKER
qualifier and has null value.- Parameters:
rowKey
- rowkeytimestamp
- timestamp
-
isReplicationMarkerEdit
Checks whether this edit is a replication marker edit.- Parameters:
edit
- edit- Returns:
- true if the cell within an edit has column = METAFAMILY and qualifier = REPLICATION_MARKER, false otherwise
-