}
}
private boolean doAbortSingle(String targetSessionId) throws IOException {
assert targetSessionId != null;
SessionMirror session;
try {
WGLOG.info("I01001",
targetSessionId,
profile.getName());
if (RuntimeContext.get().canExecute(sessionProvider)) {
session = sessionProvider.open(targetSessionId);
} else {
session = new SessionMirror.Null(targetSessionId);
}
} catch (SessionException e) {
if (e.getReason() == Reason.NOT_EXIST) {
WGLOG.info("I01002",
targetSessionId,
profile.getName());
return false;
}
throw e;
}
try {
WGLOG.info("I01003",
targetSessionId,
profile.getName());
int failureCount = 0;
for (Map.Entry<String, ResourceProvider> entry : resourceProviders.entrySet()) {
String name = entry.getKey();
ResourceProvider provider = entry.getValue();
LOG.debug("Attempting to abort resource {} (session={})",
name,
targetSessionId);
try {
if (RuntimeContext.get().isSimulation() == false) {
provider.abort(session.getId());
}
} catch (IOException e) {
failureCount++;
WGLOG.warn(e, "W01002",
targetSessionId,
profile.getName(),
name);
}
}
if (failureCount > 0) {
throw new IOException(MessageFormat.format(
"Failed to abort some resources for the session \"{0}\"",
targetSessionId));
}
WGLOG.info("I01004",
targetSessionId,
profile.getName());
session.abort();
return true;
} finally {
try {
session.close();
} catch (IOException e) {
WGLOG.warn(e, "W01003",
targetSessionId,
profile.getName());
}