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


Java ContainerEventType类代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType的典型用法代码示例。如果您正苦于以下问题:Java ContainerEventType类的具体用法?Java ContainerEventType怎么用?Java ContainerEventType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: handle

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
public void handle(ContainerEvent event) {
  if (event instanceof ContainerExitEvent) {
    containerExitEventOccured = true;
    ContainerExitEvent exitEvent = (ContainerExitEvent) event;
    Assert.assertEquals(ContainerEventType.CONTAINER_EXITED_WITH_FAILURE,
        exitEvent.getType());
    LOG.info("Diagnostic Info : " + exitEvent.getDiagnosticInfo());
    if (testForMultiFile) {
      Assert.assertTrue("Should contain the Multi file information",
          exitEvent.getDiagnosticInfo().contains("Error files : "));
    }
    Assert.assertTrue(
        "Should contain the error Log message with tail size info",
        exitEvent.getDiagnosticInfo()
            .contains("Last "
                + YarnConfiguration.DEFAULT_NM_CONTAINER_STDERR_BYTES
                + " bytes of"));
    Assert.assertTrue("Should contain contents of error Log",
        exitEvent.getDiagnosticInfo().contains(
            INVALID_JAVA_HOME + "/bin/java: No such file or directory"));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestContainerLaunch.java

示例2: testCallFailureWithNullLocalizedResources

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Test (timeout = 10000)
public void testCallFailureWithNullLocalizedResources() {
  Container container = mock(Container.class);
  when(container.getContainerId()).thenReturn(ContainerId.newContainerId(
      ApplicationAttemptId.newInstance(ApplicationId.newInstance(
          System.currentTimeMillis(), 1), 1), 1));
  ContainerLaunchContext clc = mock(ContainerLaunchContext.class);
  when(clc.getCommands()).thenReturn(Collections.<String>emptyList());
  when(container.getLaunchContext()).thenReturn(clc);
  when(container.getLocalizedResources()).thenReturn(null);
  Dispatcher dispatcher = mock(Dispatcher.class);
  EventHandler eventHandler = new EventHandler() {
    public void handle(Event event) {
      Assert.assertTrue(event instanceof ContainerExitEvent);
      ContainerExitEvent exitEvent = (ContainerExitEvent) event;
      Assert.assertEquals(ContainerEventType.CONTAINER_EXITED_WITH_FAILURE,
          exitEvent.getType());
    }
  };
  when(dispatcher.getEventHandler()).thenReturn(eventHandler);
  ContainerLaunch launch = new ContainerLaunch(context, new Configuration(),
      dispatcher, exec, null, container, dirsHandler, containerManager);
  launch.call();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestContainerLaunch.java

示例3: createContainersLauncher

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected ContainersLauncher createContainersLauncher(Context context,
    ContainerExecutor exec) {
  return new ContainersLauncher(context, super.dispatcher, exec,
                                super.dirsHandler, this) {
    @Override
    public void handle(ContainersLauncherEvent event) {
      Container container = event.getContainer();
      ContainerId containerId = container.getContainerId();
      switch (event.getType()) {
      case LAUNCH_CONTAINER:
        dispatcher.getEventHandler().handle(
            new ContainerEvent(containerId,
                ContainerEventType.CONTAINER_LAUNCHED));
        break;
      case CLEANUP_CONTAINER:
        dispatcher.getEventHandler().handle(
            new ContainerExitEvent(containerId,
                ContainerEventType.CONTAINER_KILLED_ON_REQUEST, 0,
                "Container exited with exit code 0."));
        break;
      }
    }
  };
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:DummyContainerManager.java

示例4: handle

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
public void handle(ContainerEvent event) {
  if (event instanceof ContainerExitEvent) {
    containerExitEventOccured = true;
    ContainerExitEvent exitEvent = (ContainerExitEvent) event;
    Assert.assertEquals(ContainerEventType.CONTAINER_EXITED_WITH_FAILURE,
        exitEvent.getType());
    LOG.info("Diagnostic Info : " + exitEvent.getDiagnosticInfo());
    if (testForMultiFile) {
      Assert.assertTrue("Should contain the Multi file information",
          exitEvent.getDiagnosticInfo().contains("Error files: "));
    }
    Assert.assertTrue(
        "Should contain the error Log message with tail size info",
        exitEvent.getDiagnosticInfo()
            .contains("Last "
                + YarnConfiguration.DEFAULT_NM_CONTAINER_STDERR_BYTES
                + " bytes of"));
    Assert.assertTrue("Should contain contents of error Log",
        exitEvent.getDiagnosticInfo().contains(
            INVALID_JAVA_HOME + "/bin/java: No such file or directory"));
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:23,代码来源:TestContainerLaunch.java

示例5: setup

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
@Before
public void setup() {
  executor = new MockExecutor();
  dispatcher = new AsyncDispatcher();
  context = Mockito.mock(Context.class);
  Mockito.doReturn(new ConcurrentSkipListMap<ContainerId, Container>())
      .when(context).getContainers();
  conf = new Configuration();
  conf.set(
      YarnConfiguration.NM_CONTAINER_MON_RESOURCE_CALCULATOR,
      MockResourceCalculatorPlugin.class.getCanonicalName());
  conf.set(
      YarnConfiguration.NM_CONTAINER_MON_PROCESS_TREE,
      MockResourceCalculatorProcessTree.class.getCanonicalName());
  dispatcher.init(conf);
  dispatcher.start();
  containerEventHandler = new MockContainerEventHandler();
  dispatcher.register(ContainerEventType.class, containerEventHandler);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:20,代码来源:TestContainersMonitorResourceChange.java

示例6: createContainersLauncher

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected ContainersLauncher createContainersLauncher(Context context,
    ContainerExecutor exec) {
  return new ContainersLauncher(context, super.dispatcher, exec,
                                super.dirsHandler) {
    @Override
    public void handle(ContainersLauncherEvent event) {
      Container container = event.getContainer();
      ContainerId containerId = container.getContainerId();
      switch (event.getType()) {
      case LAUNCH_CONTAINER:
        dispatcher.getEventHandler().handle(
            new ContainerEvent(containerId,
                ContainerEventType.CONTAINER_LAUNCHED));
        break;
      case CLEANUP_CONTAINER:
        dispatcher.getEventHandler().handle(
            new ContainerExitEvent(containerId,
                ContainerEventType.CONTAINER_KILLED_ON_REQUEST, 0,
                "Container exited with exit code 0."));
        break;
      }
    }
  };
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:27,代码来源:DummyContainerManager.java

示例7: testCallFailureWithNullLocalizedResources

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testCallFailureWithNullLocalizedResources() {
  Container container = mock(Container.class);
  when(container.getContainerId()).thenReturn(ContainerId.newInstance(
      ApplicationAttemptId.newInstance(ApplicationId.newInstance(
          System.currentTimeMillis(), 1), 1), 1));
  ContainerLaunchContext clc = mock(ContainerLaunchContext.class);
  when(clc.getCommands()).thenReturn(Collections.<String>emptyList());
  when(container.getLaunchContext()).thenReturn(clc);
  when(container.getLocalizedResources()).thenReturn(null);
  Dispatcher dispatcher = mock(Dispatcher.class);
  EventHandler eventHandler = new EventHandler() {
    public void handle(Event event) {
      Assert.assertTrue(event instanceof ContainerExitEvent);
      ContainerExitEvent exitEvent = (ContainerExitEvent) event;
      Assert.assertEquals(ContainerEventType.CONTAINER_EXITED_WITH_FAILURE,
          exitEvent.getType());
    }
  };
  when(dispatcher.getEventHandler()).thenReturn(eventHandler);
  ContainerLaunch launch = new ContainerLaunch(context, new Configuration(),
      dispatcher, exec, null, container, dirsHandler, containerManager);
  launch.call();
}
 
开发者ID:chendave,项目名称:hadoop-TCP,代码行数:26,代码来源:TestContainerLaunch.java

示例8: handle

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
@Override
public void handle(ContainerEvent event) {
  if (event.getType() == ContainerEventType.KILL_CONTAINER) {
    synchronized (killedContainer) {
      killedContainer.add(event.getContainerID());
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:9,代码来源:TestContainersMonitorResourceChange.java

示例9: handleCleanupContainerResources

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void handleCleanupContainerResources(
    ContainerLocalizationCleanupEvent rsrcCleanup) {
  Container c = rsrcCleanup.getContainer();
  Map<LocalResourceVisibility, Collection<LocalResourceRequest>> rsrcs =
    rsrcCleanup.getResources();
  for (Map.Entry<LocalResourceVisibility, Collection<LocalResourceRequest>> e :
       rsrcs.entrySet()) {
    LocalResourcesTracker tracker = getLocalResourcesTracker(e.getKey(), c.getUser(), 
        c.getContainerId().getApplicationAttemptId()
        .getApplicationId());
    for (LocalResourceRequest req : e.getValue()) {
      tracker.handle(new ResourceReleaseEvent(req,
          c.getContainerId()));
    }
  }
  String locId = ConverterUtils.toString(c.getContainerId());
  localizerTracker.cleanupPrivLocalizers(locId);
  
  // Delete the container directories
  String userName = c.getUser();
  String containerIDStr = c.toString();
  String appIDStr = ConverterUtils.toString(
      c.getContainerId().getApplicationAttemptId().getApplicationId());
  
  // Try deleting from good local dirs and full local dirs because a dir might
  // have gone bad while the app was running(disk full). In addition
  // a dir might have become good while the app was running.
  // Check if the container dir exists and if it does, try to delete it

  for (String localDir : dirsHandler.getLocalDirsForCleanup()) {
    // Delete the user-owned container-dir
    Path usersdir = new Path(localDir, ContainerLocalizer.USERCACHE);
    Path userdir = new Path(usersdir, userName);
    Path allAppsdir = new Path(userdir, ContainerLocalizer.APPCACHE);
    Path appDir = new Path(allAppsdir, appIDStr);
    Path containerDir = new Path(appDir, containerIDStr);
    submitDirForDeletion(userName, containerDir);

    // Delete the nmPrivate container-dir

    Path sysDir = new Path(localDir, NM_PRIVATE_DIR);
    Path appSysDir = new Path(sysDir, appIDStr);
    Path containerSysDir = new Path(appSysDir, containerIDStr);
    submitDirForDeletion(null, containerSysDir);
  }

  dispatcher.getEventHandler().handle(
      new ContainerEvent(c.getContainerId(),
          ContainerEventType.CONTAINER_RESOURCES_CLEANEDUP));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:52,代码来源:ResourceLocalizationService.java

示例10: handleContainerExitWithFailure

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
/**
 * Tries to tail and fetch TAIL_SIZE_IN_BYTES of data from the error log.
 * ErrorLog filename is not fixed and depends upon app, hence file name
 * pattern is used.
 * @param containerID
 * @param ret
 * @param containerLogDir
 * @param diagnosticInfo
 */
@SuppressWarnings("unchecked")
private void handleContainerExitWithFailure(ContainerId containerID, int ret,
    Path containerLogDir, StringBuilder diagnosticInfo) {
  LOG.warn(diagnosticInfo);

  String errorFileNamePattern =
      conf.get(YarnConfiguration.NM_CONTAINER_STDERR_PATTERN,
          YarnConfiguration.DEFAULT_NM_CONTAINER_STDERR_PATTERN);
  FSDataInputStream errorFileIS = null;
  try {
    FileSystem fileSystem = FileSystem.getLocal(conf).getRaw();
    FileStatus[] errorFileStatuses = fileSystem
        .globStatus(new Path(containerLogDir, errorFileNamePattern));
    if (errorFileStatuses != null && errorFileStatuses.length != 0) {
      long tailSizeInBytes =
          conf.getLong(YarnConfiguration.NM_CONTAINER_STDERR_BYTES,
              YarnConfiguration.DEFAULT_NM_CONTAINER_STDERR_BYTES);
      Path errorFile = errorFileStatuses[0].getPath();
      long fileSize = errorFileStatuses[0].getLen();

      // if more than one file matches the stderr pattern, take the latest
      // modified file, and also append the file names in the diagnosticInfo
      if (errorFileStatuses.length > 1) {
        String[] errorFileNames = new String[errorFileStatuses.length];
        long latestModifiedTime = errorFileStatuses[0].getModificationTime();
        errorFileNames[0] = errorFileStatuses[0].getPath().getName();
        for (int i = 1; i < errorFileStatuses.length; i++) {
          errorFileNames[i] = errorFileStatuses[i].getPath().getName();
          if (errorFileStatuses[i]
              .getModificationTime() > latestModifiedTime) {
            latestModifiedTime = errorFileStatuses[i].getModificationTime();
            errorFile = errorFileStatuses[i].getPath();
            fileSize = errorFileStatuses[i].getLen();
          }
        }
        diagnosticInfo.append("Error files : ")
            .append(StringUtils.join(", ", errorFileNames)).append(".\n");
      }

      long startPosition =
          (fileSize < tailSizeInBytes) ? 0 : fileSize - tailSizeInBytes;
      int bufferSize =
          (int) ((fileSize < tailSizeInBytes) ? fileSize : tailSizeInBytes);
      byte[] tailBuffer = new byte[bufferSize];
      errorFileIS = fileSystem.open(errorFile);
      errorFileIS.readFully(startPosition, tailBuffer);

      diagnosticInfo.append("Last ").append(tailSizeInBytes)
          .append(" bytes of ").append(errorFile.getName()).append(" :\n")
          .append(new String(tailBuffer, StandardCharsets.UTF_8));
    }
  } catch (IOException e) {
    LOG.error("Failed to get tail of the container's error log file", e);
  } finally {
    IOUtils.cleanup(LOG, errorFileIS);
  }

  this.dispatcher.getEventHandler()
      .handle(new ContainerExitEvent(containerID,
          ContainerEventType.CONTAINER_EXITED_WITH_FAILURE, ret,
          diagnosticInfo.toString()));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:72,代码来源:ContainerLaunch.java

示例11: ContainerManagerImpl

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
public ContainerManagerImpl(Context context, ContainerExecutor exec,
    DeletionService deletionContext, NodeStatusUpdater nodeStatusUpdater,
    NodeManagerMetrics metrics, ApplicationACLsManager aclsManager,
    LocalDirsHandlerService dirsHandler) {
  super(ContainerManagerImpl.class.getName());
  this.context = context;
  this.dirsHandler = dirsHandler;

  // ContainerManager level dispatcher.
  dispatcher = new AsyncDispatcher();
  this.deletionService = deletionContext;
  this.metrics = metrics;

  rsrcLocalizationSrvc =
      createResourceLocalizationService(exec, deletionContext, context);
  addService(rsrcLocalizationSrvc);

  containersLauncher = createContainersLauncher(context, exec);
  addService(containersLauncher);

  this.nodeStatusUpdater = nodeStatusUpdater;
  this.aclsManager = aclsManager;

  // Start configurable services
  auxiliaryServices = new AuxServices();
  auxiliaryServices.registerServiceListener(this);
  addService(auxiliaryServices);

  this.containersMonitor =
      new ContainersMonitorImpl(exec, dispatcher, this.context);
  addService(this.containersMonitor);

  dispatcher.register(ContainerEventType.class,
      new ContainerEventDispatcher());
  dispatcher.register(ApplicationEventType.class,
      new ApplicationEventDispatcher());
  dispatcher.register(LocalizationEventType.class, rsrcLocalizationSrvc);
  dispatcher.register(AuxServicesEventType.class, auxiliaryServices);
  dispatcher.register(ContainersMonitorEventType.class, containersMonitor);
  dispatcher.register(ContainersLauncherEventType.class, containersLauncher);
  
  addService(dispatcher);

  ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
  this.readLock = lock.readLock();
  this.writeLock = lock.writeLock();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:48,代码来源:ContainerManagerImpl.java

示例12: testConsistency

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
@Test(timeout=10000)
@SuppressWarnings("unchecked")
public void testConsistency() {
  String user = "testuser";
  DrainDispatcher dispatcher = null;
  try {
    Configuration conf = new Configuration();
    dispatcher = createDispatcher(conf);
    EventHandler<LocalizerEvent> localizerEventHandler = mock(EventHandler.class);
    EventHandler<LocalizerEvent> containerEventHandler = mock(EventHandler.class);
    dispatcher.register(LocalizerEventType.class, localizerEventHandler);
    dispatcher.register(ContainerEventType.class, containerEventHandler);

    ContainerId cId1 = BuilderUtils.newContainerId(1, 1, 1, 1);
    LocalizerContext lc1 = new LocalizerContext(user, cId1, null);
    LocalResourceRequest req1 = createLocalResourceRequest(user, 1, 1,
        LocalResourceVisibility.PUBLIC);
    LocalizedResource lr1 = createLocalizedResource(req1, dispatcher);
    ConcurrentMap<LocalResourceRequest, LocalizedResource> localrsrc = new ConcurrentHashMap<LocalResourceRequest, LocalizedResource>();
    localrsrc.put(req1, lr1);
    LocalResourcesTracker tracker = new LocalResourcesTrackerImpl(user,
        null, dispatcher, localrsrc, false, conf,
        new NMNullStateStoreService(), null);

    ResourceEvent req11Event = new ResourceRequestEvent(req1,
        LocalResourceVisibility.PUBLIC, lc1);

    ResourceEvent rel11Event = new ResourceReleaseEvent(req1, cId1);

    // Localize R1 for C1
    tracker.handle(req11Event);

    dispatcher.await();

    // Verify refCount for R1 is 1
    Assert.assertEquals(1, lr1.getRefCount());

    dispatcher.await();
    verifyTrackedResourceCount(tracker, 1);

    // Localize resource1
    ResourceLocalizedEvent rle = new ResourceLocalizedEvent(req1, new Path(
        "file:///tmp/r1"), 1);
    lr1.handle(rle);
    Assert.assertTrue(lr1.getState().equals(ResourceState.LOCALIZED));
    Assert.assertTrue(createdummylocalizefile(new Path("file:///tmp/r1")));
    LocalizedResource rsrcbefore = tracker.iterator().next();
    File resFile = new File(lr1.getLocalPath().toUri().getRawPath()
        .toString());
    Assert.assertTrue(resFile.exists());
    Assert.assertTrue(resFile.delete());

    // Localize R1 for C1
    tracker.handle(req11Event);

    dispatcher.await();
    lr1.handle(rle);
    Assert.assertTrue(lr1.getState().equals(ResourceState.LOCALIZED));
    LocalizedResource rsrcafter = tracker.iterator().next();
    if (rsrcbefore == rsrcafter) {
      Assert.fail("Localized resource should not be equal");
    }
    // Release resource1
    tracker.handle(rel11Event);
  } finally {
    if (dispatcher != null) {
      dispatcher.stop();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:71,代码来源:TestLocalResourcesTrackerImpl.java

示例13: testStateStoreSuccessfulLocalization

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testStateStoreSuccessfulLocalization() throws Exception {
  final String user = "someuser";
  final ApplicationId appId = ApplicationId.newInstance(1, 1);
  // This is a random path. NO File creation will take place at this place.
  final Path localDir = new Path("/tmp");
  Configuration conf = new YarnConfiguration();
  DrainDispatcher dispatcher = null;
  dispatcher = createDispatcher(conf);
  EventHandler<LocalizerEvent> localizerEventHandler =
      mock(EventHandler.class);
  EventHandler<LocalizerEvent> containerEventHandler =
      mock(EventHandler.class);
  dispatcher.register(LocalizerEventType.class, localizerEventHandler);
  dispatcher.register(ContainerEventType.class, containerEventHandler);
  DeletionService mockDelService = mock(DeletionService.class);
  NMStateStoreService stateStore = mock(NMStateStoreService.class);

  try {
    LocalResourcesTracker tracker = new LocalResourcesTrackerImpl(user,
        appId, dispatcher, false, conf, stateStore);
    // Container 1 needs lr1 resource
    ContainerId cId1 = BuilderUtils.newContainerId(1, 1, 1, 1);
    LocalResourceRequest lr1 = createLocalResourceRequest(user, 1, 1,
        LocalResourceVisibility.APPLICATION);
    LocalizerContext lc1 = new LocalizerContext(user, cId1, null);

    // Container 1 requests lr1 to be localized
    ResourceEvent reqEvent1 = new ResourceRequestEvent(lr1,
        LocalResourceVisibility.APPLICATION, lc1);
    tracker.handle(reqEvent1);
    dispatcher.await();

    // Simulate the process of localization of lr1
    Path hierarchicalPath1 = tracker.getPathForLocalization(lr1, localDir,
        null);

    ArgumentCaptor<LocalResourceProto> localResourceCaptor =
        ArgumentCaptor.forClass(LocalResourceProto.class);
    ArgumentCaptor<Path> pathCaptor = ArgumentCaptor.forClass(Path.class);
    verify(stateStore).startResourceLocalization(eq(user), eq(appId),
        localResourceCaptor.capture(), pathCaptor.capture());
    LocalResourceProto lrProto = localResourceCaptor.getValue();
    Path localizedPath1 = pathCaptor.getValue();
    Assert.assertEquals(lr1,
        new LocalResourceRequest(new LocalResourcePBImpl(lrProto)));
    Assert.assertEquals(hierarchicalPath1, localizedPath1.getParent());

    // Simulate lr1 getting localized
    ResourceLocalizedEvent rle1 =
        new ResourceLocalizedEvent(lr1, pathCaptor.getValue(), 120);
    tracker.handle(rle1);
    dispatcher.await();

    ArgumentCaptor<LocalizedResourceProto> localizedProtoCaptor =
        ArgumentCaptor.forClass(LocalizedResourceProto.class);
    verify(stateStore).finishResourceLocalization(eq(user), eq(appId),
        localizedProtoCaptor.capture());
    LocalizedResourceProto localizedProto = localizedProtoCaptor.getValue();
    Assert.assertEquals(lr1, new LocalResourceRequest(
        new LocalResourcePBImpl(localizedProto.getResource())));
    Assert.assertEquals(localizedPath1.toString(),
        localizedProto.getLocalPath());
    LocalizedResource localizedRsrc1 = tracker.getLocalizedResource(lr1);
    Assert.assertNotNull(localizedRsrc1);

    // simulate release and retention processing
    tracker.handle(new ResourceReleaseEvent(lr1, cId1));
    dispatcher.await();
    boolean removeResult = tracker.remove(localizedRsrc1, mockDelService);

    Assert.assertTrue(removeResult);
    verify(stateStore).removeLocalizedResource(eq(user), eq(appId),
        eq(localizedPath1));
  } finally {
    if (dispatcher != null) {
      dispatcher.stop();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:82,代码来源:TestLocalResourcesTrackerImpl.java

示例14: testStateStoreFailedLocalization

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testStateStoreFailedLocalization() throws Exception {
  final String user = "someuser";
  final ApplicationId appId = ApplicationId.newInstance(1, 1);
  // This is a random path. NO File creation will take place at this place.
  final Path localDir = new Path("/tmp");
  Configuration conf = new YarnConfiguration();
  DrainDispatcher dispatcher = null;
  dispatcher = createDispatcher(conf);
  EventHandler<LocalizerEvent> localizerEventHandler =
      mock(EventHandler.class);
  EventHandler<LocalizerEvent> containerEventHandler =
      mock(EventHandler.class);
  dispatcher.register(LocalizerEventType.class, localizerEventHandler);
  dispatcher.register(ContainerEventType.class, containerEventHandler);
  NMStateStoreService stateStore = mock(NMStateStoreService.class);

  try {
    LocalResourcesTracker tracker = new LocalResourcesTrackerImpl(user,
        appId, dispatcher, false, conf, stateStore);
    // Container 1 needs lr1 resource
    ContainerId cId1 = BuilderUtils.newContainerId(1, 1, 1, 1);
    LocalResourceRequest lr1 = createLocalResourceRequest(user, 1, 1,
        LocalResourceVisibility.APPLICATION);
    LocalizerContext lc1 = new LocalizerContext(user, cId1, null);

    // Container 1 requests lr1 to be localized
    ResourceEvent reqEvent1 = new ResourceRequestEvent(lr1,
        LocalResourceVisibility.APPLICATION, lc1);
    tracker.handle(reqEvent1);
    dispatcher.await();

    // Simulate the process of localization of lr1
    Path hierarchicalPath1 = tracker.getPathForLocalization(lr1, localDir,
        null);

    ArgumentCaptor<LocalResourceProto> localResourceCaptor =
        ArgumentCaptor.forClass(LocalResourceProto.class);
    ArgumentCaptor<Path> pathCaptor = ArgumentCaptor.forClass(Path.class);
    verify(stateStore).startResourceLocalization(eq(user), eq(appId),
        localResourceCaptor.capture(), pathCaptor.capture());
    LocalResourceProto lrProto = localResourceCaptor.getValue();
    Path localizedPath1 = pathCaptor.getValue();
    Assert.assertEquals(lr1,
        new LocalResourceRequest(new LocalResourcePBImpl(lrProto)));
    Assert.assertEquals(hierarchicalPath1, localizedPath1.getParent());

    ResourceFailedLocalizationEvent rfe1 =
        new ResourceFailedLocalizationEvent(
            lr1, new Exception("Test").toString());
    tracker.handle(rfe1);
    dispatcher.await();
    verify(stateStore).removeLocalizedResource(eq(user), eq(appId),
        eq(localizedPath1));
  } finally {
    if (dispatcher != null) {
      dispatcher.stop();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:62,代码来源:TestLocalResourcesTrackerImpl.java

示例15: testRecoveredResource

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testRecoveredResource() throws Exception {
  final String user = "someuser";
  final ApplicationId appId = ApplicationId.newInstance(1, 1);
  // This is a random path. NO File creation will take place at this place.
  final Path localDir = new Path("/tmp/localdir");
  Configuration conf = new YarnConfiguration();
  DrainDispatcher dispatcher = null;
  dispatcher = createDispatcher(conf);
  EventHandler<LocalizerEvent> localizerEventHandler =
      mock(EventHandler.class);
  EventHandler<LocalizerEvent> containerEventHandler =
      mock(EventHandler.class);
  dispatcher.register(LocalizerEventType.class, localizerEventHandler);
  dispatcher.register(ContainerEventType.class, containerEventHandler);
  NMStateStoreService stateStore = mock(NMStateStoreService.class);

  try {
    LocalResourcesTracker tracker = new LocalResourcesTrackerImpl(user,
        appId, dispatcher, false, conf, stateStore);
    // Container 1 needs lr1 resource
    ContainerId cId1 = BuilderUtils.newContainerId(1, 1, 1, 1);
    LocalResourceRequest lr1 = createLocalResourceRequest(user, 1, 1,
        LocalResourceVisibility.APPLICATION);
    Assert.assertNull(tracker.getLocalizedResource(lr1));
    final long localizedId1 = 52;
    Path hierarchicalPath1 = new Path(localDir,
        Long.toString(localizedId1));
    Path localizedPath1 = new Path(hierarchicalPath1, "resource.jar");
    tracker.handle(new ResourceRecoveredEvent(lr1, localizedPath1, 120));
    dispatcher.await();
    Assert.assertNotNull(tracker.getLocalizedResource(lr1));

    // verify new paths reflect recovery of previous resources
    LocalResourceRequest lr2 = createLocalResourceRequest(user, 2, 2,
        LocalResourceVisibility.APPLICATION);
    LocalizerContext lc2 = new LocalizerContext(user, cId1, null);
    ResourceEvent reqEvent2 = new ResourceRequestEvent(lr2,
        LocalResourceVisibility.APPLICATION, lc2);
    tracker.handle(reqEvent2);
    dispatcher.await();
    Path hierarchicalPath2 = tracker.getPathForLocalization(lr2, localDir,
        null);
    long localizedId2 = Long.parseLong(hierarchicalPath2.getName());
    Assert.assertEquals(localizedId1 + 1, localizedId2);
  } finally {
    if (dispatcher != null) {
      dispatcher.stop();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:53,代码来源:TestLocalResourcesTrackerImpl.java


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