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


Java DeletionService.init方法代码示例

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


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

示例1: testHandlingApplicationFinishedEvent

import org.apache.hadoop.yarn.server.nodemanager.DeletionService; //导入方法依赖的package包/类
@Test
public void testHandlingApplicationFinishedEvent() throws IOException {
  DeletionService delService = new DeletionService(null);
  NonAggregatingLogHandler aggregatingLogHandler =
      new NonAggregatingLogHandler(new InlineDispatcher(),
          delService,
          dirsHandler,
          new NMNullStateStoreService());

  dirsHandler.init(conf);
  dirsHandler.start();
  delService.init(conf);
  delService.start();
  aggregatingLogHandler.init(conf);
  aggregatingLogHandler.start();
  
  // It should NOT throw RejectedExecutionException
  aggregatingLogHandler.handle(new LogHandlerAppFinishedEvent(appId));
  aggregatingLogHandler.stop();

  // It should NOT throw RejectedExecutionException after stopping
  // handler service.
  aggregatingLogHandler.handle(new LogHandlerAppFinishedEvent(appId));
  aggregatingLogHandler.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestNonAggregatingLogHandler.java

示例2: testHandlingApplicationFinishedEvent

import org.apache.hadoop.yarn.server.nodemanager.DeletionService; //导入方法依赖的package包/类
@Test
public void testHandlingApplicationFinishedEvent() throws IOException {
  DeletionService delService = new DeletionService(null);
  NonAggregatingLogHandler aggregatingLogHandler =
      new NonAggregatingLogHandler(new InlineDispatcher(),
          delService,
          dirsHandler);

  dirsHandler.init(conf);
  dirsHandler.start();
  delService.init(conf);
  delService.start();
  aggregatingLogHandler.init(conf);
  aggregatingLogHandler.start();
  
  // It should NOT throw RejectedExecutionException
  aggregatingLogHandler.handle(new LogHandlerAppFinishedEvent(appId));
  aggregatingLogHandler.stop();

  // It should NOT throw RejectedExecutionException after stopping
  // handler service.
  aggregatingLogHandler.handle(new LogHandlerAppFinishedEvent(appId));
  aggregatingLogHandler.close();
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:25,代码来源:TestNonAggregatingLogHandler.java

示例3: testLocalizerRunnerException

import org.apache.hadoop.yarn.server.nodemanager.DeletionService; //导入方法依赖的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: testLocalizationInit

import org.apache.hadoop.yarn.server.nodemanager.DeletionService; //导入方法依赖的package包/类
@Test
public void testLocalizationInit() throws Exception {
  conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
  AsyncDispatcher dispatcher = new AsyncDispatcher();
  dispatcher.init(new Configuration());

  ContainerExecutor exec = mock(ContainerExecutor.class);
  DeletionService delService = spy(new DeletionService(exec));
  delService.init(conf);
  delService.start();

  List<Path> localDirs = new ArrayList<Path>();
  String[] sDirs = new String[4];
  for (int i = 0; i < 4; ++i) {
    localDirs.add(lfs.makeQualified(new Path(basedir, i + "")));
    sDirs[i] = localDirs.get(i).toString();
  }
  conf.setStrings(YarnConfiguration.NM_LOCAL_DIRS, sDirs);

  LocalDirsHandlerService diskhandler = new LocalDirsHandlerService();
  diskhandler.init(conf);

  ResourceLocalizationService locService =
    spy(new ResourceLocalizationService(dispatcher, exec, delService,
                                        diskhandler, nmContext));
  doReturn(lfs)
    .when(locService).getLocalFileContext(isA(Configuration.class));
  try {
    dispatcher.start();

    // initialize ResourceLocalizationService
    locService.init(conf);

    final FsPermission defaultPerm = new FsPermission((short)0755);

    // verify directory creation
    for (Path p : localDirs) {
      p = new Path((new URI(p.toString())).getPath());
      Path usercache = new Path(p, ContainerLocalizer.USERCACHE);
      verify(spylfs)
        .mkdir(eq(usercache),
            eq(defaultPerm), eq(true));
      Path publicCache = new Path(p, ContainerLocalizer.FILECACHE);
      verify(spylfs)
        .mkdir(eq(publicCache),
            eq(defaultPerm), eq(true));
      Path nmPriv = new Path(p, ResourceLocalizationService.NM_PRIVATE_DIR);
      verify(spylfs).mkdir(eq(nmPriv),
          eq(ResourceLocalizationService.NM_PRIVATE_PERM), eq(true));
    }
  } finally {
    dispatcher.stop();
    delService.stop();
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:56,代码来源:TestResourceLocalizationService.java

示例5: testDirectoryCleanupOnNewlyCreatedStateStore

import org.apache.hadoop.yarn.server.nodemanager.DeletionService; //导入方法依赖的package包/类
@Test
public void testDirectoryCleanupOnNewlyCreatedStateStore()
    throws IOException, URISyntaxException {
  conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
  AsyncDispatcher dispatcher = new AsyncDispatcher();
  dispatcher.init(new Configuration());

  ContainerExecutor exec = mock(ContainerExecutor.class);
  DeletionService delService = spy(new DeletionService(exec));
  delService.init(conf);
  delService.start();

  List<Path> localDirs = new ArrayList<Path>();
  String[] sDirs = new String[4];
  for (int i = 0; i < 4; ++i) {
    localDirs.add(lfs.makeQualified(new Path(basedir, i + "")));
    sDirs[i] = localDirs.get(i).toString();
  }
  conf.setStrings(YarnConfiguration.NM_LOCAL_DIRS, sDirs);

  LocalDirsHandlerService diskhandler = new LocalDirsHandlerService();
  diskhandler.init(conf);

  NMStateStoreService nmStateStoreService = mock(NMStateStoreService.class);
  when(nmStateStoreService.canRecover()).thenReturn(true);
  when(nmStateStoreService.isNewlyCreated()).thenReturn(true);

  ResourceLocalizationService locService =
      spy(new ResourceLocalizationService(dispatcher, exec, delService,
          diskhandler,nmContext));
  doReturn(lfs)
      .when(locService).getLocalFileContext(isA(Configuration.class));
  try {
    dispatcher.start();

    // initialize ResourceLocalizationService
    locService.init(conf);

    final FsPermission defaultPerm = new FsPermission((short)0755);

    // verify directory creation
    for (Path p : localDirs) {
      p = new Path((new URI(p.toString())).getPath());
      Path usercache = new Path(p, ContainerLocalizer.USERCACHE);
      verify(spylfs)
          .rename(eq(usercache), any(Path.class), any(Options.Rename.class));
      verify(spylfs)
          .mkdir(eq(usercache),
              eq(defaultPerm), eq(true));
      Path publicCache = new Path(p, ContainerLocalizer.FILECACHE);
      verify(spylfs)
          .rename(eq(usercache), any(Path.class), any(Options.Rename.class));
      verify(spylfs)
          .mkdir(eq(publicCache),
              eq(defaultPerm), eq(true));
      Path nmPriv = new Path(p, ResourceLocalizationService.NM_PRIVATE_DIR);
      verify(spylfs)
          .rename(eq(usercache), any(Path.class), any(Options.Rename.class));
      verify(spylfs).mkdir(eq(nmPriv),
          eq(ResourceLocalizationService.NM_PRIVATE_PERM), eq(true));
    }
  } finally {
    dispatcher.stop();
    delService.stop();
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:67,代码来源:TestResourceLocalizationService.java

示例6: testLocalizationInit

import org.apache.hadoop.yarn.server.nodemanager.DeletionService; //导入方法依赖的package包/类
@Test
public void testLocalizationInit() throws Exception {
  conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
  AsyncDispatcher dispatcher = new AsyncDispatcher();
  dispatcher.init(new Configuration());

  ContainerExecutor exec = mock(ContainerExecutor.class);
  DeletionService delService = spy(new DeletionService(exec));
  delService.init(conf);
  delService.start();

  List<Path> localDirs = new ArrayList<Path>();
  String[] sDirs = new String[4];
  for (int i = 0; i < 4; ++i) {
    localDirs.add(lfs.makeQualified(new Path(basedir, i + "")));
    sDirs[i] = localDirs.get(i).toString();
  }
  conf.setStrings(YarnConfiguration.NM_LOCAL_DIRS, sDirs);

  LocalDirsHandlerService diskhandler = new LocalDirsHandlerService();
  diskhandler.init(conf);

  ResourceLocalizationService locService =
    spy(new ResourceLocalizationService(dispatcher, exec, delService,
                                        diskhandler));
  doReturn(lfs)
    .when(locService).getLocalFileContext(isA(Configuration.class));
  try {
    dispatcher.start();

    // initialize ResourceLocalizationService
    locService.init(conf);

    final FsPermission defaultPerm = new FsPermission((short)0755);

    // verify directory creation
    for (Path p : localDirs) {
      p = new Path((new URI(p.toString())).getPath());
      Path usercache = new Path(p, ContainerLocalizer.USERCACHE);
      verify(spylfs)
        .mkdir(eq(usercache),
            eq(defaultPerm), eq(true));
      Path publicCache = new Path(p, ContainerLocalizer.FILECACHE);
      verify(spylfs)
        .mkdir(eq(publicCache),
            eq(defaultPerm), eq(true));
      Path nmPriv = new Path(p, ResourceLocalizationService.NM_PRIVATE_DIR);
      verify(spylfs).mkdir(eq(nmPriv),
          eq(ResourceLocalizationService.NM_PRIVATE_PERM), eq(true));
    }
  } finally {
    dispatcher.stop();
    delService.stop();
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:56,代码来源:TestResourceLocalizationService.java

示例7: testLocalizationInit

import org.apache.hadoop.yarn.server.nodemanager.DeletionService; //导入方法依赖的package包/类
@Test
public void testLocalizationInit() throws Exception {
  conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
  AsyncDispatcher dispatcher = new AsyncDispatcher();
  dispatcher.init(new Configuration());

  ContainerExecutor exec = mock(ContainerExecutor.class);
  DeletionService delService = spy(new DeletionService(exec));
  delService.init(conf);
  delService.start();

  List<Path> localDirs = new ArrayList<Path>();
  String[] sDirs = new String[4];
  for (int i = 0; i < 4; ++i) {
    localDirs.add(lfs.makeQualified(new Path(basedir, i + "")));
    sDirs[i] = localDirs.get(i).toString();
  }
  conf.setStrings(YarnConfiguration.NM_LOCAL_DIRS, sDirs);

  LocalDirsHandlerService diskhandler = new LocalDirsHandlerService();
  diskhandler.init(conf);

  ResourceLocalizationService locService =
    spy(new ResourceLocalizationService(dispatcher, exec, delService,
                                        diskhandler, nmContext));
  doReturn(lfs)
    .when(locService).getLocalFileContext(isA(Configuration.class));
  try {
    dispatcher.start();

    // initialize ResourceLocalizationService
    locService.init(conf);

    final FsPermission defaultPerm = new FsPermission((short)0755);
    final FsPermission securePerm = new FsPermission((short)0711);

    // verify directory creation
    for (Path p : localDirs) {
      p = new Path((new URI(p.toString())).getPath());
      Path usercache = new Path(p, ContainerLocalizer.USERCACHE);
      verify(spylfs)
        .mkdir(eq(usercache),
            eq(securePerm), eq(true));
      Path publicCache = new Path(p, ContainerLocalizer.FILECACHE);
      verify(spylfs)
        .mkdir(eq(publicCache),
            eq(defaultPerm), eq(true));
      Path nmPriv = new Path(p, ResourceLocalizationService.NM_PRIVATE_DIR);
      verify(spylfs).mkdir(eq(nmPriv),
          eq(ResourceLocalizationService.NM_PRIVATE_PERM), eq(true));
    }
  } finally {
    dispatcher.stop();
    delService.stop();
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:57,代码来源:TestResourceLocalizationService.java

示例8: testDirectoryCleanupOnNewlyCreatedStateStore

import org.apache.hadoop.yarn.server.nodemanager.DeletionService; //导入方法依赖的package包/类
@Test
public void testDirectoryCleanupOnNewlyCreatedStateStore()
    throws IOException, URISyntaxException {
  conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
  AsyncDispatcher dispatcher = new AsyncDispatcher();
  dispatcher.init(new Configuration());

  ContainerExecutor exec = mock(ContainerExecutor.class);
  DeletionService delService = spy(new DeletionService(exec));
  delService.init(conf);
  delService.start();

  List<Path> localDirs = new ArrayList<Path>();
  String[] sDirs = new String[4];
  for (int i = 0; i < 4; ++i) {
    localDirs.add(lfs.makeQualified(new Path(basedir, i + "")));
    sDirs[i] = localDirs.get(i).toString();
  }
  conf.setStrings(YarnConfiguration.NM_LOCAL_DIRS, sDirs);

  LocalDirsHandlerService diskhandler = new LocalDirsHandlerService();
  diskhandler.init(conf);

  NMStateStoreService nmStateStoreService = mock(NMStateStoreService.class);
  when(nmStateStoreService.canRecover()).thenReturn(true);
  when(nmStateStoreService.isNewlyCreated()).thenReturn(true);

  ResourceLocalizationService locService =
      spy(new ResourceLocalizationService(dispatcher, exec, delService,
          diskhandler,nmContext));
  doReturn(lfs)
      .when(locService).getLocalFileContext(isA(Configuration.class));
  try {
    dispatcher.start();

    // initialize ResourceLocalizationService
    locService.init(conf);

    final FsPermission defaultPerm = new FsPermission((short)0755);
    final FsPermission securePerm = new FsPermission((short)0711);
    
    // verify directory creation
    for (Path p : localDirs) {
      p = new Path((new URI(p.toString())).getPath());
      Path usercache = new Path(p, ContainerLocalizer.USERCACHE);
      verify(spylfs)
          .rename(eq(usercache), any(Path.class), any(Options.Rename.class));
      verify(spylfs)
          .mkdir(eq(usercache),
              eq(securePerm), eq(true));
      Path publicCache = new Path(p, ContainerLocalizer.FILECACHE);
      verify(spylfs)
          .rename(eq(usercache), any(Path.class), any(Options.Rename.class));
      verify(spylfs)
          .mkdir(eq(publicCache),
              eq(defaultPerm), eq(true));
      Path nmPriv = new Path(p, ResourceLocalizationService.NM_PRIVATE_DIR);
      verify(spylfs)
          .rename(eq(usercache), any(Path.class), any(Options.Rename.class));
      verify(spylfs).mkdir(eq(nmPriv),
          eq(ResourceLocalizationService.NM_PRIVATE_PERM), eq(true));
    }
  } finally {
    dispatcher.stop();
    delService.stop();
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:68,代码来源:TestResourceLocalizationService.java

示例9: testLocalizerRunnerException

import org.apache.hadoop.yarn.server.nodemanager.DeletionService; //导入方法依赖的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.DeletionService.init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。