use of de.cinovo.cloudconductor.api.lib.exceptions.CloudConductorException in project cloudconductor-agent-redhat by cinovo.
the class DefaultJob method handlePackages.
private void handlePackages() {
try {
PackageHandler packageHandler = new PackageHandler();
packageHandler.run();
} catch (ExecutionError e) {
if (e.getCause() instanceof CloudConductorException) {
DefaultJob.LOGGER.error("Error handling packages: " + e.getMessage(), e);
} else {
DefaultJob.LOGGER.error("Error handling packages: " + e.getMessage());
}
}
}
use of de.cinovo.cloudconductor.api.lib.exceptions.CloudConductorException in project cloudconductor-agent-redhat by cinovo.
the class HeartBeatJob method run.
@Override
public void run() {
HeartBeatJob.LOGGER.debug("Starting HeartBeatJob");
AgentOption newOptions;
try {
newOptions = ServerCom.heartBeat();
} catch (CloudConductorException e) {
HeartBeatJob.LOGGER.error("Error getting options from server: ", e);
return;
}
new OptionHandler(newOptions).run();
try {
if (AgentState.repoExecutionLock.tryLock()) {
new RepoHandler().run();
}
} catch (ExecutionError e) {
HeartBeatJob.LOGGER.error("Error updating repos: ", e);
} finally {
AgentState.repoExecutionLock.unlock();
}
HeartBeatJob.LOGGER.debug("Finished HeartBeatJob");
}
use of de.cinovo.cloudconductor.api.lib.exceptions.CloudConductorException in project cloudconductor-agent-redhat by cinovo.
the class ConfigFileHandler method run.
/**
* @throws ExecutionError an error occurred during execution
*/
public void run() throws ExecutionError {
ConfigFileHandler.LOGGER.debug("Start Config File Handler");
Set<ConfigFile> configFiles;
try {
configFiles = ServerCom.getFiles();
ConfigFileHandler.LOGGER.debug("Received " + configFiles.size() + " configuration files.");
} catch (CloudConductorException e) {
ConfigFileHandler.LOGGER.error("Error getting configuration files from server: ", e);
throw new ExecutionError(e);
}
// handle files
ConfigFileHandler.LOGGER.debug("Handle files");
IExecutor<Set<String>> files = new FileExecutor(configFiles);
try {
files.execute();
} catch (ExecutionError e) {
// just log the error but go on with execution
ConfigFileHandler.LOGGER.error("Error handling files: " + e.getMessage(), e);
}
Set<String> servicesToRestart = files.getResult();
if ((servicesToRestart != null) && !servicesToRestart.isEmpty()) {
// handle restart of services
ConfigFileHandler.LOGGER.debug("Restart services");
ScriptExecutor serviceHandler = ScriptExecutor.generateServiceStateHandler(servicesToRestart, null, null);
try {
serviceHandler.execute();
} catch (ExecutionError e) {
// just log the error but go on with execution
ConfigFileHandler.LOGGER.error(e.getMessage());
}
}
ConfigFileHandler.LOGGER.debug("Finished Config File Handler");
}
use of de.cinovo.cloudconductor.api.lib.exceptions.CloudConductorException in project cloudconductor-agent-redhat by cinovo.
the class ServerCom method getConfig.
/**
* @return the config for this agent
* @throws CloudConductorException error if retrieval fails
*/
public static Map<String, String> getConfig() throws CloudConductorException {
Map<String, String> configMap = new HashMap<>();
try {
for (ConfigValue c : ServerCom.config.getConfig(AgentState.info().getTemplate(), AgentVars.SERVICE_NAME)) {
if ((c.getService() != null) && c.getService().equals(AgentVars.SERVICE_NAME)) {
ServerCom.LOGGER.debug("Add config: " + c.getKey() + ": " + c.getValue());
configMap.put(c.getKey(), (String) c.getValue());
}
}
} catch (RuntimeException e) {
ServerCom.LOGGER.error("Error getting config from server: ", e);
throw new CloudConductorException(e.getMessage());
}
return configMap;
}
use of de.cinovo.cloudconductor.api.lib.exceptions.CloudConductorException in project cloudconductor-agent-redhat by cinovo.
the class ServerCom method heartBeat.
/**
* @return the response
* @throws CloudConductorException thrown if communication with cloudconductor failed
*/
public static AgentOption heartBeat() throws CloudConductorException {
try {
String template = AgentState.info().getTemplate();
String host = AgentState.info().getHost();
String uuid = AgentState.info().getUuid();
String agentName = AgentState.info().getAgent();
return ServerCom.agent.heartBeat(template, host, agentName, uuid);
} catch (RuntimeException e) {
ServerCom.LOGGER.error("Error sending heart beat: ", e);
throw new CloudConductorException(e.getMessage());
}
}
Aggregations