private RemoveSessionResult handleReturnedInUseSessionOnMasterThread( EventState e, WmTezSession session, HashSet<String> poolsToRedistribute, boolean isReturn) { // This handles the common logic for destroy and return - everything except // the invalid combination of destroy and return themselves, as well as the actual // statement that destroys or returns it. if (e.updateErrors.remove(session) != null) { LOG.info("Ignoring an update error for a session being destroyed or returned"); } SettableFuture<WmTezSession> future = e.toReopen.remove(session); if (future != null) { future.setException(new AssertionError("Invalid reopen attempt")); } GetRequest reuseRequest = e.toReuse.remove(session); if (reuseRequest != null) { reuseRequest.future.setException(new AssertionError("Invalid reuse attempt")); } session.setQueryId(null); return checkAndRemoveSessionFromItsPool(session, poolsToRedistribute, isReturn, true); }
RemoveSessionResult rr = checkAndRemoveSessionFromItsPool( session, poolsToRedistribute, null, true); switch (rr) {
RemoveSessionResult rr = checkAndRemoveSessionFromItsPool( session, poolsToRedistribute, false, false); switch (rr) {
WmEvent moveEvent = new WmEvent(WmEvent.EventType.MOVE); RemoveSessionResult rr = checkAndRemoveSessionFromItsPool( moveSession.srcSession, poolsToRedistribute, true, true); if (rr == RemoveSessionResult.OK) {
RemoveSessionResult rr = checkAndRemoveSessionFromItsPool( req.sessionToReuse, poolsToRedistribute, true, false); if (rr != RemoveSessionResult.OK) {
private void returnSessionOnFailedReuse( GetRequest req, WmThreadSyncWork syncWork, HashSet<String> poolsToRedistribute) { WmTezSession session = req.sessionToReuse; if (session == null) return; req.sessionToReuse = null; session.setQueryId(null); if (poolsToRedistribute != null) { RemoveSessionResult rr = checkAndRemoveSessionFromItsPool( session, poolsToRedistribute, true, true); // The session cannot have been killed just now; this happens after all the kills in // the current iteration, so we would have cleared sessionToReuse when killing this. boolean isOk = (rr == RemoveSessionResult.OK); assert isOk || rr == RemoveSessionResult.IGNORE; if (!isOk) return; } WmEvent wmEvent = new WmEvent(WmEvent.EventType.RETURN); if (!tezAmPool.returnSessionAsync(session)) { syncWork.toDestroyNoRestart.add(session); } else { if (session.getWmContext() != null && session.getWmContext().isQueryCompleted()) { session.resolveReturnFuture(); } wmEvent.endEvent(session); } }