Skip to content

Commit

Permalink
Merge pull request #63 from emc-mongoose/wait-op-finish-limit
Browse files Browse the repository at this point in the history
Adding wait-op-finish-limit config
  • Loading branch information
dlarge authored Feb 28, 2025
2 parents 7bde8b7 + 8142653 commit a2741ef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class LoadStepContextImpl<I extends Item, O extends Operation<I>> extends
private volatile Output<O> opsResultsOutput;
private volatile Output<O> opsMetricsOutput;
private final boolean waitOpFinishBeforeStop;
private final int waitOpFinishLimit;
private final boolean outputDuplicates;
private final boolean updateContents;
private final ThreadLocal<SplittableRandom> rand = ThreadLocal.withInitial(SplittableRandom::new);
Expand Down Expand Up @@ -110,6 +111,7 @@ public LoadStepContextImpl(
this.failCountLimit = configFailCount > 0 ? configFailCount : Long.MAX_VALUE;
this.failRateLimitFlag = failConfig.boolVal("rate");
this.waitOpFinishBeforeStop = opConfig.boolVal("wait-finish");
this.waitOpFinishLimit = opConfig.intVal("wait-limit");
this.outputDuplicates = opConfig.boolVal("output-duplicates");
}

Expand Down Expand Up @@ -515,14 +517,14 @@ protected final void doStop() throws IllegalStateException {
if (waitOpFinishBeforeStop) {
var i = 0;
var sleep = 1000;
for (; ((activeOpCount() != 0) && !Thread.currentThread().isInterrupted()) && i < 10; i++) {
for (; ((activeOpCount() != 0) && !Thread.currentThread().isInterrupted()) && ((i * sleep)/1000D < waitOpFinishLimit); i++) {
try {
Thread.sleep(sleep);
} catch (InterruptedException e) {
Loggers.MSG.debug("couldn't put context thread {} to sleep or was interrupted", this);
}
}
Loggers.MSG.info("{}: waited {}ms for ops to finish (active count = {})", id, i * sleep, activeOpCount());
Loggers.MSG.info("{}: waited {}s for ops to finish (active count = {})", id, i, activeOpCount());
}

driver.stop();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ load:
type: string
wait:
finish: boolean
limit: int
output:
color: boolean
metrics:
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/config/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ load:
type: create
wait:
finish: true
limit: 30
service:
threads: 0
step:
Expand Down Expand Up @@ -92,7 +93,7 @@ run:
node: false
port: 9999
scenario: null
version: 4.3.12
version: 4.3.13

storage:
auth:
Expand Down

0 comments on commit a2741ef

Please sign in to comment.