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.
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 hbase: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, AtomicLong sequenceId)
          Same as appendNoSync(HRegionInfo, TableName, WALEdit, List, long, HTableDescriptor), except it causes a sync on the log
 long appendNoSync(HRegionInfo info, TableName tableName, WALEdit edits, List<UUID> clusterIds, long now, HTableDescriptor htd, AtomicLong sequenceId, boolean isInMemstore, long nonceGroup, long nonce)
          Deprecated. 
 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 getLogFileSize()
           
 int getNumLogFiles()
           
 void hflush()
           
 void hsync()
           
 boolean isLowReplicationRollEnabled()
          Get LowReplication-Roller status
 void postAppend(List<HLog.Entry> entries)
          For notification post append to the writer.
 void postSync()
          For notification post writer sync.
 void registerWALActionsListener(WALActionsListener listener)
          registers WALActionsListener
 byte[][] rollWriter()
          Roll the log writer.
 byte[][] rollWriter(boolean force)
          Roll the log writer.
 boolean 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 hbase: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.

getNumLogFiles

int getNumLogFiles()
Returns:
the number of HLog files

getLogFileSize

long getLogFileSize()
Returns:
the size of HLog files

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,
            AtomicLong sequenceId)
            throws IOException
Same as appendNoSync(HRegionInfo, TableName, WALEdit, List, long, HTableDescriptor), except it causes a sync on the log

Parameters:
sequenceId - of the region.
Throws:
IOException

postAppend

void postAppend(List<HLog.Entry> entries)
For notification post append to the writer.

Parameters:
entries -

postSync

void postSync()
For notification post writer sync.


appendNoSync

@Deprecated
long appendNoSync(HRegionInfo info,
                             TableName tableName,
                             WALEdit edits,
                             List<UUID> clusterIds,
                             long now,
                             HTableDescriptor htd,
                             AtomicLong sequenceId,
                             boolean isInMemstore,
                             long nonceGroup,
                             long nonce)
                  throws IOException
Deprecated. 

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 -
clusterIds - The clusters that have consumed the change (for replication)
now -
htd -
sequenceId - of the region
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

startCacheFlush

boolean 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, AtomicLong) 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:
true if the flush can proceed, false in case wal is closing (ususally, when server is closing) and flush couldn't 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 © 2007–2016 The Apache Software Foundation. All rights reserved.