use of org.voltcore.logging.Level in project voltdb by VoltDB.
the class UpdateLogging method run.
/**
* Change the operational log configuration.
* @param ctx Internal parameter. Not user-accessible.
* @param xmlConfig New configuration XML document.
* @return Standard STATUS table.
*/
@SuppressWarnings("deprecation")
public VoltTable[] run(SystemProcedureExecutionContext ctx, String username, String remoteHost, String xmlConfig) {
long oldLevels = 0;
if (ctx.isLowestSiteId()) {
// Logger level is a global property, pick the site with lowest id to do it.
hostLog.info(String.format("%s from %s changed the log4j settings", username, remoteHost));
hostLog.info(xmlConfig);
oldLevels = hostLog.getLogLevels(loggers);
}
try {
// Mimic the multi-fragment semantics as scatter-gather pattern is an overkill for this simple task.
// There are chances that some sites being interrupted and update the logging before old logger level
// being read, but the reasons we don't care because 1) it is rare and 2) it only effects when HOST
// logger being changed from higher than INFO level to INFO or lower level.
barrier.await();
} catch (InterruptedException | BrokenBarrierException dontcare) {
}
VoltDB.instance().logUpdate(xmlConfig, DeprecatedProcedureAPIAccess.getVoltPrivateRealTransactionId(this), ctx.getPaths().getVoltDBRoot());
ctx.updateBackendLogLevels();
if (ctx.isLowestSiteId()) {
long newLevels = hostLog.getLogLevels(loggers);
if (newLevels != oldLevels) {
// If HOST logger wasn't able to log before and now it can, logs the setting change event.
int index = (int) ((oldLevels >> 3) & 7);
Level before = Level.values()[index];
index = (int) ((newLevels >> 3) & 7);
Level after = Level.values()[index];
if (before.ordinal() > Level.INFO.ordinal() && after.ordinal() <= Level.INFO.ordinal()) {
hostLog.info(String.format("%s from %s changed the log4j settings", username, remoteHost));
hostLog.info(xmlConfig);
}
}
barrier.reset();
}
VoltTable t = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA);
t.addRow(VoltSystemProcedure.STATUS_OK);
return (new VoltTable[] { t });
}
Aggregations