Closeable, AutoCloseable, CommandReceivingComponent, Component, GeneratedDataReceivingComponent, PlatformConnectorpublic abstract class AbstractSequencingTaskGenerator extends AbstractTaskGenerator
AbstractTaskGenerator that offers methods to wait
for acknowledgements for single tasks. The workflow for waiting for a task is
AbstractTaskGenerator.getNextTaskId()
should be used)setTaskIdToWaitFor(String)sendTaskToSystemAdapter(String, byte[]) and
AbstractTaskGenerator.sendTaskToEvalStorage(String, long, byte[])waitForAck()Note that the acknowledgements only work if the evaluation storage is configured to send acknowledgements for the single tasks.
| Modifier and Type | Field | Description |
|---|---|---|
protected com.rabbitmq.client.Channel |
ackChannel |
Channel on which the acknowledgments are received.
|
private long |
ackTimeout |
Timeout for the acknowledgement.
|
private static long |
DEFAULT_ACK_TIMEOUT |
Default timeout for the acknowledgement.
|
private static org.slf4j.Logger |
LOGGER |
|
private String |
seqTaskId |
Id of the task the generator is waiting for an acknowledgement.
|
private Semaphore |
taskIdMutex |
Semaphore used to wait for the acknowledgement.
|
cmdChannel, cmdQueueFactory, defaultContainerTypeconnectionFactory, incomingDataQueueFactory, NUMBER_OF_RETRIES_TO_CONNECT_TO_RABBIT_MQ, outgoingDataQueuefactory, rabbitMQHostName, START_WAITING_TIME_BEFORE_RETRYconsumer, dataGenReceiver, runFlag, sender2EvalStore, sender2System| Constructor | Description |
|---|---|
AbstractSequencingTaskGenerator() |
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
|
protected void |
handleAck(byte[] body) |
Handles the acknowledgement messages.
|
void |
init() |
This method initializes the component.
|
protected void |
sendTaskToSystemAdapter(String taskIdString,
byte[] data) |
Sends the given task with the given task id and data to the system and
blocks until an acknowledgement has been received for the task or the
timeout has been reached.
|
protected boolean |
sendTaskToSystemAdapterInSequence(String taskIdString,
byte[] data) |
Sends the given task with the given task id and data to the system and
blocks until an acknowledgement has been received for the task or the
timeout has been reached.
|
void |
setAckTimeout(long ackTimeout) |
Setter for the maximum time the task generator waits for an
acknowledgement.
|
protected void |
setTaskIdToWaitFor(String taskId) |
Deprecated.
It is not necessary anymore since its usage has been
integrated into the
sendTaskToSystemAdapterInSequence(String, byte[])
method. |
private boolean |
waitForAck() |
Method to wait for the acknowledgement of a task with the given Id.
|
addCommandHeaderId, createContainer, createContainer, handleCmd, sendToCmdQueue, sendToCmdQueue, sendToCmdQueuecreateConnection, generateSessionQueueName, getHobbitSessionIdaddContainerObserver, createContainer, getFactoryForIncomingCmdQueues, getFactoryForIncomingDataQueues, getFactoryForOutgoingCmdQueues, getFactoryForOutgoingDataQueues, stopContainergenerateTask, getGeneratorId, getNextTaskId, getNumberOfGenerators, receiveCommand, receiveGeneratedData, run, sendTaskToEvalStorageprivate static final org.slf4j.Logger LOGGER
private static final long DEFAULT_ACK_TIMEOUT
private long ackTimeout
private String seqTaskId
private Semaphore taskIdMutex
protected com.rabbitmq.client.Channel ackChannel
public void init()
throws Exception
Componentinit in interface Componentinit in class AbstractTaskGeneratorException - if an error occurs during the initializationprotected void handleAck(byte[] body)
body - the body of the acknowledgement messageprotected void sendTaskToSystemAdapter(String taskIdString, byte[] data) throws IOException
sendTaskToSystemAdapterInSequence(String, byte[])
should be used.sendTaskToSystemAdapter in class AbstractTaskGeneratortaskIdString - the id of the taskdata - the data of the taskIOException - if there is an error during the sendingprotected boolean sendTaskToSystemAdapterInSequence(String taskIdString, byte[] data) throws IOException
taskIdString - the task iddata - the data of the tasktrue if the acknowledgement has been received,
false if the timeout has been reached or the method
has been interrupted.IOException - if there is an error during the sending@Deprecated protected void setTaskIdToWaitFor(String taskId)
sendTaskToSystemAdapterInSequence(String, byte[])
method.waitForAck().taskId - id of the task for which the acknowledgement should be
receivedprivate boolean waitForAck()
true if the acknowledgement has been received,
false if the timeout has been reached or the method
has been interrupted.public void setAckTimeout(long ackTimeout)
ackTimeout - the new timeout in millisecondspublic void close()
throws IOException
close in interface AutoCloseableclose in interface Closeableclose in class AbstractTaskGeneratorIOExceptionCopyright © 2017. All rights reserved.