diff --git a/mvn-defaults/pom.xml b/mvn-defaults/pom.xml
index 1704c21af..69651a200 100644
--- a/mvn-defaults/pom.xml
+++ b/mvn-defaults/pom.xml
@@ -527,7 +527,7 @@
This enum indicates the state of a thread within an activity. The state is kept in an atomic
* register. Ownership of state changes is shared between a supervising thread and a managed thread.
diff --git a/nb-engine/nb-engine-core/src/main/java/io/nosqlbench/engine/api/activityapi/input/InputDispenser.java b/nb-engine/nb-engine-core/src/main/java/io/nosqlbench/engine/api/activityapi/input/InputDispenser.java
index 159561d4e..997613c7b 100644
--- a/nb-engine/nb-engine-core/src/main/java/io/nosqlbench/engine/api/activityapi/input/InputDispenser.java
+++ b/nb-engine/nb-engine-core/src/main/java/io/nosqlbench/engine/api/activityapi/input/InputDispenser.java
@@ -27,8 +27,7 @@ public interface InputDispenser {
/**
* Resolve (find or create) an Input instance for the slot specified.
* The input is not required to be per-slot (per-thread), but any shared inputs must be thread safe.
- * @param slot The numbered slot within the activity instance for this action.
* @return A new or cached Input for the specified slot.
*/
- Input getInput(long slot);
+ Input getInput();
}
diff --git a/nb-engine/nb-engine-core/src/main/java/io/nosqlbench/engine/api/activityimpl/MotorState.java b/nb-engine/nb-engine-core/src/main/java/io/nosqlbench/engine/api/activityimpl/MotorState.java
deleted file mode 100644
index ef59b7a1e..000000000
--- a/nb-engine/nb-engine-core/src/main/java/io/nosqlbench/engine/api/activityimpl/MotorState.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2022-2023 nosqlbench
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.nosqlbench.engine.api.activityimpl;
-
-import io.nosqlbench.engine.api.activityapi.core.RunState;
-import io.nosqlbench.engine.api.activityimpl.motor.RunStateTally;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.Supplier;
-
-/**
- * Holds the state of a slot, allows only valid transitions, and shares the
- * slot state as
- */
-public class MotorState implements Supplier Transition the thread slot to a new state. only accepting valid transitions. The valid slot states will be moved to a data type eventually, simplifying this method.
* This motor implementation splits the handling of sync and async actions with a hard
* fork in the middle to limit potential breakage of the prior sync implementation
* with new async logic.
*/
-public class CoreMotor
- * This allows the API to be consolidated so that the internal machinery of NB
- * works in a very consistent and uniform way for all users and drivers.
- *
- * @param
- * The type of activity
- * @param An ActivityExecutor is an execution harness for a single activity instance.
- * It is responsible for managing threads and activity settings which may be changed while the activity is running. In order to allow for dynamic thread management, which is not easily supported as an explicit feature
- * of most executor services, threads are started as long-running processes and managed via state signaling.
- * The {@link RunState} enum, {@link MotorState} type, and {@link RunStateTally}
- * state tracking class are used together to represent valid states and transitions, contain and transition state
- * atomically,
- * and provide blocking conditions for observers, respectively. Some basic rules and invariants must be observed for consistent concurrent behavior.
- * Any state changes for a Motor must be made through {@link Motor#getState()}.
- * This allows the state tracking to work consistently for all observers. True-up the number of motor instances known to the executor. Start all non-running motors.
- * The protocol between the motors and the executor should be safe as long as each state change is owned by either
- * the motor logic or the activity executor but not both, and strictly serialized as well. This is enforced by
- * forcing start(...) to be serialized as well as using CAS on the motor states. The startActivity method may be called to true-up the number of active motors in an activity executor after
- * changes to threads. Stop an activity, given an activity def map. The only part of the map that is important is the
@@ -342,8 +323,8 @@ public class ContainerActivitiesController extends NBBaseComponent {
*/
public synchronized void forceStopActivities(int waitTimeMillis) {
logger.debug("force stopping scenario {}", description());
- activityInfoMap.values().forEach(a -> a.getActivityExecutor().forceStopActivity(2000));
- logger.debug("Scenario force stopped.");
+ throw new RuntimeException("implement me");
+ //logger.debug("Scenario force stopped.");
}
// public synchronized void stopAll() {
diff --git a/nb-engine/nb-engine-core/src/test/java/io/nosqlbench/engine/api/activityimpl/motor/RunStateImageTest.java b/nb-engine/nb-engine-core/src/test/java/io/nosqlbench/engine/api/activityimpl/motor/RunStateImageTest.java
deleted file mode 100644
index 2084f90d4..000000000
--- a/nb-engine/nb-engine-core/src/test/java/io/nosqlbench/engine/api/activityimpl/motor/RunStateImageTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2022-2023 nosqlbench
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.nosqlbench.engine.api.activityimpl.motor;
-
-import io.nosqlbench.engine.api.activityapi.core.RunState;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class RunStateImageTest {
-
- @Test
- public void testMaxStateImage() {
- int[] counts = new int[RunState.values().length];
- counts[RunState.Running.ordinal()]=3;
- counts[RunState.Starting.ordinal()]=2;
- RunStateImage image = new RunStateImage(counts, false);
- assertThat(image.is(RunState.Running)).isTrue();
- assertThat(image.is(RunState.Starting)).isTrue();
- assertThat(image.isTimeout()).isFalse();
- assertThat(image.is(RunState.Errored)).isFalse();
- assertThat(image.isNoneOther(RunState.Starting, RunState.Running)).isTrue();
- RunState maxState = image.getMaxState();
- assertThat(maxState).isEqualTo(RunState.values()[RunState.Running.ordinal()]);
- RunState minState = image.getMinState();
- assertThat(minState).isEqualTo(RunState.values()[RunState.Starting.ordinal()]);
- }
-
-}
diff --git a/nb-engine/nb-engine-core/src/test/java/io/nosqlbench/engine/api/activityimpl/motor/RunStateTallyTest.java b/nb-engine/nb-engine-core/src/test/java/io/nosqlbench/engine/api/activityimpl/motor/RunStateTallyTest.java
deleted file mode 100644
index 5eb13c631..000000000
--- a/nb-engine/nb-engine-core/src/test/java/io/nosqlbench/engine/api/activityimpl/motor/RunStateTallyTest.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (c) 2022-2023 nosqlbench
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.nosqlbench.engine.api.activityimpl.motor;
-
-import io.nosqlbench.engine.api.activityapi.core.RunState;
-import org.junit.jupiter.api.*;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class RunStateTallyTest {
-
- volatile boolean awaited = false;
- volatile RunStateImage event = null;
-
- @BeforeEach
- public void setup() {
- awaited = false;
- event = null;
- }
-
- @Test
- @Order(1)
- public void testAwaitAny() {
- Thread.currentThread().setName("SETTER");
-
- RunStateTally tally = new RunStateTally();
- awaited = false;
- Thread waiter = new Thread(new Runnable() {
- @Override
- public void run() {
- event = tally.awaitAny(RunState.Running);
- awaited = true;
- }
- });
- waiter.setName("WAITER");
- waiter.setDaemon(true);
- waiter.start();
-
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- }
-
- assertThat(awaited).isFalse();
- tally.add(RunState.Running);
-
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- }
-
-
- assertThat(event.is(RunState.Running)).isTrue();
- assertThat(event.isOnly(RunState.Running)).isTrue();
-
- assertThat(awaited).isTrue();
- assertThat(waiter.getState()).isNotEqualTo(Thread.State.RUNNABLE);
- }
-
- @Test
- @Order(2)
- public void testAwaitNoneOf() {
- Thread.currentThread().setName("SETTER");
-
- RunStateTally tally = new RunStateTally();
- tally.add(RunState.Uninitialized);
- tally.add(RunState.Stopped);
- awaited = false;
- Thread waiter = new Thread(new Runnable() {
- @Override
- public void run() {
- tally.awaitNoneOf(RunState.Stopped, RunState.Uninitialized);
- awaited = true;
- }
- });
- waiter.setName("WAITER");
- waiter.setDaemon(true);
- waiter.start();
-
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- }
-
- assertThat(awaited).isFalse();
- tally.change(RunState.Stopped, RunState.Finished);
-
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- }
-
- assertThat(awaited).isFalse();
- tally.change(RunState.Uninitialized, RunState.Finished);
-
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- }
-
- assertThat(awaited).isTrue();
- assertThat(waiter.getState()).isNotEqualTo(Thread.State.RUNNABLE);
-
- }
-
- @Test
- @Order(3)
- public void testAwaitNoneOther() {
- Thread.currentThread().setName("SETTER");
-
- RunStateTally tally = new RunStateTally();
- tally.add(RunState.Uninitialized);
- tally.add(RunState.Running);
- awaited = false;
- Thread waiter = new Thread(new Runnable() {
- @Override
- public void run() {
- event = tally.awaitNoneOther(RunState.Stopped, RunState.Finished);
- awaited = true;
- }
- });
- waiter.setName("WAITER");
- waiter.setDaemon(true);
- waiter.start();
-
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- }
-
- assertThat(awaited).isFalse();
- tally.change(RunState.Uninitialized, RunState.Finished);
-
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- }
-
- assertThat(awaited).isFalse();
-
- // Note that neither Stopped or Finished are required to be positive,
- // as long as all others are zero total.
- tally.remove(RunState.Running);
-
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- }
-
- assertThat(awaited).isTrue();
- assertThat(waiter.getState()).isNotEqualTo(Thread.State.RUNNABLE);
-
- }
-
- @Test
- @Order(4)
- public void testAwaitNoneOtherTimedOut() {
- Thread.currentThread().setName("SETTER");
-
- RunStateTally tally = new RunStateTally();
- tally.add(RunState.Uninitialized);
- tally.add(RunState.Running);
- Thread waiter = new Thread(new Runnable() {
- @Override
- public void run() {
- event = tally.awaitNoneOther(1500, RunState.Stopped, RunState.Finished);
- awaited = true;
- }
- });
- waiter.setName("WAITER");
- waiter.setDaemon(true);
- waiter.start();
-
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- }
-
- assertThat(awaited).isFalse();
- tally.change(RunState.Uninitialized, RunState.Finished);
-
- try {
- Thread.sleep(1500);
- } catch (Exception e) {
- }
-
-// try {
-// waiter.join();
-// } catch (InterruptedException e) {
-// throw new RuntimeException(e);
-// }
-
- assertThat(event.isOnly(RunState.Errored)).isFalse();
- assertThat(waiter.getState()).isNotEqualTo(Thread.State.RUNNABLE);
-
- }
-
-
-}
diff --git a/nb-engine/nb-engine-core/src/test/java/io/nosqlbench/engine/core/ActivityExecutorTest.java b/nb-engine/nb-engine-core/src/test/java/io/nosqlbench/engine/core/ActivityExecutorTest.java
deleted file mode 100644
index cc2d65bb8..000000000
--- a/nb-engine/nb-engine-core/src/test/java/io/nosqlbench/engine/core/ActivityExecutorTest.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 2022-2023 nosqlbench
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.nosqlbench.engine.core;
-
-import io.nosqlbench.nb.api.config.standard.TestComponent;
-import io.nosqlbench.nb.api.engine.activityimpl.ActivityDef;
-import io.nosqlbench.engine.api.activityapi.core.*;
-import io.nosqlbench.engine.api.activityapi.input.Input;
-import io.nosqlbench.engine.api.activityapi.input.InputDispenser;
-import io.nosqlbench.engine.api.activityapi.output.OutputDispenser;
-import io.nosqlbench.engine.api.activityimpl.CoreServices;
-import io.nosqlbench.engine.api.activityimpl.SimpleActivity;
-import io.nosqlbench.engine.api.activityimpl.action.CoreActionDispenser;
-import io.nosqlbench.engine.api.activityimpl.input.CoreInputDispenser;
-import io.nosqlbench.engine.api.activityimpl.motor.CoreMotor;
-import io.nosqlbench.engine.api.activityimpl.motor.CoreMotorDispenser;
-import io.nosqlbench.engine.core.lifecycle.ExecutionResult;
-import io.nosqlbench.engine.core.lifecycle.activity.ActivityExecutor;
-import io.nosqlbench.engine.core.lifecycle.activity.ActivityTypeLoader;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.junit.jupiter.api.Test;
-
-import java.util.concurrent.*;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
-class ActivityExecutorTest {
- private static final Logger logger = LogManager.getLogger(ActivityExecutorTest.class);
-
-// TODO: Design review of this mechanism
-// @Test
-// synchronized void testRestart() {
-// ActivityDef activityDef = ActivityDef.parseActivityDef("driver=diag;alias=test-restart;cycles=1000;cyclerate=10;op=initdelay:initdelay=5000;");
-// new ActivityTypeLoader().load(activityDef);
-//
-// final Activity activity = new DelayedInitActivity(activityDef);
-// InputDispenser inputDispenser = new CoreInputDispenser(activity);
-// ActionDispenser adisp = new CoreActionDispenser(activity);
-// OutputDispenser tdisp = CoreServices.getOutputDispenser(activity).orElse(null);
-//
-// final MotorDispenser> mdisp = new CoreMotorDispenser(activity, inputDispenser, adisp, tdisp);
-// activity.setActionDispenserDelegate(adisp);
-// activity.setOutputDispenserDelegate(tdisp);
-// activity.setInputDispenserDelegate(inputDispenser);
-// activity.setMotorDispenserDelegate(mdisp);
-//
-// final ExecutorService executor = Executors.newCachedThreadPool();
-// ActivityExecutor activityExecutor = new ActivityExecutor(activity, "test-restart");
-// final Future
- * The context type for the activity, AKA the 'space' for a named driver instance and its associated object graph
- */
-public class StandardActivity