SchedulerApplicationAttempt { public synchronized void move(Queue newQueue) { QueueMetrics oldMetrics = queue.getMetrics(); QueueMetrics newMetrics = newQueue.getMetrics(); String user = getUser(); for (RMContainer liveContainer : liveContainers.values()) { Resource resource = liveContainer.getContainer().getResource(); oldMetrics.releaseResources(user, 1, resource); newMetrics.allocateResources(user, 1, resource, false); } for (Map<NodeId, RMContainer> map : reservedContainers.values()) { for (RMContainer reservedContainer : map.values()) { Resource resource = reservedContainer.getReservedResource(); oldMetrics.unreserveResource(user, resource); newMetrics.reserveResource(user, resource); } } appSchedulingInfo.move(newQueue); this.queue = newQueue; } SchedulerApplicationAttempt(ApplicationAttemptId applicationAttemptId, 
      String user, Queue queue, ActiveUsersManager activeUsersManager,
      RMContext rmContext); synchronized Collection<RMContainer> getLiveContainers(); boolean isPending(); ApplicationAttemptId getApplicationAttemptId(); ApplicationId getApplicationId(); String getUser(); Map<String, ResourceRequest> getResourceRequests(Priority priority); Set<ContainerId> getPendingRelease(); long getNewContainerId(); Collection<Priority> getPriorities(); synchronized ResourceRequest getResourceRequest(Priority priority, String resourceName); synchronized int getTotalRequiredResources(Priority priority); synchronized Resource getResource(Priority priority); String getQueueName(); Resource getAMResource(); void setAMResource(Resource amResource); boolean isAmRunning(); void setAmRunning(boolean bool); boolean getUnmanagedAM(); synchronized RMContainer getRMContainer(ContainerId id); synchronized int getReReservations(Priority priority); @Stable @Private synchronized Resource getCurrentReservation(); Queue getQueue(); synchronized void updateResourceRequests(
      List<ResourceRequest> requests); synchronized void recoverResourceRequests(
      List<ResourceRequest> requests); synchronized void stop(RMAppAttemptState rmAppAttemptFinalState); synchronized boolean isStopped(); synchronized List<RMContainer> getReservedContainers(); synchronized RMContainer reserve(SchedulerNode node, Priority priority,
      RMContainer rmContainer, Container container); synchronized boolean isReserved(SchedulerNode node, Priority priority); synchronized void setHeadroom(Resource globalLimit); synchronized Resource getHeadroom(); synchronized int getNumReservedContainers(Priority priority); @SuppressWarnings("unchecked") synchronized void containerLaunchedOnNode(ContainerId containerId,
      NodeId nodeId); synchronized void showRequests(); Resource getCurrentConsumption(); synchronized ContainersAndNMTokensAllocation pullNewlyAllocatedContainersAndNMTokens(); synchronized void updateBlacklist(
      List<String> blacklistAdditions, List<String> blacklistRemovals); boolean isBlacklisted(String resourceName); synchronized void addSchedulingOpportunity(Priority priority); synchronized void subtractSchedulingOpportunity(Priority priority); synchronized int getSchedulingOpportunities(Priority priority); synchronized void resetSchedulingOpportunities(Priority priority); synchronized void resetSchedulingOpportunities(Priority priority,
      long currentTimeMs); synchronized ApplicationResourceUsageReport getResourceUsageReport(); synchronized Map<ContainerId, RMContainer> getLiveContainersMap(); synchronized Resource getResourceLimit(); synchronized Map<Priority, Long> getLastScheduledContainer(); synchronized void transferStateFromPreviousAttempt(
      SchedulerApplicationAttempt appAttempt); synchronized void move(Queue newQueue); synchronized void recoverContainer(RMContainer rmContainer); Set<String> getBlacklistedNodes();  }
@Test public void testMove() { final String user = "user1"; Queue parentQueue = createQueue("parent", null); Queue oldQueue = createQueue("old", parentQueue); Queue newQueue = createQueue("new", parentQueue); QueueMetrics parentMetrics = parentQueue.getMetrics(); QueueMetrics oldMetrics = oldQueue.getMetrics(); QueueMetrics newMetrics = newQueue.getMetrics(); ApplicationAttemptId appAttId = createAppAttemptId(0, 0); RMContext rmContext = mock(RMContext.class); when(rmContext.getEpoch()).thenReturn(3L); SchedulerApplicationAttempt app = new SchedulerApplicationAttempt(appAttId, user, oldQueue, oldQueue.getActiveUsersManager(), rmContext); oldMetrics.submitApp(user); assertEquals(0x30000000001L, app.getNewContainerId()); Resource requestedResource = Resource.newInstance(1536, 2); Priority requestedPriority = Priority.newInstance(2); ResourceRequest request = ResourceRequest.newInstance(requestedPriority, ResourceRequest.ANY, requestedResource, 3); app.updateResourceRequests(Arrays.asList(request)); RMContainer container1 = createRMContainer(appAttId, 1, requestedResource); app.liveContainers.put(container1.getContainerId(), container1); SchedulerNode node = createNode(); app.appSchedulingInfo.allocate(NodeType.OFF_SWITCH, node, requestedPriority, request, container1.getContainer()); Priority prio1 = Priority.newInstance(1); Resource reservedResource = Resource.newInstance(2048, 3); RMContainer container2 = createReservedRMContainer(appAttId, 1, reservedResource, node.getNodeID(), prio1); Map<NodeId, RMContainer> reservations = new HashMap<NodeId, RMContainer>(); reservations.put(node.getNodeID(), container2); app.reservedContainers.put(prio1, reservations); oldMetrics.reserveResource(user, reservedResource); checkQueueMetrics(oldMetrics, 1, 1, 1536, 2, 2048, 3, 3072, 4); checkQueueMetrics(newMetrics, 0, 0, 0, 0, 0, 0, 0, 0); checkQueueMetrics(parentMetrics, 1, 1, 1536, 2, 2048, 3, 3072, 4); app.move(newQueue); checkQueueMetrics(oldMetrics, 0, 0, 0, 0, 0, 0, 0, 0); checkQueueMetrics(newMetrics, 1, 1, 1536, 2, 2048, 3, 3072, 4); checkQueueMetrics(parentMetrics, 1, 1, 1536, 2, 2048, 3, 3072, 4); }