Example usage for java.util.concurrent ThreadPoolExecutor getTaskCount

List of usage examples for java.util.concurrent ThreadPoolExecutor getTaskCount

Introduction

In this page you can find the example usage for java.util.concurrent ThreadPoolExecutor getTaskCount.

Prototype

public long getTaskCount() 

Source Link

Document

Returns the approximate total number of tasks that have ever been scheduled for execution.

Usage

From source file:org.apache.jackrabbit.oak.plugins.segment.SegmentDataStoreBlobGCIT.java

private Set<String> gcInternal(long maxBlobGcInSecs) throws Exception {
    ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
    MarkSweepGarbageCollector gc = init(maxBlobGcInSecs, executor);
    gc.collectGarbage(false);//from  www. j ava2  s. co  m

    assertEquals(0, executor.getTaskCount());
    Set<String> existingAfterGC = iterate();
    log.info("{} blobs existing after gc : {}", existingAfterGC.size(), existingAfterGC);
    return existingAfterGC;
}

From source file:org.paxle.filter.robots.impl.RobotsTxtManager.java

/**
 * {@inheritDoc}//  w ww .  j  a  va  2 s .  c  o  m
 * @see org.osgi.service.monitor.Monitorable#getStatusVariable(String)
 */
public StatusVariable getStatusVariable(String id) throws IllegalArgumentException {
    if (!VAR_NAMES.contains(id)) {
        throw new IllegalArgumentException("Invalid Status Variable name " + id);
    }

    int val = 0;
    int type = StatusVariable.CM_GAUGE;

    if (id.equals(MONITOR_STORE_SIZE)) {
        val = this.loader.size();
    } else if (id.startsWith(MONITOR_JOBS_PREFIX)) {
        ThreadPoolExecutor execService = this.execService;
        if (id.equals(MONITOR_JOBS_ACTIVE)) {
            val = execService.getActiveCount();
        } else if (id.equals(MONITOR_JOBS_IDLE)) {
            long max = execService.getMaximumPoolSize();
            long active = execService.getActiveCount();
            val = (int) (max - active);
        } else if (id.equals(MONITOR_JOBS_MAX)) {
            val = execService.getMaximumPoolSize();
        } else if (id.equals(MONITOR_JOBS_PENDING)) {
            long enqued = execService.getTaskCount();
            long total = execService.getCompletedTaskCount();
            long active = execService.getActiveCount();
            val = (int) (enqued - total - active);
        } else if (id.equals(MONITOR_JOBS_TOTAL)) {
            val = (int) execService.getCompletedTaskCount();
            type = StatusVariable.CM_CC;
        }
    }

    return new StatusVariable(id, type, val);
}