Package org.apache.hadoop.yarn.server.nodemanager

Examples of org.apache.hadoop.yarn.server.nodemanager.Context


      dispatcher.register(ContainersMonitorEventType.class, monitorBus);
      dispatcher.register(AuxServicesEventType.class, auxBus);
      dispatcher.register(ApplicationEventType.class, appBus);
      dispatcher.register(LogHandlerEventType.class, LogBus);

      Context context = mock(Context.class);
      when(context.getApplications()).thenReturn(
          new ConcurrentHashMap<ApplicationId, Application>());
      launcher = new ContainersLauncher(context, dispatcher, null, null, null);
      // create a mock ExecutorService, which will not really launch
      // ContainerLaunch at all.
      launcher.containerLauncher = mock(ExecutorService.class);
View Full Code Here


    Assert.assertTrue(testStartContainer(rpc, attempt2, validNode,
      newContainerToken, attempt1NMToken, false).isEmpty());
  }

  private void waitForContainerToFinishOnNM(ContainerId containerId) {
    Context nmContet = yarnCluster.getNodeManager(0).getNMContext();
    int interval = 4 * 60; // Max time for container token to expire.
    while ((interval-- > 0)
        && nmContet.getContainers().containsKey(containerId)) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
      }
    }
    Assert.assertFalse(nmContet.getContainers().containsKey(containerId));
  }
View Full Code Here

      dispatcher.register(ContainersMonitorEventType.class, monitorBus);
      dispatcher.register(AuxServicesEventType.class, auxBus);
      dispatcher.register(ApplicationEventType.class, appBus);
      dispatcher.register(LogHandlerEventType.class, LogBus);

      Context context = mock(Context.class);
      when(context.getApplications()).thenReturn(
          new ConcurrentHashMap<ApplicationId, Application>());
      ContainerExecutor executor = mock(ContainerExecutor.class);
      launcher =
          new ContainersLauncher(context, dispatcher, executor, null, null);
      // create a mock ExecutorService, which will not really launch
View Full Code Here

    FileUtil.fullyDelete(testRootDir);
    FileUtil.fullyDelete(testLogDir);
  }
 
  private int startNMWebAppServer(String webAddr) {
    Context nmContext = new NodeManager.NMContext(null, null, null, null,
        null);
    ResourceView resourceView = new ResourceView() {
      @Override
      public long getVmemAllocatedForContainers() {
        return 0;
View Full Code Here

    validatePortVal(port);
  }

  @Test
  public void testNMWebApp() throws IOException, YarnException {
    Context nmContext = new NodeManager.NMContext(null, null, null, null,
        null);
    ResourceView resourceView = new ResourceView() {
      @Override
      public long getVmemAllocatedForContainers() {
        return 0;
      }
      @Override
      public long getPmemAllocatedForContainers() {
        return 0;
      }
      @Override
      public long getVCoresAllocatedForContainers() {
        return 0;
      }
      @Override
      public boolean isVmemCheckEnabled() {
        return true;
      }
      @Override
      public boolean isPmemCheckEnabled() {
        return true;
      }
    };
    Configuration conf = new Configuration();
    conf.set(YarnConfiguration.NM_LOCAL_DIRS, testRootDir.getAbsolutePath());
    conf.set(YarnConfiguration.NM_LOG_DIRS, testLogDir.getAbsolutePath());
    NodeHealthCheckerService healthChecker = new NodeHealthCheckerService();
    healthChecker.init(conf);
    LocalDirsHandlerService dirsHandler = healthChecker.getDiskHandler();

    WebServer server = new WebServer(nmContext, resourceView,
        new ApplicationACLsManager(conf), dirsHandler);
    server.init(conf);
    server.start();

    // Add an application and the corresponding containers
    RecordFactory recordFactory =
        RecordFactoryProvider.getRecordFactory(conf);
    Dispatcher dispatcher = new AsyncDispatcher();
    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);
    nmContext.getApplications().put(appId, app);
    ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
        appId, 1);
    ContainerId container1 =
        BuilderUtils.newContainerId(recordFactory, appId, appAttemptId, 0);
    ContainerId container2 =
        BuilderUtils.newContainerId(recordFactory, appId, appAttemptId, 1);
    NodeManagerMetrics metrics = mock(NodeManagerMetrics.class);
    NMStateStoreService stateStore = new NMNullStateStoreService();
    for (ContainerId containerId : new ContainerId[] { container1,
        container2}) {
      // TODO: Use builder utils
      ContainerLaunchContext launchContext =
          recordFactory.newRecordInstance(ContainerLaunchContext.class);
      long currentTime = System.currentTimeMillis();
      Token containerToken =
          BuilderUtils.newContainerToken(containerId, "127.0.0.1", 1234, user,
            BuilderUtils.newResource(1024, 1), currentTime + 10000L, 123,
            "password".getBytes(), currentTime);
      Container container =
          new ContainerImpl(conf, dispatcher, launchContext,
            null, metrics,
            BuilderUtils.newContainerTokenIdentifier(containerToken)) {

            @Override
            public ContainerState getContainerState() {
              return ContainerState.RUNNING;
            };
          };
      nmContext.getContainers().put(containerId, container);
      //TODO: Gross hack. Fix in code.
      ApplicationId applicationId =
          containerId.getApplicationAttemptId().getApplicationId();
      nmContext.getApplications().get(applicationId).getContainers()
          .put(containerId, container);
      writeContainerLogs(nmContext, containerId, dirsHandler);

    }
    // TODO: Pull logs and test contents.
View Full Code Here

      BufferedOutputStream out =
          new BufferedOutputStream(new FileOutputStream(syslog));
      out.write("Log file Content".getBytes());
      out.close();

      Context context = mock(Context.class);
      ConcurrentMap<ApplicationId, Application> appMap =
          new ConcurrentHashMap<ApplicationId, Application>();
      appMap.put(appId, app);
      when(context.getApplications()).thenReturn(appMap);
      ConcurrentHashMap<ContainerId, Container> containers =
          new ConcurrentHashMap<ContainerId, Container>();
      when(context.getContainers()).thenReturn(containers);
      when(context.getLocalDirsHandler()).thenReturn(dirsHandler);

      MockContainer container = new MockContainer(appAttemptId,
        new AsyncDispatcher(), conf, user, appId, 1);
      container.setState(ContainerState.RUNNING);
      context.getContainers().put(container1, container);

      ContainersLogsBlock cLogsBlock =
          new ContainersLogsBlock(context);

      Map<String, String> params = new HashMap<String, String>();
View Full Code Here

      out.write("Log file Content".getBytes());
      out.close();

      ApplicationACLsManager aclsManager = mock(ApplicationACLsManager.class);

      Context context = mock(Context.class);
      ConcurrentMap<ApplicationId, Application> appMap =
          new ConcurrentHashMap<ApplicationId, Application>();
      appMap.put(appId, app);
      when(context.getApplications()).thenReturn(appMap);
      ConcurrentHashMap<ContainerId, Container> containers =
          new ConcurrentHashMap<ContainerId, Container>();
      when(context.getContainers()).thenReturn(containers);

      MockContainer container = new MockContainer(appAttemptId,
        new AsyncDispatcher(), conf, user, appId, 1);
      container.setState(ContainerState.RUNNING);
      context.getContainers().put(container1, container);

      ContainersLogsBlock cLogsBlock =
          new ContainersLogsBlock(conf, context, aclsManager, dirsHandler);

      Map<String, String> params = new HashMap<String, String>();
View Full Code Here

        validContainerId, validNMToken, false).contains(sb.toString()));

  }

  private void waitForContainerToFinishOnNM(ContainerId containerId) {
    Context nmContet = yarnCluster.getNodeManager(0).getNMContext();
    int interval = 4 * 60; // Max time for container token to expire.
    while ((interval-- > 0)
        && nmContet.getContainers().containsKey(containerId)) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
      }
    }
    Assert.assertFalse(nmContet.getContainers().containsKey(containerId));
  }
View Full Code Here

      dispatcher.register(ContainersMonitorEventType.class, monitorBus);
      dispatcher.register(AuxServicesEventType.class, auxBus);
      dispatcher.register(ApplicationEventType.class, appBus);
      dispatcher.register(LogHandlerEventType.class, LogBus);

      Context context = mock(Context.class);
      when(context.getApplications()).thenReturn(
          new ConcurrentHashMap<ApplicationId, Application>());
      ContainerExecutor executor = mock(ContainerExecutor.class);
      launcher =
          new ContainersLauncher(context, dispatcher, executor, null, null);
      // create a mock ExecutorService, which will not really launch
View Full Code Here

    FileUtil.fullyDelete(testRootDir);
    FileUtil.fullyDelete(testLogDir);
  }
 
  private String startNMWebAppServer(String webAddr) {
    Context nmContext = new NodeManager.NMContext(null);
    ResourceView resourceView = new ResourceView() {
      @Override
      public long getVmemAllocatedForContainers() {
        return 0;
      }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.yarn.server.nodemanager.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.