// server got already destroyed - no need to continue.
return;
}
int tries = (int) ((oti * AppContext.getBasicConfiguration().getOperationTimeoutMultiplier()) / Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
int i = 0;
CommandCallback callback = null;
int otiOnServerMillis = 0;
try {
// Following loop implements the wait mechanism in case of a busy connection pool
do {
callback = new CommandCallback(true);
try {
otiOnServerMillis = oti - (i * Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
if (abortSubscription == true) {
this.serverAbortSubscription(abortMessage, callback, otiOnServerMillis);
} else {
this.serverAbortSession(abortMessage, callback, otiOnServerMillis);
}
// no exception has been thrown - get out of wait loop
break;
} catch (ConnectionPoolBusyException ex) {
LOGGER.warn("ConnectionPoolBusyException caught in wait mec of session abort");
if (i >= (tries - 1)) {
// only one loop outstanding - don't continue throw current exception
LOGGER.warn(SCMPError.NO_FREE_CONNECTION.getErrorText("service=" + abortMessage.getServiceName()));
SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.NO_FREE_CONNECTION,
"service=" + abortMessage.getServiceName());
throw scmpCommandException;
}
}
// sleep for a while and then try again
Thread.sleep(Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
} while (++i < tries);
// validate reply of server
SCMPMessage reply = callback.getMessageSync(oti);
if (reply.isFault()) {
// error in server abort session - destroy server
this.abortSessionsAndDestroy("Session abort failed, abort reason: " + reason);
}
} catch (SCMPCommandException scmpCommandException) {
LOGGER.warn("ConnectionPoolBusyException in aborting session wait mec " + scmpCommandException.toString());
// ConnectionPoolBusyException after wait mec - try opening a new connection
// RemoteNodeConfiguration remoteNodeConfiguration = this.requester.getRemoteNodeConfiguration();
// set up a new requester to make the SAS - only 1 connection is allowed
Requester sasRequester = new Requester(this.sasRemoteNodeConfiguration);
try {
this.serverAbortSessionWithExtraRequester(sasRequester, abortMessage, callback, oti);
} catch (ConnectionPoolBusyException e) {
sasRequester.destroy();
LOGGER.warn("ConnectionPoolBusyException in aborting session wait mec over special connection. " + e.toString());
if (this.service.getType() == ServiceType.SESSION_SERVICE) {
this.abortSessionsAndDestroy("Session abort over a new connection failed");
}
return;
}
sasRequester.destroy();
// validate reply of server
SCMPMessage reply = callback.getMessageSync(oti);
if (reply.isFault()) {
LOGGER.warn("Fault in aborting session wait mec over special connection");
// error in server abort session - destroy server
this.abortSessionsAndDestroy("Session abort over a new connection failed");
}