use of org.opennms.core.concurrent.LogPreservingThreadFactory in project opennms by OpenNMS.
the class EventIpcManagerDefaultImpl method afterPropertiesSet.
/**
* <p>afterPropertiesSet</p>
*/
@Override
public void afterPropertiesSet() {
Assert.state(m_eventHandlerPool == null, "afterPropertiesSet() has already been called");
Assert.state(m_eventHandler != null, "eventHandler not set");
Assert.state(m_handlerPoolSize != null, "handlerPoolSize not set");
final LinkedBlockingQueue<Runnable> workQueue = m_handlerQueueLength == null ? new LinkedBlockingQueue<>() : new LinkedBlockingQueue<>(m_handlerQueueLength);
m_registry.remove("eventlogs.queued");
m_registry.register("eventlogs.queued", new Gauge<Integer>() {
@Override
public Integer getValue() {
return workQueue.size();
}
});
Logging.withPrefix(Eventd.LOG4J_CATEGORY, new Runnable() {
@Override
public void run() {
/**
* Create a fixed-size thread pool. The number of threads can be configured by using
* the "receivers" attribute in the config. The queue length for the pool can be configured
* with the "queueLength" attribute in the config.
*/
m_eventHandlerPool = new ThreadPoolExecutor(m_handlerPoolSize, m_handlerPoolSize, 0L, TimeUnit.MILLISECONDS, workQueue, new LogPreservingThreadFactory(EventIpcManagerDefaultImpl.class.getSimpleName(), m_handlerPoolSize));
}
});
}
use of org.opennms.core.concurrent.LogPreservingThreadFactory in project opennms by OpenNMS.
the class Executor method start.
public synchronized void start() {
for (final Engine engine : m_config.getEngines()) {
LOG.debug("Registering engine: {}", engine.getLanguage());
String[] extensions = null;
if (engine.getExtensions().isPresent()) {
StringTokenizer st = new StringTokenizer(engine.getExtensions().get());
extensions = new String[st.countTokens()];
int j = 0;
while (st.hasMoreTokens()) {
extensions[j++] = st.nextToken();
}
}
BSFManager.registerScriptingEngine(engine.getLanguage(), engine.getClassName(), extensions);
}
m_scriptManager = new BSFManager();
m_scriptManager.registerBean("log", LOG);
// Run all start scripts
for (final StartScript startScript : m_config.getStartScripts()) {
if (startScript.getContent().isPresent()) {
try {
m_scriptManager.exec(startScript.getLanguage(), "", 0, 0, startScript.getContent().get());
} catch (BSFException e) {
LOG.error("Start script failed: " + startScript, e);
}
} else {
LOG.warn("Start script has no script content: " + startScript);
}
}
// Start the thread pool
m_executorService = Executors.newFixedThreadPool(1, new LogPreservingThreadFactory("Scriptd-Executor", 1));
// started
try {
m_broadcastEventProcessor = new BroadcastEventProcessor(this);
} catch (Throwable e) {
LOG.error("Failed to setup event reader", e);
throw new UndeclaredThrowableException(e);
}
LOG.debug("Scriptd executor started");
}
Aggregations