org.apache.hadoop.hbase.regionserver.transactional
Class TransactionalRegion

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.HRegion
      extended by org.apache.hadoop.hbase.regionserver.transactional.TransactionalRegion
All Implemented Interfaces:
HConstants, HeapSize

public class TransactionalRegion
extends HRegion

Regionserver which provides transactional support for atomic transactions. This is achieved with optimistic concurrency control (see http://www.seas.upenn.edu/~zives/cis650/papers/opt-cc.pdf). We keep track read and write sets for each transaction, and hold off on processing the writes. To decide to commit a transaction we check its read sets with all transactions that have committed while it was running for overlaps.

Because transactions can span multiple regions, all regions must agree to commit a transactions. The client side of this commit protocol is encoded in org.apache.hadoop.hbase.client.transactional.TransactionManger

In the event of an failure of the client mid-commit, (after we voted yes), we will have to consult the transaction log to determine the final decision of the transaction. This is not yet implemented.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.HConstants
HConstants.Modify
 
Field Summary
protected  Map<String,org.apache.hadoop.hbase.regionserver.transactional.TransactionState> transactionsById
           
 
Fields inherited from class org.apache.hadoop.hbase.regionserver.HRegion
DEEP_OVERHEAD, FIXED_OVERHEAD, REGIONINFO_FILE, REGIONINFO_FILE_BYTES, rwcc, stores
 
Fields inherited from interface org.apache.hadoop.hbase.HConstants
ALL_VERSIONS, CATALOG_FAMILY, CATALOG_FAMILY_STR, CATALOG_HISTORIAN_FAMILY, CLUSTER_DISTRIBUTED, CLUSTER_IS_DISTRIBUTED, CLUSTER_IS_LOCAL, DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE, DEFAULT_HOST, DEFAULT_MASTER_INFOPORT, DEFAULT_MASTER_PORT, DEFAULT_MAX_FILE_SIZE, DEFAULT_REGION_SERVER_CLASS, DEFAULT_REGIONSERVER_INFOPORT, DEFAULT_REGIONSERVER_PORT, DEFAULT_SIZE_RESERVATION_BLOCK, DEFAULT_ZOOKEEPER_PAUSE, DEFAULT_ZOOKEEPER_RETRIES, EMPTY_BYTE_ARRAY, EMPTY_END_ROW, EMPTY_START_ROW, FILE_SYSTEM_VERSION, FOREVER, HBASE_CLIENT_RETRIES_NUMBER_KEY, HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, HBASE_DIR, HREGION_COMPACTIONDIR_NAME, HREGION_LOGDIR_NAME, HREGION_OLDLOGFILE_NAME, IN_MEMORY, LAST_ROW, LATEST_TIMESTAMP, LATEST_TIMESTAMP_BYTES, MAJOR_COMPACTION_PERIOD, MASTER_PORT, MAX_ROW_LENGTH, MAXIMUM_VALUE_LENGTH, META_ROW_DELIMITER, META_TABLE_NAME, NAME, NINES, REGION_IMPL, REGION_SERVER_CLASS, REGION_SERVER_IMPL, REGIONINFO_QUALIFIER, REGIONSERVER_PORT, RETRY_BACKOFF, ROOT_TABLE_NAME, SERVER_QUALIFIER, SPLITA_QUALIFIER, SPLITB_QUALIFIER, STARTCODE_QUALIFIER, THREAD_WAKE_FREQUENCY, UTF8_ENCODING, VERSION_FILE_NAME, VERSIONS, WEEK_IN_SECONDS, ZERO_L, ZEROES, ZOOKEEPER_CONFIG_NAME, ZOOKEEPER_PAUSE, ZOOKEEPER_QUORUM, ZOOKEEPER_RETRIES
 
Constructor Summary
TransactionalRegion(org.apache.hadoop.fs.Path basedir, HLog log, org.apache.hadoop.fs.FileSystem fs, HBaseConfiguration conf, HRegionInfo regionInfo, FlushRequester flushListener, Leases transactionalLeases)
           
 
Method Summary
 void abort(long transactionId)
          Commit the transaction.
 void beginTransaction(long transactionId)
           
 List<StoreFile> close(boolean abort)
          Close down this HRegion.
 void commit(long transactionId)
          Commit the transaction.
 boolean commitIfPossible(long transactionId)
           
 int commitRequest(long transactionId)
           
 void delete(long transactionId, Delete delete)
          Add a delete to the transaction.
protected  void doReconstructionLog(org.apache.hadoop.fs.Path oldLogFile, long minSeqId, long maxSeqId, org.apache.hadoop.util.Progressable reporter)
           
 Result get(long transactionId, Get get)
           
protected  long getCompleteCacheFlushSequenceId(long currentSequenceId)
          We need to make sure that we don't complete a cache flush between running transactions.
 InternalScanner getScanner(long transactionId, Scan scan)
          Get a transactional scanner.
protected  org.apache.hadoop.hbase.regionserver.transactional.TransactionState getTransactionState(long transactionId)
           
protected  void prepareToSplit()
           
 void put(long transactionId, Put put)
          Add a write to the transaction.
 void put(long transactionId, Put[] puts)
          Add multiple writes to the transaction.
 
Methods inherited from class org.apache.hadoop.hbase.regionserver.HRegion
addRegionToMETA, checkAndPut, checkReadOnly, cleanRegionInMETA, close, compactStores, createHRegion, delete, delete, deleteRegion, equals, flushcache, get, getBaseDir, getClosestRowBefore, getConf, getEndKey, getFilesystem, getLargestHStoreSize, getLastFlushTime, getLog, getRegionDir, getRegionDir, getRegionDir, getRegionId, getRegionInfo, getRegionName, getRegionNameAsString, getScanner, getScanner, getStartKey, getStore, getTableDesc, hashCode, hasTooManyStoreFiles, heapSize, incrementColumnValue, initialize, instantiateHStore, instantiateInternalScanner, internalFlushcache, internalPreFlushcacheCommit, isClosed, isClosing, main, makeColumnFamilyDirs, merge, mergeAdjacent, newHRegion, obtainRowLock, offlineRegionInMETA, openHRegion, put, put, put, put, removeRegionFromMETA, rowIsInRange, shouldSplit, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

transactionsById

protected Map<String,org.apache.hadoop.hbase.regionserver.transactional.TransactionState> transactionsById
Constructor Detail

TransactionalRegion

public TransactionalRegion(org.apache.hadoop.fs.Path basedir,
                           HLog log,
                           org.apache.hadoop.fs.FileSystem fs,
                           HBaseConfiguration conf,
                           HRegionInfo regionInfo,
                           FlushRequester flushListener,
                           Leases transactionalLeases)
Parameters:
basedir -
log -
fs -
conf -
regionInfo -
flushListener -
Method Detail

doReconstructionLog

protected void doReconstructionLog(org.apache.hadoop.fs.Path oldLogFile,
                                   long minSeqId,
                                   long maxSeqId,
                                   org.apache.hadoop.util.Progressable reporter)
                            throws UnsupportedEncodingException,
                                   IOException
Overrides:
doReconstructionLog in class HRegion
Throws:
UnsupportedEncodingException
IOException

getCompleteCacheFlushSequenceId

protected long getCompleteCacheFlushSequenceId(long currentSequenceId)
We need to make sure that we don't complete a cache flush between running transactions. If we did, then we would not find all log messages needed to restore the transaction, as some of them would be before the last "complete" flush id.

Overrides:
getCompleteCacheFlushSequenceId in class HRegion
Returns:
sequence id to complete the cache flush with

beginTransaction

public void beginTransaction(long transactionId)
                      throws IOException
Parameters:
transactionId -
Throws:
IOException

get

public Result get(long transactionId,
                  Get get)
           throws IOException
Throws:
IOException

getScanner

public InternalScanner getScanner(long transactionId,
                                  Scan scan)
                           throws IOException
Get a transactional scanner.

Throws:
IOException

put

public void put(long transactionId,
                Put put)
         throws IOException
Add a write to the transaction. Does not get applied until commit process.

Parameters:
transactionId -
put -
Throws:
IOException

put

public void put(long transactionId,
                Put[] puts)
         throws IOException
Add multiple writes to the transaction. Does not get applied until commit process.

Parameters:
transactionId -
puts -
Throws:
IOException

delete

public void delete(long transactionId,
                   Delete delete)
            throws IOException
Add a delete to the transaction. Does not get applied until commit process.

Parameters:
transactionId -
delete -
Throws:
IOException

commitRequest

public int commitRequest(long transactionId)
                  throws IOException
Parameters:
transactionId -
Returns:
TransactionRegionInterface commit code
Throws:
IOException

commitIfPossible

public boolean commitIfPossible(long transactionId)
                         throws IOException
Parameters:
transactionId -
Returns:
true if commit is successful
Throws:
IOException

commit

public void commit(long transactionId)
            throws IOException
Commit the transaction.

Parameters:
transactionId -
Throws:
IOException

abort

public void abort(long transactionId)
           throws IOException
Commit the transaction.

Parameters:
transactionId -
Throws:
IOException

close

public List<StoreFile> close(boolean abort)
                      throws IOException
Description copied from class: HRegion
Close down this HRegion. Flush the cache unless abort parameter is true, Shut down each HStore, don't service any more calls. This method could take some time to execute, so don't call it from a time-sensitive thread.

Overrides:
close in class HRegion
Parameters:
abort - true if server is aborting (only during testing)
Returns:
Vector of all the storage files that the HRegion's component HStores make use of. It's a list of HStoreFile objects. Can be null if we are not to close at this time or we are already closed.
Throws:
IOException - e

prepareToSplit

protected void prepareToSplit()
Overrides:
prepareToSplit in class HRegion

getTransactionState

protected org.apache.hadoop.hbase.regionserver.transactional.TransactionState getTransactionState(long transactionId)
                                                                                           throws UnknownTransactionException
Throws:
UnknownTransactionException


Copyright © 2010 The Apache Software Foundation