org.apache.hadoop.hbase.regionserver.wal
Interface HLog


@InterfaceAudience.Private
public interface HLog


Nested Class Summary
static class HLog.Entry
          Utility class that lets us keep track of the edit with it's key Only used when splitting logs
static interface HLog.Reader
           
static interface HLog.Writer
           
 
Field Summary
static int DEFAULT_WAL_TRAILER_WARN_SIZE
           
static Pattern EDITFILES_NAME_PATTERN
           
static org.apache.commons.logging.Log LOG
           
static String META_HLOG_FILE_EXTN
          The META region's HLog filename extension
static String RECOVERED_LOG_TMPFILE_SUFFIX
           
static boolean SPLIT_SKIP_ERRORS_DEFAULT
           
static String SPLITTING_EXT
          File Extension used while splitting an HLog into regions (HBASE-2312)
static String WAL_TRAILER_WARN_SIZE
          Configuration name of HLog Trailer's warning size.
 
Method Summary
 void abortCacheFlush(byte[] encodedRegionName)
          Abort a cache flush.
 void append(HRegionInfo info, TableName tableName, WALEdit edits, long now, HTableDescriptor htd)
          Same as appendNoSync(HRegionInfo, TableName, WALEdit, UUID, long, HTableDescriptor), except it causes a sync on the log
 void append(HRegionInfo info, TableName tableName, WALEdit edits, long now, HTableDescriptor htd, boolean isInMemstore)
          Append a set of edits to the log.
 long appendNoSync(HRegionInfo info, TableName tableName, WALEdit edits, UUID clusterId, long now, HTableDescriptor htd)
          Append a set of edits to the log.
 void close()
          Shut down the log.
 void closeAndDelete()
          Shut down the log and delete the log directory
 void completeCacheFlush(byte[] encodedRegionName)
          Complete the cache flush.
 WALCoprocessorHost getCoprocessorHost()
           
 long getEarliestMemstoreSeqNum(byte[] encodedRegionName)
          Gets the earliest sequence number in the memstore for this particular region.
 long getFilenum()
           
 long getSequenceNumber()
           
 void hflush()
           
 void hsync()
           
 boolean isLowReplicationRollEnabled()
          Get LowReplication-Roller status
 long obtainSeqNum()
          Obtain a log sequence number.
 void registerWALActionsListener(WALActionsListener listener)
          registers WALActionsListener
 byte[][] rollWriter()
          Roll the log writer.
 byte[][] rollWriter(boolean force)
          Roll the log writer.
 void setSequenceNumber(long newvalue)
          Called by HRegionServer when it opens a new region to ensure that log sequence numbers are always greater than the latest sequence number of the region being brought on-line.
 Long startCacheFlush(byte[] encodedRegionName)
          WAL keeps track of the sequence numbers that were not yet flushed from memstores in order to be able to do cleanup.
 void sync()
           
 void sync(long txid)
           
 boolean unregisterWALActionsListener(WALActionsListener listener)
          unregisters WALActionsListener
 

Field Detail

LOG

static final org.apache.commons.logging.Log LOG

SPLITTING_EXT

static final String SPLITTING_EXT
File Extension used while splitting an HLog into regions (HBASE-2312)

See Also:
Constant Field Values

SPLIT_SKIP_ERRORS_DEFAULT

static final boolean SPLIT_SKIP_ERRORS_DEFAULT
See Also:
Constant Field Values

META_HLOG_FILE_EXTN

static final String META_HLOG_FILE_EXTN
The META region's HLog filename extension

See Also:
Constant Field Values

WAL_TRAILER_WARN_SIZE

static final String WAL_TRAILER_WARN_SIZE
Configuration name of HLog Trailer's warning size. If a waltrailer's size is greater than the configured size, a warning is logged. This is used with Protobuf reader/writer.

See Also:
Constant Field Values

DEFAULT_WAL_TRAILER_WARN_SIZE

static final int DEFAULT_WAL_TRAILER_WARN_SIZE
See Also:
Constant Field Values

EDITFILES_NAME_PATTERN

static final Pattern EDITFILES_NAME_PATTERN

RECOVERED_LOG_TMPFILE_SUFFIX

static final String RECOVERED_LOG_TMPFILE_SUFFIX
See Also:
Constant Field Values
Method Detail

registerWALActionsListener

void registerWALActionsListener(WALActionsListener listener)
registers WALActionsListener

Parameters:
listener -

unregisterWALActionsListener

boolean unregisterWALActionsListener(WALActionsListener listener)
unregisters WALActionsListener

Parameters:
listener -

getFilenum

long getFilenum()
Returns:
Current state of the monotonically increasing file id.

setSequenceNumber

void setSequenceNumber(long newvalue)
Called by HRegionServer when it opens a new region to ensure that log sequence numbers are always greater than the latest sequence number of the region being brought on-line.

Parameters:
newvalue - We'll set log edit/sequence number to this value if it is greater than the current value.

getSequenceNumber

long getSequenceNumber()
Returns:
log sequence number

rollWriter

byte[][] rollWriter()
                    throws FailedLogCloseException,
                           IOException
Roll the log writer. That is, start writing log messages to a new file.

The implementation is synchronized in order to make sure there's one rollWriter running at any given time.

Returns:
If lots of logs, flush the returned regions so next time through we can clean logs. Returns null if nothing to flush. Names are actual region names as returned by HRegionInfo.getEncodedName()
Throws:
FailedLogCloseException
IOException

rollWriter

byte[][] rollWriter(boolean force)
                    throws FailedLogCloseException,
                           IOException
Roll the log writer. That is, start writing log messages to a new file.

The implementation is synchronized in order to make sure there's one rollWriter running at any given time.

Parameters:
force - If true, force creation of a new writer even if no entries have been written to the current writer
Returns:
If lots of logs, flush the returned regions so next time through we can clean logs. Returns null if nothing to flush. Names are actual region names as returned by HRegionInfo.getEncodedName()
Throws:
FailedLogCloseException
IOException

close

void close()
           throws IOException
Shut down the log.

Throws:
IOException

closeAndDelete

void closeAndDelete()
                    throws IOException
Shut down the log and delete the log directory

Throws:
IOException

append

void append(HRegionInfo info,
            TableName tableName,
            WALEdit edits,
            long now,
            HTableDescriptor htd)
            throws IOException
Same as appendNoSync(HRegionInfo, TableName, WALEdit, UUID, long, HTableDescriptor), except it causes a sync on the log

Throws:
IOException

append

void append(HRegionInfo info,
            TableName tableName,
            WALEdit edits,
            long now,
            HTableDescriptor htd,
            boolean isInMemstore)
            throws IOException
Append a set of edits to the log. Log edits are keyed by (encoded) regionName, rowname, and log-sequence-id. The HLog is flushed after this transaction is written to the log.

Parameters:
info -
tableName -
edits -
now -
htd -
isInMemstore - Whether the record is in memstore. False for system records.
Throws:
IOException

appendNoSync

long appendNoSync(HRegionInfo info,
                  TableName tableName,
                  WALEdit edits,
                  UUID clusterId,
                  long now,
                  HTableDescriptor htd)
                  throws IOException
Append a set of edits to the log. Log edits are keyed by (encoded) regionName, rowname, and log-sequence-id. The HLog is not flushed after this transaction is written to the log.

Parameters:
info -
tableName -
edits -
clusterId - The originating clusterId for this edit (for replication)
now -
htd -
Returns:
txid of this transaction
Throws:
IOException

hsync

void hsync()
           throws IOException
Throws:
IOException

hflush

void hflush()
            throws IOException
Throws:
IOException

sync

void sync()
          throws IOException
Throws:
IOException

sync

void sync(long txid)
          throws IOException
Throws:
IOException

obtainSeqNum

long obtainSeqNum()
Obtain a log sequence number.


startCacheFlush

Long startCacheFlush(byte[] encodedRegionName)
WAL keeps track of the sequence numbers that were not yet flushed from memstores in order to be able to do cleanup. This method tells WAL that some region is about to flush memstore. We stash the oldest seqNum for the region, and let the the next edit inserted in this region be recorded in append(HRegionInfo, TableName, WALEdit, long, HTableDescriptor) as new oldest seqnum. In case of flush being aborted, we put the stashed value back; in case of flush succeeding, the seqNum of that first edit after start becomes the valid oldest seqNum for this region.

Returns:
current seqNum, to pass on to flushers (who will put it into the metadata of the resulting file as an upper-bound seqNum for that file), or NULL if flush should not be started.

completeCacheFlush

void completeCacheFlush(byte[] encodedRegionName)
Complete the cache flush.

Parameters:
encodedRegionName - Encoded region name.

abortCacheFlush

void abortCacheFlush(byte[] encodedRegionName)
Abort a cache flush. Call if the flush fails. Note that the only recovery for an aborted flush currently is a restart of the regionserver so the snapshot content dropped by the failure gets restored to the memstore.v

Parameters:
encodedRegionName - Encoded region name.

getCoprocessorHost

WALCoprocessorHost getCoprocessorHost()
Returns:
Coprocessor host.

isLowReplicationRollEnabled

boolean isLowReplicationRollEnabled()
Get LowReplication-Roller status

Returns:
lowReplicationRollEnabled

getEarliestMemstoreSeqNum

long getEarliestMemstoreSeqNum(byte[] encodedRegionName)
Gets the earliest sequence number in the memstore for this particular region. This can serve as best-effort "recent" WAL number for this region.

Parameters:
encodedRegionName - The region to get the number for.
Returns:
The number if present, HConstants.NO_SEQNUM if absent.


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.