/** * Find the RetrieveColumnRunnable from map and waiting queue. Map stores running runnables * * @param key * @return */ public synchronized RetrieveColumnRunnable getRunnable(INoSQLSchemaNode node) { // Get the runnable from map first, else then find it in the waiting queue. RetrieveColumnRunnable runnable = remainRunnables.get(node); if (runnable != null) { return runnable; } for (Object element : getQueue()) { RetrieveColumnRunnable ele = (RetrieveColumnRunnable) element; if (ele.getNode() == node) { return ele; } } return null; }
/* * (non-Javadoc) * * @see java.util.concurrent.ThreadPoolExecutor#beforeExecute(java.lang.Thread, java.lang.Runnable) */ @Override protected void beforeExecute(Thread t, Runnable r) { RetrieveColumnRunnable runnable = (RetrieveColumnRunnable) r; remainRunnables.put(runnable.getNode(), runnable); }
/* * (non-Javadoc) * * @see java.util.concurrent.ThreadPoolExecutor#afterExecute(java.lang.Runnable, java.lang.Throwable) */ @Override protected void afterExecute(Runnable r, Throwable t) { RetrieveColumnRunnable runnable = (RetrieveColumnRunnable) r; remainRunnables.remove(runnable.getNode()); }