Class ContainerActivitiesController

java.lang.Object
io.nosqlbench.nb.api.components.core.NBBaseComponentMetrics
io.nosqlbench.nb.api.components.core.NBBaseComponent
io.nosqlbench.engine.core.lifecycle.scenario.container.ContainerActivitiesController
All Implemented Interfaces:
NBComponent, NBComponentAdvisors, NBComponentEvents, NBComponentMetrics, NBComponentProps, NBComponentServices, NBComponentTimeline, NBProviderSearch, NBTokenWords, NBLabeledElement, AutoCloseable

public class ContainerActivitiesController extends NBBaseComponent
A ScenarioController provides a way to start Activities, modify them while running, and forceStopMotors, pause or restart them.
  • Constructor Details

    • ContainerActivitiesController

      public ContainerActivitiesController(NBComponent parent)
  • Method Details

    • start

      public Activity start(ActivityDef activityDef)
      Start an activity, given the activity definition for it. The activity will be known in the scenario by the alias parameter.
      Parameters:
      activityDef - string in alias=value1;driver=value2;... format
    • start

      public Activity start(Map<String,String> activityDefMap)
      Start an activity, given a map which holds the activity definition for it. The activity will be known in the scenario by the alias parameter.
      Parameters:
      activityDefMap - A map containing the activity definition
    • start

      public Activity start(String alias)
      Start an activity, given the name by which it is known already in the scenario. This is useful if you have stopped an activity and want to start it again.
      Parameters:
      alias - the alias of an activity that is already known to the scenario
    • run

      public void run(int timeout, Map<String,String> activityDefMap)
    • run

      public void run(ActivityDef activityDef, long timeoutMs)
      Synchronously run the defined activity with a timeout in seconds.
      Parameters:
      activityDef - A definition for an activity to run
      timeoutMs - seconds to await completion of the activity.
    • run

      public void run(int timeout, String activityDefString)
    • run

      public void run(Map<String,String> activityDefMap)
    • run

      public void run(String activityDefString)
    • run

      public void run(ActivityDef activityDef)
    • isRunningActivity

      public boolean isRunningActivity(String alias)
    • isRunningActivity

      public boolean isRunningActivity(ActivityDef activityDef)
    • isRunningActivity

      public boolean isRunningActivity(Map<String,String> activityDefMap)
    • stop

      public void stop(ActivityDef activityDef)

      Stop an activity, given an activity def. The only part of the activity def that is important is the alias parameter. This method retains the activity def signature to provide convenience for scripting.

      For example, sc.stop("alias=foo")

      Parameters:
      activityDef - An activity def, including at least the alias parameter.
    • awaitAllThreadsOnline

      public boolean awaitAllThreadsOnline(ActivityDef activityDef, long timeoutMs)
    • stop

      public void stop(Activity activity)
    • awaitAllThreadsOnline

      public boolean awaitAllThreadsOnline(Activity activity, long timeoutMs)
    • stop

      public void stop(Map<String,String> activityDefMap)

      Stop an activity, given an activity def map. The only part of the map that is important is the alias parameter. This method retains the map signature to provide convenience for scripting.

      Parameters:
      activityDefMap - A map, containing at least the alias parameter
    • stop

      public void stop(String spec)
      Stop an activity, given the name by which it is known already in the scenario. This causes the activity to stop all threads, but keeps the thread objects handy for starting again. This can be useful for certain testing scenarios in which you want to stop some workloads and start others based on other conditions. Alternately, you can provide one or more aliases in the same command, and all matching names will be stopped.
      Parameters:
      spec - The name of the activity that is already known to the scenario
    • forceStop

      public void forceStop(ActivityDef activityDef)

      Force stopping an activity, given an activity def. The only part of the activity def that is important is the alias parameter. This method retains the activity def signature to provide convenience for scripting.

      For example, sc.forceStop("alias=foo")

      Parameters:
      activityDef - An activity def, including at least the alias parameter.
    • forceStop

      public void forceStop(Map<String,String> activityDefMap)

      Stop an activity, given an activity def map. The only part of the map that is important is the alias parameter. This method retains the map signature to provide convenience for scripting.

      Parameters:
      activityDefMap - A map, containing at least the alias parameter
    • forceStop

      public void forceStop(String spec)
      Stop an activity, given the name by which it is known already in the scenario. This causes the activity to stop all threads, but keeps the thread objects handy for starting again. This can be useful for certain testing scenarios in which you want to stop some workloads and start others based on other conditions. Alternately, you can provide one or more aliases in the same command, and all matching names will be stopped.
      Parameters:
      spec - The name of the activity that is already known to the scenario
    • waitMillis

      public void waitMillis(long waitMillis)
      Wait for a bit. This is not the best approach, and will be replaced with a different system in the future.
      Parameters:
      waitMillis - time to wait, in milliseconds
    • getAliases

      public Set<String> getAliases()
      Return all the names of the activites that are known to this scenario.
      Returns:
      set of activity names
    • forceStopActivities

      public void forceStopActivities(int waitTimeMillis)
      Force the scenario to stop running. Stop all activity threads, and after waitTimeMillis, force stop all activity threads. An activity will stop its threads cooperatively in this time as long as the internal cycles complete before the timer expires.
      Parameters:
      waitTimeMillis - grace period during which an activity may cooperatively shut down
    • awaitCompletion

      public boolean awaitCompletion(long waitTimeMillis)
      Await completion of all running activities, but do not force shutdownActivity. This method is meant to provide the blocking point for calling logic. It waits. If there is an error which should propagate into the scenario, then it should be thrown from this method.
      Parameters:
      waitTimeMillis - The time to wait, usually set very high
      Returns:
      true, if all activities completed before the timer expired, false otherwise
    • await

      public void await(Map<String,String> activityDefMap)
    • awaitActivity

      public boolean awaitActivity(Map<String,String> activityDefMap)
    • await

      public boolean await(String alias)
    • awaitActivity

      public boolean awaitActivity(String alias, long timeoutMs)
    • await

      public void await(ActivityDef activityDef, long timeoutMs)
    • awaitActivity

      public boolean awaitActivity(ActivityDef activityDef, long timeoutMs)
    • getActivityExecutorMap

      public Map<String,ActivityRuntimeInfo> getActivityExecutorMap()
      Returns:
      an unmodifyable String to executor map of all activities known to this scenario
    • getActivityDefs

      public List<ActivityDef> getActivityDefs()
    • reportMetrics

      public void reportMetrics()
    • getSoloActivity

      public Optional<Activity> getSoloActivity()
    • getActivity

      public Optional<Activity> getActivity(String activityName)
    • getProgressMeters

      public List<ProgressMeterDisplay> getProgressMeters()
    • notifyException

      public void notifyException(Thread t, Throwable e)
    • getActivityDef

      public ActivityDef getActivityDef(String alias)
    • shutdown

      public void shutdown()