use of com.googlecode.jmxtrans.model.ValidationException in project jmxtrans by jmxtrans.
the class JmxTransformer method processServersIntoJobs.
/**
* Processes all the Servers into Job's
* <p/>
* Needs to be called after processFiles()
*/
private void processServersIntoJobs() throws LifecycleException {
for (Server server : this.masterServersList) {
try {
// need to inject the poolMap
for (Query query : server.getQueries()) {
for (OutputWriter writer : query.getOutputWriterInstances()) {
writer.start();
}
}
// Now validate the setup of each of the OutputWriter's per
// query.
this.validateSetup(server, server.getQueries());
// Now schedule the jobs for execution.
this.scheduleJob(server);
} catch (ParseException ex) {
throw new LifecycleException("Error parsing cron expression: " + server.getCronExpression(), ex);
} catch (SchedulerException ex) {
throw new LifecycleException("Error scheduling job for server: " + server, ex);
} catch (ValidationException ex) {
throw new LifecycleException("Error validating json setup for query", ex);
}
}
}
use of com.googlecode.jmxtrans.model.ValidationException in project jmxtrans by jmxtrans.
the class KeyOutWriter method validateSetup.
/**
* Creates the logging
*/
@Override
public void validateSetup(Server server, Query query) throws ValidationException {
// Check if we've already created a logger for this file. If so, use it.
if (loggers.containsKey(outputFile)) {
logger = loggers.get(outputFile);
return;
}
// need to create a logger
try {
logger = initLogger(outputFile);
loggers.put(outputFile, logger);
} catch (IOException e) {
throw new ValidationException("Failed to setup log4j", query, e);
}
}
use of com.googlecode.jmxtrans.model.ValidationException in project jmxtrans by jmxtrans.
the class NagiosWriter method checkFile.
/**
* Creates the logging. Nagios doesn't start if the external command pipe
* exists, so we write to /dev/null until we have it available.
* From the official documentation:
* <blockquote>
* The external command file is implemented as a named pipe (FIFO),
* which is created when Nagios starts and removed when it shuts down.
* If the file exists when Nagios starts,
* the Nagios process will terminate with an error message.
* http://nagios.sourceforge.net/docs/3_0/configmain.html#command_file
* </blockquote>
*/
public void checkFile(Query query) throws ValidationException {
if (!outputFile.exists()) {
if (loggers.containsKey("/dev/null")) {
logger = loggers.get("/dev/null");
} else {
try {
logger = initLogger("/dev/null");
loggers.put("/dev/null", logger);
} catch (IOException e) {
throw new ValidationException("Failed to setup log4j", query, e);
}
}
if (loggers.containsKey(outputFile.getAbsolutePath())) {
loggers.remove(outputFile.getAbsolutePath());
}
return;
} else if (loggers.containsKey(outputFile.getAbsolutePath())) {
logger = loggers.get(outputFile.getAbsolutePath());
return;
}
try {
logger = initLogger(outputFile.getAbsolutePath());
loggers.put(outputFile.getAbsolutePath(), logger);
} catch (IOException e) {
throw new ValidationException("Failed to setup log4j", query, e);
}
}
Aggregations