Class SyncTable.SyncMapper
java.lang.Object
org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable,Result,KEYOUT,VALUEOUT>
org.apache.hadoop.hbase.mapreduce.TableMapper<ImmutableBytesWritable,Mutation>
org.apache.hadoop.hbase.mapreduce.SyncTable.SyncMapper
- Enclosing class:
- SyncTable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classstatic enumNested classes/interfaces inherited from class org.apache.hadoop.mapreduce.Mapper
org.apache.hadoop.mapreduce.Mapper.Context -
Field Summary
FieldsModifier and TypeFieldDescription(package private) ImmutableBytesWritable(package private) boolean(package private) boolean(package private) booleanprivate static final SyncTable.SyncMapper.CellScanner(package private) boolean(package private) Throwable(package private) ImmutableBytesWritable(package private) Connection(package private) org.apache.hadoop.fs.Path(package private) HashTable.TableHash.Reader(package private) Table(package private) HashTable.TableHash(package private) Connection(package private) HashTable.ResultHasher(package private) Table -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate CellcheckAndResetTimestamp(Cell sourceCell) protected voidcleanup(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) private intcompareCellKeysWithinRow(Cell c1, Cell c2) Compare families, qualifiers, and timestamps of the given Cells.private static intcompareRowKeys(byte[] r1, byte[] r2) Compare row keys of the given Result objects.private voidAttempt to read the next source key/hash pair.private voidfinishBatchAndCompareHashes(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) Finish the currently open hash batch.private voidfinishRemainingHashRanges(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) protected voidmap(ImmutableBytesWritable key, Result value, org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) private voidmoveToNextBatch(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) If there is an open hash batch, complete it and sync if there are diffs.private static ConnectionopenConnection(org.apache.hadoop.conf.Configuration conf, String zkClusterConfKey, String configPrefix) private static TableopenTable(Connection connection, org.apache.hadoop.conf.Configuration conf, String tableNameConfKey) protected voidsetup(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) private voidsyncRange(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context, ImmutableBytesWritable startRow, ImmutableBytesWritable stopRow) Rescan the given range directly from the source and target tables.private booleansyncRowCells(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context, byte[] rowKey, SyncTable.SyncMapper.CellScanner sourceCells, SyncTable.SyncMapper.CellScanner targetCells) Compare the cells for the given row from the source and target tables.private static StringtoHex(ImmutableBytesWritable bytes) Methods inherited from class org.apache.hadoop.mapreduce.Mapper
run
-
Field Details
-
sourceHashDir
org.apache.hadoop.fs.Path sourceHashDir -
sourceConnection
-
targetConnection
-
sourceTable
-
targetTable
-
dryRun
boolean dryRun -
doDeletes
boolean doDeletes -
doPuts
boolean doPuts -
ignoreTimestamp
boolean ignoreTimestamp -
sourceTableHash
-
sourceHashReader
-
currentSourceHash
-
nextSourceKey
-
targetHasher
-
mapperException
-
EMPTY_CELL_SCANNER
-
-
Constructor Details
-
SyncMapper
public SyncMapper()
-
-
Method Details
-
setup
protected void setup(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, throws IOExceptionImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) - Overrides:
setupin classorg.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable,Result, ImmutableBytesWritable, Mutation> - Throws:
IOException
-
openConnection
private static Connection openConnection(org.apache.hadoop.conf.Configuration conf, String zkClusterConfKey, String configPrefix) throws IOException - Throws:
IOException
-
openTable
private static Table openTable(Connection connection, org.apache.hadoop.conf.Configuration conf, String tableNameConfKey) throws IOException - Throws:
IOException
-
findNextKeyHashPair
Attempt to read the next source key/hash pair. If there are no more, set nextSourceKey to null- Throws:
IOException
-
map
protected void map(ImmutableBytesWritable key, Result value, org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, throws IOException, InterruptedExceptionImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) - Overrides:
mapin classorg.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable,Result, ImmutableBytesWritable, Mutation> - Throws:
IOExceptionInterruptedException
-
moveToNextBatch
private void moveToNextBatch(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, throws IOException, InterruptedExceptionImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) If there is an open hash batch, complete it and sync if there are diffs. Start a new batch, and seek to read the- Throws:
IOExceptionInterruptedException
-
finishBatchAndCompareHashes
private void finishBatchAndCompareHashes(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, throws IOException, InterruptedExceptionImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) Finish the currently open hash batch. Compare the target hash to the given source hash. If they do not match, then sync the covered key range.- Throws:
IOExceptionInterruptedException
-
toHex
-
syncRange
private void syncRange(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, throws IOException, InterruptedExceptionImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context, ImmutableBytesWritable startRow, ImmutableBytesWritable stopRow) Rescan the given range directly from the source and target tables. Count and log differences, and if this is not a dry run, output Puts and Deletes to make the target table match the source table for this range- Throws:
IOExceptionInterruptedException
-
checkAndResetTimestamp
-
syncRowCells
private boolean syncRowCells(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, throws IOException, InterruptedExceptionImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context, byte[] rowKey, SyncTable.SyncMapper.CellScanner sourceCells, SyncTable.SyncMapper.CellScanner targetCells) Compare the cells for the given row from the source and target tables. Count and log any differences. If not a dry run, output a Put and/or Delete needed to sync the target table to match the source table.- Throws:
IOExceptionInterruptedException
-
compareRowKeys
Compare row keys of the given Result objects. Nulls are after non-nulls -
compareCellKeysWithinRow
Compare families, qualifiers, and timestamps of the given Cells. They are assumed to be of the same row. Nulls are after non-nulls. -
cleanup
protected void cleanup(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, throws IOException, InterruptedExceptionImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) - Overrides:
cleanupin classorg.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable,Result, ImmutableBytesWritable, Mutation> - Throws:
IOExceptionInterruptedException
-
finishRemainingHashRanges
private void finishRemainingHashRanges(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, throws IOException, InterruptedExceptionImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) - Throws:
IOExceptionInterruptedException
-