Package io.engineblock.script
Class ScenariosExecutor
- java.lang.Object
-
- io.engineblock.script.ScenariosExecutor
-
public class ScenariosExecutor extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ScenariosExecutor(java.lang.String name)ScenariosExecutor(java.lang.String name, int threads)
-
Method Summary
Modifier and Type Method Description ScenariosResultsawaitAllResults()Shuts down all running scenarios and awaits all results.ScenariosResultsawaitAllResults(long timeout, long updateInterval)Shuts down all running scenarios and awaits all results.voidcancelScenario(java.lang.String scenarioName)voidexecute(Scenario scenario)voidexecute(Scenario scenario, ScenarioLogger scenarioLogger)java.util.Map<Scenario,java.util.Optional<ScenarioResult>>getAsyncResultStatus()Returns a map of all pending scenario names and optional results.java.lang.StringgetName()java.util.Optional<ScenarioResult>getPendingResult(java.lang.String scenarioName)Get the result of a pending or completed scenario.java.util.Optional<Scenario>getPendingScenario(java.lang.String scenarioName)java.util.List<java.lang.String>getPendingScenarios()voidnotifyException(java.lang.Thread t, java.lang.Throwable e)java.lang.StringtoString()
-
-
-
Method Detail
-
execute
public void execute(Scenario scenario)
-
execute
public void execute(Scenario scenario, ScenarioLogger scenarioLogger)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
awaitAllResults
public ScenariosResults awaitAllResults()
Shuts down all running scenarios and awaits all results.- Returns:
- the final scenario-result map.
-
awaitAllResults
public ScenariosResults awaitAllResults(long timeout, long updateInterval)
Shuts down all running scenarios and awaits all results.- Parameters:
timeout- how long to wait for the results to completeupdateInterval- how frequently to log status while waiting- Returns:
- the final scenario-result map
-
getPendingScenarios
public java.util.List<java.lang.String> getPendingScenarios()
- Returns:
- list of scenarios which have been submitted, in order
-
getAsyncResultStatus
public java.util.Map<Scenario,java.util.Optional<ScenarioResult>> getAsyncResultStatus()
Returns a map of all pending scenario names and optional results. All submitted scenarios are included. Those which are still pending are returned with an empty option.
Results may be exceptional. If
ScenarioResult.getException()is present, then the result did not complete normally.- Returns:
- map of async results, with incomplete results as Optional.empty()
-
getPendingScenario
public java.util.Optional<Scenario> getPendingScenario(java.lang.String scenarioName)
-
getPendingResult
public java.util.Optional<ScenarioResult> getPendingResult(java.lang.String scenarioName)
Get the result of a pending or completed scenario. If the scenario has run to completion, then the Optional will be present. If the scenario threw an exception, or there was an error accessing the future, then the result will contain the exception. If the callable for the scenario was cancelled, then the result will contain an exception stating such.If the scenario is still pending, then the optional will be empty.
- Parameters:
scenarioName- the scenario name of interest- Returns:
- an optional result
-
cancelScenario
public void cancelScenario(java.lang.String scenarioName)
-
getName
public java.lang.String getName()
-
notifyException
public void notifyException(java.lang.Thread t, java.lang.Throwable e)
-
-