public 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)AbstractTaskGenerator.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 and Description |
|---|---|
protected com.rabbitmq.client.Channel |
ackChannel
Channel on which the acknowledgements 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 |
taskId
Id of the task the generator is waiting for an acknowledgement.
|
private Semaphore |
taskIdMutex
Semaphore used to wait for the acknowledgement.
|
consumer, dataGen2TaskGenQueue, runFlag, taskGen2EvalStoreQueue, taskGen2SystemQueuecmdChannel, defaultContainerTypeconnection, NUMBER_OF_RETRIES_TO_CONNECT_TO_RABBIT_MQ, rabbitMQHostName, START_WAITING_TIME_BEFORE_RETRY| Constructor and Description |
|---|
AbstractSequencingTaskGenerator() |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected void |
handleAck(byte[] body)
Handles the acknowledgement messages.
|
void |
init()
This method initializes the component.
|
protected void |
setTaskIdToWaitFor(String taskId)
Method to set the task id for which the task generator will wait when
calling
waitForAck(). |
protected boolean |
waitForAck()
Method to wait for the acknowledgement of a task with the given Id.
|
generateTask, getGeneratorId, getNextTaskId, getNumberOfGenerators, receiveCommand, receiveGeneratedData, run, sendTaskToEvalStorage, sendTaskToSystemAdapteraddCommandHeaderId, createContainer, createContainer, handleCmd, sendToCmdQueue, sendToCmdQueue, sendToCmdQueue, stopContainercreateDefaultRabbitQueue, generateSessionQueueName, getHobbitSessionIdprivate static final org.slf4j.Logger LOGGER
private static final long DEFAULT_ACK_TIMEOUT
private long ackTimeout
private String taskId
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 setTaskIdToWaitFor(String taskId)
waitForAck().taskId - id of the task for which the acknowledgement should be
receivedprotected boolean waitForAck()
true if the acknowledgement has been received,
false if the timeout has been reached or the method
has been interrupted.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class AbstractTaskGeneratorIOExceptionCopyright © 2017. All rights reserved.