Skip to content

Commit c510213

Browse files
committed
HBASE-29877. Introduce new LTT parameter --timeline to control timeline consistency in read operations (#7723)
1 parent 3424f6d commit c510213

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ public class LoadTestTool extends AbstractHBaseTool {
172172
protected static final String OPT_REGION_REPLICA_ID_USAGE =
173173
"Region replica id to do the reads from";
174174

175+
public static final String OPT_TIMELINE_CONSISTENCY = "timeline";
176+
protected static final String OPT_TIMELINE_CONSISTENCY_USAGE =
177+
"Use TIMELINE consistency in read operations. Leave region_replica_id unset, otherwise it will override this setting.";
178+
175179
public static final String OPT_MOB_THRESHOLD = "mob_threshold";
176180
protected static final String OPT_MOB_THRESHOLD_USAGE =
177181
"Desired cell size to exceed in bytes that will use the MOB write path";
@@ -227,6 +231,7 @@ public class LoadTestTool extends AbstractHBaseTool {
227231
private int numRegionsPerServer = DEFAULT_NUM_REGIONS_PER_SERVER;
228232
private int regionReplication = -1; // not set
229233
private int regionReplicaId = -1; // not set
234+
private boolean timelineConsistency = false;
230235

231236
private int mobThreshold = -1; // not set
232237

@@ -360,6 +365,7 @@ protected void addOptions() {
360365
addOptWithArg(OPT_NUM_REGIONS_PER_SERVER, OPT_NUM_REGIONS_PER_SERVER_USAGE);
361366
addOptWithArg(OPT_REGION_REPLICATION, OPT_REGION_REPLICATION_USAGE);
362367
addOptWithArg(OPT_REGION_REPLICA_ID, OPT_REGION_REPLICA_ID_USAGE);
368+
addOptNoArg(OPT_TIMELINE_CONSISTENCY, OPT_TIMELINE_CONSISTENCY_USAGE);
363369
addOptWithArg(OPT_MOB_THRESHOLD, OPT_MOB_THRESHOLD_USAGE);
364370
}
365371

@@ -519,6 +525,11 @@ protected void processOptions(CommandLine cmd) {
519525
if (cmd.hasOption(OPT_REGION_REPLICA_ID)) {
520526
regionReplicaId = Integer.parseInt(cmd.getOptionValue(OPT_REGION_REPLICA_ID));
521527
}
528+
529+
timelineConsistency = false;
530+
if (cmd.hasOption(OPT_TIMELINE_CONSISTENCY)) {
531+
timelineConsistency = true;
532+
}
522533
}
523534

524535
private void parseColumnFamilyOptions(CommandLine cmd) {
@@ -705,6 +716,7 @@ protected int loadTable() throws IOException {
705716
readerThreads.setKeyWindow(keyWindow);
706717
readerThreads.setMultiGetBatchSize(multiGetBatchSize);
707718
readerThreads.setRegionReplicaId(regionReplicaId);
719+
readerThreads.setTimelineConsistency(timelineConsistency);
708720
}
709721

710722
if (isUpdate && isWrite) {

hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedReader.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public class MultiThreadedReader extends MultiThreadedAction {
7676
private int keyWindow = DEFAULT_KEY_WINDOW;
7777
private int batchSize = DEFAULT_BATCH_SIZE;
7878
private int regionReplicaId = -1; // particular region replica id to do reads against if set
79+
private boolean timelineConsistency = false;
7980

8081
public MultiThreadedReader(LoadTestDataGenerator dataGen, Configuration conf, TableName tableName,
8182
double verifyPercent) throws IOException {
@@ -104,6 +105,10 @@ public void setRegionReplicaId(int regionReplicaId) {
104105
this.regionReplicaId = regionReplicaId;
105106
}
106107

108+
public void setTimelineConsistency(boolean timelineConsistency) {
109+
this.timelineConsistency = timelineConsistency;
110+
}
111+
107112
@Override
108113
public void start(long startKey, long endKey, int numThreads) throws IOException {
109114
super.start(startKey, endKey, numThreads);
@@ -318,6 +323,8 @@ protected Get createGet(long keyToRead) throws IOException {
318323
get = dataGenerator.beforeGet(keyToRead, get);
319324
if (regionReplicaId > 0) {
320325
get.setReplicaId(regionReplicaId);
326+
}
327+
if (timelineConsistency) {
321328
get.setConsistency(Consistency.TIMELINE);
322329
}
323330
if (verbose) {

0 commit comments

Comments
 (0)