YARN-1007. Enhance History Reader interface for Containers. Contributed by Mayank Bansal.
svn merge --ignore-ancestry -c 1556723 ../YARN-321 git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1562180 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ddd48ba1cb
commit
e4d6b2f485
|
@ -474,6 +474,9 @@ Branch YARN-321: Generic ApplicationHistoryService
|
|||
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.2.0 - 2013-10-13
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -94,4 +94,16 @@ public interface ApplicationHistoryReader {
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -161,4 +161,17 @@ public class MemoryApplicationHistoryStore implements ApplicationHistoryStore {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 TestMemoryApplicationHistoryStore {
|
|||
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 TestMemoryApplicationHistoryStore {
|
|||
.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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue