Пример #1
0
 @Override
 protected void afterExecute(Runnable r, Throwable t) {
   super.afterExecute(r, t);
   Thread thread = (Thread) r;
   runningThreadNames.remove(thread.getName());
   logger.debug("{} ===================> Finished.", thread.getName());
 }
  /** {@inheritDoc} */
  @Override
  protected void afterExecute(final Runnable r, final Throwable t) {
    super.afterExecute(r, t);

    this.pending.remove(r);

    Throwable rootCause = null;
    if (t == null && r instanceof Future<?>) {
      try {
        final Object result = ((Future<?>) r).get();
        if (result != null) {
          LOGGER.log(FUTURE_DONE, r.hashCode(), result.toString());
        }
      } catch (final CancellationException | ExecutionException e) {
        rootCause = e.getCause();
      } catch (final InterruptedException ie) {
        Thread.currentThread().interrupt(); // ignore/reset
      }
    }
    if (t != null) {
      LOGGER.log(JTP_ERROR, t);
    }
    if (rootCause != null) {
      LOGGER.log(JTP_ERROR_EXPLANATION, rootCause);
    }
  }
 @Override
 protected void afterExecute(Runnable r, Throwable th) {
   // TODO Auto-generated method stub
   super.afterExecute(r, th);
   Date now = new Date();
   System.out.println(MessageFormat.format("Starting to execute:{0} at {1}", r.toString(), now));
 }
Пример #4
0
  @Override
  protected void afterExecute(Runnable r, Throwable t) {

    super.afterExecute(r, t);

    try {
      long endTime = System.currentTimeMillis();
      long taskTime = endTime - startTime.get();

      numTasks.incrementAndGet();
      totalTime.addAndGet(taskTime);

      log.info(String.format("%s: end %s,time = %dns", t, r, taskTime));
    } finally {
      super.afterExecute(r, t);
    }
  }
Пример #5
0
 @Override
 protected void afterExecute(Runnable r, Throwable t) {
   try {
     semaphore.release();
   } finally {
     super.afterExecute(r, t);
   }
 }
  @Override
  protected void afterExecute(Runnable r, Throwable t) {
    super.afterExecute(r, t);

    SPARQLSearchThread thread = (SPARQLSearchThread) r;

    if (t == null) matcher.deleteRunningThread(thread.getN());
    else System.out.println("Anomaly: " + thread.getN() + "," + t);
  }
    /**
     * @param runnable the <code>Retriever</code> running on the thread
     * @param throwable an exception thrown during retrieval, will be null if no exception occurred
     * @throws IllegalArgumentException if <code>runnable</code> is null
     */
    @Override
    protected void afterExecute(Runnable runnable, Throwable throwable) {
      if (runnable == null) {
        String msg = Logging.getMessage("nullValue.RunnableIsNull");
        Logging.logger().fine(msg);
        throw new IllegalArgumentException(msg);
      }

      super.afterExecute(runnable, throwable);

      RetrievalTask task = (RetrievalTask) runnable;
      DownloaderRetrievalService.this.activeTasks.remove(task);
      task.retriever.setEndTime(System.currentTimeMillis());

      try {
        if (throwable != null) {
          Logging.logger()
              .log(
                  Level.FINE,
                  Logging.getMessage(
                      "BasicRetrievalService.ExceptionDuringRetrieval",
                      task.getRetriever().getName()),
                  throwable);
        }

        task.get(); // Wait for task to finish, cancel or break
      } catch (java.util.concurrent.ExecutionException e) {
        String message =
            Logging.getMessage(
                "BasicRetrievalService.ExecutionExceptionDuringRetrieval",
                task.getRetriever().getName());
        if (e.getCause() instanceof SocketTimeoutException) {
          Logging.logger().fine(message + " " + e.getCause().getLocalizedMessage());
        } else if (e.getCause() instanceof SSLHandshakeException) {
          if (sslExceptionListener != null)
            sslExceptionListener.onException(e.getCause(), task.getRetriever().getName());
          else Logging.logger().fine(message + " " + e.getCause().getLocalizedMessage());
        } else {
          Logging.logger().log(Level.FINE, message, e);
        }
      } catch (InterruptedException e) {
        Logging.logger()
            .log(
                Level.FINE,
                Logging.getMessage(
                    "BasicRetrievalService.RetrievalInterrupted", task.getRetriever().getName()),
                e);
      } catch (java.util.concurrent.CancellationException e) {
        Logging.logger()
            .fine(
                Logging.getMessage(
                    "BasicRetrievalService.RetrievalCancelled", task.getRetriever().getName()));
      } finally {
        Thread.currentThread().setName(IDLE_THREAD_NAME_PREFIX);
      }
    }
  @Override
  public void afterExecute(Runnable r, Throwable t) {
    super.afterExecute(r, t);

    /*
     * clean up what we can after every render job
     *
     * we should really be keeping RenderJob/Scene pools
     */
    if (usePurgatory) {
      Screen screen = Screen.getMainScreen();
      Renderer renderer = Renderer.getRenderer(PrFilterContext.getInstance(screen));
      renderer.releasePurgatory();
    }
  }
 @Override
 protected void afterExecute(Runnable runnable, Throwable throwable) {
   super.afterExecute(runnable, throwable);
   if (throwable != null) {
     Throwable cause = Exceptions.unwrap(throwable);
     if (cause instanceof InterruptedException) {
       // Ignore this, might happen when we shutdownNow() the executor. We can't
       // log at this point as the logging system might be stopped already (e.g.
       // if it's a CDI component).
       return;
     }
     // Log only
     Logger.getLogger(DefaultUpnpServiceConfiguration.class.getName())
         .warning("Thread terminated " + runnable + " abruptly with exception: " + throwable);
     Logger.getLogger(DefaultUpnpServiceConfiguration.class.getName())
         .warning("Root cause: " + cause);
   }
 }
  public void afterExecute(Runnable r, Throwable t) {
    super.afterExecute(r, t);

    // exceptions wrapped by FutureTask
    if (r instanceof FutureTask) {
      try {
        ((FutureTask) r).get();
      } catch (InterruptedException e) {
        throw new AssertionError(e);
      } catch (ExecutionException e) {
        logger.error("Error in executor futuretask", e);
      }
    }

    // exceptions for non-FutureTask runnables [i.e., added via execute() instead of submit()]
    if (t != null) {
      logger.error("Error in ThreadPoolExecutor", t);
    }
  }
Пример #11
0
 @Override
 protected void afterExecute(Runnable r, Throwable t) {
   super.afterExecute(r, t);
   if (t == null) {
     System.out.println(Thread.currentThread().getId() + " has been succeesfully finished!");
   } else {
     System.out.println(Thread.currentThread().getId() + " errroed! Retry");
   }
   for (Future<?> future : mRunnable_Monitor_HashMap.keySet()) {
     if (future.isDone() == false) {
       DownloadRunnable runnable = (DownloadRunnable) mRunnable_Monitor_HashMap.get(future);
       DownloadRunnable newRunnable = runnable.split();
       if (newRunnable != null) {
         submit(newRunnable);
         break;
       }
     }
   }
 }
 @Override
 protected void afterExecute(Runnable r, Throwable t) {
   super.afterExecute(r, t);
   DebugLog.d(TAG, "XThreadPoolExecutor->afterExecute !" + ((PriorityFutureTask) r).getPriority());
 }
Пример #13
0
 @Override
 protected void afterExecute(Runnable r, Throwable t) {
   super.afterExecute(r, t);
   running.remove(Thread.currentThread());
 }
 @Override
 protected void afterExecute(Runnable r, Throwable t) {
   super.afterExecute(r, t);
   logExceptionsAfterExecute(r, t);
 }