当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationEventType.APPLICATION_LOG_HANDLING_INITED属性代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationEventType.APPLICATION_LOG_HANDLING_INITED属性的典型用法代码示例。如果您正苦于以下问题:Java ApplicationEventType.APPLICATION_LOG_HANDLING_INITED属性的具体用法?Java ApplicationEventType.APPLICATION_LOG_HANDLING_INITED怎么用?Java ApplicationEventType.APPLICATION_LOG_HANDLING_INITED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationEventType的用法示例。


在下文中一共展示了ApplicationEventType.APPLICATION_LOG_HANDLING_INITED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: finishApplication

private void finishApplication(ApplicationId appId,
    LogAggregationService logAggregationService) throws Exception {
  dispatcher.await();
  ApplicationEvent expectedInitEvents[] =
      new ApplicationEvent[] { new ApplicationEvent(appId,
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED) };
  checkEvents(appEventHandler, expectedInitEvents, false, "getType",
      "getApplicationID");
  reset(appEventHandler);

  logAggregationService.handle(new LogHandlerAppFinishedEvent(appId));
  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:14,代码来源:TestLogAggregationService.java

示例2: verifyLocalFileDeletion

private void verifyLocalFileDeletion(
    LogAggregationService logAggregationService) throws Exception {
  logAggregationService.init(this.conf);
  logAggregationService.start();

  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);

  // AppLogDir should be created
  File app1LogDir =
      new File(localLogDir, ConverterUtils.toString(application1));
  app1LogDir.mkdir();
  logAggregationService
      .handle(new LogHandlerAppStartedEvent(
          application1, this.user, null,
          ContainerLogsRetentionPolicy.ALL_CONTAINERS, this.acls));

  ApplicationAttemptId appAttemptId =
      BuilderUtils.newApplicationAttemptId(application1, 1);
  ContainerId container11 = BuilderUtils.newContainerId(appAttemptId, 1);
  // Simulate log-file creation
  writeContainerLogs(app1LogDir, container11, new String[] { "stdout",
      "stderr", "syslog" });
  logAggregationService.handle(
      new LogHandlerContainerFinishedEvent(container11, 0));

  logAggregationService.handle(new LogHandlerAppFinishedEvent(
      application1));

  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());
  // ensure filesystems were closed
  verify(logAggregationService).closeFileSystems(
      any(UserGroupInformation.class));
  verify(delSrvc).delete(eq(user), eq((Path) null),
    eq(new Path(app1LogDir.getAbsolutePath())));
  delSrvc.stop();
  
  String containerIdStr = ConverterUtils.toString(container11);
  File containerLogDir = new File(app1LogDir, containerIdStr);
  for (String fileType : new String[] { "stdout", "stderr", "syslog" }) {
    File f = new File(containerLogDir, fileType);
    Assert.assertFalse("check "+f, f.exists());
  }

  Assert.assertFalse(app1LogDir.exists());

  Path logFilePath =
      logAggregationService.getRemoteNodeLogFileForApp(application1,
          this.user);

  Assert.assertTrue("Log file [" + logFilePath + "] not found", new File(
      logFilePath.toUri().getPath()).exists());
  
  dispatcher.await();
  
  ApplicationEvent expectedEvents[] = new ApplicationEvent[]{
      new ApplicationEvent(
          appAttemptId.getApplicationId(),
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED),
      new ApplicationEvent(
          appAttemptId.getApplicationId(),
          ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED)
  };

  checkEvents(appEventHandler, expectedEvents, true, "getType",
      "getApplicationID");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:67,代码来源:TestLogAggregationService.java

示例3: testNoContainerOnNode

@Test
public void testNoContainerOnNode() throws Exception {
  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
      this.remoteRootLogDir.getAbsolutePath());
  
  LogAggregationService logAggregationService =
      new LogAggregationService(dispatcher, this.context, this.delSrvc,
                                super.dirsHandler);
  logAggregationService.init(this.conf);
  logAggregationService.start();

  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);

  // AppLogDir should be created
  File app1LogDir =
    new File(localLogDir, ConverterUtils.toString(application1));
  app1LogDir.mkdir();
  logAggregationService
      .handle(new LogHandlerAppStartedEvent(
          application1, this.user, null,
          ContainerLogsRetentionPolicy.ALL_CONTAINERS, this.acls));

  logAggregationService.handle(new LogHandlerAppFinishedEvent(
      application1));

  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());

  Assert.assertFalse(new File(logAggregationService
      .getRemoteNodeLogFileForApp(application1, this.user).toUri().getPath())
      .exists());

  dispatcher.await();
  
  ApplicationEvent expectedEvents[] = new ApplicationEvent[]{
      new ApplicationEvent(
          application1,
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED),
      new ApplicationEvent(
          application1,
          ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED)
  };
  checkEvents(appEventHandler, expectedEvents, true, "getType", "getApplicationID");
  logAggregationService.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:46,代码来源:TestLogAggregationService.java

示例4: testVerifyAndCreateRemoteDirsFailure

@Test
public void testVerifyAndCreateRemoteDirsFailure()
    throws Exception {
  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
      this.remoteRootLogDir.getAbsolutePath());
  
  LogAggregationService logAggregationService = spy(
      new LogAggregationService(dispatcher, this.context, this.delSrvc,
                                super.dirsHandler));
  logAggregationService.init(this.conf);
  
  YarnRuntimeException e = new YarnRuntimeException("KABOOM!");
  doThrow(e)
    .when(logAggregationService).verifyAndCreateRemoteLogDir(
        any(Configuration.class));
      
  logAggregationService.start();
  
  // Now try to start an application
  ApplicationId appId =
      BuilderUtils.newApplicationId(System.currentTimeMillis(),
        (int) (Math.random() * 1000));
  logAggregationService.handle(new LogHandlerAppStartedEvent(appId,
      this.user, null,
      ContainerLogsRetentionPolicy.AM_AND_FAILED_CONTAINERS_ONLY,
      this.acls));
  dispatcher.await();
  
  // Verify that it failed
  ApplicationEvent[] expectedEvents = new ApplicationEvent[] {
      new ApplicationEvent(appId, 
          ApplicationEventType.APPLICATION_LOG_HANDLING_FAILED)
  };
  checkEvents(appEventHandler, expectedEvents, false,
      "getType", "getApplicationID", "getDiagnostic");

  Mockito.reset(logAggregationService);
  
  // Now try to start another one
  ApplicationId appId2 =
      BuilderUtils.newApplicationId(System.currentTimeMillis(),
        (int) (Math.random() * 1000));
  File appLogDir =
      new File(localLogDir, ConverterUtils.toString(appId2));
  appLogDir.mkdir();
  
  logAggregationService.handle(new LogHandlerAppStartedEvent(appId2,
      this.user, null,
      ContainerLogsRetentionPolicy.AM_AND_FAILED_CONTAINERS_ONLY,
      this.acls));
  dispatcher.await();
  
  // Verify that it worked
  expectedEvents = new ApplicationEvent[] {
      new ApplicationEvent(appId, // original failure
          ApplicationEventType.APPLICATION_LOG_HANDLING_FAILED), 
      new ApplicationEvent(appId2, // success
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED)
  };
  checkEvents(appEventHandler, expectedEvents, false,
      "getType", "getApplicationID", "getDiagnostic");
  
  logAggregationService.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:65,代码来源:TestLogAggregationService.java

示例5: testFailedDirsLocalFileDeletionAfterUpload

@Test
public void testFailedDirsLocalFileDeletionAfterUpload() throws Exception {

  // setup conf and services
  DeletionService mockDelService = mock(DeletionService.class);
  File[] localLogDirs =
      TestNonAggregatingLogHandler.getLocalLogDirFiles(this.getClass()
        .getName(), 7);
  final List<String> localLogDirPaths =
      new ArrayList<String>(localLogDirs.length);
  for (int i = 0; i < localLogDirs.length; i++) {
    localLogDirPaths.add(localLogDirs[i].getAbsolutePath());
  }

  String localLogDirsString = StringUtils.join(localLogDirPaths, ",");

  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDirsString);
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
    this.remoteRootLogDir.getAbsolutePath());
  this.conf.setLong(YarnConfiguration.NM_DISK_HEALTH_CHECK_INTERVAL_MS, 500);

  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);
  ApplicationAttemptId appAttemptId =
      BuilderUtils.newApplicationAttemptId(application1, 1);

  this.dirsHandler = new LocalDirsHandlerService();
  LocalDirsHandlerService mockDirsHandler = mock(LocalDirsHandlerService.class);

  LogAggregationService logAggregationService =
      spy(new LogAggregationService(dispatcher, this.context, mockDelService,
        mockDirsHandler));
  AbstractFileSystem spylfs =
      spy(FileContext.getLocalFSFileContext().getDefaultFileSystem());
  FileContext lfs = FileContext.getFileContext(spylfs, conf);
  doReturn(lfs).when(logAggregationService).getLocalFileContext(
    isA(Configuration.class));

  logAggregationService.init(this.conf);
  logAggregationService.start();

  TestNonAggregatingLogHandler.runMockedFailedDirs(logAggregationService,
    application1, user, mockDelService, mockDirsHandler, conf, spylfs, lfs,
    localLogDirs);

  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());
  verify(logAggregationService).closeFileSystems(
    any(UserGroupInformation.class));

  ApplicationEvent expectedEvents[] =
      new ApplicationEvent[] {
          new ApplicationEvent(appAttemptId.getApplicationId(),
            ApplicationEventType.APPLICATION_LOG_HANDLING_INITED),
          new ApplicationEvent(appAttemptId.getApplicationId(),
            ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED) };

  checkEvents(appEventHandler, expectedEvents, true, "getType",
    "getApplicationID");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:59,代码来源:TestLogAggregationService.java

示例6: verifyLocalFileDeletion

private void verifyLocalFileDeletion(
    LogAggregationService logAggregationService) throws Exception {
  logAggregationService.init(this.conf);
  logAggregationService.start();

  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);

  // AppLogDir should be created
  File app1LogDir =
      new File(localLogDir, ConverterUtils.toString(application1));
  app1LogDir.mkdir();
  logAggregationService
      .handle(new LogHandlerAppStartedEvent(
          application1, this.user, null, this.acls));

  ApplicationAttemptId appAttemptId =
      BuilderUtils.newApplicationAttemptId(application1, 1);
  ContainerId container11 = createContainer(appAttemptId, 1,
      ContainerType.APPLICATION_MASTER);
  // Simulate log-file creation
  writeContainerLogs(app1LogDir, container11, new String[] { "stdout",
      "stderr", "syslog" });
  logAggregationService.handle(
      new LogHandlerContainerFinishedEvent(container11, 0));

  logAggregationService.handle(new LogHandlerAppFinishedEvent(
      application1));

  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());
  // ensure filesystems were closed
  verify(logAggregationService).closeFileSystems(
      any(UserGroupInformation.class));
  verify(delSrvc).delete(eq(user), eq((Path) null),
    eq(new Path(app1LogDir.getAbsolutePath())));
  delSrvc.stop();
  
  String containerIdStr = ConverterUtils.toString(container11);
  File containerLogDir = new File(app1LogDir, containerIdStr);
  for (String fileType : new String[] { "stdout", "stderr", "syslog" }) {
    File f = new File(containerLogDir, fileType);
    Assert.assertFalse("check "+f, f.exists());
  }

  Assert.assertFalse(app1LogDir.exists());

  Path logFilePath =
      logAggregationService.getRemoteNodeLogFileForApp(application1,
          this.user);

  Assert.assertTrue("Log file [" + logFilePath + "] not found", new File(
      logFilePath.toUri().getPath()).exists());
  
  dispatcher.await();
  
  ApplicationEvent expectedEvents[] = new ApplicationEvent[]{
      new ApplicationEvent(
          appAttemptId.getApplicationId(),
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED),
      new ApplicationEvent(
          appAttemptId.getApplicationId(),
          ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED)
  };

  checkEvents(appEventHandler, expectedEvents, true, "getType",
      "getApplicationID");
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:67,代码来源:TestLogAggregationService.java

示例7: testNoContainerOnNode

@Test
public void testNoContainerOnNode() throws Exception {
  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
      this.remoteRootLogDir.getAbsolutePath());
  
  LogAggregationService logAggregationService =
      new LogAggregationService(dispatcher, this.context, this.delSrvc,
                                super.dirsHandler);
  logAggregationService.init(this.conf);
  logAggregationService.start();

  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);

  // AppLogDir should be created
  File app1LogDir =
    new File(localLogDir, ConverterUtils.toString(application1));
  app1LogDir.mkdir();
  logAggregationService
      .handle(new LogHandlerAppStartedEvent(
          application1, this.user, null, this.acls));

  logAggregationService.handle(new LogHandlerAppFinishedEvent(
      application1));

  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());

  Assert.assertFalse(new File(logAggregationService
      .getRemoteNodeLogFileForApp(application1, this.user).toUri().getPath())
      .exists());

  dispatcher.await();
  
  ApplicationEvent expectedEvents[] = new ApplicationEvent[]{
      new ApplicationEvent(
          application1,
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED),
      new ApplicationEvent(
          application1,
          ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED)
  };
  checkEvents(appEventHandler, expectedEvents, true, "getType", "getApplicationID");
  logAggregationService.close();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:45,代码来源:TestLogAggregationService.java

示例8: testVerifyAndCreateRemoteDirsFailure

@Test
public void testVerifyAndCreateRemoteDirsFailure()
    throws Exception {
  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
      this.remoteRootLogDir.getAbsolutePath());
  
  LogAggregationService logAggregationService = spy(
      new LogAggregationService(dispatcher, this.context, this.delSrvc,
                                super.dirsHandler));
  logAggregationService.init(this.conf);
  
  YarnRuntimeException e = new YarnRuntimeException("KABOOM!");
  doThrow(e)
    .when(logAggregationService).verifyAndCreateRemoteLogDir(
        any(Configuration.class));
      
  logAggregationService.start();
  
  // Now try to start an application
  ApplicationId appId =
      BuilderUtils.newApplicationId(System.currentTimeMillis(),
        (int) (Math.random() * 1000));
  LogAggregationContext contextWithAMAndFailed =
      Records.newRecord(LogAggregationContext.class);
  contextWithAMAndFailed.setLogAggregationPolicyClassName(
      AMOrFailedContainerLogAggregationPolicy.class.getName());

  logAggregationService.handle(new LogHandlerAppStartedEvent(appId,
      this.user, null, this.acls, contextWithAMAndFailed));
  dispatcher.await();
  
  // Verify that it failed
  ApplicationEvent[] expectedEvents = new ApplicationEvent[] {
      new ApplicationEvent(appId, 
          ApplicationEventType.APPLICATION_LOG_HANDLING_FAILED)
  };
  checkEvents(appEventHandler, expectedEvents, false,
      "getType", "getApplicationID", "getDiagnostic");

  Mockito.reset(logAggregationService);
  
  // Now try to start another one
  ApplicationId appId2 =
      BuilderUtils.newApplicationId(System.currentTimeMillis(),
        (int) (Math.random() * 1000));
  File appLogDir =
      new File(localLogDir, ConverterUtils.toString(appId2));
  appLogDir.mkdir();
  logAggregationService.handle(new LogHandlerAppStartedEvent(appId2,
      this.user, null, this.acls, contextWithAMAndFailed));
  dispatcher.await();
  
  // Verify that it worked
  expectedEvents = new ApplicationEvent[] {
      new ApplicationEvent(appId, // original failure
          ApplicationEventType.APPLICATION_LOG_HANDLING_FAILED), 
      new ApplicationEvent(appId2, // success
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED)
  };
  checkEvents(appEventHandler, expectedEvents, false,
      "getType", "getApplicationID", "getDiagnostic");
  
  logAggregationService.stop();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:65,代码来源:TestLogAggregationService.java

示例9: testLocalFileDeletionAfterUpload

@Test
public void testLocalFileDeletionAfterUpload() throws Exception {
  this.delSrvc = new DeletionService(createContainerExecutor());
  delSrvc = spy(delSrvc);
  this.delSrvc.init(conf);
  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
      this.remoteRootLogDir.getAbsolutePath());
  
  LogAggregationService logAggregationService = spy(
      new LogAggregationService(dispatcher, this.context, this.delSrvc,
                                super.dirsHandler));
  logAggregationService.init(this.conf);
  logAggregationService.start();

  
  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);

  // AppLogDir should be created
  File app1LogDir =
      new File(localLogDir, ConverterUtils.toString(application1));
  app1LogDir.mkdir();
  logAggregationService
      .handle(new LogHandlerAppStartedEvent(
          application1, this.user, null,
          ContainerLogsRetentionPolicy.ALL_CONTAINERS, this.acls));

  ApplicationAttemptId appAttemptId =
      BuilderUtils.newApplicationAttemptId(application1, 1);
  ContainerId container11 = BuilderUtils.newContainerId(appAttemptId, 1);
  // Simulate log-file creation
  writeContainerLogs(app1LogDir, container11, new String[] { "stdout",
      "stderr", "syslog" });
  logAggregationService.handle(
      new LogHandlerContainerFinishedEvent(container11, 0));

  logAggregationService.handle(new LogHandlerAppFinishedEvent(
      application1));

  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());
  // ensure filesystems were closed
  verify(logAggregationService).closeFileSystems(
      any(UserGroupInformation.class));
  verify(delSrvc).delete(eq(user), eq((Path) null),
    eq(new Path(app1LogDir.getAbsolutePath())));
  delSrvc.stop();
  
  String containerIdStr = ConverterUtils.toString(container11);
  File containerLogDir = new File(app1LogDir, containerIdStr);
  for (String fileType : new String[] { "stdout", "stderr", "syslog" }) {
    File f = new File(containerLogDir, fileType);
    Assert.assertFalse("check "+f, f.exists());
  }

  Assert.assertFalse(app1LogDir.exists());

  Path logFilePath =
      logAggregationService.getRemoteNodeLogFileForApp(application1,
          this.user);

  Assert.assertTrue("Log file [" + logFilePath + "] not found", new File(
      logFilePath.toUri().getPath()).exists());
  
  dispatcher.await();
  
  ApplicationEvent expectedEvents[] = new ApplicationEvent[]{
      new ApplicationEvent(
          appAttemptId.getApplicationId(),
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED),
      new ApplicationEvent(
          appAttemptId.getApplicationId(),
          ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED)
  };

  checkEvents(appEventHandler, expectedEvents, true, "getType", "getApplicationID");
  dispatcher.stop();
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:78,代码来源:TestLogAggregationService.java

示例10: testNoContainerOnNode

@Test
public void testNoContainerOnNode() throws Exception {
  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
      this.remoteRootLogDir.getAbsolutePath());
  
  LogAggregationService logAggregationService =
      new LogAggregationService(dispatcher, this.context, this.delSrvc,
                                super.dirsHandler);
  logAggregationService.init(this.conf);
  logAggregationService.start();

  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);

  // AppLogDir should be created
  File app1LogDir =
    new File(localLogDir, ConverterUtils.toString(application1));
  app1LogDir.mkdir();
  logAggregationService
      .handle(new LogHandlerAppStartedEvent(
          application1, this.user, null,
          ContainerLogsRetentionPolicy.ALL_CONTAINERS, this.acls));

  logAggregationService.handle(new LogHandlerAppFinishedEvent(
      application1));

  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());

  Assert.assertFalse(new File(logAggregationService
      .getRemoteNodeLogFileForApp(application1, this.user).toUri().getPath())
      .exists());

  dispatcher.await();
  
  ApplicationEvent expectedEvents[] = new ApplicationEvent[]{
      new ApplicationEvent(
          application1,
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED),
      new ApplicationEvent(
          application1,
          ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED)
  };
  checkEvents(appEventHandler, expectedEvents, true, "getType", "getApplicationID");
  dispatcher.stop();
  logAggregationService.close();
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:47,代码来源:TestLogAggregationService.java

示例11: testLocalFileDeletionAfterUpload

@Test
@SuppressWarnings("unchecked")
public void testLocalFileDeletionAfterUpload() throws Exception {
  this.delSrvc = new DeletionService(createContainerExecutor());
  delSrvc = spy(delSrvc);
  this.delSrvc.init(conf);
  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
      this.remoteRootLogDir.getAbsolutePath());
  
  DrainDispatcher dispatcher = createDispatcher();
  EventHandler<ApplicationEvent> appEventHandler = mock(EventHandler.class);
  dispatcher.register(ApplicationEventType.class, appEventHandler);
  
  LogAggregationService logAggregationService = spy(
      new LogAggregationService(dispatcher, this.context, this.delSrvc,
                                super.dirsHandler));
  logAggregationService.init(this.conf);
  logAggregationService.start();

  
  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);

  // AppLogDir should be created
  File app1LogDir =
      new File(localLogDir, ConverterUtils.toString(application1));
  app1LogDir.mkdir();
  logAggregationService
      .handle(new LogHandlerAppStartedEvent(
          application1, this.user, null,
          ContainerLogsRetentionPolicy.ALL_CONTAINERS, this.acls));

  ApplicationAttemptId appAttemptId =
      BuilderUtils.newApplicationAttemptId(application1, 1);
  ContainerId container11 = BuilderUtils.newContainerId(appAttemptId, 1);
  // Simulate log-file creation
  writeContainerLogs(app1LogDir, container11);
  logAggregationService.handle(
      new LogHandlerContainerFinishedEvent(container11, 0));

  logAggregationService.handle(new LogHandlerAppFinishedEvent(
      application1));

  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());
  // ensure filesystems were closed
  verify(logAggregationService).closeFileSystems(
      any(UserGroupInformation.class));
  verify(delSrvc).delete(eq(user), eq((Path) null),
    eq(new Path(app1LogDir.getAbsolutePath())));
  delSrvc.stop();
  
  String containerIdStr = ConverterUtils.toString(container11);
  File containerLogDir = new File(app1LogDir, containerIdStr);
  for (String fileType : new String[] { "stdout", "stderr", "syslog" }) {
    File f = new File(containerLogDir, fileType);
    Assert.assertFalse("check "+f, f.exists());
  }

  Assert.assertFalse(app1LogDir.exists());

  Path logFilePath =
      logAggregationService.getRemoteNodeLogFileForApp(application1,
          this.user);
  Assert.assertTrue("Log file [" + logFilePath + "] not found", new File(
      logFilePath.toUri().getPath()).exists());
  
  dispatcher.await();
  
  ApplicationEvent expectedEvents[] = new ApplicationEvent[]{
      new ApplicationEvent(
          appAttemptId.getApplicationId(),
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED),
      new ApplicationEvent(
          appAttemptId.getApplicationId(),
          ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED)
  };

  checkEvents(appEventHandler, expectedEvents, true, "getType", "getApplicationID");
  dispatcher.stop();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:81,代码来源:TestLogAggregationService.java

示例12: testNoContainerOnNode

@Test
@SuppressWarnings("unchecked")
public void testNoContainerOnNode() throws Exception {
  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
      this.remoteRootLogDir.getAbsolutePath());
  
  DrainDispatcher dispatcher = createDispatcher();
  EventHandler<ApplicationEvent> appEventHandler = mock(EventHandler.class);
  dispatcher.register(ApplicationEventType.class, appEventHandler);
  
  LogAggregationService logAggregationService =
      new LogAggregationService(dispatcher, this.context, this.delSrvc,
                                super.dirsHandler);
  logAggregationService.init(this.conf);
  logAggregationService.start();

  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);

  // AppLogDir should be created
  File app1LogDir =
    new File(localLogDir, ConverterUtils.toString(application1));
  app1LogDir.mkdir();
  logAggregationService
      .handle(new LogHandlerAppStartedEvent(
          application1, this.user, null,
          ContainerLogsRetentionPolicy.ALL_CONTAINERS, this.acls));

  logAggregationService.handle(new LogHandlerAppFinishedEvent(
      application1));

  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());

  Assert.assertFalse(new File(logAggregationService
      .getRemoteNodeLogFileForApp(application1, this.user).toUri().getPath())
      .exists());
  
  dispatcher.await();
  
  ApplicationEvent expectedEvents[] = new ApplicationEvent[]{
      new ApplicationEvent(
          application1,
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED),
      new ApplicationEvent(
          application1,
          ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED)
  };
  checkEvents(appEventHandler, expectedEvents, true, "getType", "getApplicationID");
  dispatcher.stop();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:51,代码来源:TestLogAggregationService.java

示例13: testVerifyAndCreateRemoteDirsFailure

@Test
@SuppressWarnings("unchecked")
public void testVerifyAndCreateRemoteDirsFailure()
    throws Exception {
  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
      this.remoteRootLogDir.getAbsolutePath());
  
  DrainDispatcher dispatcher = createDispatcher();
  EventHandler<ApplicationEvent> appEventHandler = mock(EventHandler.class);
  dispatcher.register(ApplicationEventType.class, appEventHandler);
  
  LogAggregationService logAggregationService = spy(
      new LogAggregationService(dispatcher, this.context, this.delSrvc,
                                super.dirsHandler));
  logAggregationService.init(this.conf);
  
  YarnRuntimeException e = new YarnRuntimeException("KABOOM!");
  doThrow(e)
    .when(logAggregationService).verifyAndCreateRemoteLogDir(
        any(Configuration.class));
      
  logAggregationService.start();
  
  // Now try to start an application
  ApplicationId appId = BuilderUtils.newApplicationId(
      System.currentTimeMillis(), (int)Math.random());
  logAggregationService.handle(new LogHandlerAppStartedEvent(appId,
      this.user, null,
      ContainerLogsRetentionPolicy.AM_AND_FAILED_CONTAINERS_ONLY,
      this.acls));
  dispatcher.await();
  
  // Verify that it failed
  ApplicationEvent[] expectedEvents = new ApplicationEvent[] {
      new ApplicationEvent(appId, 
          ApplicationEventType.APPLICATION_LOG_HANDLING_FAILED)
  };
  checkEvents(appEventHandler, expectedEvents, false,
      "getType", "getApplicationID", "getDiagnostic");

  Mockito.reset(logAggregationService);
  
  // Now try to start another one
  ApplicationId appId2 = BuilderUtils.newApplicationId(
      System.currentTimeMillis(), (int)Math.random());
  File appLogDir =
      new File(localLogDir, ConverterUtils.toString(appId2));
  appLogDir.mkdir();
  
  logAggregationService.handle(new LogHandlerAppStartedEvent(appId2,
      this.user, null,
      ContainerLogsRetentionPolicy.AM_AND_FAILED_CONTAINERS_ONLY,
      this.acls));
  dispatcher.await();
  
  // Verify that it worked
  expectedEvents = new ApplicationEvent[] {
      new ApplicationEvent(appId, // original failure
          ApplicationEventType.APPLICATION_LOG_HANDLING_FAILED), 
      new ApplicationEvent(appId2, // success
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED)
  };
  checkEvents(appEventHandler, expectedEvents, false,
      "getType", "getApplicationID", "getDiagnostic");
  
  logAggregationService.stop();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:68,代码来源:TestLogAggregationService.java

示例14: verifyLocalFileDeletion

private void verifyLocalFileDeletion(
    LogAggregationService logAggregationService) throws Exception {
  logAggregationService.init(this.conf);
  logAggregationService.start();

  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);

  // AppLogDir should be created
  File userFold = new File(localLogDir, userFolder);
  File app1LogDir = new File(userFold, application1.toString());
  app1LogDir.mkdir();
  logAggregationService
      .handle(new LogHandlerAppStartedEvent(
          application1, this.user, null, this.acls, this.userFolder));

  ApplicationAttemptId appAttemptId =
      BuilderUtils.newApplicationAttemptId(application1, 1);
  ContainerId container11 = createContainer(appAttemptId, 1,
      ContainerType.APPLICATION_MASTER);
  // Simulate log-file creation
  writeContainerLogs(app1LogDir, container11, new String[] { "stdout",
      "stderr", "syslog" });
  logAggregationService.handle(
      new LogHandlerContainerFinishedEvent(container11, 0));

  logAggregationService.handle(new LogHandlerAppFinishedEvent(
      application1));

  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());
  // ensure filesystems were closed
  verify(logAggregationService).closeFileSystems(
      any(UserGroupInformation.class));
  verify(delSrvc).delete(eq(user), eq((Path) null),
    eq(new Path(app1LogDir.getAbsolutePath())));
  
  String containerIdStr = container11.toString();
  File containerLogDir = new File(app1LogDir, containerIdStr);
  int count = 0;
  int maxAttempts = 50;
  for (String fileType : new String[] { "stdout", "stderr", "syslog" }) {
    File f = new File(containerLogDir, fileType);
    count = 0;
    while ((f.exists()) && (count < maxAttempts)) {
      count++;
      Thread.sleep(100);
    }
    Assert.assertFalse("File [" + f + "] was not deleted", f.exists());
  }
  count = 0;
  while ((app1LogDir.exists()) && (count < maxAttempts)) {
    count++;
    Thread.sleep(100);
  }
  Assert.assertFalse("Directory [" + app1LogDir + "] was not deleted",
    app1LogDir.exists());

  Path logFilePath =
      logAggregationService.getRemoteNodeLogFileForApp(application1,
      this.user);

  Assert.assertTrue("Log file [" + logFilePath + "] not found", new File(
      logFilePath.toUri().getPath()).exists());
  
  dispatcher.await();
  
  ApplicationEvent expectedEvents[] = new ApplicationEvent[]{
      new ApplicationEvent(
          appAttemptId.getApplicationId(),
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED),
      new ApplicationEvent(
          appAttemptId.getApplicationId(),
          ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED)
  };

  checkEvents(appEventHandler, expectedEvents, true, "getType",
      "getApplicationID");
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:78,代码来源:TestLogAggregationService.java

示例15: testNoContainerOnNode

@Test
public void testNoContainerOnNode() throws Exception {
  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
      this.remoteRootLogDir.getAbsolutePath());
  
  LogAggregationService logAggregationService =
      new LogAggregationService(dispatcher, this.context, this.delSrvc,
                                super.dirsHandler);
  logAggregationService.init(this.conf);
  logAggregationService.start();

  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);

  // AppLogDir should be created
  File userFold = new File(localLogDir, userFolder);
  File app1LogDir = new File(userFold, application1.toString());
  app1LogDir.mkdir();
  logAggregationService
      .handle(new LogHandlerAppStartedEvent(
          application1, this.user, null, this.acls, this.userFolder));

  logAggregationService.handle(new LogHandlerAppFinishedEvent(
      application1));

  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());

  Assert.assertFalse(new File(logAggregationService
      .getRemoteNodeLogFileForApp(application1, this.user).toUri().getPath())
      .exists());

  dispatcher.await();
  
  ApplicationEvent expectedEvents[] = new ApplicationEvent[]{
      new ApplicationEvent(
          application1,
          ApplicationEventType.APPLICATION_LOG_HANDLING_INITED),
      new ApplicationEvent(
          application1,
          ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED)
  };
  checkEvents(appEventHandler, expectedEvents, true, "getType", "getApplicationID");
  logAggregationService.close();
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:45,代码来源:TestLogAggregationService.java


注:本文中的org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationEventType.APPLICATION_LOG_HANDLING_INITED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。