Author: devaraj Date: Sat Aug 3 14:44:55 2013 New Revision: 1510001 URL: http://svn.apache.org/r1510001 Log: YARN-1007. Enhance History Reader interface for Containers. Contributed by Mayank Bansal.
Modified: hadoop/common/branches/YARN-321/hadoop-yarn-project/CHANGES.txt hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryReader.java hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/MemoryApplicationHistoryStore.java hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java Modified: hadoop/common/branches/YARN-321/hadoop-yarn-project/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-yarn-project/CHANGES.txt?rev=1510001&r1=1510000&r2=1510001&view=diff ============================================================================== --- hadoop/common/branches/YARN-321/hadoop-yarn-project/CHANGES.txt (original) +++ hadoop/common/branches/YARN-321/hadoop-yarn-project/CHANGES.txt Sat Aug 3 14:44:55 2013 @@ -51,6 +51,9 @@ Branch YARN-321: Generic ApplicationHist YARN-956. Added a testable in-memory HistoryStorage. (Mayank Bansal via vinodkv) + YARN-1007. Enhance History Reader interface for Containers. (Mayank Bansal via + devaraj) + Release 2.1.1-beta - UNRELEASED INCOMPATIBLE CHANGES Modified: hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryReader.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryReader.java?rev=1510001&r1=1510000&r2=1510001&view=diff ============================================================================== --- hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryReader.java (original) +++ hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryReader.java Sat Aug 3 14:44:55 2013 @@ -94,4 +94,16 @@ public interface ApplicationHistoryReade */ ContainerHistoryData getAMContainer(ApplicationAttemptId appAttemptId) throws IOException; + + /** + * This method returns Map{@link ContainerId,@link ContainerHistoryData} for + * specified {@link ApplicationAttemptId}. + * + * @param {@link ApplicationAttemptId} + * @return Map{@link ContainerId, @link ContainerHistoryData} for + * ApplicationAttemptId + * @throws {@link IOException} + */ + Map<ContainerId, ContainerHistoryData> getContainers( + ApplicationAttemptId appAttemptId) throws IOException; } Modified: hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/MemoryApplicationHistoryStore.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/MemoryApplicationHistoryStore.java?rev=1510001&r1=1510000&r2=1510001&view=diff ============================================================================== --- hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/MemoryApplicationHistoryStore.java (original) +++ hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/MemoryApplicationHistoryStore.java Sat Aug 3 14:44:55 2013 @@ -161,4 +161,17 @@ public class MemoryApplicationHistorySto } } } + + @Override + public Map<ContainerId, ContainerHistoryData> getContainers( + ApplicationAttemptId appAttemptId) throws IOException { + HashMap<ContainerId, ContainerHistoryData> containers = + new HashMap<ContainerId, ContainerHistoryData>(); + for (ContainerId container : containerData.keySet()) { + if (container.getApplicationAttemptId().equals(appAttemptId)) { + containers.put(container, containerData.get(container)); + } + } + return containers; + } } Modified: hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java?rev=1510001&r1=1510000&r2=1510001&view=diff ============================================================================== --- hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java (original) +++ hadoop/common/branches/YARN-321/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java Sat Aug 3 14:44:55 2013 @@ -18,6 +18,7 @@ package org.apache.hadoop.yarn.server.applicationhistoryservice; +import java.io.IOException; import java.util.HashMap; import junit.framework.Assert; @@ -67,12 +68,21 @@ public class TestMemoryApplicationHistor memstore.writeContainer(container); } + public ContainerHistoryData writeContainer(ApplicationAttemptId appAttemptId, + int containerId) throws Throwable { + ContainerHistoryData container = new ContainerHistoryDataPBImpl(); + container + .setContainerId(ContainerId.newInstance(appAttemptId, containerId)); + memstore.writeContainer(container); + return container; + } + @After public void tearDown() { } @Test - public void testReadApplication() { + public void testReadApplication() throws Throwable { HashMap<ApplicationId, ApplicationHistoryData> map = (HashMap<ApplicationId, ApplicationHistoryData>) memstore .getAllApplications(); @@ -98,5 +108,13 @@ public class TestMemoryApplicationHistor .newInstance(ApplicationId.newInstance(1234, 1), 1), 1)); Assert.assertEquals("container_1234_0001_01_000001", amContainer .getContainerId().toString()); + ContainerHistoryData container2 = + writeContainer(appAttempt.getApplicationAttemptId(), 2); + HashMap<ContainerId, ContainerHistoryData> containers = + (HashMap<ContainerId, ContainerHistoryData>) memstore + .getContainers(appAttempt.getApplicationAttemptId()); + Assert.assertEquals(2, containers.size()); + Assert.assertEquals("container_1234_0001_01_000002", containers.get( + container2.getContainerId()).getContainerId().toString()); } }