• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ContainerResourceFailedEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: transition

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceFailedEvent; //导入依赖的package包/类
@Override
public void transition(LocalizedResource rsrc, ResourceEvent event) {
  ResourceFailedLocalizationEvent failedEvent =
      (ResourceFailedLocalizationEvent) event;
  Queue<ContainerId> containers = rsrc.ref;
  for (ContainerId container : containers) {
    rsrc.dispatcher.getEventHandler().handle(
      new ContainerResourceFailedEvent(container, failedEvent
        .getLocalResourceRequest(), failedEvent.getDiagnosticMessage()));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:LocalizedResource.java


示例2: run

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceFailedEvent; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked") // dispatcher not typed
public void run() {
  Path nmPrivateCTokensPath = null;
  Throwable exception = null;
  try {
    // Get nmPrivateDir
    nmPrivateCTokensPath =
      dirsHandler.getLocalPathForWrite(
            NM_PRIVATE_DIR + Path.SEPARATOR
                + String.format(ContainerLocalizer.TOKEN_FILE_NAME_FMT,
                    localizerId));

    // 0) init queue, etc.
    // 1) write credentials to private dir
    writeCredentials(nmPrivateCTokensPath);
    // 2) exec initApplication and wait
    if (dirsHandler.areDisksHealthy()) {
      exec.startLocalizer(new LocalizerStartContext.Builder()
          .setNmPrivateContainerTokens(nmPrivateCTokensPath)
          .setNmAddr(localizationServerAddress)
          .setUser(context.getUser())
          .setAppId(ConverterUtils.toString(context.getContainerId()
              .getApplicationAttemptId().getApplicationId()))
          .setLocId(localizerId)
          .setDirsHandler(dirsHandler)
          .build());
    } else {
      throw new IOException("All disks failed. "
          + dirsHandler.getDisksHealthReport(false));
    }
  // TODO handle ExitCodeException separately?
  } catch (FSError fe) {
    exception = fe;
  } catch (Exception e) {
    exception = e;
  } finally {
    if (exception != null) {
      LOG.info("Localizer failed", exception);
      // On error, report failure to Container and signal ABORT
      // Notify resource of failed localization
      ContainerId cId = context.getContainerId();
      dispatcher.getEventHandler().handle(new ContainerResourceFailedEvent(
          cId, null, exception.getMessage()));
    }
    for (LocalizerResourceRequestEvent event : scheduled.values()) {
      event.getResource().unlock();
    }
    delService.delete(null, nmPrivateCTokensPath, new Path[] {});
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:52,代码来源:ResourceLocalizationService.java


示例3: testLocalizerRunnerException

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceFailedEvent; //导入依赖的package包/类
@Test( timeout = 10000)
@SuppressWarnings("unchecked") // mocked generics
public void testLocalizerRunnerException() throws Exception {
  DrainDispatcher dispatcher = new DrainDispatcher();
  dispatcher.init(conf);
  dispatcher.start();
  EventHandler<ApplicationEvent> applicationBus = mock(EventHandler.class);
  dispatcher.register(ApplicationEventType.class, applicationBus);
  EventHandler<ContainerEvent> containerBus = mock(EventHandler.class);
  dispatcher.register(ContainerEventType.class, containerBus);

  ContainerExecutor exec = mock(ContainerExecutor.class);
  LocalDirsHandlerService dirsHandler = new LocalDirsHandlerService();
  LocalDirsHandlerService dirsHandlerSpy = spy(dirsHandler);
  dirsHandlerSpy.init(conf);

  DeletionService delServiceReal = new DeletionService(exec);
  DeletionService delService = spy(delServiceReal);
  delService.init(new Configuration());
  delService.start();

  ResourceLocalizationService rawService =
      new ResourceLocalizationService(dispatcher, exec, delService,
      dirsHandlerSpy, nmContext);
  ResourceLocalizationService spyService = spy(rawService);
  doReturn(mockServer).when(spyService).createServer();
  try {
    spyService.init(conf);
    spyService.start();

    // init application
    final Application app = mock(Application.class);
    final ApplicationId appId =
        BuilderUtils.newApplicationId(314159265358979L, 3);
    when(app.getUser()).thenReturn("user0");
    when(app.getAppId()).thenReturn(appId);
    spyService.handle(new ApplicationLocalizationEvent(
        LocalizationEventType.INIT_APPLICATION_RESOURCES, app));
    dispatcher.await();

    Random r = new Random();
    long seed = r.nextLong();
    System.out.println("SEED: " + seed);
    r.setSeed(seed);
    final Container c = getMockContainer(appId, 42, "user0");
    final LocalResource resource1 = getPrivateMockedResource(r);
    System.out.println("Here 4");
    
    final LocalResourceRequest req1 = new LocalResourceRequest(resource1);
    Map<LocalResourceVisibility, Collection<LocalResourceRequest>> rsrcs =
      new HashMap<LocalResourceVisibility, 
                  Collection<LocalResourceRequest>>();
    List<LocalResourceRequest> privateResourceList =
        new ArrayList<LocalResourceRequest>();
    privateResourceList.add(req1);
    rsrcs.put(LocalResourceVisibility.PRIVATE, privateResourceList);

    final Constructor<?>[] constructors =
        FSError.class.getDeclaredConstructors();
    constructors[0].setAccessible(true);
    FSError fsError =
        (FSError) constructors[0].newInstance(new IOException("Disk Error"));

    Mockito
      .doThrow(fsError)
      .when(dirsHandlerSpy)
      .getLocalPathForWrite(isA(String.class));
    spyService.handle(new ContainerLocalizationRequestEvent(c, rsrcs));
    Thread.sleep(1000);
    dispatcher.await();
    // Verify if ContainerResourceFailedEvent is invoked on FSError
    verify(containerBus).handle(isA(ContainerResourceFailedEvent.class));
  } finally {
    spyService.stop();
    dispatcher.stop();
    delService.stop();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:79,代码来源:TestResourceLocalizationService.java


示例4: run

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceFailedEvent; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked") // dispatcher not typed
public void run() {
  Path nmPrivateCTokensPath = null;
  Throwable exception = null;
  try {
    // Get nmPrivateDir
    nmPrivateCTokensPath =
      dirsHandler.getLocalPathForWrite(
            NM_PRIVATE_DIR + Path.SEPARATOR
                + String.format(ContainerLocalizer.TOKEN_FILE_NAME_FMT,
                    localizerId));

    // 0) init queue, etc.
    // 1) write credentials to private dir
    writeCredentials(nmPrivateCTokensPath);
    // 2) exec initApplication and wait
    if (dirsHandler.areDisksHealthy()) {
      exec.startLocalizer(new LocalizerStartContext.Builder()
          .setNmPrivateContainerTokens(nmPrivateCTokensPath)
          .setNmAddr(localizationServerAddress)
          .setUser(context.getUser())
          .setAppId(ConverterUtils.toString(context.getContainerId()
              .getApplicationAttemptId().getApplicationId()))
          .setLocId(localizerId)
          .setDirsHandler(dirsHandler)
          .build());
    } else {
      throw new IOException("All disks failed. "
          + dirsHandler.getDisksHealthReport(false));
    }
  // TODO handle ExitCodeException separately?
  } catch (FSError fe) {
    exception = fe;
  } catch (Exception e) {
    exception = e;
  } finally {
    if (exception != null) {
      LOG.info("Localizer failed", exception);
      // On error, report failure to Container and signal ABORT
      // Notify resource of failed localization
      ContainerId cId = context.getContainerId();
      dispatcher.getEventHandler().handle(new ContainerResourceFailedEvent(
          cId, null, exception.getMessage()));
    }
    List<Path> paths = new ArrayList<Path>();
    for (LocalizerResourceRequestEvent event : scheduled.values()) {
      // This means some resources were in downloading state. Schedule
      // deletion task for localization dir and tmp dir used for downloading
      Path locRsrcPath = event.getResource().getLocalPath();
      if (locRsrcPath != null) {
        Path locRsrcDirPath = locRsrcPath.getParent();
        paths.add(locRsrcDirPath);
        paths.add(new Path(locRsrcDirPath + "_tmp"));
      }
      event.getResource().unlock();
    }
    if (!paths.isEmpty()) {
      delService.delete(context.getUser(),
          null, paths.toArray(new Path[paths.size()]));
    }
    delService.delete(null, nmPrivateCTokensPath, new Path[] {});
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:65,代码来源:ResourceLocalizationService.java


示例5: run

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceFailedEvent; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked") // dispatcher not typed
public void run() {
  Path nmPrivateCTokensPath = null;
  Throwable exception = null;
  try {
    // Get nmPrivateDir
    nmPrivateCTokensPath =
      dirsHandler.getLocalPathForWrite(
            NM_PRIVATE_DIR + Path.SEPARATOR
                + String.format(ContainerLocalizer.TOKEN_FILE_NAME_FMT,
                    localizerId));

    // 0) init queue, etc.
    // 1) write credentials to private dir
    writeCredentials(nmPrivateCTokensPath);
    // 2) exec initApplication and wait
    List<String> localDirs = getInitializedLocalDirs();
    List<String> logDirs = getInitializedLogDirs();
    if (dirsHandler.areDisksHealthy()) {
      exec.startLocalizer(nmPrivateCTokensPath, localizationServerAddress,
          context.getUser(),
          ConverterUtils.toString(
              context.getContainerId().
              getApplicationAttemptId().getApplicationId()),
          localizerId,
          dirsHandler);
    } else {
      throw new IOException("All disks failed. "
          + dirsHandler.getDisksHealthReport(false));
    }
  // TODO handle ExitCodeException separately?
  } catch (FSError fe) {
    exception = fe;
  } catch (Exception e) {
    exception = e;
  } finally {
    if (exception != null) {
      LOG.info("Localizer failed", exception);
      // On error, report failure to Container and signal ABORT
      // Notify resource of failed localization
      ContainerId cId = context.getContainerId();
      dispatcher.getEventHandler().handle(new ContainerResourceFailedEvent(
          cId, null, exception.getMessage()));
    }
    for (LocalizerResourceRequestEvent event : scheduled.values()) {
      event.getResource().unlock();
    }
    delService.delete(null, nmPrivateCTokensPath, new Path[] {});
  }
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:52,代码来源:ResourceLocalizationService.java


示例6: run

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceFailedEvent; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked") // dispatcher not typed
public void run() {
  Path nmPrivateCTokensPath = null;
  Throwable exception = null;
  try {
    // Get nmPrivateDir
    nmPrivateCTokensPath =
      dirsHandler.getLocalPathForWrite(
            NM_PRIVATE_DIR + Path.SEPARATOR
                + String.format(ContainerLocalizer.TOKEN_FILE_NAME_FMT,
                    localizerId));

    // 0) init queue, etc.
    // 1) write credentials to private dir
    writeCredentials(nmPrivateCTokensPath);
    // 2) exec initApplication and wait
    if (dirsHandler.areDisksHealthy()) {
      exec.startLocalizer(nmPrivateCTokensPath, localizationServerAddress,
          context.getUser(),
          ConverterUtils.toString(
              context.getContainerId().
              getApplicationAttemptId().getApplicationId()),
          localizerId,
          dirsHandler);
    } else {
      throw new IOException("All disks failed. "
          + dirsHandler.getDisksHealthReport(false));
    }
  // TODO handle ExitCodeException separately?
  } catch (FSError fe) {
    exception = fe;
  } catch (Exception e) {
    exception = e;
  } finally {
    if (exception != null) {
      LOG.info("Localizer failed", exception);
      // On error, report failure to Container and signal ABORT
      // Notify resource of failed localization
      ContainerId cId = context.getContainerId();
      dispatcher.getEventHandler().handle(new ContainerResourceFailedEvent(
          cId, null, exception.getMessage()));
    }
    for (LocalizerResourceRequestEvent event : scheduled.values()) {
      event.getResource().unlock();
    }
    delService.delete(null, nmPrivateCTokensPath, new Path[] {});
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:50,代码来源:ResourceLocalizationService.java


示例7: run

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceFailedEvent; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked") // dispatcher not typed
public void run() {
  Path nmPrivateCTokensPath = null;
  try {
    // Get nmPrivateDir
    nmPrivateCTokensPath =
      dirsHandler.getLocalPathForWrite(
            NM_PRIVATE_DIR + Path.SEPARATOR
                + String.format(ContainerLocalizer.TOKEN_FILE_NAME_FMT,
                    localizerId));

    // 0) init queue, etc.
    // 1) write credentials to private dir
    writeCredentials(nmPrivateCTokensPath);
    // 2) exec initApplication and wait
    List<String> localDirs = dirsHandler.getLocalDirs();
    List<String> logDirs = dirsHandler.getLogDirs();
    if (dirsHandler.areDisksHealthy()) {
      exec.startLocalizer(nmPrivateCTokensPath, localizationServerAddress,
          context.getUser(),
          ConverterUtils.toString(
              context.getContainerId().
              getApplicationAttemptId().getApplicationId()),
          localizerId, localDirs, logDirs);
    } else {
      throw new IOException("All disks failed. "
          + dirsHandler.getDisksHealthReport());
    }
  // TODO handle ExitCodeException separately?
  } catch (Exception e) {
    LOG.info("Localizer failed", e);
    // 3) on error, report failure to Container and signal ABORT
    // 3.1) notify resource of failed localization
    ContainerId cId = context.getContainerId();
    dispatcher.getEventHandler().handle(
        new ContainerResourceFailedEvent(cId, null, e.getMessage()));
  } finally {
    for (LocalizerResourceRequestEvent event : scheduled.values()) {
      event.getResource().unlock();
    }
    delService.delete(null, nmPrivateCTokensPath, new Path[] {});
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:45,代码来源:ResourceLocalizationService.java


示例8: run

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceFailedEvent; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked") // dispatcher not typed
public void run() {
  Path nmPrivateCTokensPath = null;
  Throwable exception = null;
  try {
    // Get nmPrivateDir
    nmPrivateCTokensPath =
      dirsHandler.getLocalPathForWrite(
            NM_PRIVATE_DIR + Path.SEPARATOR
                + String.format(ContainerLocalizer.TOKEN_FILE_NAME_FMT,
                    localizerId));

    // 0) init queue, etc.
    // 1) write credentials to private dir
    writeCredentials(nmPrivateCTokensPath);
    // 2) exec initApplication and wait
    if (dirsHandler.areDisksHealthy()) {
      exec.startLocalizer(new LocalizerStartContext.Builder()
          .setNmPrivateContainerTokens(nmPrivateCTokensPath)
          .setNmAddr(localizationServerAddress)
          .setUser(context.getUser())
          .setAppId(context.getContainerId()
              .getApplicationAttemptId().getApplicationId().toString())
          .setLocId(localizerId)
          .setDirsHandler(dirsHandler)
          .setUserFolder(context.getUserFolder())
          .build());
    } else {
      throw new IOException("All disks failed. "
          + dirsHandler.getDisksHealthReport(false));
    }
  // TODO handle ExitCodeException separately?
  } catch (FSError fe) {
    exception = fe;
  } catch (Exception e) {
    exception = e;
  } finally {
    if (exception != null) {
      LOG.info("Localizer failed", exception);
      // On error, report failure to Container and signal ABORT
      // Notify resource of failed localization
      ContainerId cId = context.getContainerId();
      dispatcher.getEventHandler().handle(new ContainerResourceFailedEvent(
          cId, null, exception.getMessage()));
    }
    List<Path> paths = new ArrayList<Path>();
    for (LocalizerResourceRequestEvent event : scheduled.values()) {
      // This means some resources were in downloading state. Schedule
      // deletion task for localization dir and tmp dir used for downloading
      Path locRsrcPath = event.getResource().getLocalPath();
      if (locRsrcPath != null) {
        Path locRsrcDirPath = locRsrcPath.getParent();
        paths.add(locRsrcDirPath);
        paths.add(new Path(locRsrcDirPath + "_tmp"));
      }
      event.getResource().unlock();
    }
    if (!paths.isEmpty()) {
      delService.delete(context.getUser(),
          null, paths.toArray(new Path[paths.size()]));
    }
    delService.delete(null, nmPrivateCTokensPath, new Path[] {});
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:66,代码来源:ResourceLocalizationService.java


示例9: testLocalizerRunnerException

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceFailedEvent; //导入依赖的package包/类
@Test( timeout = 10000)
@SuppressWarnings("unchecked") // mocked generics
public void testLocalizerRunnerException() throws Exception {
  DrainDispatcher dispatcher = new DrainDispatcher();
  dispatcher.init(conf);
  dispatcher.start();
  EventHandler<ApplicationEvent> applicationBus = mock(EventHandler.class);
  dispatcher.register(ApplicationEventType.class, applicationBus);
  EventHandler<ContainerEvent> containerBus = mock(EventHandler.class);
  dispatcher.register(ContainerEventType.class, containerBus);

  ContainerExecutor exec = mock(ContainerExecutor.class);
  LocalDirsHandlerService dirsHandler = new LocalDirsHandlerService();
  LocalDirsHandlerService dirsHandlerSpy = spy(dirsHandler);
  dirsHandlerSpy.init(conf);

  DeletionService delServiceReal = new DeletionService(exec);
  DeletionService delService = spy(delServiceReal);
  delService.init(new Configuration());
  delService.start();

  ResourceLocalizationService rawService =
      new ResourceLocalizationService(dispatcher, exec, delService,
      dirsHandlerSpy, nmContext);
  ResourceLocalizationService spyService = spy(rawService);
  doReturn(mockServer).when(spyService).createServer();
  try {
    spyService.init(conf);
    spyService.start();

    // init application
    final Application app = mock(Application.class);
    final ApplicationId appId =
        BuilderUtils.newApplicationId(314159265358979L, 3);
    when(app.getUser()).thenReturn("user0");
    when(app.getAppId()).thenReturn(appId);
    spyService.handle(new ApplicationLocalizationEvent(
        LocalizationEventType.INIT_APPLICATION_RESOURCES, app));
    dispatcher.await();

    Random r = new Random();
    long seed = r.nextLong();
    System.out.println("SEED: " + seed);
    r.setSeed(seed);
    final Container c = getMockContainer(appId, 42, "user0", "user0Folder");
    final LocalResource resource1 = getPrivateMockedResource(r);
    System.out.println("Here 4");
    
    final LocalResourceRequest req1 = new LocalResourceRequest(resource1);
    Map<LocalResourceVisibility, Collection<LocalResourceRequest>> rsrcs =
      new HashMap<LocalResourceVisibility, 
                  Collection<LocalResourceRequest>>();
    List<LocalResourceRequest> privateResourceList =
        new ArrayList<LocalResourceRequest>();
    privateResourceList.add(req1);
    rsrcs.put(LocalResourceVisibility.PRIVATE, privateResourceList);

    final Constructor<?>[] constructors =
        FSError.class.getDeclaredConstructors();
    constructors[0].setAccessible(true);
    FSError fsError =
        (FSError) constructors[0].newInstance(new IOException("Disk Error"));

    Mockito
      .doThrow(fsError)
      .when(dirsHandlerSpy)
      .getLocalPathForWrite(isA(String.class));
    spyService.handle(new ContainerLocalizationRequestEvent(c, rsrcs));
    Thread.sleep(1000);
    dispatcher.await();
    // Verify if ContainerResourceFailedEvent is invoked on FSError
    verify(containerBus).handle(isA(ContainerResourceFailedEvent.class));
  } finally {
    spyService.stop();
    dispatcher.stop();
    delService.stop();
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:79,代码来源:TestResourceLocalizationService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GetContainerReportResponse类代码示例发布时间:2022-05-22
下一篇:
Java SampleTableBox类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap