protected OperationResult stopNode() {
ProcessInfo process = getResourceContext().getNativeProcess();
if (process == null) {
log.warn("Failed to obtain process info. It appears Cassandra is already shutdown.");
return new OperationResult("Failed to obtain process info. It appears Cassandra is already shutdown.");
}
long pid = process.getPid();
try {
process.kill("KILL");
Configuration pluginConfig = getResourceContext().getPluginConfiguration();
File basedir = new File(pluginConfig.getSimpleValue("baseDir"));
File binDir = new File(basedir, "bin");
File pidFile = new File(binDir, "cassandra.pid");
pidFile.delete();
return new OperationResult("Successfully shut down Cassandra daemon with pid " + pid);
} catch (SigarException e) {
log.warn("Failed to shut down Cassandra node with pid " + pid, e);
OperationResult failure = new OperationResult("Failed to shut down Cassandra node with pid " + pid);
failure.setErrorMessage(ThrowableUtil.getAllMessages(e));
return failure;
}
}