Example usage for org.apache.commons.collections.map LRUMap size

List of usage examples for org.apache.commons.collections.map LRUMap size

Introduction

In this page you can find the example usage for org.apache.commons.collections.map LRUMap size.

Prototype

public int size() 

Source Link

Document

Gets the size of the map.

Usage

From source file:de.suse.swamp.modules.screens.Debug.java

public void doBuildTemplate(RunData data, Context context) throws Exception {
    super.doBuildTemplate(data, context);

    // Memory Stuff 
    long totalMem = Runtime.getRuntime().totalMemory() / 1024l / 1024l;
    int cpu = Runtime.getRuntime().availableProcessors();
    long freeMem = Runtime.getRuntime().freeMemory() / 1024l / 1024l;
    long usedMem = totalMem - freeMem;
    String user = data.getUser().getName();
    SWAMPAPI swamp = new SWAMPAPI();
    WorkflowAPI wfApi = new WorkflowAPI();
    TaskAPI taskApi = new TaskAPI();
    SecurityAPI secApi = new SecurityAPI();
    DataAPI dataApi = new DataAPI();

    context.put("bootdate", swamp.doGetProperty("bootDate", user));
    context.put("standardlogo", "true");

    context.put("totalMem", String.valueOf(totalMem));
    context.put("cpu", String.valueOf(cpu));
    context.put("freeMem", String.valueOf(freeMem));
    context.put("usedMem", String.valueOf(usedMem));

    context.put("buildtime", swamp.doGetProperty("BUILDTIME", user));
    context.put("buildhost", swamp.doGetProperty("BUILDHOST", user));

    // cache information: 
    context.put("taskcachesize", String.valueOf(taskApi.doGetTaskCacheSize(user)));
    LRUMap cache = wfApi.doGetWorkflowCache(user);
    context.put("cacheMaxsize", String.valueOf(cache.maxSize()));
    context.put("cachesize", String.valueOf(cache.size()));
    context.put("usercachesize", String.valueOf(secApi.doGetUserCacheSize(user)));
    context.put("datacachesize", String.valueOf(dataApi.doGetDatacacheSize(user)));

    // job scheduler (TurbineSchedulerService)
    context.put("jobs", TurbineScheduler.listJobs());

}

From source file:org.apache.jackrabbit.core.query.lucene.DocNumberCache.java

/**
 * Returns the cache entry for <code>uuid</code>, or <code>null</code> if
 * no entry exists for <code>uuid</code>.
 *
 * @param uuid the key./*from w  w w  . ja  v a 2 s .co m*/
 * @return cache entry or <code>null</code>.
 */
Entry get(String uuid) {
    LRUMap cacheSegment = docNumbers[getSegmentIndex(uuid.charAt(0))];
    Entry entry;
    synchronized (cacheSegment) {
        entry = (Entry) cacheSegment.get(uuid);
    }
    if (log.isInfoEnabled()) {
        accesses++;
        if (entry == null) {
            misses++;
        }
        // log at most after 1000 accesses and every 10 seconds
        if (accesses > 1000 && System.currentTimeMillis() - lastLog > LOG_INTERVAL) {
            long ratio = 100;
            if (misses != 0) {
                ratio -= misses * 100L / accesses;
            }
            StringBuffer statistics = new StringBuffer();
            int inUse = 0;
            for (LRUMap docNumber : docNumbers) {
                inUse += docNumber.size();
            }
            statistics.append("size=").append(inUse);
            statistics.append("/").append(docNumbers[0].maxSize() * CACHE_SEGMENTS);
            statistics.append(", #accesses=").append(accesses);
            statistics.append(", #hits=").append((accesses - misses));
            statistics.append(", #misses=").append(misses);
            statistics.append(", cacheRatio=").append(ratio).append("%");
            log.info(statistics.toString());
            accesses = 0;
            misses = 0;
            lastLog = System.currentTimeMillis();
        }
    }
    return entry;
}