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
public abstract class AbstractBenchmarkController extends AbstractPlatformConnectorComponent
This abstract class implements basic methods for a benchmark controller.- Author:
- Michael Röder (roeder@informatik.uni-leipzig.de)
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.jena.rdf.model.ModelbenchmarkParamModelThe RDF model containing the benchmark parameters.protected SemaphorebenchmarkStartSignalMutexMutex used to wait for the start signal for this benchmark.protected Set<String>dataGenContainerIdsThe set of data generator container ids.protected SemaphoredataGenReadyMutexMutex used to wait for the data generators to be ready.protected SemaphoredataGenTerminatedMutexMutex used to wait for the data generators to terminate.protected static StringDEFAULT_EVAL_STORAGE_IMAGEprotected static String[]DEFAULT_EVAL_STORAGE_PARAMETERSprotected StringevalModuleContainerIdThe container id of the evaluation module.protected SemaphoreevalModuleTerminatedMutexMutex used to wait for the evaluation module to terminate.protected StringevalStoreContainerIdThe container id of the evaluation storage.protected SemaphoreevalStoreReadyMutexMutex used to wait for the evaluation storage to be ready.protected SemaphoreevalStoreTerminatedMutexMutex used to wait for the evaluation storage to terminate.protected StringexperimentUriThe URI of the experiment.private static org.slf4j.LoggerLOGGERprotected org.apache.jena.rdf.model.ModelresultModelThe benchmark result as RDF model received from the evaluation module.protected SemaphoreresultModelMutexThe benchmark result as RDF model received from the evaluation module.protected SemaphorestartBenchmarkMutexMutex used to wait for the start signal from the controller.protected StringsystemContainerIdThe container id of the benchmarked system.protected intsystemExitCodeThe exit code of the system containerprotected SemaphoresystemTerminatedMutexMutex used to wait for the benchmarked system to terminate.protected Set<String>taskGenContainerIdsThe set of task generator container ids.protected SemaphoretaskGenReadyMutexMutex used to wait for the task generators to be ready.protected SemaphoretaskGenTerminatedMutexMutex 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
-
Fields inherited from class org.hobbit.core.components.AbstractComponent
connectionFactory, incomingDataQueueFactory, NUMBER_OF_RETRIES_TO_CONNECT_TO_RABBIT_MQ, outgoingDataQueuefactory, rabbitMQHostName, START_WAITING_TIME_BEFORE_RETRY
-
-
Constructor Summary
Constructors Constructor Description AbstractBenchmarkController()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddParametersToResultModel()Adds 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 voidcreateEvaluationStorage()Creates 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 voidexecuteBenchmark()protected voidgenerateErrorResultModel()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.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 voidwaitForComponentsToInitialize()This method waits for the data generators, task generators and evaluation storage to send their ready signals.protected voidwaitForDataGenToFinish()Waits for the termination of all data generators.protected voidwaitForEvalComponentsToFinish()Waits for the termination of the evaluation module and the evaluation storage.protected voidwaitForSystemToFinish()This 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 voidwaitForTaskGenToFinish()Waits for the termination of all task generators.-
Methods inherited from class org.hobbit.core.components.AbstractPlatformConnectorComponent
addContainerObserver, createContainer, getFactoryForIncomingCmdQueues, getFactoryForIncomingDataQueues, getFactoryForOutgoingCmdQueues, getFactoryForOutgoingDataQueues, stopContainer
-
Methods inherited from class org.hobbit.core.components.AbstractCommandReceivingComponent
addCommandHeaderId, close, createContainer, createContainer, getCmdResponseTimeout, handleCmd, sendToCmdQueue, sendToCmdQueue, sendToCmdQueue, setCmdResponseTimeout
-
Methods inherited from class org.hobbit.core.components.AbstractComponent
createConnection, generateSessionQueueName, getHobbitSessionId
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
DEFAULT_EVAL_STORAGE_IMAGE
protected static final String DEFAULT_EVAL_STORAGE_IMAGE
- See Also:
- Constant Field Values
-
DEFAULT_EVAL_STORAGE_PARAMETERS
protected static final String[] DEFAULT_EVAL_STORAGE_PARAMETERS
-
resultModel
protected org.apache.jena.rdf.model.Model resultModel
The benchmark result as RDF model received from the evaluation module.
-
resultModelMutex
protected Semaphore resultModelMutex
The benchmark result as RDF model received from the evaluation module.
-
startBenchmarkMutex
protected Semaphore startBenchmarkMutex
Mutex used to wait for the start signal from the controller.
-
dataGenReadyMutex
protected Semaphore dataGenReadyMutex
Mutex used to wait for the data generators to be ready.
-
taskGenReadyMutex
protected Semaphore taskGenReadyMutex
Mutex used to wait for the task generators to be ready.
-
evalStoreReadyMutex
protected Semaphore evalStoreReadyMutex
Mutex used to wait for the evaluation storage to be ready.
-
benchmarkStartSignalMutex
protected Semaphore benchmarkStartSignalMutex
Mutex used to wait for the start signal for this benchmark.
-
dataGenTerminatedMutex
protected Semaphore dataGenTerminatedMutex
Mutex used to wait for the data generators to terminate.
-
taskGenTerminatedMutex
protected Semaphore taskGenTerminatedMutex
Mutex used to wait for the task generators to terminate.
-
systemTerminatedMutex
protected Semaphore systemTerminatedMutex
Mutex used to wait for the benchmarked system to terminate.
-
evalStoreTerminatedMutex
protected Semaphore evalStoreTerminatedMutex
Mutex used to wait for the evaluation storage to terminate.
-
evalModuleTerminatedMutex
protected Semaphore evalModuleTerminatedMutex
Mutex used to wait for the evaluation module to terminate.
-
dataGenContainerIds
protected Set<String> dataGenContainerIds
The set of data generator container ids.
-
taskGenContainerIds
protected Set<String> taskGenContainerIds
The set of task generator container ids.
-
evalStoreContainerId
protected String evalStoreContainerId
The container id of the evaluation storage.
-
evalModuleContainerId
protected String evalModuleContainerId
The container id of the evaluation module.
-
systemContainerId
protected String systemContainerId
The container id of the benchmarked system.
-
systemExitCode
protected int systemExitCode
The exit code of the system container
-
benchmarkParamModel
protected org.apache.jena.rdf.model.Model benchmarkParamModel
The RDF model containing the benchmark parameters.
-
experimentUri
protected String experimentUri
The URI of the experiment.
-
-
Method Detail
-
init
public void init() throws ExceptionDescription 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
public void run() throws ExceptionDescription copied from interface:ComponentThis method executes the component.- Throws:
Exception- if an error occurs during the execution
-
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
protected void createEvaluationModule(String evalModuleImageName, String[] envVariables)
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
protected void createEvaluationStorage(String evalStorageImageName, String[] envVariables)
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
protected void containerTerminated(String containerName, int exitCode)
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
protected void containerCrashed(String containerName)
-
-