Search in sources :

Example 1 with CDCExecutorServiceDecorator

use of org.dcache.util.CDCExecutorServiceDecorator in project dcache by dCache.

the class UnpinProcessor method run.

@Override
public void run() {
    final ExecutorService executor = new CDCExecutorServiceDecorator(Executors.newSingleThreadExecutor());
    NDC.push("BackgroundUnpinner-" + _count.incrementAndGet());
    try {
        Semaphore idle = new Semaphore(MAX_RUNNING);
        unpin(idle, executor);
        idle.acquire(MAX_RUNNING);
    } catch (InterruptedException e) {
        LOGGER.debug(e.toString());
    } catch (JDOException | DataAccessException e) {
        LOGGER.error("Database failure while unpinning: {}", e.getMessage());
    } catch (RemoteConnectFailureException e) {
        LOGGER.error("Remote connection failure while unpinning: {}", e.getMessage());
    } catch (RuntimeException e) {
        LOGGER.error("Unexpected failure while unpinning", e);
    } finally {
        executor.shutdown();
        NDC.pop();
    }
}
Also used : RemoteConnectFailureException(org.springframework.remoting.RemoteConnectFailureException) ExecutorService(java.util.concurrent.ExecutorService) CDCExecutorServiceDecorator(org.dcache.util.CDCExecutorServiceDecorator) Semaphore(java.util.concurrent.Semaphore) DataAccessException(org.springframework.dao.DataAccessException) JDOException(javax.jdo.JDOException)

Aggregations

ExecutorService (java.util.concurrent.ExecutorService)1 Semaphore (java.util.concurrent.Semaphore)1 JDOException (javax.jdo.JDOException)1 CDCExecutorServiceDecorator (org.dcache.util.CDCExecutorServiceDecorator)1 DataAccessException (org.springframework.dao.DataAccessException)1 RemoteConnectFailureException (org.springframework.remoting.RemoteConnectFailureException)1