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
Modifier and TypeClassDescriptionprivate static class
static enum
Nested classes/interfaces inherited from class org.apache.hadoop.mapreduce.Mapper
org.apache.hadoop.mapreduce.Mapper.Context
-
Field Summary
Modifier and TypeFieldDescription(package private) ImmutableBytesWritable
(package private) boolean
(package private) boolean
(package private) boolean
private 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
-
Method Summary
Modifier and TypeMethodDescriptionprivate Cell
checkAndResetTimestamp
(Cell sourceCell) protected void
cleanup
(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) private int
compareCellKeysWithinRow
(Cell c1, Cell c2) Compare families, qualifiers, and timestamps of the given Cells.private static int
compareRowKeys
(byte[] r1, byte[] r2) Compare row keys of the given Result objects.private void
Attempt to read the next source key/hash pair.private void
finishBatchAndCompareHashes
(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) Finish the currently open hash batch.private void
finishRemainingHashRanges
(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) protected void
map
(ImmutableBytesWritable key, Result value, org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) private void
moveToNextBatch
(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 Connection
openConnection
(org.apache.hadoop.conf.Configuration conf, String zkClusterConfKey, String configPrefix) private static Table
openTable
(Connection connection, org.apache.hadoop.conf.Configuration conf, String tableNameConfKey) protected void
setup
(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) private void
syncRange
(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 boolean
syncRowCells
(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 String
toHex
(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:
setup
in 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:
map
in classorg.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable,
Result, ImmutableBytesWritable, Mutation> - Throws:
IOException
InterruptedException
-
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:
IOException
InterruptedException
-
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:
IOException
InterruptedException
-
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:
IOException
InterruptedException
-
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:
IOException
InterruptedException
-
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:
cleanup
in classorg.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable,
Result, ImmutableBytesWritable, Mutation> - Throws:
IOException
InterruptedException
-
finishRemainingHashRanges
private void finishRemainingHashRanges(org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable, Result, throws IOException, InterruptedExceptionImmutableBytesWritable, Mutation>.org.apache.hadoop.mapreduce.Mapper.Context context) - Throws:
IOException
InterruptedException
-