@Override public void preValidateMoveApplication(ApplicationId appId, String newQueue) throws YarnException { writeLock.lock(); try { SchedulerApplication<FSAppAttempt> app = applications.get(appId); if (app == null) { throw new YarnException("App to be moved " + appId + " not found."); } FSAppAttempt attempt = app.getCurrentAppAttempt(); // To serialize with FairScheduler#allocate, synchronize on app attempt attempt.getWriteLock().lock(); try { FSLeafQueue oldQueue = (FSLeafQueue) app.getQueue(); String destQueueName = handleMoveToPlanQueue(newQueue); FSLeafQueue targetQueue = queueMgr.getLeafQueue(destQueueName, false); if (targetQueue == null) { throw new YarnException("Target queue " + newQueue + " not found or is not a leaf queue."); } if (oldQueue.isRunnableApp(attempt)) { verifyMoveDoesNotViolateConstraints(attempt, oldQueue, targetQueue); } } finally { attempt.getWriteLock().unlock(); } } finally { writeLock.unlock(); } }
attempt.getWriteLock().lock(); try { FSLeafQueue oldQueue = (FSLeafQueue) app.getQueue(); return targetQueue.getQueueName(); } finally { attempt.getWriteLock().unlock();
ReentrantReadWriteLock.WriteLock lock = application.getWriteLock(); lock.lock(); try {