Return-Path: X-Original-To: apmail-hadoop-yarn-commits-archive@minotaur.apache.org Delivered-To: apmail-hadoop-yarn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 96D3ED2E0 for ; Fri, 7 Sep 2012 00:30:51 +0000 (UTC) Received: (qmail 3056 invoked by uid 500); 7 Sep 2012 00:30:51 -0000 Delivered-To: apmail-hadoop-yarn-commits-archive@hadoop.apache.org Received: (qmail 3031 invoked by uid 500); 7 Sep 2012 00:30:51 -0000 Mailing-List: contact yarn-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: yarn-commits@hadoop.apache.org Delivered-To: mailing list yarn-commits@hadoop.apache.org Received: (qmail 3022 invoked by uid 99); 7 Sep 2012 00:30:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2012 00:30:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2012 00:30:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3AEB123888EA; Fri, 7 Sep 2012 00:30:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1381823 - /hadoop/common/branches/branch-2.1.0-alpha/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java Date: Fri, 07 Sep 2012 00:30:07 -0000 To: yarn-commits@hadoop.apache.org From: vinodkv@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120907003007.3AEB123888EA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: vinodkv Date: Fri Sep 7 00:30:06 2012 New Revision: 1381823 URL: http://svn.apache.org/viewvc?rev=1381823&view=rev Log: YARN-75. Fixing spurious patch apply. Modified: hadoop/common/branches/branch-2.1.0-alpha/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java Modified: hadoop/common/branches/branch-2.1.0-alpha/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1.0-alpha/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java?rev=1381823&r1=1381822&r2=1381823&view=diff ============================================================================== --- hadoop/common/branches/branch-2.1.0-alpha/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java (original) +++ hadoop/common/branches/branch-2.1.0-alpha/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java Fri Sep 7 00:30:06 2012 @@ -117,122 +117,3 @@ public class TestRMContainerImpl { } } -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.server.resourcemanager.rmcontainer; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; - -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.Container; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ContainerStatus; -import org.apache.hadoop.yarn.api.records.NodeId; -import org.apache.hadoop.yarn.api.records.Priority; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.conf.YarnConfiguration; -import org.apache.hadoop.yarn.event.DrainDispatcher; -import org.apache.hadoop.yarn.event.EventHandler; -import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEvent; -import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEventType; -import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptContainerFinishedEvent; -import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeEventType; -import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils; -import org.apache.hadoop.yarn.util.BuilderUtils; -import org.junit.Test; -import org.mockito.ArgumentCaptor; - -@SuppressWarnings({ "unchecked", "rawtypes" }) -public class TestRMContainerImpl { - - @Test - public void testReleaseWhileRunning() { - - DrainDispatcher drainDispatcher = new DrainDispatcher(); - EventHandler eventHandler = drainDispatcher.getEventHandler(); - EventHandler appAttemptEventHandler = mock(EventHandler.class); - EventHandler generic = mock(EventHandler.class); - drainDispatcher.register(RMAppAttemptEventType.class, - appAttemptEventHandler); - drainDispatcher.register(RMNodeEventType.class, generic); - drainDispatcher.init(new YarnConfiguration()); - drainDispatcher.start(); - NodeId nodeId = BuilderUtils.newNodeId("host", 3425); - ApplicationId appId = BuilderUtils.newApplicationId(1, 1); - ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId( - appId, 1); - ContainerId containerId = BuilderUtils.newContainerId(appAttemptId, 1); - ContainerAllocationExpirer expirer = mock(ContainerAllocationExpirer.class); - - Resource resource = BuilderUtils.newResource(512); - Priority priority = BuilderUtils.newPriority(5); - - Container container = BuilderUtils.newContainer(containerId, nodeId, - "host:3465", resource, priority, null); - - RMContainer rmContainer = new RMContainerImpl(container, appAttemptId, - nodeId, eventHandler, expirer); - - assertEquals(RMContainerState.NEW, rmContainer.getState()); - - rmContainer.handle(new RMContainerEvent(containerId, - RMContainerEventType.START)); - drainDispatcher.await(); - assertEquals(RMContainerState.ALLOCATED, rmContainer.getState()); - - rmContainer.handle(new RMContainerEvent(containerId, - RMContainerEventType.ACQUIRED)); - drainDispatcher.await(); - assertEquals(RMContainerState.ACQUIRED, rmContainer.getState()); - - rmContainer.handle(new RMContainerEvent(containerId, - RMContainerEventType.LAUNCHED)); - drainDispatcher.await(); - assertEquals(RMContainerState.RUNNING, rmContainer.getState()); - - // In RUNNING state. Verify RELEASED and associated actions. - reset(appAttemptEventHandler); - ContainerStatus containerStatus = SchedulerUtils - .createAbnormalContainerStatus(containerId, - SchedulerUtils.RELEASED_CONTAINER); - rmContainer.handle(new RMContainerFinishedEvent(containerId, - containerStatus, RMContainerEventType.RELEASED)); - drainDispatcher.await(); - assertEquals(RMContainerState.RELEASED, rmContainer.getState()); - - ArgumentCaptor captor = ArgumentCaptor - .forClass(RMAppAttemptContainerFinishedEvent.class); - verify(appAttemptEventHandler).handle(captor.capture()); - RMAppAttemptContainerFinishedEvent cfEvent = captor.getValue(); - assertEquals(appAttemptId, cfEvent.getApplicationAttemptId()); - assertEquals(containerStatus, cfEvent.getContainerStatus()); - assertEquals(RMAppAttemptEventType.CONTAINER_FINISHED, cfEvent.getType()); - - // In RELEASED state. A FINIHSED event may come in. - rmContainer.handle(new RMContainerFinishedEvent(containerId, SchedulerUtils - .createAbnormalContainerStatus(containerId, "FinishedContainer"), - RMContainerEventType.FINISHED)); - assertEquals(RMContainerState.RELEASED, rmContainer.getState()); - } - -}