Search in sources :

Example 1 with ApplicationIdPBImpl

use of org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl in project hadoop by apache.

the class TestContainerLogsPage method testLogDirWithDriveLetter.

@Test
public void testLogDirWithDriveLetter() throws Exception {
    //To verify that logs paths which include drive letters (Windows)
    //do not lose their drive letter specification
    LocalDirsHandlerService localDirs = mock(LocalDirsHandlerService.class);
    List<String> logDirs = new ArrayList<String>();
    logDirs.add("F:/nmlogs");
    when(localDirs.getLogDirsForRead()).thenReturn(logDirs);
    ApplicationIdPBImpl appId = mock(ApplicationIdPBImpl.class);
    when(appId.toString()).thenReturn("app_id_1");
    ApplicationAttemptIdPBImpl appAttemptId = mock(ApplicationAttemptIdPBImpl.class);
    when(appAttemptId.getApplicationId()).thenReturn(appId);
    ContainerId containerId = mock(ContainerIdPBImpl.class);
    when(containerId.getApplicationAttemptId()).thenReturn(appAttemptId);
    List<File> logDirFiles = ContainerLogsUtils.getContainerLogDirs(containerId, localDirs);
    Assert.assertTrue("logDir lost drive letter " + logDirFiles.get(0), logDirFiles.get(0).toString().indexOf("F:" + File.separator + "nmlogs") > -1);
}
Also used : ApplicationAttemptIdPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptIdPBImpl) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ArrayList(java.util.ArrayList) LocalDirsHandlerService(org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService) File(java.io.File) ApplicationIdPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl) Test(org.junit.Test)

Example 2 with ApplicationIdPBImpl

use of org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl in project hadoop by apache.

the class ContainerManagerImpl method recoverApplication.

private void recoverApplication(ContainerManagerApplicationProto p) throws IOException {
    ApplicationId appId = new ApplicationIdPBImpl(p.getId());
    Credentials creds = new Credentials();
    creds.readTokenStorageStream(new DataInputStream(p.getCredentials().newInput()));
    List<ApplicationACLMapProto> aclProtoList = p.getAclsList();
    Map<ApplicationAccessType, String> acls = new HashMap<ApplicationAccessType, String>(aclProtoList.size());
    for (ApplicationACLMapProto aclProto : aclProtoList) {
        acls.put(ProtoUtils.convertFromProtoFormat(aclProto.getAccessType()), aclProto.getAcl());
    }
    LogAggregationContext logAggregationContext = null;
    if (p.getLogAggregationContext() != null) {
        logAggregationContext = new LogAggregationContextPBImpl(p.getLogAggregationContext());
    }
    LOG.info("Recovering application " + appId);
    //TODO: Recover flow and flow run ID
    ApplicationImpl app = new ApplicationImpl(dispatcher, p.getUser(), appId, creds, context, p.getAppLogAggregationInitedTime());
    context.getApplications().put(appId, app);
    app.handle(new ApplicationInitEvent(appId, acls, logAggregationContext));
}
Also used : HashMap(java.util.HashMap) ApplicationImpl(org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationImpl) ApplicationInitEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationInitEvent) ByteString(com.google.protobuf.ByteString) DataInputStream(java.io.DataInputStream) LogAggregationContextPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.LogAggregationContextPBImpl) ApplicationIdPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl) ApplicationAccessType(org.apache.hadoop.yarn.api.records.ApplicationAccessType) ApplicationACLMapProto(org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Credentials(org.apache.hadoop.security.Credentials) LogAggregationContext(org.apache.hadoop.yarn.api.records.LogAggregationContext)

Example 3 with ApplicationIdPBImpl

use of org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl in project hadoop by apache.

the class TestContainerLogsPage method testLogFileWithDriveLetter.

@Test
public void testLogFileWithDriveLetter() throws Exception {
    ContainerImpl container = mock(ContainerImpl.class);
    ApplicationIdPBImpl appId = mock(ApplicationIdPBImpl.class);
    when(appId.toString()).thenReturn("appId");
    Application app = mock(Application.class);
    when(app.getAppId()).thenReturn(appId);
    ApplicationAttemptIdPBImpl appAttemptId = mock(ApplicationAttemptIdPBImpl.class);
    when(appAttemptId.getApplicationId()).thenReturn(appId);
    ConcurrentMap<ApplicationId, Application> applications = new ConcurrentHashMap<ApplicationId, Application>();
    applications.put(appId, app);
    ContainerId containerId = mock(ContainerIdPBImpl.class);
    when(containerId.toString()).thenReturn("containerId");
    when(containerId.getApplicationAttemptId()).thenReturn(appAttemptId);
    ConcurrentMap<ContainerId, Container> containers = new ConcurrentHashMap<ContainerId, Container>();
    containers.put(containerId, container);
    LocalDirsHandlerService localDirs = mock(LocalDirsHandlerService.class);
    when(localDirs.getLogPathToRead("appId" + Path.SEPARATOR + "containerId" + Path.SEPARATOR + "fileName")).thenReturn(new Path("F:/nmlogs/appId/containerId/fileName"));
    NMContext context = mock(NMContext.class);
    when(context.getLocalDirsHandler()).thenReturn(localDirs);
    when(context.getApplications()).thenReturn(applications);
    when(context.getContainers()).thenReturn(containers);
    File logFile = ContainerLogsUtils.getContainerLogFile(containerId, "fileName", null, context);
    Assert.assertTrue("logFile lost drive letter " + logFile, logFile.toString().indexOf("F:" + File.separator + "nmlogs") > -1);
}
Also used : Path(org.apache.hadoop.fs.Path) LocalDirsHandlerService(org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService) ApplicationIdPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl) ApplicationAttemptIdPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptIdPBImpl) Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) NMContext(org.apache.hadoop.yarn.server.nodemanager.NodeManager.NMContext) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ContainerImpl(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerImpl) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Application(org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application) File(java.io.File) Test(org.junit.Test)

Aggregations

ApplicationIdPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl)3 File (java.io.File)2 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)2 ApplicationAttemptIdPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptIdPBImpl)2 LocalDirsHandlerService (org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService)2 Test (org.junit.Test)2 ByteString (com.google.protobuf.ByteString)1 DataInputStream (java.io.DataInputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Path (org.apache.hadoop.fs.Path)1 Credentials (org.apache.hadoop.security.Credentials)1 ApplicationAccessType (org.apache.hadoop.yarn.api.records.ApplicationAccessType)1 LogAggregationContext (org.apache.hadoop.yarn.api.records.LogAggregationContext)1 LogAggregationContextPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.LogAggregationContextPBImpl)1 ApplicationACLMapProto (org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto)1 NMContext (org.apache.hadoop.yarn.server.nodemanager.NodeManager.NMContext)1 Application (org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application)1