improve thread pool rejection message

This commit is contained in:
Shay Banon 2013-10-03 07:41:57 -07:00
parent e53a26ff21
commit 373e64b3eb
2 changed files with 14 additions and 1 deletions

View File

@ -49,7 +49,16 @@ public class EsAbortPolicy implements XRejectedExecutionHandler {
} }
} }
rejected.inc(); rejected.inc();
throw new EsRejectedExecutionException("rejected execution of [" + r.getClass().getName() + "]"); StringBuilder sb = new StringBuilder("rejected execution ");
if (executor.isShutdown()) {
sb.append("(shutting down) ");
} else {
if (executor.getQueue() instanceof SizeBlockingQueue) {
sb.append("(queue capacity ").append(((SizeBlockingQueue) executor.getQueue()).capacity()).append(") ");
}
}
sb.append("on ").append(r.toString());
throw new EsRejectedExecutionException(sb.toString());
} }
@Override @Override

View File

@ -51,6 +51,10 @@ public class SizeBlockingQueue<E> extends AbstractQueue<E> implements BlockingQu
return size.get(); return size.get();
} }
public int capacity() {
return this.capacity;
}
@Override @Override
public Iterator<E> iterator() { public Iterator<E> iterator() {
final Iterator<E> it = queue.iterator(); final Iterator<E> it = queue.iterator();