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


Java BuilderUtils.newApplicationId方法代码示例

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


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

示例1: testStopAfterError

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test(timeout=20000)
public void testStopAfterError() throws Exception {
  DeletionService delSrvc = mock(DeletionService.class);

  // get the AppLogAggregationImpl thread to crash
  LocalDirsHandlerService mockedDirSvc = mock(LocalDirsHandlerService.class);
  when(mockedDirSvc.getLogDirs()).thenThrow(new RuntimeException());
  
  LogAggregationService logAggregationService =
      new LogAggregationService(dispatcher, this.context, delSrvc,
                                mockedDirSvc);
  logAggregationService.init(this.conf);
  logAggregationService.start();

  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);
  logAggregationService.handle(new LogHandlerAppStartedEvent(
          application1, this.user, null,
          ContainerLogsRetentionPolicy.ALL_CONTAINERS, this.acls));

  logAggregationService.stop();
  assertEquals(0, logAggregationService.getNumAggregators());
  logAggregationService.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestLogAggregationService.java

示例2: testGetProxyUriNull

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test
public void testGetProxyUriNull() throws Exception {
  URI originalUri = null;
  URI proxyUri = new URI("http://proxy.net:8080/");
  ApplicationId id = BuilderUtils.newApplicationId(6384623l, 5);
  URI expected = new URI("http://proxy.net:8080/proxy/application_6384623_0005/");
  URI result = ProxyUriUtils.getProxyUri(originalUri, proxyUri, id);
  assertEquals(expected, result);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TestProxyUriUtils.java

示例3: testGetProxyUriFromPluginsReturnsNullIfNoPlugins

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test
public void testGetProxyUriFromPluginsReturnsNullIfNoPlugins()
    throws URISyntaxException {
  ApplicationId id = BuilderUtils.newApplicationId(6384623l, 5);
  List<TrackingUriPlugin> list =
      Lists.newArrayListWithExpectedSize(0);
  assertNull(ProxyUriUtils.getUriFromTrackingPlugins(id, list));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TestProxyUriUtils.java

示例4: MockApp

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
public MockApp(String user, long clusterTimeStamp, int uniqId) {
  super();
  this.user = user;
  // Add an application and the corresponding containers
  RecordFactory recordFactory = RecordFactoryProvider
      .getRecordFactory(new Configuration());
  this.appId = BuilderUtils.newApplicationId(recordFactory, clusterTimeStamp,
      uniqId);
  appState = ApplicationState.NEW;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:MockApp.java

示例5: testBlackListNodes

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test
public void testBlackListNodes() throws Exception {
  Configuration conf = new Configuration();
  conf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class,
      ResourceScheduler.class);
  MockRM rm = new MockRM(conf);
  rm.start();
  FifoScheduler fs = (FifoScheduler) rm.getResourceScheduler();

  String host = "127.0.0.1";
  RMNode node =
      MockNodes.newNodeInfo(0, MockNodes.newResource(4 * GB), 1, host);
  fs.handle(new NodeAddedSchedulerEvent(node));

  ApplicationId appId = BuilderUtils.newApplicationId(100, 1);
  ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
      appId, 1);

  createMockRMApp(appAttemptId, rm.getRMContext());

  SchedulerEvent appEvent =
      new AppAddedSchedulerEvent(appId, "default",
        "user");
  fs.handle(appEvent);
  SchedulerEvent attemptEvent =
      new AppAttemptAddedSchedulerEvent(appAttemptId, false);
  fs.handle(attemptEvent);

  // Verify the blacklist can be updated independent of requesting containers
  fs.allocate(appAttemptId, Collections.<ResourceRequest>emptyList(),
      Collections.<ContainerId>emptyList(),
      Collections.singletonList(host), null);
  Assert.assertTrue(fs.getApplicationAttempt(appAttemptId).isBlacklisted(host));
  fs.allocate(appAttemptId, Collections.<ResourceRequest>emptyList(),
      Collections.<ContainerId>emptyList(), null,
      Collections.singletonList(host));
  Assert.assertFalse(fs.getApplicationAttempt(appAttemptId).isBlacklisted(host));
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:40,代码来源:TestFifoScheduler.java

示例6: setup

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Before
@SuppressWarnings("unchecked")
public void setup() {
  mockDelService = mock(DeletionService.class);
  conf = new YarnConfiguration();
  dispatcher = createDispatcher(conf);
  appEventHandler = mock(EventHandler.class);
  dispatcher.register(ApplicationEventType.class, appEventHandler);
  appId = BuilderUtils.newApplicationId(1234, 1);
  appAttemptId = BuilderUtils.newApplicationAttemptId(appId, 1);
  container11 = BuilderUtils.newContainerId(appAttemptId, 1);
  dirsHandler = new LocalDirsHandlerService();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TestNonAggregatingLogHandler.java

示例7: getMockApplicationAttemptId

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
public static ApplicationAttemptId 
getMockApplicationAttemptId(int appId, int attemptId) {
  ApplicationId applicationId = BuilderUtils.newApplicationId(0l, appId);
  ApplicationAttemptId applicationAttemptId = mock(ApplicationAttemptId.class);  
  when(applicationAttemptId.getApplicationId()).thenReturn(applicationId);
  when(applicationAttemptId.getAttemptId()).thenReturn(attemptId);
  return applicationAttemptId;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TestUtils.java

示例8: testUpdateHeartbeatResponseForCleanup

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test(timeout=20000)
public void testUpdateHeartbeatResponseForCleanup() {
  RMNodeImpl node = getRunningNode();
  NodeId nodeId = node.getNodeID();

  // Expire a container
ContainerId completedContainerId = BuilderUtils.newContainerId(
		BuilderUtils.newApplicationAttemptId(
				BuilderUtils.newApplicationId(0, 0), 0), 0);
  node.handle(new RMNodeCleanContainerEvent(nodeId, completedContainerId));
  Assert.assertEquals(1, node.getContainersToCleanUp().size());

  // Finish an application
  ApplicationId finishedAppId = BuilderUtils.newApplicationId(0, 1);
  node.handle(new RMNodeCleanAppEvent(nodeId, finishedAppId));
  Assert.assertEquals(1, node.getAppsToCleanup().size());

  // Verify status update does not clear containers/apps to cleanup
  // but updating heartbeat response for cleanup does
  RMNodeStatusEvent statusEvent = getMockRMNodeStatusEvent();
  node.handle(statusEvent);
  Assert.assertEquals(1, node.getContainersToCleanUp().size());
  Assert.assertEquals(1, node.getAppsToCleanup().size());
  NodeHeartbeatResponse hbrsp = Records.newRecord(NodeHeartbeatResponse.class);
  node.updateNodeHeartbeatResponseForCleanup(hbrsp);
  Assert.assertEquals(0, node.getContainersToCleanUp().size());
  Assert.assertEquals(0, node.getAppsToCleanup().size());
  Assert.assertEquals(1, hbrsp.getContainersToCleanup().size());
  Assert.assertEquals(completedContainerId, hbrsp.getContainersToCleanup().get(0));
  Assert.assertEquals(1, hbrsp.getApplicationsToCleanup().size());
  Assert.assertEquals(finishedAppId, hbrsp.getApplicationsToCleanup().get(0));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:TestRMNodeTransitions.java

示例9: testLogAggregatorCleanup

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test
public void testLogAggregatorCleanup() throws Exception {
  DeletionService delSrvc = mock(DeletionService.class);

  // get the AppLogAggregationImpl thread to crash
  LocalDirsHandlerService mockedDirSvc = mock(LocalDirsHandlerService.class);

  LogAggregationService logAggregationService =
      new LogAggregationService(dispatcher, this.context, delSrvc,
                                mockedDirSvc);
  logAggregationService.init(this.conf);
  logAggregationService.start();

  ApplicationId application1 = BuilderUtils.newApplicationId(1234, 1);
  logAggregationService.handle(new LogHandlerAppStartedEvent(
          application1, this.user, null,
          ContainerLogsRetentionPolicy.ALL_CONTAINERS, this.acls));

  logAggregationService.handle(new LogHandlerAppFinishedEvent(application1));
  dispatcher.await();
  int timeToWait = 20 * 1000;
  while (timeToWait > 0 && logAggregationService.getNumAggregators() > 0) {
    Thread.sleep(100);
    timeToWait -= 100;
  }
  Assert.assertEquals("Log aggregator failed to cleanup!", 0,
      logAggregationService.getNumAggregators());
  logAggregationService.stop();
  logAggregationService.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:TestLogAggregationService.java

示例10: testDTRenewalWithNoCancel

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
/**
 * Basic idea of the test:
 * 1. register a token for 2 seconds with no cancel at the end
 * 2. cancel it immediately
 * 3. Sleep and check that the 2 seconds renew didn't happen 
 * (totally 5 renewals)
 * 4. check cancellation
 * @throws IOException
 * @throws URISyntaxException
 */
@Test(timeout=60000)
public void testDTRenewalWithNoCancel () throws Exception {
  MyFS dfs = (MyFS)FileSystem.get(conf);
  LOG.info("dfs="+(Object)dfs.hashCode() + ";conf="+conf.hashCode());

  Credentials ts = new Credentials();
  MyToken token1 = dfs.getDelegationToken("user1");

  //to cause this one to be set for renew in 2 secs
  Renewer.tokenToRenewIn2Sec = token1; 
  LOG.info("token="+token1+" should be renewed for 2 secs");
  
  String nn1 = DelegationTokenRenewer.SCHEME + "://host1:0";
  ts.addToken(new Text(nn1), token1);
  

  ApplicationId applicationId_1 = BuilderUtils.newApplicationId(0, 1);
  delegationTokenRenewer.addApplicationAsync(applicationId_1, ts, false, "user");
  waitForEventsToGetProcessed(delegationTokenRenewer);
  delegationTokenRenewer.applicationFinished(applicationId_1);
  waitForEventsToGetProcessed(delegationTokenRenewer);
  int numberOfExpectedRenewals = Renewer.counter; // number of renewals so far
  try {
    Thread.sleep(6*1000); // sleep 6 seconds, so it has time to renew
  } catch (InterruptedException e) {}
  LOG.info("Counter = " + Renewer.counter + ";t="+ Renewer.lastRenewed);
  
  // counter and the token should still be the old ones
  assertEquals("renew wasn't called as many times as expected",
      numberOfExpectedRenewals, Renewer.counter);
  
  // also renewing of the canceled token should not fail, because it has not
  // been canceled
  token1.renew(conf);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:46,代码来源:TestDelegationTokenRenewer.java

示例11: testHeadroom

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test (timeout = 50000)
public void testHeadroom() throws Exception {
  
  Configuration conf = new Configuration();
  conf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class,
      ResourceScheduler.class);
  MockRM rm = new MockRM(conf);
  rm.start();
  FifoScheduler fs = (FifoScheduler) rm.getResourceScheduler();

  // Add a node
  RMNode n1 =
      MockNodes.newNodeInfo(0, MockNodes.newResource(4 * GB), 1, "127.0.0.2");
  fs.handle(new NodeAddedSchedulerEvent(n1));
  
  // Add two applications
  ApplicationId appId1 = BuilderUtils.newApplicationId(100, 1);
  ApplicationAttemptId appAttemptId1 = BuilderUtils.newApplicationAttemptId(
      appId1, 1);
  createMockRMApp(appAttemptId1, rm.getRMContext());
  SchedulerEvent appEvent =
      new AppAddedSchedulerEvent(appId1, "queue", "user");
  fs.handle(appEvent);
  SchedulerEvent attemptEvent =
      new AppAttemptAddedSchedulerEvent(appAttemptId1, false);
  fs.handle(attemptEvent);

  ApplicationId appId2 = BuilderUtils.newApplicationId(200, 2);
  ApplicationAttemptId appAttemptId2 = BuilderUtils.newApplicationAttemptId(
      appId2, 1);
  createMockRMApp(appAttemptId2, rm.getRMContext());
  SchedulerEvent appEvent2 =
      new AppAddedSchedulerEvent(appId2, "queue", "user");
  fs.handle(appEvent2);
  SchedulerEvent attemptEvent2 =
      new AppAttemptAddedSchedulerEvent(appAttemptId2, false);
  fs.handle(attemptEvent2);

  List<ContainerId> emptyId = new ArrayList<ContainerId>();
  List<ResourceRequest> emptyAsk = new ArrayList<ResourceRequest>();

  // Set up resource requests
  
  // Ask for a 1 GB container for app 1
  List<ResourceRequest> ask1 = new ArrayList<ResourceRequest>();
  ask1.add(BuilderUtils.newResourceRequest(BuilderUtils.newPriority(0),
      ResourceRequest.ANY, BuilderUtils.newResource(GB, 1), 1));
  fs.allocate(appAttemptId1, ask1, emptyId, null, null);

  // Ask for a 2 GB container for app 2
  List<ResourceRequest> ask2 = new ArrayList<ResourceRequest>();
  ask2.add(BuilderUtils.newResourceRequest(BuilderUtils.newPriority(0),
      ResourceRequest.ANY, BuilderUtils.newResource(2 * GB, 1), 1));
  fs.allocate(appAttemptId2, ask2, emptyId, null, null);
  
  // Trigger container assignment
  fs.handle(new NodeUpdateSchedulerEvent(n1));
  
  // Get the allocation for the applications and verify headroom
  Allocation allocation1 = fs.allocate(appAttemptId1, emptyAsk, emptyId, null, null);
  Assert.assertEquals("Allocation headroom", 1 * GB,
      allocation1.getResourceLimit().getMemory());

  Allocation allocation2 = fs.allocate(appAttemptId2, emptyAsk, emptyId, null, null);
  Assert.assertEquals("Allocation headroom", 1 * GB,
      allocation2.getResourceLimit().getMemory());

  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:70,代码来源:TestFifoScheduler.java

示例12: testContainerLogDirs

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test(timeout=30000)
public void testContainerLogDirs() throws IOException, YarnException {
  File absLogDir = new File("target",
    TestNMWebServer.class.getSimpleName() + "LogDir").getAbsoluteFile();
  String logdirwithFile = absLogDir.toURI().toString();
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.NM_LOG_DIRS, logdirwithFile);
  NodeHealthCheckerService healthChecker = createNodeHealthCheckerService(conf);
  healthChecker.init(conf);
  LocalDirsHandlerService dirsHandler = healthChecker.getDiskHandler();
  NMContext nmContext = new NodeManager.NMContext(null, null, dirsHandler,
      new ApplicationACLsManager(conf), new NMNullStateStoreService());
  // Add an application and the corresponding containers
  RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(conf);
  String user = "nobody";
  long clusterTimeStamp = 1234;
  ApplicationId appId = BuilderUtils.newApplicationId(recordFactory,
      clusterTimeStamp, 1);
  Application app = mock(Application.class);
  when(app.getUser()).thenReturn(user);
  when(app.getAppId()).thenReturn(appId);
  ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
      appId, 1);
  ContainerId container1 = BuilderUtils.newContainerId(recordFactory, appId,
      appAttemptId, 0);
  nmContext.getApplications().put(appId, app);

  MockContainer container =
      new MockContainer(appAttemptId, new AsyncDispatcher(), conf, user,
          appId, 1);
  container.setState(ContainerState.RUNNING);
  nmContext.getContainers().put(container1, container);   
  List<File> files = null;
  files = ContainerLogsUtils.getContainerLogDirs(container1, user, nmContext);
  Assert.assertTrue(!(files.get(0).toString().contains("file:")));
  
  // After container is completed, it is removed from nmContext
  nmContext.getContainers().remove(container1);
  Assert.assertNull(nmContext.getContainers().get(container1));
  files = ContainerLogsUtils.getContainerLogDirs(container1, user, nmContext);
  Assert.assertTrue(!(files.get(0).toString().contains("file:")));

  // Create a new context to check if correct container log dirs are fetched
  // on full disk.
  LocalDirsHandlerService dirsHandlerForFullDisk = spy(dirsHandler);
  // good log dirs are empty and nm log dir is in the full log dir list.
  when(dirsHandlerForFullDisk.getLogDirs()).
      thenReturn(new ArrayList<String>());
  when(dirsHandlerForFullDisk.getLogDirsForRead()).
      thenReturn(Arrays.asList(new String[] {absLogDir.getAbsolutePath()}));
  nmContext = new NodeManager.NMContext(null, null, dirsHandlerForFullDisk,
      new ApplicationACLsManager(conf), new NMNullStateStoreService());
  nmContext.getApplications().put(appId, app);
  container.setState(ContainerState.RUNNING);
  nmContext.getContainers().put(container1, container);
  List<File> dirs =
      ContainerLogsUtils.getContainerLogDirs(container1, user, nmContext);
  File containerLogDir = new File(absLogDir, appId + "/" + container1);
  Assert.assertTrue(dirs.contains(containerLogDir));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:61,代码来源:TestContainerLogsPage.java

示例13: WrappedApplication

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
WrappedApplication(int id, long timestamp, String user, int numContainers) {
  Configuration conf = new Configuration();
  
  dispatcher = new DrainDispatcher();
  containerTokenIdentifierMap =
      new HashMap<ContainerId, ContainerTokenIdentifier>();
  dispatcher.init(conf);

  localizerBus = mock(EventHandler.class);
  launcherBus = mock(EventHandler.class);
  monitorBus = mock(EventHandler.class);
  auxBus = mock(EventHandler.class);
  containerBus = mock(EventHandler.class);
  logAggregationBus = mock(EventHandler.class);

  dispatcher.register(LocalizationEventType.class, localizerBus);
  dispatcher.register(ContainersLauncherEventType.class, launcherBus);
  dispatcher.register(ContainersMonitorEventType.class, monitorBus);
  dispatcher.register(AuxServicesEventType.class, auxBus);
  dispatcher.register(ContainerEventType.class, containerBus);
  dispatcher.register(LogHandlerEventType.class, logAggregationBus);

  nmTokenSecretMgr = mock(NMTokenSecretManagerInNM.class);

  context = mock(Context.class);
  
  when(context.getContainerTokenSecretManager()).thenReturn(
    new NMContainerTokenSecretManager(conf));
  when(context.getApplicationACLsManager()).thenReturn(
    new ApplicationACLsManager(conf));
  when(context.getNMTokenSecretManager()).thenReturn(nmTokenSecretMgr);
  
  // Setting master key
  MasterKey masterKey = new MasterKeyPBImpl();
  masterKey.setKeyId(123);
  masterKey.setBytes(ByteBuffer.wrap(new byte[] { (new Integer(123)
    .byteValue()) }));
  context.getContainerTokenSecretManager().setMasterKey(masterKey);
  
  this.user = user;
  this.appId = BuilderUtils.newApplicationId(timestamp, id);

  app = new ApplicationImpl(dispatcher, this.user, appId, null, context);
  containers = new ArrayList<Container>();
  for (int i = 0; i < numContainers; i++) {
    Container container = createMockedContainer(this.appId, i);
    containers.add(container);
    long currentTime = System.currentTimeMillis();
    ContainerTokenIdentifier identifier =
        new ContainerTokenIdentifier(container.getContainerId(), "", "",
          null, currentTime + 2000, masterKey.getKeyId(), currentTime,
          Priority.newInstance(0), 0);
    containerTokenIdentifierMap
      .put(identifier.getContainerID(), identifier);
    context.getContainerTokenSecretManager().startContainerSuccessful(
      identifier);
    Assert.assertFalse(context.getContainerTokenSecretManager()
      .isValidStartContainerRequest(identifier));
  }

  dispatcher.start();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:63,代码来源:TestApplication.java

示例14: testNoContainerOnNode

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@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,代码行数:47,代码来源:TestLogAggregationService.java

示例15: testVerifyAndCreateRemoteDirsFailure

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@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,代码行数:66,代码来源:TestLogAggregationService.java


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