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;
}
Aggregations