Search in sources :

Example 1 with OrderedTaskCollection

use of com.serotonin.timer.OrderedThreadPoolExecutor.OrderedTaskCollection in project ma-core-public by infiniteautomation.

the class TaskRejectionHandler method rejectedExecution.

/*
	 * This will be called by the Executor when Runnable's are not executable due to pool constraints
	 * (non-Javadoc)
	 * @see java.util.concurrent.RejectedExecutionHandler#rejectedExecution(java.lang.Runnable, java.util.concurrent.ThreadPoolExecutor)
	 */
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
    if (r instanceof TaskWrapper) {
        TaskWrapper wrapper = (TaskWrapper) r;
        RejectedTaskReason reason = new RejectedTaskReason(RejectedTaskReason.POOL_FULL, wrapper.getExecutionTime(), wrapper.getTask(), e);
        wrapper.getTask().rejected(reason);
        this.rejectedTask(reason);
    } else if (r instanceof OrderedTaskCollection) {
        // Pool must be full since the entire collection was rejected
        TaskWrapper wrapper = ((OrderedTaskCollection) r).getWrapper();
        RejectedTaskReason reason = new RejectedTaskReason(RejectedTaskReason.POOL_FULL, wrapper.getExecutionTime(), wrapper.getTask(), e);
        wrapper.getTask().rejected(reason);
        this.rejectedTask(reason);
    } else {
        log.fatal("SHOULD NOT HAPPEN: " + r.toString());
    }
}
Also used : TaskWrapper(com.serotonin.timer.TaskWrapper) RejectedTaskReason(com.serotonin.timer.RejectedTaskReason) OrderedTaskCollection(com.serotonin.timer.OrderedThreadPoolExecutor.OrderedTaskCollection)

Aggregations

OrderedTaskCollection (com.serotonin.timer.OrderedThreadPoolExecutor.OrderedTaskCollection)1 RejectedTaskReason (com.serotonin.timer.RejectedTaskReason)1 TaskWrapper (com.serotonin.timer.TaskWrapper)1