public StatelessContainer(final Object id, final SecurityService securityService, final Duration accessTimeout, final Duration closeTimeout, final Pool.Builder poolBuilder, final int callbackThreads, final boolean useOneSchedulerThreadByBean, final int evictionThreads) { this.containerID = id; this.securityService = securityService; this.instanceManager = new StatelessInstanceManager( securityService, accessTimeout, closeTimeout, poolBuilder, callbackThreads, useOneSchedulerThreadByBean ? null : Executors.newScheduledThreadPool(Math.max(evictionThreads, 1), new DaemonThreadFactory(id))); }
public DaemonThreadFactory(final Class... clazz) { this(asStrings(clazz)); }
public static void preLoadClassesAsynchronously(final String classesToLoad) { if (classesToLoad == null || classesToLoad.isEmpty()) { return; } final ClassLoader loader = Thread.currentThread().getContextClassLoader(); final String[] split = classesToLoad.trim().split(","); final ExecutorService es = Executors.newCachedThreadPool(new DaemonThreadFactory(split)); for (final String clazz : split) { es.submit(new PreLoadClassTask(loader, clazz)); } es.shutdown(); }
public DaemonThreadFactory(final Class... clazz) { this(asStrings(clazz)); }
private static synchronized ExecutorService getExecutorService() { if (null == executor) { int length = getInterfaces().length; if (length < 1) { length = 1; } executor = Executors.newFixedThreadPool(length * 3, new DaemonThreadFactory("multicast-pulse-agent-")); } return executor; }
private Executor createExecutor() { final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(3, 10, 60L, SECONDS, new LinkedBlockingQueue<Runnable>(2), new DaemonThreadFactory("org.apache.openejb.util.Pool", hashCode())); threadPoolExecutor.setRejectedExecutionHandler(new RejectedExecutionHandler() { @Override public void rejectedExecution(final Runnable r, final ThreadPoolExecutor tpe) { if (null == r || null == tpe || tpe.isShutdown() || tpe.isTerminated() || tpe.isTerminating()) { return; } try { if (!tpe.getQueue().offer(r, 20, SECONDS)) { org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB, "org.apache.openejb.util.resources") .warning("Default pool executor failed to run asynchronous process: " + r); } } catch (final InterruptedException e) { //Ignore } } }); return threadPoolExecutor; }
private Executor createExecutor() { final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(3, 10, 60L, SECONDS, new LinkedBlockingQueue<Runnable>(2), new DaemonThreadFactory("org.apache.openejb.util.Pool", hashCode())); threadPoolExecutor.setRejectedExecutionHandler(new RejectedExecutionHandler() { @Override public void rejectedExecution(final Runnable r, final ThreadPoolExecutor tpe) { if (null == r || null == tpe || tpe.isShutdown() || tpe.isTerminated() || tpe.isTerminating()) { return; } try { if (!tpe.getQueue().offer(r, 20, SECONDS)) { org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB, "org.apache.openejb.util.resources") .warning("Default pool executor failed to run asynchronous process: " + r); } } catch (final InterruptedException e) { //Ignore } } }); return threadPoolExecutor; }
public HealthCheckServlet(final Collection<Class<?>> classes, final Set<HealthCheck> checks) { iterable = new HealthCheckIterable(classes).construct(); providedInstances = checks; numberOfThreads = Integer.getInteger("tribe.monitor.healthcheck.nb-threads", 3); timeoutSeconds = Long.getLong("tribe.monitor.healthcheck.timeout", 5); timeout = TimeUnit.SECONDS.toNanos(timeoutSeconds); executor = Executors.newFixedThreadPool(numberOfThreads, new DaemonThreadFactory("healthcheck")); }
public static void init() { if (!"true".equalsIgnoreCase(SystemInstance.get().getProperty("openejb.http.async.eviction", "true"))) { return; } es = Executors.newScheduledThreadPool(1, new DaemonThreadFactory(OpenEJBAsyncContext.class)); es.scheduleWithFixedDelay(new Runnable() { @Override public void run() { for (final OpenEJBAsyncContext ctx : new ArrayList<>(INITIALIZED)) { if (ctx.lastTouch + ctx.getTimeout() < System.currentTimeMillis()) { INITIALIZED.remove(ctx); for (final AsyncListener listener : ctx.listeners) { try { listener.onTimeout(ctx.event); } catch (final IOException t) { throw new OpenEJBRuntimeException(t); } } ctx.complete(); } } } }, 1, 1, TimeUnit.MINUTES); }
public StatelessInstanceManager(final SecurityService securityService, final Duration accessTimeout, final Duration closeTimeout, final Pool.Builder poolBuilder, final int callbackThreads) { this.securityService = securityService; this.accessTimeout = accessTimeout; this.closeTimeout = closeTimeout; this.poolBuilder = poolBuilder; if (accessTimeout.getUnit() == null) { accessTimeout.setUnit(TimeUnit.MILLISECONDS); } final int qsize = callbackThreads > 1 ? callbackThreads - 1 : 1; final ThreadFactory threadFactory = new DaemonThreadFactory("StatelessPool.worker."); this.executor = new ThreadPoolExecutor( callbackThreads, callbackThreads * 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>(qsize), threadFactory); this.executor.setRejectedExecutionHandler(new RejectedExecutionHandler() { @Override public void rejectedExecution(final Runnable r, final ThreadPoolExecutor tpe) { if (null == r || null == tpe || tpe.isShutdown() || tpe.isTerminated() || tpe.isTerminating()) { return; } try { if (!tpe.getQueue().offer(r, 20, TimeUnit.SECONDS)) { logger.warning("Executor failed to run asynchronous process: " + r); } } catch (final InterruptedException e) { //Ignore } } }); }
final ExecutorService es = Executors.newFixedThreadPool( Math.min(urls.size(), 2 * Runtime.getRuntime().availableProcessors() + 1), new DaemonThreadFactory("OpenEJB-tld-server-scanning"));
final ExecutorService es = Executors.newFixedThreadPool(2 * Runtime.getRuntime().availableProcessors() + 1, new DaemonThreadFactory("OpenEJB-tld-server-scanning"));
public MdbPoolContainer(final Object containerID, final SecurityService securityService, final ResourceAdapter resourceAdapter, final Class messageListenerInterface, final Class activationSpecClass, final boolean failOnUnknownActivationSpec, final Duration accessTimeout, final Duration closeTimeout, final Pool.Builder poolBuilder, final int callbackThreads, final boolean useOneSchedulerThreadByBean, final int evictionThreads ) { this.containerID = containerID; this.resourceAdapter = resourceAdapter; this.messageListenerInterface = messageListenerInterface; this.activationSpecClass = activationSpecClass; this.failOnUnknownActivationSpec = failOnUnknownActivationSpec; xaResourceWrapper = SystemInstance.get().getComponent(XAResourceWrapper.class); inboundRecovery = SystemInstance.get().getComponent(InboundRecovery.class); this.instanceManager = new MdbInstanceManager( securityService, resourceAdapter, inboundRecovery, containerID, accessTimeout, closeTimeout, poolBuilder, callbackThreads, useOneSchedulerThreadByBean ? null : Executors.newScheduledThreadPool(Math.max(evictionThreads, 1), new DaemonThreadFactory(containerID))); }
final ExecutorService es = Executors.newSingleThreadExecutor(new DaemonThreadFactory("openejb-resource-destruction-" + name)); final Object o = object; try {
}; final ExecutorService executor = Executors.newFixedThreadPool(4, new DaemonThreadFactory("warmup"));
final ThreadFactory threadFactory = new DaemonThreadFactory("StatelessPool.worker."); this.executor = new ThreadPoolExecutor( callbackThreads, callbackThreads * 2,
final ThreadFactory threadFactory = new DaemonThreadFactory("InstanceManagerPool.worker."); this.executor = new ThreadPoolExecutor( callbackThreads, callbackThreads * 2,
public void initEviction() { if (!"true".equalsIgnoreCase(SystemInstance.get().getProperty("openejb.http.eviction", "true"))) { return; } final Duration duration = new Duration(SystemInstance.get().getProperty("openejb.http.eviction.duration", "1 minute")); es = Executors.newScheduledThreadPool(1, new DaemonThreadFactory(SessionManager.class)); es.scheduleWithFixedDelay(new Runnable() { @Override public void run() { for (final SessionWrapper data : new ArrayList<>(sessions.values())) { final HttpSession session = data.session; if (session.getMaxInactiveInterval() > 0 && session.getLastAccessedTime() + TimeUnit.SECONDS.toMillis(session.getMaxInactiveInterval()) < System.currentTimeMillis()) { doDestroy(data); sessions.remove(data.session.getId()); } } } }, duration.getTime(), duration.getTime(), duration.getUnit()); }
factory = new DaemonThreadFactory(prefix);
factory = new DaemonThreadFactory(prefix);