mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Merge pull request #973 from nosqlbench/nosqlbench-972-errorenum
Adds missing logic to accomodate the Errored state
This commit is contained in:
commit
91fead7095
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 nosqlbench
|
* Copyright (c) 2022-2023 nosqlbench
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -33,6 +33,7 @@ import io.nosqlbench.engine.api.activityimpl.MotorState;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static io.nosqlbench.engine.api.activityapi.core.RunState.*;
|
import static io.nosqlbench.engine.api.activityapi.core.RunState.*;
|
||||||
@ -460,18 +461,17 @@ public class CoreMotor<D> implements ActivityDefObserver, Motor<D>, Stoppable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void requestStop() {
|
public synchronized void requestStop() {
|
||||||
if (motorState.get() == Running) {
|
RunState currentState = motorState.get();
|
||||||
|
if (Objects.requireNonNull(currentState) == Running) {
|
||||||
if (input instanceof Stoppable) {
|
if (input instanceof Stoppable) {
|
||||||
((Stoppable) input).requestStop();
|
((Stoppable) input).requestStop();
|
||||||
}
|
}
|
||||||
if (action instanceof Stoppable) {
|
if (action instanceof Stoppable) {
|
||||||
((Stoppable) action).requestStop();
|
((Stoppable) action).requestStop();
|
||||||
}
|
}
|
||||||
motorState.enterState(RunState.Stopping);
|
motorState.enterState(Stopping);
|
||||||
} else {
|
} else {
|
||||||
if (motorState.get() != Stopped && motorState.get() != Stopping) {
|
logger.warn(() -> "attempted to stop motor " + this.getSlotId() + ": from non Running state:" + currentState);
|
||||||
logger.warn(()->"attempted to stop motor " + this.getSlotId() + ": from non Running state:" + motorState.get());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +299,9 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
|
|||||||
break;
|
break;
|
||||||
case Finished:
|
case Finished:
|
||||||
case Stopping:
|
case Stopping:
|
||||||
throw new RuntimeException("Invalid requested state in activity executor:" + activity.getRunState());
|
case Errored:
|
||||||
|
break;
|
||||||
|
// throw new RuntimeException("Invalid requested state in activity executor:" + activity.getRunState());
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unmatched run state:" + activity.getRunState());
|
throw new RuntimeException("Unmatched run state:" + activity.getRunState());
|
||||||
@ -314,16 +316,16 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
|
|||||||
case Running:
|
case Running:
|
||||||
tally.awaitNoneOther(RunState.Running, RunState.Finished);
|
tally.awaitNoneOther(RunState.Running, RunState.Finished);
|
||||||
break;
|
break;
|
||||||
|
case Errored:
|
||||||
|
case Stopping:
|
||||||
case Stopped:
|
case Stopped:
|
||||||
tally.awaitNoneOther(RunState.Stopped, RunState.Finished);
|
tally.awaitNoneOther(RunState.Stopped, RunState.Finished, RunState.Errored);
|
||||||
break;
|
break;
|
||||||
case Uninitialized:
|
case Uninitialized:
|
||||||
break;
|
break;
|
||||||
case Finished:
|
case Finished:
|
||||||
tally.awaitNoneOther(RunState.Finished);
|
tally.awaitNoneOther(RunState.Finished);
|
||||||
break;
|
break;
|
||||||
case Stopping:
|
|
||||||
throw new RuntimeException("Invalid requested state in activity executor:" + activity.getRunState());
|
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unmatched run state:" + activity.getRunState());
|
throw new RuntimeException("Unmatched run state:" + activity.getRunState());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user