}
else
{
// on timeout, we write TASK SET FULL to the transport port
lock.unlock(); // we don't want to block on transport port operations
Command command = task.getCommand();
task.getTargetTransportPort().writeResponse(command.getNexus(),
command.getCommandReferenceNumber(), Status.TASK_SET_FULL, null);
_logger.debug("task set is full, rejecting task: " + task);
return false;
}
}
// Check that untagged tasks have the SIMPLE task attribute
long taskTag = task.getCommand().getNexus().getTaskTag();
if (taskTag < 0 && task.getCommand().getTaskAttribute() != TaskAttribute.SIMPLE)
{
throw new RuntimeException("Transport layer should have set untagged task as SIMPLE");
}
// check for duplicate task tags; 'null' key is the untagged task
if (this.tasks.containsKey(taskTag < 0 ? null : taskTag))
{
// Note that we treat two untagged tasks as an overlapped command condition.
// FIXME: Is treating overlapping untagged tasks in this way actually proper?
lock.unlock(); // we don't want to block on transport port operations
Command command = task.getCommand();
task.getTargetTransportPort().writeResponse(command.getNexus(),
command.getCommandReferenceNumber(), Status.CHECK_CONDITION,
ByteBuffer.wrap((new OverlappedCommandsAttemptedException(true)).encode()));
if (_logger.isDebugEnabled())
_logger.debug("command not accepted due to preexisting untagged task: " + task);
return false;
}