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
Fields Modifier and Type Field Description private ExceptioncauseThe cause for an unusual termination.private SemaphorecauseMutexMutex used to manage access to thecauseobject.protected DataReceiverdataGenReceiverReceiver for data coming from the data generator.private static intDEFAULT_MAX_PARALLEL_PROCESSED_MESSAGESDefault value of themaxParallelProcessedMsgsattribute.private static org.slf4j.LoggerLOGGERprivate intmaxParallelProcessedMsgsThe maximum number of incoming messages of a single queue that are processed in parallel.protected DataSendersender2EvalStoreSender for sending messages from the benchmarked system to the evaluation storage.protected org.apache.jena.rdf.model.ModelsystemParamModelThe RDF model containing the system parameters.protected DataReceivertaskGenReceiverReceiver for tasks coming from the task generator.private SemaphoreterminateMutexMutex used to wait for the terminate signal.-
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 AbstractSystemAdapter()Constructor using theDEFAULT_MAX_PARALLEL_PROCESSED_MESSAGES= 100.AbstractSystemAdapter(int maxParallelProcessedMsgs)Constructor setting the maximum number of messages processed in parallel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()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 voidterminate(Exception cause)Starts termination of the main thread of this system adapter.-
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, createContainer, createContainer, getCmdResponseTimeout, handleCmd, sendToCmdQueue, sendToCmdQueue, sendToCmdQueue, setCmdResponseTimeout
-
Methods inherited from class org.hobbit.core.components.AbstractComponent
createConnection, generateSessionQueueName, getHobbitSessionId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hobbit.core.components.GeneratedDataReceivingComponent
receiveGeneratedData
-
Methods inherited from interface org.hobbit.core.components.TaskReceivingComponent
receiveGeneratedTask
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
DEFAULT_MAX_PARALLEL_PROCESSED_MESSAGES
private static final int DEFAULT_MAX_PARALLEL_PROCESSED_MESSAGES
Default value of themaxParallelProcessedMsgsattribute.- See Also:
- Constant Field Values
-
terminateMutex
private Semaphore terminateMutex
Mutex used to wait for the terminate signal.
-
cause
private Exception cause
The cause for an unusual termination.
-
maxParallelProcessedMsgs
private final int maxParallelProcessedMsgs
The maximum number of incoming messages of a single queue that are processed in parallel. Additional messages have to wait.
-
dataGenReceiver
protected DataReceiver dataGenReceiver
Receiver for data coming from the data generator.
-
taskGenReceiver
protected DataReceiver taskGenReceiver
Receiver for tasks coming from the task generator.
-
sender2EvalStore
protected DataSender sender2EvalStore
Sender for sending messages from the benchmarked system to the evaluation storage.
-
systemParamModel
protected org.apache.jena.rdf.model.Model systemParamModel
The RDF model containing the system parameters.
-
-
Constructor Detail
-
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 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.
-
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
protected void sendResultToEvalStorage(String taskIdString, byte[] data) throws IOException
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
protected void terminate(Exception cause)
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
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classAbstractCommandReceivingComponent- Throws:
IOException
-
-