Skip to content

Commit

Permalink
Optimize duration option.
Browse files Browse the repository at this point in the history
  • Loading branch information
jianghuazhu committed Sep 29, 2024
1 parent bd26755 commit 804b030
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ private void taskLoop(TaskProvider provider) {
completed.set(true);
break;
}
}

//in case of an other failed test, we shouldn't execute more tasks.
if (counter >= testNo || (!failAtEnd && failureCounter.get() > 0)) {
completed.set(true);
break;
} else {
//in case of an other failed test, we shouldn't execute more tasks.
if (counter >= testNo || (!failAtEnd && failureCounter.get() > 0)) {
completed.set(true);
break;
}
}

tryNextTask(provider, counter % testNo);
Expand Down Expand Up @@ -290,7 +290,7 @@ public void init() {
//replace environment variables to support multi-node execution
prefix = resolvePrefix(prefix);
}
if (duration != null) {
if (duration != null && allowDuration()) {
durationInSecond = TimeDurationUtil.getTimeDurationHelper(
"--runtime", duration, TimeUnit.SECONDS);
if (durationInSecond <= 0) {
Expand Down Expand Up @@ -327,7 +327,7 @@ public void init() {
executor = Executors.newFixedThreadPool(threadNo);
long maxValue;
LongSupplier supplier;
if (duration != null) {
if (duration != null && allowDuration()) {
maxValue = durationInSecond;
supplier = () -> Duration.between(
Instant.ofEpochMilli(startTime), Instant.now()).getSeconds();
Expand Down Expand Up @@ -554,6 +554,19 @@ public String getPrefix() {
return prefix;
}

/**
* Whether to enable Duration.
* If enabled, the command will load the --duration option.
* If not enabled, the command will not load the --duration option.
*/
public boolean allowDuration() {
return true;
}

public String getDuration() {
return duration;
}

public MetricRegistry getMetrics() {
return metrics;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol;

import com.codahale.metrics.Timer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

Expand All @@ -41,6 +43,8 @@
public class OmBucketGenerator extends BaseFreonGenerator
implements Callable<Void> {

private static final Logger LOG = LoggerFactory.getLogger(OmBucketGenerator.class);

@Option(names = {"-v", "--volume"},
description = "Name of the volume which contains the test data. Will be"
+ " created if missing.",
Expand All @@ -57,8 +61,16 @@ public class OmBucketGenerator extends BaseFreonGenerator

private Timer bucketCreationTimer;

@Override
public boolean allowDuration() {
return false;
}

@Override
public Void call() throws Exception {
if (getDuration() != null) {
LOG.warn("When running ombg, setting --duration has no effect.");
}

init();

Expand Down

0 comments on commit 804b030

Please sign in to comment.