public class ExperimentManager extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
static long |
CHECK_FOR_FIRST_EXPERIMENT
Time interval the experiment manager waits before it checks for the an
experiment to start.
|
static long |
CHECK_FOR_NEW_EXPERIMENT
Time interval with which the experiment manager checks for a new experiment
to start.
|
private PlatformController |
controller
The controller this manager belongs to.
|
private static int |
DEFAULT_MAX_EXECUTION_TIME |
long |
defaultMaxExecutionTime
Default time an experiment has to terminate after it has been started.
|
private Semaphore |
experimentMutex
Mutex used to synchronize the access to the
experimentStatus
instance. |
private ExperimentStatus |
experimentStatus
Status of the current experiment.
|
private Timer |
expStartTimer
Timer used to trigger the creation of the next benchmark.
|
private static org.slf4j.Logger |
LOGGER |
| Modifier | Constructor and Description |
|---|---|
|
ExperimentManager(PlatformController controller) |
protected |
ExperimentManager(PlatformController controller,
long checkForFirstExperiment,
long checkForNewExperiment) |
| Modifier and Type | Method and Description |
|---|---|
void |
addStatusInfo(org.hobbit.core.data.status.ControllerStatus status,
String userName)
Adds the status of the current experiment to the given status object.
|
void |
close() |
void |
createNextExperiment()
Creates the next experiment if there is no experiment running and there is an
experiment waiting in the queue.
|
private void |
forceBenchmarkTerminate_unsecured(org.apache.jena.rdf.model.Resource error)
Forces the benchmark controller and its child containers to terminate.
|
protected static String |
getSerializedSystemParams(ExperimentConfiguration config,
org.hobbit.core.data.BenchmarkMetaData benchmark,
org.hobbit.core.data.SystemMetaData system) |
private void |
handleExperimentTermination_unsecured() |
void |
handleExperimentTermination()
This method handles the storing of the experiment results in the database,
the removing of the experiment from the queue and its closing in a
synchronized way.
|
void |
notifyExpRuntimeExpired(ExperimentStatus expiredState)
Called by the
ExperimentAbortTimerTask if the maximum runtime of an
experiment has been reached. |
void |
notifyTermination(String containerId,
int exitCode)
Handles the termination of the container with the given container Id and the
given exit code.
|
protected void |
prefetchImages(org.hobbit.core.data.BenchmarkMetaData benchmark,
org.hobbit.core.data.SystemMetaData system) |
private void |
setResultModel_unsecured(org.apache.jena.rdf.model.Model model)
Sets the result model of the current running experiment.
|
void |
setResultModel(byte[] data,
Function<? super byte[],? extends org.apache.jena.rdf.model.Model> function)
Sets the result model of the current running experiment by transforming the
given data into an RDF model using the given function while owning the
experimentStatus object and therefore blocking all other operations
on that object. |
void |
setResultModel(org.apache.jena.rdf.model.Model model)
Sets the result model of the current running experiment.
|
private void |
startBenchmark_unsecured()
Sends the start message to the benchmark controller.
|
void |
stopExperimentIfRunning(String experimentId)
Stops the currently running experiment if it has the given experiment id.
|
void |
systemOrBenchmarkReady(boolean systemReportedReady)
Handles the messages that either the system or the benchmark controller are
ready.
|
void |
taskGenFinished()
Changes the state of the internal experiment to
ExperimentStatus.States#EVALUATION. |
private static final org.slf4j.Logger LOGGER
private static final int DEFAULT_MAX_EXECUTION_TIME
public static final long CHECK_FOR_FIRST_EXPERIMENT
CHECK_FOR_NEW_EXPERIMENT
since the system needs some time to initialize all components and we want to
make sure that everything is up and running.public static final long CHECK_FOR_NEW_EXPERIMENT
public long defaultMaxExecutionTime
private PlatformController controller
private Semaphore experimentMutex
experimentStatus
instance.private ExperimentStatus experimentStatus
null if no benchmark is
running.private Timer expStartTimer
public ExperimentManager(PlatformController controller)
protected ExperimentManager(PlatformController controller, long checkForFirstExperiment, long checkForNewExperiment)
public void createNextExperiment()
protected static String getSerializedSystemParams(ExperimentConfiguration config, org.hobbit.core.data.BenchmarkMetaData benchmark, org.hobbit.core.data.SystemMetaData system)
protected void prefetchImages(org.hobbit.core.data.BenchmarkMetaData benchmark,
org.hobbit.core.data.SystemMetaData system)
throws Exception
Exceptionpublic void setResultModel(byte[] data,
Function<? super byte[],? extends org.apache.jena.rdf.model.Model> function)
experimentStatus object and therefore blocking all other operations
on that object.data - binary data containing a serialized RDF modelfunction - a deserialization function transforming the binary data into an
RDF modelpublic void setResultModel(org.apache.jena.rdf.model.Model model)
model - the result modelprivate void setResultModel_unsecured(org.apache.jena.rdf.model.Model model)
model - the result modelpublic void handleExperimentTermination()
private void handleExperimentTermination_unsecured()
private void forceBenchmarkTerminate_unsecured(org.apache.jena.rdf.model.Resource error)
null it is added to the result model of the
experiment.error - error that is added to the result model of the experimentpublic void notifyTermination(String containerId, int exitCode)
containerId - Id of the terminated containerexitCode - exit code of the terminationpublic void systemOrBenchmarkReady(boolean systemReportedReady)
systemReportedReady - true if the message was sent by the system,
false if the benchmark controller is readyprivate void startBenchmark_unsecured()
throws IOException
IOException - if there is a communication problem or if the name of the system
container can not be retrieved from the docker daemonpublic void addStatusInfo(org.hobbit.core.data.status.ControllerStatus status,
String userName)
status - the status object to which the data should be addedpublic void taskGenFinished()
ExperimentStatus.States#EVALUATION.public void notifyExpRuntimeExpired(ExperimentStatus expiredState)
ExperimentAbortTimerTask if the maximum runtime of an
experiment has been reached.expiredState - the experiment status the timer was working on which is used to
make sure that the timer was started for the currently running
experiment.public void stopExperimentIfRunning(String experimentId)
experimentId - the id of the experiment that should be stoppedpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2017–2018. All rights reserved.