keith-turner commented on code in PR #4871:
URL: https://github.com/apache/accumulo/pull/4871#discussion_r1757718427
##########
server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java:
##########
@@ -453,83 +453,64 @@ public List<ActiveScan> getActiveScans() {
final Set<Entry<Long,Session>> copiedIdleSessions = new HashSet<>();
/**
- * Add sessions so that get the list returned in the active scans call
+ * Add sessions that get the list returned in the active scans call
*/
for (Session session : deferredCleanupQueue) {
copiedIdleSessions.add(Maps.immutableEntry(expiredSessionMarker,
session));
}
List.of(sessions.entrySet(), copiedIdleSessions).forEach(s ->
s.forEach(entry -> {
Session session = entry.getValue();
- if (session instanceof SingleScanSession) {
- SingleScanSession ss = (SingleScanSession) session;
-
- ScanState state = ScanState.RUNNING;
-
- ScanTask<ScanBatch> nbt = ss.getScanTask();
- if (nbt == null) {
- state = ScanState.IDLE;
- } else {
- switch (nbt.getScanRunState()) {
- case QUEUED:
- state = ScanState.QUEUED;
- break;
- case FINISHED:
- state = ScanState.IDLE;
- break;
- case RUNNING:
- default:
- /* do nothing */
- break;
- }
- }
- var params = ss.scanParams;
- ActiveScan activeScan = new ActiveScan(ss.client, ss.getUser(),
- ss.extent.tableId().canonical(), ct - ss.startTime, ct -
ss.lastAccessTime,
- ScanType.SINGLE, state, ss.extent.toThrift(),
-
params.getColumnSet().stream().map(Column::toThrift).collect(Collectors.toList()),
- params.getSsiList(), params.getSsio(),
params.getAuthorizations().getAuthorizationsBB(),
- params.getClassLoaderContext());
+ if (session instanceof ScanSession) {
+ ScanSession<?> scanSession = (ScanSession<?>) session;
+ boolean isSingle = session instanceof SingleScanSession;
- // scanId added by ACCUMULO-2641 is an optional thrift argument and
not available in
- // ActiveScan constructor
- activeScan.setScanId(entry.getKey());
- activeScans.add(activeScan);
+ addActiveScan(activeScans, scanSession,
+ isSingle ? ((SingleScanSession) scanSession).extent
+ : ((MultiScanSession) scanSession).threadPoolExtent,
+ ct, isSingle ? ScanType.SINGLE : ScanType.BATCH,
+ computeScanState(scanSession.getScanTask()),
scanSession.scanParams, entry.getKey());
+ }
+ }));
- } else if (session instanceof MultiScanSession) {
- MultiScanSession mss = (MultiScanSession) session;
+ return activeScans;
+ }
- ScanState state = ScanState.RUNNING;
+ private ScanState computeScanState(ScanTask<?> scanTask) {
Review Comment:
Nice to see this redundant code collapsed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]