@Override public boolean cancel(boolean mayInterruptIfRunning) { boolean removeOnCancel = !executor.isShutdown(); boolean cancelled = delegate.cancel(mayInterruptIfRunning); if (cancelled && removeOnCancel) { executor.remove(this); } return cancelled; }
public LoggingScheduledExecutor(ILogger logger, int corePoolSize, ThreadFactory threadFactory, boolean removeOnCancel) { super(corePoolSize, threadFactory); this.logger = checkNotNull(logger, "logger cannot be null"); this.manualRemoveOnCancel = manualRemoveOnCancel(removeOnCancel); }
private boolean manualRemoveOnCancel(boolean removeOnCancel) { if (trySetRemoveOnCancelPolicy()) { return false; } else { return removeOnCancel; } }
public void shutdown() { logger.finest("Stopping executors..."); scheduledExecutorService.notifyShutdownInitiated(); for (ExecutorService executorService : executors.values()) { executorService.shutdown(); } for (ExecutorService executorService : durableExecutors.values()) { executorService.shutdown(); } for (ExecutorService executorService : scheduleDurableExecutors.values()) { executorService.shutdown(); } scheduledExecutorService.shutdownNow(); cachedExecutorService.shutdown(); try { scheduledExecutorService.awaitTermination(AWAIT_TIME, TimeUnit.SECONDS); } catch (InterruptedException e) { currentThread().interrupt(); logger.finest(e); } try { cachedExecutorService.awaitTermination(AWAIT_TIME, TimeUnit.SECONDS); } catch (InterruptedException e) { currentThread().interrupt(); logger.finest(e); } executors.clear(); durableExecutors.clear(); scheduleDurableExecutors.clear(); }
internalExecutor = new LoggingScheduledExecutor(logger, internalPoolSize, new PoolExecutorThreadFactory(name + ".internal-", classLoader), properties.getBoolean(TASK_SCHEDULER_REMOVE_ON_CANCEL),
public void shutdown() { logger.finest("Stopping executors..."); scheduledExecutorService.notifyShutdownInitiated(); for (ExecutorService executorService : executors.values()) { executorService.shutdown(); } for (ExecutorService executorService : durableExecutors.values()) { executorService.shutdown(); } for (ExecutorService executorService : scheduleDurableExecutors.values()) { executorService.shutdown(); } scheduledExecutorService.shutdownNow(); cachedExecutorService.shutdown(); try { scheduledExecutorService.awaitTermination(AWAIT_TIME, TimeUnit.SECONDS); } catch (InterruptedException e) { currentThread().interrupt(); logger.finest(e); } try { cachedExecutorService.awaitTermination(AWAIT_TIME, TimeUnit.SECONDS); } catch (InterruptedException e) { currentThread().interrupt(); logger.finest(e); } executors.clear(); durableExecutors.clear(); scheduleDurableExecutors.clear(); }
internalExecutor = new LoggingScheduledExecutor(logger, internalPoolSize, new PoolExecutorThreadFactory(name + ".internal-", classLoader), properties.getBoolean(TASK_SCHEDULER_REMOVE_ON_CANCEL),
@Override public boolean cancel(boolean mayInterruptIfRunning) { boolean removeOnCancel = !executor.isShutdown(); boolean cancelled = delegate.cancel(mayInterruptIfRunning); if (cancelled && removeOnCancel) { executor.remove(this); } return cancelled; }
public LoggingScheduledExecutor(ILogger logger, int corePoolSize, ThreadFactory threadFactory, boolean removeOnCancel, RejectedExecutionHandler handler) { super(corePoolSize, threadFactory, handler); this.logger = checkNotNull(logger, "logger cannot be null"); this.manualRemoveOnCancel = manualRemoveOnCancel(removeOnCancel); }
this.scheduledExecutorService = new LoggingScheduledExecutor(logger, 1, singleExecutorThreadFactory, nodeEngine.getProperties().getBoolean(GroupProperty.TASK_SCHEDULER_REMOVE_ON_CANCEL));
private boolean manualRemoveOnCancel(boolean removeOnCancel) { if (trySetRemoveOnCancelPolicy()) { return false; } else { return removeOnCancel; } }
public LoggingScheduledExecutor(ILogger logger, int corePoolSize, ThreadFactory threadFactory, boolean removeOnCancel) { super(corePoolSize, threadFactory); this.logger = checkNotNull(logger, "logger cannot be null"); this.manualRemoveOnCancel = manualRemoveOnCancel(removeOnCancel); }
this.scheduledExecutorService = new LoggingScheduledExecutor(logger, 1, singleExecutorThreadFactory, nodeEngine.getProperties().getBoolean(GroupProperty.TASK_SCHEDULER_REMOVE_ON_CANCEL));
public LoggingScheduledExecutor(ILogger logger, int corePoolSize, ThreadFactory threadFactory, boolean removeOnCancel, RejectedExecutionHandler handler) { super(corePoolSize, threadFactory, handler); this.logger = checkNotNull(logger, "logger cannot be null"); this.manualRemoveOnCancel = manualRemoveOnCancel(removeOnCancel); }