"node failed with this error: " + shutdownResult.getErrorMessage());
return result;
}
Configuration pluginConfig = context.getPluginConfiguration();
ConfigEditor configEditor = getYamlConfigEditor();
try {
configEditor.load();
purgeDataDirs(configEditor);
log.info("Updating cluster settings");
String address = pluginConfig.getSimpleValue("host");
int cqlPort = Integer.parseInt(params.getSimpleValue("cqlPort"));
int gossipPort = Integer.parseInt(params.getSimpleValue("gossipPort"));
List<String> addresses = getAddresses(params.getList("addresses"));
// Make sure this node's address is not in the list; otherwise, it
// won't bootstrap properly.
List<String> seeds = new ArrayList<String>(addresses);
seeds.remove(address);
log.info("Updating seeds property to " + seeds);
configEditor.setSeeds(seeds.toArray(new String[seeds.size()]));
configEditor.setNativeTransportPort(cqlPort);
configEditor.setStoragePort(gossipPort);
configEditor.save();
log.info("Cluster configuration settings have been applied to " + configEditor.getConfigFile());
updateInternodeAuthConfFile(new HashSet<String>(addresses));
log.info(this + " is ready to be bootstrap. Restarting storage node...");
OperationResult startResult = startNode();
if (startResult.getErrorMessage() != null) {
log.error("Failed to restart storage node:\n" + startResult.getErrorMessage());
result.setErrorMessage("Failed to restart storage node:\n" + startResult.getErrorMessage());
} else {
result.setSimpleResult("The storage node was successfully updated is now bootstrapping into the cluster.");
}
return result;
} catch (ConfigEditorException e) {
log.error("There was an error while trying to update " + configEditor.getConfigFile(), e);
if (e.getCause() instanceof YAMLException) {
log.info("Attempting to restore " + configEditor.getConfigFile());
try {
configEditor.restore();
result.setErrorMessage("Failed to update configuration file [" + configEditor.getConfigFile() + "]: " +
ThrowableUtil.getAllMessages(e.getCause()));
} catch (ConfigEditorException e1) {
log.error("Failed to restore " + configEditor.getConfigFile() + ". A copy of the file prior to any modifications " +
"can be found at " + configEditor.getBackupFile());
result.setErrorMessage("There was an error updating [" + configEditor.getConfigFile() + "] and undoing the changes " +
"Failed. A copy of the file can be found at " + configEditor.getBackupFile() + ". See the " +
"agent logs for more details");
}
}
EmsConnection emsConnection = getEmsConnection();