mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Separate ActivityExecutor.forceStop() method out from the stop() method. Removing the "forcing" flag in the stop() method.
This commit is contained in:
@@ -82,18 +82,40 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
|
||||
|
||||
/**
|
||||
* Simply stop the motors
|
||||
*
|
||||
* @param forcing whether to force (without trying to wait) the activity to reach stopped/finished state
|
||||
*/
|
||||
public void stopActivity(boolean forcing) {
|
||||
logger.info(() ->
|
||||
(forcing ? "forcing " : "") + "stopping activity in progress: " + this.getActivityDef().getAlias());
|
||||
public void stopActivity() {
|
||||
logger.info(() -> "stopping activity in progress: " + this.getActivityDef().getAlias());
|
||||
|
||||
activity.setRunState(RunState.Stopping);
|
||||
motors.forEach(Motor::requestStop);
|
||||
tally.awaitNoneOther(RunState.Stopped, RunState.Finished);
|
||||
|
||||
shutdownExecutorService(Integer.MAX_VALUE);
|
||||
tally.awaitNoneOther(RunState.Stopped,RunState.Finished);
|
||||
activity.setRunState(RunState.Stopped);
|
||||
|
||||
logger.info(() -> "stopped: " + this.getActivityDef().getAlias() + " with " + motors.size() + " slots");
|
||||
|
||||
Annotators.recordAnnotation(Annotation.newBuilder()
|
||||
.session(sessionId)
|
||||
.interval(this.startedAt, this.stoppedAt)
|
||||
.layer(Layer.Activity)
|
||||
.label("alias", getActivityDef().getAlias())
|
||||
.label("driver", getActivityDef().getActivityType())
|
||||
.label("workload", getActivityDef().getParams().getOptionalString("workload").orElse("none"))
|
||||
.detail("params", getActivityDef().toString())
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force stop the motors without trying to wait for the activity to reach stopped/finished state
|
||||
*/
|
||||
public void forceStopActivity() {
|
||||
logger.info(() -> "force stopping activity in progress: " + this.getActivityDef().getAlias());
|
||||
|
||||
activity.setRunState(RunState.Stopping);
|
||||
motors.forEach(Motor::requestStop);
|
||||
if (!forcing) {
|
||||
tally.awaitNoneOther(RunState.Stopped, RunState.Finished);
|
||||
}
|
||||
|
||||
shutdownExecutorService(Integer.MAX_VALUE);
|
||||
tally.awaitNoneOther(RunState.Stopped,RunState.Finished);
|
||||
|
||||
@@ -84,10 +84,9 @@ public class ActivityRuntimeInfo implements ProgressCapable {
|
||||
return this.activity.getRunState();
|
||||
}
|
||||
|
||||
public void stopActivity() { this.executor.stopActivity(false); }
|
||||
public void forceStopActivity() {
|
||||
this.executor.stopActivity(true);
|
||||
}
|
||||
public void stopActivity() { this.executor.stopActivity(); }
|
||||
|
||||
public void forceStopActivity() { this.executor.forceStopActivity(); }
|
||||
|
||||
public ActivityExecutor getActivityExecutor() {
|
||||
return executor;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ActivityExecutorTest {
|
||||
try {
|
||||
ad.setThreads(1);
|
||||
ae.startActivity();
|
||||
ae.stopActivity(false);
|
||||
ae.stopActivity();
|
||||
ae.startActivity();
|
||||
ae.startActivity();
|
||||
ExecutionResult executionResult = future.get();
|
||||
|
||||
Reference in New Issue
Block a user