Package org.hobbit.core.components
Class AbstractEvaluationStorage
- java.lang.Object
-
- org.hobbit.core.components.AbstractComponent
-
- org.hobbit.core.components.AbstractCommandReceivingComponent
-
- org.hobbit.core.components.AbstractPlatformConnectorComponent
-
- org.hobbit.core.components.AbstractEvaluationStorage
-
- All Implemented Interfaces:
Closeable,AutoCloseable,CommandReceivingComponent,Component,ExpectedResponseReceivingComponent,PlatformConnector,ResponseReceivingComponent
- Direct Known Subclasses:
InMemoryEvaluationStore
public abstract class AbstractEvaluationStorage extends AbstractPlatformConnectorComponent implements ResponseReceivingComponent, ExpectedResponseReceivingComponent
This abstract class implements basic functions that can be used to implement a task generator.- Author:
- Michael Röder (roeder@informatik.uni-leipzig.de)
-
-
Field Summary
Fields Modifier and Type Field Description protected com.rabbitmq.client.ChannelackChannelChannel on which the acknowledgements are send.private static intDEFAULT_MAX_PARALLEL_PROCESSED_MESSAGESDefault value of themaxParallelProcessedMsgsattribute.private static byte[]EMPTY_RESPONSEThe empty response that is sent if an error occurs.protected RabbitQueueevalModule2EvalStoreQueueThe incoming queue from the evaluation module.private static org.slf4j.LoggerLOGGERprivate intmaxParallelProcessedMsgsThe maximum number of incoming messages of a single queue that are processed in parallel.static byteNEW_ITERATOR_IDIf a request contains this iterator ID, a new iterator is created and its first result as well as its Id are returned.static StringRECEIVE_TIMESTAMP_FOR_SYSTEM_RESULTS_KEYprotected List<Iterator<? extends ResultPair>>resultPairIteratorsIterators that have been started.protected DataReceiversystemResultReceiverThe incoming queue from the system.protected DataReceivertaskResultReceiverThe incoming queue from the task generator.private SemaphoreterminationMutexMutex used to wait for the termination 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 AbstractEvaluationStorage()Constructor using theDEFAULT_MAX_PARALLEL_PROCESSED_MESSAGES= 50.AbstractEvaluationStorage(int maxParallelProcessedMsgs)Constructor setting the maximum number of messages processed in parallel.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()protected abstract Iterator<? extends ResultPair>createIterator()Creates a new iterator that iterates over the response pairs.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.-
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.ExpectedResponseReceivingComponent
receiveExpectedResponseData
-
Methods inherited from interface org.hobbit.core.components.ResponseReceivingComponent
receiveResponseData
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
RECEIVE_TIMESTAMP_FOR_SYSTEM_RESULTS_KEY
public static final String RECEIVE_TIMESTAMP_FOR_SYSTEM_RESULTS_KEY
- See Also:
- Constant Field Values
-
NEW_ITERATOR_ID
public static final byte NEW_ITERATOR_ID
If a request contains this iterator ID, a new iterator is created and its first result as well as its Id are returned.- See Also:
- Constant Field Values
-
EMPTY_RESPONSE
private static final byte[] EMPTY_RESPONSE
The empty response that is sent if an error occurs.
-
DEFAULT_MAX_PARALLEL_PROCESSED_MESSAGES
private static final int DEFAULT_MAX_PARALLEL_PROCESSED_MESSAGES
Default value of themaxParallelProcessedMsgsattribute.- See Also:
- Constant Field Values
-
terminationMutex
private Semaphore terminationMutex
Mutex used to wait for the termination signal.
-
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.
-
resultPairIterators
protected List<Iterator<? extends ResultPair>> resultPairIterators
Iterators that have been started.
-
taskResultReceiver
protected DataReceiver taskResultReceiver
The incoming queue from the task generator.
-
systemResultReceiver
protected DataReceiver systemResultReceiver
The incoming queue from the system.
-
evalModule2EvalStoreQueue
protected RabbitQueue evalModule2EvalStoreQueue
The incoming queue from the evaluation module.
-
ackChannel
protected com.rabbitmq.client.Channel ackChannel
Channel on which the acknowledgements are send.
-
-
Constructor Detail
-
AbstractEvaluationStorage
public AbstractEvaluationStorage()
Constructor using theDEFAULT_MAX_PARALLEL_PROCESSED_MESSAGES= 50.
-
AbstractEvaluationStorage
public AbstractEvaluationStorage(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
-
createIterator
protected abstract Iterator<? extends ResultPair> createIterator()
Creates a new iterator that iterates over the response pairs.- Returns:
- a new iterator or null if an error occurred
-
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
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classAbstractCommandReceivingComponent- Throws:
IOException
-
-