use of ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter in project cassandra by apache.
the class ThreadAwareSecurityManager method install.
public static void install() {
if (installed)
return;
System.setSecurityManager(new ThreadAwareSecurityManager());
Logger l = LoggerFactory.getLogger(ThreadAwareSecurityManager.class);
ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) l;
LoggerContext ctx = logbackLogger.getLoggerContext();
TurboFilterList turboFilterList = ctx.getTurboFilterList();
for (int i = 0; i < turboFilterList.size(); i++) {
TurboFilter turboFilter = turboFilterList.get(i);
if (turboFilter instanceof ReconfigureOnChangeFilter) {
ReconfigureOnChangeFilter reconfigureOnChangeFilter = (ReconfigureOnChangeFilter) turboFilter;
turboFilterList.set(i, new SMAwareReconfigureOnChangeFilter(reconfigureOnChangeFilter));
break;
}
}
installed = true;
}
use of ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter in project cassandra by apache.
the class LogbackLoggingSupport method onStartup.
@Override
public void onStartup() {
// The default logback configuration in conf/logback.xml allows reloading the
// configuration when the configuration file has changed (every 60 seconds by default).
// This requires logback to use file I/O APIs. But file I/O is not allowed from UDFs.
// I.e. if logback decides to check for a modification of the config file while
// executing a sandbox thread, the UDF execution and therefore the whole request
// execution will fail with an AccessControlException.
// To work around this, a custom ReconfigureOnChangeFilter is installed, that simply
// prevents this configuration file check and possible reload of the configuration,
// while executing sandboxed UDF code.
//
// NOTE: this is obsolte with logback versions (at least since 1.2.3)
Logger logbackLogger = (Logger) LoggerFactory.getLogger(ThreadAwareSecurityManager.class);
LoggerContext ctx = logbackLogger.getLoggerContext();
TurboFilterList turboFilterList = ctx.getTurboFilterList();
for (int i = 0; i < turboFilterList.size(); i++) {
TurboFilter turboFilter = turboFilterList.get(i);
if (turboFilter instanceof ReconfigureOnChangeFilter) {
ReconfigureOnChangeFilter reconfigureOnChangeFilter = (ReconfigureOnChangeFilter) turboFilter;
turboFilterList.set(i, new SMAwareReconfigureOnChangeFilter(reconfigureOnChangeFilter));
break;
}
}
}
use of ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter in project cassandra by apache.
the class AggregationTest method configureLogbackScanPeriod.
private static void configureLogbackScanPeriod(long millis) {
Logger l = LoggerFactory.getLogger(AggregationTest.class);
ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) l;
LoggerContext ctx = logbackLogger.getLoggerContext();
TurboFilterList turboFilterList = ctx.getTurboFilterList();
boolean done = false;
for (TurboFilter turboFilter : turboFilterList) {
if (turboFilter instanceof ReconfigureOnChangeFilter) {
ReconfigureOnChangeFilter reconfigureFilter = (ReconfigureOnChangeFilter) turboFilter;
reconfigureFilter.setContext(ctx);
reconfigureFilter.setRefreshPeriod(millis);
reconfigureFilter.stop();
// start() sets the next check timestammp
reconfigureFilter.start();
done = true;
break;
}
}
ReconfigureOnChangeTask roct = (ReconfigureOnChangeTask) ctx.getObject(RECONFIGURE_ON_CHANGE_TASK);
if (roct != null) {
// Let the test run anyway, just we cannot reconfigure it (and it is pointless to reconfigure).
return;
}
assertTrue("ReconfigureOnChangeFilter not in logback's turbo-filter list - do that by adding scan=\"true\" to logback-test.xml's configuration element", done);
}
Aggregations