Skip to content

Commit 2a46c13

Browse files
author
Hernan Gelaf-Romer
committed
re-use VRRunnable
1 parent 4535d3c commit 2a46c13

File tree

1 file changed

+5
-38
lines changed

1 file changed

+5
-38
lines changed

hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/replication/VerifyReplication.java

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.apache.hadoop.hbase.TableName;
3636
import org.apache.hadoop.hbase.client.Connection;
3737
import org.apache.hadoop.hbase.client.ConnectionFactory;
38-
import org.apache.hadoop.hbase.client.Get;
3938
import org.apache.hadoop.hbase.client.Put;
4039
import org.apache.hadoop.hbase.client.Result;
4140
import org.apache.hadoop.hbase.client.ResultScanner;
@@ -61,7 +60,6 @@
6160
import org.apache.hadoop.hbase.util.Bytes;
6261
import org.apache.hadoop.hbase.util.CommonFSUtils;
6362
import org.apache.hadoop.hbase.util.Pair;
64-
import org.apache.hadoop.hbase.util.Threads;
6563
import org.apache.hadoop.hbase.zookeeper.ZKConfig;
6664
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
6765
import org.apache.hadoop.mapreduce.InputSplit;
@@ -293,14 +291,15 @@ private void logFailRowAndIncreaseCounter(Context context, Counters counter, Res
293291
return;
294292
}
295293

294+
VerifyReplicationRecompareRunnable runnable = new VerifyReplicationRecompareRunnable(context,
295+
row, replicatedRow, counter, delimiter, tableScan, sourceTable, replicatedTable,
296+
reCompareTries, sleepMsBeforeReCompare, reCompareBackoffExponent, verbose);
297+
296298
if (reCompareExecutor == null) {
297-
syncLogFailRowAndIncreaseCounter(context, counter, rowKey);
299+
runnable.run();
298300
return;
299301
}
300302

301-
VerifyReplicationRecompareRunnable runnable = new VerifyReplicationRecompareRunnable(context,
302-
row, replicatedRow, counter, delimiter, tableScan, sourceTable, replicatedTable,
303-
reCompareTries, sleepMsBeforeReCompare, reCompareBackoffExponent, verbose);
304303
reCompareExecutor.submit(runnable);
305304
}
306305

@@ -375,38 +374,6 @@ protected void cleanup(Context context) {
375374
}
376375
}
377376
}
378-
379-
private void syncLogFailRowAndIncreaseCounter(Mapper.Context context, Counters counter,
380-
byte[] row) {
381-
int sleepMs = sleepMsBeforeReCompare;
382-
int tries = 0;
383-
384-
while (++tries <= reCompareTries) {
385-
context.getCounter(VerifyReplication.Verifier.Counters.RECOMPARES).increment(1);
386-
Threads.sleep(sleepMs);
387-
try {
388-
Result sourceResult = sourceTable.get(new Get(row));
389-
Result replicatedResult = replicatedTable.get(new Get(row));
390-
Result.compareResults(sourceResult, replicatedResult, false);
391-
if (!sourceResult.isEmpty()) {
392-
context.getCounter(Counters.GOODROWS).increment(1);
393-
if (verbose) {
394-
LOG.info("Good row key (with recompare): " + delimiter + Bytes.toStringBinary(row)
395-
+ delimiter);
396-
}
397-
}
398-
return;
399-
} catch (Exception e) {
400-
context.getCounter(Counters.FAILED_RECOMPARE).increment(1);
401-
LOG.error("recompare fail after sleep, rowkey=" + delimiter + Bytes.toStringBinary(row)
402-
+ delimiter);
403-
}
404-
sleepMs = sleepMs * (2 ^ reCompareBackoffExponent);
405-
}
406-
context.getCounter(counter).increment(1);
407-
context.getCounter(Counters.BADROWS).increment(1);
408-
LOG.error("{}, rowkey={}{}{}", counter, delimiter, Bytes.toStringBinary(row), delimiter);
409-
}
410377
}
411378

412379
private static Pair<ReplicationPeerConfig, Configuration>

0 commit comments

Comments
 (0)