Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize duration option.
Browse files Browse the repository at this point in the history
jianghuazhu committed Sep 29, 2024
1 parent bd26755 commit 3b54f19
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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) {
@@ -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();
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;

@@ -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.",
@@ -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();

0 comments on commit 3b54f19

Please sign in to comment.