Search in sources :

Example 1 with ScanRunState

use of org.apache.accumulo.tserver.scan.ScanRunState in project accumulo by apache.

the class SessionManager method getActiveScansPerTable.

public Map<Table.ID, MapCounter<ScanRunState>> getActiveScansPerTable() {
    Map<Table.ID, MapCounter<ScanRunState>> counts = new HashMap<>();
    Set<Entry<Long, Session>> copiedIdleSessions = new HashSet<>();
    synchronized (idleSessions) {
        /**
         * Add sessions so that get the list returned in the active scans call
         */
        for (Session session : idleSessions) {
            copiedIdleSessions.add(Maps.immutableEntry(expiredSessionMarker, session));
        }
    }
    for (Entry<Long, Session> entry : Iterables.concat(sessions.entrySet(), copiedIdleSessions)) {
        Session session = entry.getValue();
        @SuppressWarnings("rawtypes") ScanTask nbt = null;
        Table.ID tableID = null;
        if (session instanceof ScanSession) {
            ScanSession ss = (ScanSession) session;
            nbt = ss.nextBatchTask;
            tableID = ss.extent.getTableId();
        } else if (session instanceof MultiScanSession) {
            MultiScanSession mss = (MultiScanSession) session;
            nbt = mss.lookupTask;
            tableID = mss.threadPoolExtent.getTableId();
        }
        if (nbt == null)
            continue;
        ScanRunState srs = nbt.getScanRunState();
        if (srs == ScanRunState.FINISHED)
            continue;
        MapCounter<ScanRunState> stateCounts = counts.get(tableID);
        if (stateCounts == null) {
            stateCounts = new MapCounter<>();
            counts.put(tableID, stateCounts);
        }
        stateCounts.increment(srs, 1);
    }
    return counts;
}
Also used : Table(org.apache.accumulo.core.client.impl.Table) ScanTask(org.apache.accumulo.tserver.scan.ScanTask) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Entry(java.util.Map.Entry) MapCounter(org.apache.accumulo.core.util.MapCounter) ScanRunState(org.apache.accumulo.tserver.scan.ScanRunState) HashSet(java.util.HashSet)

Aggregations

HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Entry (java.util.Map.Entry)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Table (org.apache.accumulo.core.client.impl.Table)1 MapCounter (org.apache.accumulo.core.util.MapCounter)1 ScanRunState (org.apache.accumulo.tserver.scan.ScanRunState)1 ScanTask (org.apache.accumulo.tserver.scan.ScanTask)1