if (state != OPEN && state != CLOSED && state != CLOSING)
{
Thread current = Thread.currentThread();
if (!current.equals(resumer) )
{
Waiter w = new Waiter(commandsLock, timeout);
while (w.hasTime() && (state != OPEN && state != CLOSED))
{
checkFailoverRequired("Command was interrupted because of failover, before being sent");
w.await();
}
}
}
switch (state)
{
case OPEN:
break;
case RESUMING:
Thread current = Thread.currentThread();
if (!current.equals(resumer))
{
throw new SessionException
("timed out waiting for resume to finish");
}
break;
case CLOSING:
case CLOSED:
ExecutionException exc = getException();
if (exc != null)
{
throw new SessionException(exc);
}
else
{
throw new SessionClosedException();
}
default:
throw new SessionException
(String.format
("timed out waiting for session to become open " +
"(state=%s)", state));
}
int next;
next = commandsOut++;
m.setId(next);
if(postIdSettingAction != null)
{
postIdSettingAction.run();
}
if (isFull(next))
{
Waiter w = new Waiter(commandsLock, timeout);
while (w.hasTime() && isFull(next) && state != CLOSED)
{
if (state == OPEN || state == RESUMING)
{
try
{
sessionFlush(COMPLETED);
}
catch (SenderException e)
{
if (!closing)
{
// if expiry is > 0 then this will
// happen again on resume
log.error(e, "error sending flush (full replay buffer)");
}
else
{
e.rethrow();
}
}
}
checkFailoverRequired("Command was interrupted because of failover, before being sent");
w.await();
}
}
if (state == CLOSED)
{