Package org.hobbit.core.components
Class AbstractSystemAdapter
java.lang.Object
org.hobbit.core.components.AbstractComponent
org.hobbit.core.components.AbstractCommandReceivingComponent
org.hobbit.core.components.AbstractPlatformConnectorComponent
org.hobbit.core.components.AbstractSystemAdapter
- All Implemented Interfaces:
Closeable,AutoCloseable,CommandReceivingComponent,Component,GeneratedDataReceivingComponent,PlatformConnector,TaskReceivingComponent
public abstract class AbstractSystemAdapter
extends AbstractPlatformConnectorComponent
implements GeneratedDataReceivingComponent, TaskReceivingComponent
This abstract class implements basic functions that can be used to implement
a system adapter.
- Author:
- Michael Röder (roeder@informatik.uni-leipzig.de)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ExceptionThe cause for an unusual termination.private SemaphoreMutex used to manage access to thecauseobject.protected DataReceiverReceiver for data coming from the data generator.private static final intDefault value of themaxParallelProcessedMsgsattribute.private static final org.slf4j.Loggerprivate final intThe maximum number of incoming messages of a single queue that are processed in parallel.protected DataSenderSender for sending messages from the benchmarked system to the evaluation storage.protected org.apache.jena.rdf.model.ModelThe RDF model containing the system parameters.protected DataReceiverReceiver for tasks coming from the task generator.private SemaphoreMutex used to wait for the terminate signal.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
ConstructorsConstructorDescriptionConstructor using theDEFAULT_MAX_PARALLEL_PROCESSED_MESSAGES= 100.AbstractSystemAdapter(int maxParallelProcessedMsgs) Constructor setting the maximum number of messages processed in parallel. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()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 voidsendResultToEvalStorage(String taskIdString, byte[] data) This method sends the given result data for the task with the given task id to the evaluation storage.protected voidStarts termination of the main thread of this system adapter.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, 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
setConfigurationMethods inherited from interface org.hobbit.core.components.GeneratedDataReceivingComponent
receiveGeneratedDataMethods inherited from interface org.hobbit.core.components.TaskReceivingComponent
receiveGeneratedTask
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
DEFAULT_MAX_PARALLEL_PROCESSED_MESSAGES
private static final int DEFAULT_MAX_PARALLEL_PROCESSED_MESSAGESDefault value of themaxParallelProcessedMsgsattribute.- See Also:
-
terminateMutex
Mutex used to wait for the terminate signal. -
cause
The cause for an unusual termination. -
causeMutex
Mutex used to manage access to thecauseobject. -
maxParallelProcessedMsgs
private final int maxParallelProcessedMsgsThe maximum number of incoming messages of a single queue that are processed in parallel. Additional messages have to wait. -
dataGenReceiver
Receiver for data coming from the data generator. -
taskGenReceiver
Receiver for tasks coming from the task generator. -
sender2EvalStore
Sender for sending messages from the benchmarked system to the evaluation storage. -
systemParamModel
protected org.apache.jena.rdf.model.Model systemParamModelThe RDF model containing the system parameters.
-
-
Constructor Details
-
AbstractSystemAdapter
public AbstractSystemAdapter()Constructor using theDEFAULT_MAX_PARALLEL_PROCESSED_MESSAGES= 100. -
AbstractSystemAdapter
public AbstractSystemAdapter(int maxParallelProcessedMsgs) Constructor setting the maximum number of messages processed in parallel.- Parameters:
maxParallelProcessedMsgs- The maximum number of incoming messages of a single queue that are processed in parallel. Additional messages have to wait.
-
-
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. -
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
-
sendResultToEvalStorage
This method sends the given result data for the task with the given task id to the evaluation storage.- Parameters:
taskIdString- the id of the taskdata- the data of the task- Throws:
IOException- if there is an error during the sending
-
terminate
Starts termination of the main thread of this system adapter. If a cause is given, it will be thrown causing an abortion from the main thread instead of a normal termination.- Parameters:
cause- the cause for an abortion of the process or {code null} if the component should terminate in a normal way.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classAbstractCommandReceivingComponent- Throws:
IOException
-