Package org.hobbit.core.components
Class AbstractBenchmarkController
java.lang.Object
org.hobbit.core.components.AbstractComponent
org.hobbit.core.components.AbstractCommandReceivingComponent
org.hobbit.core.components.AbstractPlatformConnectorComponent
org.hobbit.core.components.AbstractBenchmarkController
- All Implemented Interfaces:
Closeable,AutoCloseable,CommandReceivingComponent,Component,PlatformConnector
This abstract class implements basic methods for a benchmark controller.
- Author:
- Michael Röder (roeder@informatik.uni-leipzig.de)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.jena.rdf.model.ModelThe RDF model containing the benchmark parameters.protected SemaphoreMutex used to wait for the start signal for this benchmark.The set of data generator container ids.protected SemaphoreMutex used to wait for the data generators to be ready.protected SemaphoreMutex used to wait for the data generators to terminate.protected static final Stringprotected static final String[]protected StringThe container id of the evaluation module.protected SemaphoreMutex used to wait for the evaluation module to terminate.protected StringThe container id of the evaluation storage.protected SemaphoreMutex used to wait for the evaluation storage to be ready.protected SemaphoreMutex used to wait for the evaluation storage to terminate.protected StringThe URI of the experiment.private static final org.slf4j.Loggerprotected org.apache.jena.rdf.model.ModelThe benchmark result as RDF model received from the evaluation module.protected SemaphoreThe benchmark result as RDF model received from the evaluation module.protected SemaphoreMutex used to wait for the start signal from the controller.protected StringThe container id of the benchmarked system.protected intThe exit code of the system containerprotected SemaphoreMutex used to wait for the benchmarked system to terminate.The set of task generator container ids.protected SemaphoreMutex used to wait for the task generators to be ready.protected SemaphoreMutex used to wait for the task generators to terminate.Fields inherited from class org.hobbit.core.components.AbstractCommandReceivingComponent
cmdChannel, cmdQueueFactory, cmdResponseTimeout, DEFAULT_CMD_RESPONSE_TIMEOUT, defaultContainerType, gson, reportUnhandledExceptionsFields inherited from class org.hobbit.core.components.AbstractComponent
configuration, connectionFactory, incomingDataQueueFactory, NUMBER_OF_RETRIES_TO_CONNECT_TO_RABBIT_MQ, outgoingDataQueuefactory, rabbitMQHostName, START_WAITING_TIME_BEFORE_RETRY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds thebenchmarkParamModeltriples to theresultModel.protected voidcontainerCrashed(String containerName) protected voidcontainerTerminated(String containerName, int exitCode) This method handles messages from the command bus containing the information that a container terminated.protected voidcreateDataGenerators(String dataGeneratorImageName, int numberOfDataGenerators, String[] envVariables) Creates the given number of data generators using the given image name and environment variables.protected voidcreateEvaluationModule(String evalModuleImageName, String[] envVariables) Creates the evaluate module using the given image name and environment variables.protected voidCreates the default evaluation storage using the given image name and environment variables.protected voidcreateEvaluationStorage(String evalStorageImageName, String[] envVariables) Creates the evaluate storage using the given image name and environment variables.private voidcreateGenerator(String generatorImageName, int numberOfGenerators, String[] envVariables, Set<String> generatorIds) Internal method for creating generator components.protected voidcreateTaskGenerators(String taskGeneratorImageName, int numberOfTaskGenerators, String[] envVariables) Creates the given number of task generators using the given image name and environment variables.protected abstract voidprotected voidGenerates a default model containing an error code and the benchmark parameters if no result model has been received from the evaluation module until now.voidinit()This method initializes the component.voidreceiveCommand(byte command, byte[] data) This method is called if a command is received and might be interesting for this particular component.voidrun()This method executes the component.protected voidsendResultModel(org.apache.jena.rdf.model.Model model) Sends the result RDF model to the platform controller.protected voidsetResultModel(org.apache.jena.rdf.model.Model resultModel) Uses the given model as result model if the result model isnull.protected voidThis method waits for the data generators, task generators and evaluation storage to send their ready signals.protected voidWaits for the termination of all data generators.protected voidWaits for the termination of the evaluation module and the evaluation storage.protected voidThis method waits for the benchmarked system to terminate.protected booleanwaitForSystemToFinish(long maxWaitingTime) This method waits for the benchmarked system to terminate or times out after the given amount of time (in milliseconds).protected voidWaits for the termination of all task generators.Methods inherited from class org.hobbit.core.components.AbstractPlatformConnectorComponent
addContainerObserver, createContainer, getFactoryForIncomingCmdQueues, getFactoryForIncomingDataQueues, getFactoryForOutgoingCmdQueues, getFactoryForOutgoingDataQueues, stopContainerMethods inherited from class org.hobbit.core.components.AbstractCommandReceivingComponent
addCommandHeaderId, close, createContainer, createContainer, createContainer, createContainerAsync, createContainerAsync, extendContainerEnvVariables, getCmdResponseTimeout, handleCmd, handleCmd, isReportUnhandledExceptions, reportAndWrap, reportError, reportErrorSavely, reportExceptionSavely, reportUnhandledExceptionSavely, sendToCmdQueue, sendToCmdQueue, sendToCmdQueue, setCmdResponseTimeout, setReportUnhandledExceptionsMethods inherited from class org.hobbit.core.components.AbstractComponent
createConnection, generateSessionQueueName, getConfiguration, getHobbitSessionId, setConfigurationMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hobbit.core.components.Component
setConfiguration
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
DEFAULT_EVAL_STORAGE_IMAGE
- See Also:
-
DEFAULT_EVAL_STORAGE_PARAMETERS
-
resultModel
protected org.apache.jena.rdf.model.Model resultModelThe benchmark result as RDF model received from the evaluation module. -
resultModelMutex
The benchmark result as RDF model received from the evaluation module. -
startBenchmarkMutex
Mutex used to wait for the start signal from the controller. -
dataGenReadyMutex
Mutex used to wait for the data generators to be ready. -
taskGenReadyMutex
Mutex used to wait for the task generators to be ready. -
evalStoreReadyMutex
Mutex used to wait for the evaluation storage to be ready. -
benchmarkStartSignalMutex
Mutex used to wait for the start signal for this benchmark. -
dataGenTerminatedMutex
Mutex used to wait for the data generators to terminate. -
taskGenTerminatedMutex
Mutex used to wait for the task generators to terminate. -
systemTerminatedMutex
Mutex used to wait for the benchmarked system to terminate. -
evalStoreTerminatedMutex
Mutex used to wait for the evaluation storage to terminate. -
evalModuleTerminatedMutex
Mutex used to wait for the evaluation module to terminate. -
dataGenContainerIds
The set of data generator container ids. -
taskGenContainerIds
The set of task generator container ids. -
evalStoreContainerId
The container id of the evaluation storage. -
evalModuleContainerId
The container id of the evaluation module. -
systemContainerId
The container id of the benchmarked system. -
systemExitCode
protected int systemExitCodeThe exit code of the system container -
benchmarkParamModel
protected org.apache.jena.rdf.model.Model benchmarkParamModelThe RDF model containing the benchmark parameters. -
experimentUri
The URI of the experiment.
-
-
Constructor Details
-
AbstractBenchmarkController
public AbstractBenchmarkController()Constructor.
-
-
Method Details
-
init
Description copied from interface:ComponentThis method initializes the component.- Specified by:
initin interfaceComponent- Overrides:
initin classAbstractCommandReceivingComponent- Throws:
Exception- if an error occurs during the initialization
-
run
Description copied from interface:ComponentThis method executes the component.- Throws:
Exception- if an error occurs during the execution
-
executeBenchmark
- Throws:
Exception
-
createDataGenerators
protected void createDataGenerators(String dataGeneratorImageName, int numberOfDataGenerators, String[] envVariables) Creates the given number of data generators using the given image name and environment variables.- Parameters:
dataGeneratorImageName- name of the data generator Docker imagenumberOfDataGenerators- number of generators that should be createdenvVariables- environment variables for the data generators
-
createTaskGenerators
protected void createTaskGenerators(String taskGeneratorImageName, int numberOfTaskGenerators, String[] envVariables) Creates the given number of task generators using the given image name and environment variables.- Parameters:
taskGeneratorImageName- name of the task generator Docker imagenumberOfTaskGenerators- number of generators that should be createdenvVariables- environment variables for the task generators
-
createGenerator
private void createGenerator(String generatorImageName, int numberOfGenerators, String[] envVariables, Set<String> generatorIds) Internal method for creating generator components.- Parameters:
generatorImageName- name of the generator Docker imagenumberOfGenerators- number of generators that should be createdenvVariables- environment variables for the task generatorsgeneratorIds- set of generator container names
-
createEvaluationModule
Creates the evaluate module using the given image name and environment variables.- Parameters:
evalModuleImageName- name of the evaluation module imageenvVariables- environment variables that should be given to the module
-
createEvaluationStorage
protected void createEvaluationStorage()Creates the default evaluation storage using the given image name and environment variables. -
createEvaluationStorage
Creates the evaluate storage using the given image name and environment variables.- Parameters:
evalStorageImageName- name of the evaluation storage imageenvVariables- environment variables that should be given to the component
-
waitForComponentsToInitialize
protected void waitForComponentsToInitialize()This method waits for the data generators, task generators and evaluation storage to send their ready signals. -
waitForDataGenToFinish
protected void waitForDataGenToFinish()Waits for the termination of all data generators. -
waitForTaskGenToFinish
protected void waitForTaskGenToFinish()Waits for the termination of all task generators. -
waitForSystemToFinish
protected boolean waitForSystemToFinish(long maxWaitingTime) This method waits for the benchmarked system to terminate or times out after the given amount of time (in milliseconds).- Parameters:
maxWaitingTime- maximum waiting time in milliseconds- Returns:
trueif the system has been terminated orfalseif the method timed out
-
waitForSystemToFinish
protected void waitForSystemToFinish()This method waits for the benchmarked system to terminate. -
waitForEvalComponentsToFinish
protected void waitForEvalComponentsToFinish()Waits for the termination of the evaluation module and the evaluation storage. -
setResultModel
protected void setResultModel(org.apache.jena.rdf.model.Model resultModel) Uses the given model as result model if the result model isnull. Else, the two models are merged.- Parameters:
resultModel- the new result model
-
generateErrorResultModel
protected void generateErrorResultModel()Generates a default model containing an error code and the benchmark parameters if no result model has been received from the evaluation module until now. If the model already has been received, the error is added to the existing model. -
addParametersToResultModel
protected void addParametersToResultModel()Adds thebenchmarkParamModeltriples to theresultModel. -
sendResultModel
protected void sendResultModel(org.apache.jena.rdf.model.Model model) Sends the result RDF model to the platform controller.- Parameters:
model- model containing the results
-
receiveCommand
public void receiveCommand(byte command, byte[] data) Description copied from interface:CommandReceivingComponentThis method is called if a command is received and might be interesting for this particular component.- Specified by:
receiveCommandin interfaceCommandReceivingComponent- Overrides:
receiveCommandin classAbstractPlatformConnectorComponent- Parameters:
command- the byte encoding the commanddata- additional data that was sent together with the command
-
containerTerminated
This method handles messages from the command bus containing the information that a container terminated. It checks whether the container belongs to the current benchmark and whether it has to react.- Parameters:
containerName- the name of the terminated containerexitCode- the exit code of the terminated container
-
containerCrashed
-