Merge pull request #973 from nosqlbench/nosqlbench-972-errorenum

Adds missing logic to accomodate the Errored state
This commit is contained in:
Jonathan Shook 2023-02-01 10:58:54 -06:00 committed by GitHub
commit 91fead7095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 10 deletions

View File

@ -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());
}
} }
} }

View File

@ -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());
} }