Java Code Examples for org.apache.hadoop.yarn.server.resourcemanager.ResourceManager

The following examples show how to use org.apache.hadoop.yarn.server.resourcemanager.ResourceManager. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   Source File: MiniYARNCluster.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Wait for all the NodeManagers to connect to the ResourceManager.
 *
 * @param timeout Time to wait (sleeps in 100 ms intervals) in milliseconds.
 * @return true if all NodeManagers connect to the (Active)
 * ResourceManager, false otherwise.
 * @throws YarnException
 * @throws InterruptedException
 */
public boolean waitForNodeManagersToConnect(long timeout)
    throws YarnException, InterruptedException {
  GetClusterMetricsRequest req = GetClusterMetricsRequest.newInstance();
  for (int i = 0; i < timeout / 100; i++) {
    ResourceManager rm = getResourceManager();
    if (rm == null) {
      throw new YarnException("Can not find the active RM.");
    }
    else if (nodeManagers.length == rm.getClientRMService()
          .getClusterMetrics(req).getClusterMetrics().getNumNodeManagers()) {
      return true;
    }
    Thread.sleep(100);
  }
  return false;
}
 
Example 2
Source Project: big-c   Source File: MRAMSimulator.java    License: Apache License 2.0 6 votes vote down vote up
public void init(int id, int heartbeatInterval,
    List<ContainerSimulator> containerList, ResourceManager rm, SLSRunner se,
    long traceStartTime, long traceFinishTime, String user, String queue, 
    boolean isTracked, String oldAppId) {
  super.init(id, heartbeatInterval, containerList, rm, se, 
            traceStartTime, traceFinishTime, user, queue,
            isTracked, oldAppId);
  amtype = "mapreduce";
  
  // get map/reduce tasks
  for (ContainerSimulator cs : containerList) {
    if (cs.getType().equals("map")) {
      cs.setPriority(PRIORITY_MAP);
      pendingMaps.add(cs);
    } else if (cs.getType().equals("reduce")) {
      cs.setPriority(PRIORITY_REDUCE);
      pendingReduces.add(cs);
    }
  }
  allMaps.addAll(pendingMaps);
  allReduces.addAll(pendingReduces);
  mapTotal = pendingMaps.size();
  reduceTotal = pendingReduces.size();
  totalContainers = mapTotal + reduceTotal;
}
 
Example 3
Source Project: hadoop   Source File: AboutBlock.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void render(Block html) {
  html._(MetricsOverviewTable.class);
  ResourceManager rm = getInstance(ResourceManager.class);
  ClusterInfo cinfo = new ClusterInfo(rm);
  info("Cluster overview").
    _("Cluster ID:", cinfo.getClusterId()).
    _("ResourceManager state:", cinfo.getState()).
    _("ResourceManager HA state:", cinfo.getHAState()).
    _("ResourceManager RMStateStore:", cinfo.getRMStateStore()).
    _("ResourceManager started on:", Times.format(cinfo.getStartedOn())).
    _("ResourceManager version:", cinfo.getRMBuildVersion() +
        " on " + cinfo.getRMVersionBuiltOn()).
    _("Hadoop version:", cinfo.getHadoopBuildVersion() +
        " on " + cinfo.getHadoopVersionBuiltOn());
  html._(InfoBlock.class);
}
 
Example 4
Source Project: hadoop   Source File: RmController.java    License: Apache License 2.0 6 votes vote down vote up
public void scheduler() {
  // limit applications to those in states relevant to scheduling
  set(YarnWebParams.APP_STATE, StringHelper.cjoin(
      YarnApplicationState.NEW.toString(),
      YarnApplicationState.NEW_SAVING.toString(),
      YarnApplicationState.SUBMITTED.toString(),
      YarnApplicationState.ACCEPTED.toString(),
      YarnApplicationState.RUNNING.toString()));

  ResourceManager rm = getInstance(ResourceManager.class);
  ResourceScheduler rs = rm.getResourceScheduler();
  if (rs == null || rs instanceof CapacityScheduler) {
    setTitle("Capacity Scheduler");
    render(CapacitySchedulerPage.class);
    return;
  }
  
  if (rs instanceof FairScheduler) {
    setTitle("Fair Scheduler");
    render(FairSchedulerPage.class);
    return;
  }
  
  setTitle("Default Scheduler");
  render(DefaultSchedulerPage.class);
}
 
Example 5
Source Project: hadoop   Source File: RMWebApp.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setup() {
  bind(JAXBContextResolver.class);
  bind(RMWebServices.class);
  bind(GenericExceptionHandler.class);
  bind(RMWebApp.class).toInstance(this);

  if (rm != null) {
    bind(ResourceManager.class).toInstance(rm);
    bind(ApplicationBaseProtocol.class).toInstance(rm.getClientRMService());
  }
  route("/", RmController.class);
  route(pajoin("/nodes", NODE_STATE), RmController.class, "nodes");
  route(pajoin("/apps", APP_STATE), RmController.class);
  route("/cluster", RmController.class, "about");
  route(pajoin("/app", APPLICATION_ID), RmController.class, "app");
  route("/scheduler", RmController.class, "scheduler");
  route(pajoin("/queue", QUEUE_NAME), RmController.class, "queue");
  route("/nodelabels", RmController.class, "nodelabels");
  route(pajoin("/appattempt", APPLICATION_ATTEMPT_ID), RmController.class,
    "appattempt");
  route(pajoin("/container", CONTAINER_ID), RmController.class, "container");
}
 
Example 6
Source Project: hadoop   Source File: AbstractYarnScheduler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Resource getMaximumResourceCapability() {
  Resource maxResource;
  maxAllocReadLock.lock();
  try {
    if (useConfiguredMaximumAllocationOnly) {
      if (System.currentTimeMillis() - ResourceManager.getClusterTimeStamp()
          > configuredMaximumAllocationWaitTime) {
        useConfiguredMaximumAllocationOnly = false;
      }
      maxResource = Resources.clone(configuredMaximumAllocation);
    } else {
      maxResource = Resources.clone(maximumAllocation);
    }
  } finally {
    maxAllocReadLock.unlock();
  }
  return maxResource;
}
 
Example 7
Source Project: hadoop   Source File: AbstractYarnScheduler.java    License: Apache License 2.0 6 votes vote down vote up
protected void releaseContainers(List<ContainerId> containers,
    SchedulerApplicationAttempt attempt) {
  for (ContainerId containerId : containers) {
    RMContainer rmContainer = getRMContainer(containerId);
    if (rmContainer == null) {
      if (System.currentTimeMillis() - ResourceManager.getClusterTimeStamp()
          < nmExpireInterval) {
        LOG.info(containerId + " doesn't exist. Add the container"
            + " to the release request cache as it maybe on recovery.");
        synchronized (attempt) {
          attempt.getPendingRelease().add(containerId);
        }
      } else {
        RMAuditLogger.logFailure(attempt.getUser(),
          AuditConstants.RELEASE_CONTAINER,
          "Unauthorized access or invalid container", "Scheduler",
          "Trying to release container not owned by app or with invalid id.",
          attempt.getApplicationId(), containerId);
      }
    }
    completedContainer(rmContainer,
      SchedulerUtils.createAbnormalContainerStatus(containerId,
        SchedulerUtils.RELEASED_CONTAINER), RMContainerEventType.RELEASED);
  }
}
 
Example 8
Source Project: big-c   Source File: FairSchedulerAppsBlock.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
public FairSchedulerAppsBlock(ResourceManager rm, ViewContext ctx,
    Configuration conf) {
  super(ctx);
  FairScheduler scheduler = (FairScheduler) rm.getResourceScheduler();
  fsinfo = new FairSchedulerInfo(scheduler);
  apps = new ConcurrentHashMap<ApplicationId, RMApp>();
  for (Map.Entry<ApplicationId, RMApp> entry : rm.getRMContext().getRMApps()
      .entrySet()) {
    if (!(RMAppState.NEW.equals(entry.getValue().getState())
        || RMAppState.NEW_SAVING.equals(entry.getValue().getState())
        || RMAppState.SUBMITTED.equals(entry.getValue().getState()))) {
      apps.put(entry.getKey(), entry.getValue());
    }
  }
  this.conf = conf;
  this.rm = rm;
}
 
Example 9
Source Project: hadoop   Source File: TestNodesPage.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  final RMContext mockRMContext =
      TestRMWebApp.mockRMContext(3, numberOfRacks, numberOfNodesPerRack,
        8 * TestRMWebApp.GiB);
  injector =
      WebAppTests.createMockInjector(RMContext.class, mockRMContext,
        new Module() {
          @Override
          public void configure(Binder binder) {
            try {
              binder.bind(ResourceManager.class).toInstance(
                TestRMWebApp.mockRm(mockRMContext));
            } catch (IOException e) {
              throw new IllegalStateException(e);
            }
          }
        });
}
 
Example 10
Source Project: big-c   Source File: RmController.java    License: Apache License 2.0 6 votes vote down vote up
public void scheduler() {
  // limit applications to those in states relevant to scheduling
  set(YarnWebParams.APP_STATE, StringHelper.cjoin(
      YarnApplicationState.NEW.toString(),
      YarnApplicationState.NEW_SAVING.toString(),
      YarnApplicationState.SUBMITTED.toString(),
      YarnApplicationState.ACCEPTED.toString(),
      YarnApplicationState.RUNNING.toString()));

  ResourceManager rm = getInstance(ResourceManager.class);
  ResourceScheduler rs = rm.getResourceScheduler();
  if (rs == null || rs instanceof CapacityScheduler) {
    setTitle("Capacity Scheduler");
    render(CapacitySchedulerPage.class);
    return;
  }
  
  if (rs instanceof FairScheduler) {
    setTitle("Fair Scheduler");
    render(FairSchedulerPage.class);
    return;
  }
  
  setTitle("Default Scheduler");
  render(DefaultSchedulerPage.class);
}
 
Example 11
Source Project: big-c   Source File: TestNodesPage.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  final RMContext mockRMContext =
      TestRMWebApp.mockRMContext(3, numberOfRacks, numberOfNodesPerRack,
        8 * TestRMWebApp.GiB);
  injector =
      WebAppTests.createMockInjector(RMContext.class, mockRMContext,
        new Module() {
          @Override
          public void configure(Binder binder) {
            try {
              binder.bind(ResourceManager.class).toInstance(
                TestRMWebApp.mockRm(mockRMContext));
            } catch (IOException e) {
              throw new IllegalStateException(e);
            }
          }
        });
}
 
Example 12
Source Project: hadoop   Source File: TestFairSchedulerEventLog.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws IOException {
  scheduler = new FairScheduler();
  
  Configuration conf = new YarnConfiguration();
  conf.setClass(YarnConfiguration.RM_SCHEDULER, FairScheduler.class,
      ResourceScheduler.class);
  conf.set("yarn.scheduler.fair.event-log-enabled", "true");

  // All tests assume only one assignment per node update
  conf.set(FairSchedulerConfiguration.ASSIGN_MULTIPLE, "false");
  resourceManager = new ResourceManager();
  resourceManager.init(conf);
  ((AsyncDispatcher)resourceManager.getRMContext().getDispatcher()).start();
  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, resourceManager.getRMContext());
}
 
Example 13
Source Project: hadoop   Source File: TestFairScheduler.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws IOException {
  scheduler = new FairScheduler();
  conf = createConfiguration();
  resourceManager = new ResourceManager();
  resourceManager.init(conf);

  // TODO: This test should really be using MockRM. For now starting stuff
  // that is needed at a bare minimum.
  ((AsyncDispatcher)resourceManager.getRMContext().getDispatcher()).start();
  resourceManager.getRMContext().getStateStore().start();

  // to initialize the master key
  resourceManager.getRMContext().getContainerTokenSecretManager().rollMasterKey();

  scheduler.setRMContext(resourceManager.getRMContext());
}
 
Example 14
Source Project: hadoop   Source File: TestCapacityScheduler.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  resourceManager = new ResourceManager() {
    @Override
    protected RMNodeLabelsManager createNodeLabelManager() {
      RMNodeLabelsManager mgr = new NullRMNodeLabelsManager();
      mgr.init(getConfig());
      return mgr;
    }
  };
  CapacitySchedulerConfiguration csConf 
     = new CapacitySchedulerConfiguration();
  setupQueueConfiguration(csConf);
  YarnConfiguration conf = new YarnConfiguration(csConf);
  conf.setClass(YarnConfiguration.RM_SCHEDULER, 
      CapacityScheduler.class, ResourceScheduler.class);
  resourceManager.init(conf);
  resourceManager.getRMContext().getContainerTokenSecretManager().rollMasterKey();
  resourceManager.getRMContext().getNMTokenSecretManager().rollMasterKey();
  ((AsyncDispatcher)resourceManager.getRMContext().getDispatcher()).start();
  mockContext = mock(RMContext.class);
  when(mockContext.getConfigurationProvider()).thenReturn(
      new LocalConfigurationProvider());
}
 
Example 15
Source Project: big-c   Source File: AbstractYarnScheduler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Resource getMaximumResourceCapability() {
  Resource maxResource;
  maxAllocReadLock.lock();
  try {
    if (useConfiguredMaximumAllocationOnly) {
      if (System.currentTimeMillis() - ResourceManager.getClusterTimeStamp()
          > configuredMaximumAllocationWaitTime) {
        useConfiguredMaximumAllocationOnly = false;
      }
      maxResource = Resources.clone(configuredMaximumAllocation);
    } else {
      maxResource = Resources.clone(maximumAllocation);
    }
  } finally {
    maxAllocReadLock.unlock();
  }
  return maxResource;
}
 
Example 16
Source Project: hadoop   Source File: MRAMSimulator.java    License: Apache License 2.0 6 votes vote down vote up
public void init(int id, int heartbeatInterval,
    List<ContainerSimulator> containerList, ResourceManager rm, SLSRunner se,
    long traceStartTime, long traceFinishTime, String user, String queue, 
    boolean isTracked, String oldAppId) {
  super.init(id, heartbeatInterval, containerList, rm, se, 
            traceStartTime, traceFinishTime, user, queue,
            isTracked, oldAppId);
  amtype = "mapreduce";
  
  // get map/reduce tasks
  for (ContainerSimulator cs : containerList) {
    if (cs.getType().equals("map")) {
      cs.setPriority(PRIORITY_MAP);
      pendingMaps.add(cs);
    } else if (cs.getType().equals("reduce")) {
      cs.setPriority(PRIORITY_REDUCE);
      pendingReduces.add(cs);
    }
  }
  allMaps.addAll(pendingMaps);
  allReduces.addAll(pendingReduces);
  mapTotal = pendingMaps.size();
  reduceTotal = pendingReduces.size();
  totalContainers = mapTotal + reduceTotal;
}
 
Example 17
Source Project: big-c   Source File: TestRMWebServicesDelegationTokens.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void configureServlets() {
  bind(JAXBContextResolver.class);
  bind(RMWebServices.class);
  bind(GenericExceptionHandler.class);
  Configuration rmconf = new Configuration();
  rmconf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS,
    YarnConfiguration.DEFAULT_RM_AM_MAX_ATTEMPTS);
  rmconf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class,
    ResourceScheduler.class);
  rmconf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
  rm = new MockRM(rmconf);
  bind(ResourceManager.class).toInstance(rm);
  if (isKerberosAuth == true) {
    filter("/*").through(TestKerberosAuthFilter.class);
  } else {
    filter("/*").through(TestSimpleAuthFilter.class);
  }
  serve("/*").with(GuiceContainer.class);
}
 
Example 18
Source Project: big-c   Source File: MiniYARNCluster.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Wait for all the NodeManagers to connect to the ResourceManager.
 *
 * @param timeout Time to wait (sleeps in 100 ms intervals) in milliseconds.
 * @return true if all NodeManagers connect to the (Active)
 * ResourceManager, false otherwise.
 * @throws YarnException
 * @throws InterruptedException
 */
public boolean waitForNodeManagersToConnect(long timeout)
    throws YarnException, InterruptedException {
  GetClusterMetricsRequest req = GetClusterMetricsRequest.newInstance();
  for (int i = 0; i < timeout / 100; i++) {
    ResourceManager rm = getResourceManager();
    if (rm == null) {
      throw new YarnException("Can not find the active RM.");
    }
    else if (nodeManagers.length == rm.getClientRMService()
          .getClusterMetrics(req).getClusterMetrics().getNumNodeManagers()) {
      return true;
    }
    Thread.sleep(100);
  }
  return false;
}
 
Example 19
Source Project: big-c   Source File: RMWebApp.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setup() {
  bind(JAXBContextResolver.class);
  bind(RMWebServices.class);
  bind(GenericExceptionHandler.class);
  bind(RMWebApp.class).toInstance(this);

  if (rm != null) {
    bind(ResourceManager.class).toInstance(rm);
    bind(ApplicationBaseProtocol.class).toInstance(rm.getClientRMService());
  }
  route("/", RmController.class);
  route(pajoin("/nodes", NODE_STATE), RmController.class, "nodes");
  route(pajoin("/apps", APP_STATE), RmController.class);
  route("/cluster", RmController.class, "about");
  route(pajoin("/app", APPLICATION_ID), RmController.class, "app");
  route("/scheduler", RmController.class, "scheduler");
  route(pajoin("/queue", QUEUE_NAME), RmController.class, "queue");
  route("/nodelabels", RmController.class, "nodelabels");
  route(pajoin("/appattempt", APPLICATION_ATTEMPT_ID), RmController.class,
    "appattempt");
  route(pajoin("/container", CONTAINER_ID), RmController.class, "container");
}
 
Example 20
Source Project: big-c   Source File: TestRMWebServices.java    License: Apache License 2.0 5 votes vote down vote up
public void verifyClusterGeneric(long clusterid, long startedon,
    String state, String haState, String hadoopVersionBuiltOn,
    String hadoopBuildVersion, String hadoopVersion,
    String resourceManagerVersionBuiltOn, String resourceManagerBuildVersion,
    String resourceManagerVersion) {

  assertEquals("clusterId doesn't match: ",
      ResourceManager.getClusterTimeStamp(), clusterid);
  assertEquals("startedOn doesn't match: ",
      ResourceManager.getClusterTimeStamp(), startedon);
  assertTrue("stated doesn't match: " + state,
      state.matches(STATE.INITED.toString()));
  assertTrue("HA state doesn't match: " + haState,
      haState.matches("INITIALIZING"));

  WebServicesTestUtils.checkStringMatch("hadoopVersionBuiltOn",
      VersionInfo.getDate(), hadoopVersionBuiltOn);
  WebServicesTestUtils.checkStringEqual("hadoopBuildVersion",
      VersionInfo.getBuildVersion(), hadoopBuildVersion);
  WebServicesTestUtils.checkStringMatch("hadoopVersion",
      VersionInfo.getVersion(), hadoopVersion);

  WebServicesTestUtils.checkStringMatch("resourceManagerVersionBuiltOn",
      YarnVersionInfo.getDate(), resourceManagerVersionBuiltOn);
  WebServicesTestUtils.checkStringEqual("resourceManagerBuildVersion",
      YarnVersionInfo.getBuildVersion(), resourceManagerBuildVersion);
  WebServicesTestUtils.checkStringMatch("resourceManagerVersion",
      YarnVersionInfo.getVersion(), resourceManagerVersion);
}
 
Example 21
Source Project: hadoop   Source File: CapacitySchedulerPage.java    License: Apache License 2.0 5 votes vote down vote up
@Inject QueuesBlock(ResourceManager rm, CSQInfo info) {
  cs = (CapacityScheduler) rm.getResourceScheduler();
  csqinfo = info;
  RMNodeLabelsManager nodeLabelManager =
      rm.getRMContext().getNodeLabelManager();
  nodeLabelsInfo = nodeLabelManager.pullRMNodeLabelsInfo();      
}
 
Example 22
Source Project: big-c   Source File: TestRMWebAppFairScheduler.java    License: Apache License 2.0 5 votes vote down vote up
private static ResourceManager mockRm(RMContext rmContext) throws
    IOException {
  ResourceManager rm = mock(ResourceManager.class);
  ResourceScheduler rs = mockFairScheduler();
  ClientRMService clientRMService = mockClientRMService(rmContext);
  when(rm.getResourceScheduler()).thenReturn(rs);
  when(rm.getRMContext()).thenReturn(rmContext);
  when(rm.getClientRMService()).thenReturn(clientRMService);
  return rm;
}
 
Example 23
Source Project: big-c   Source File: TestRMWebServicesCapacitySched.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configureServlets() {
  bind(JAXBContextResolver.class);
  bind(RMWebServices.class);
  bind(GenericExceptionHandler.class);
  csConf = new CapacitySchedulerConfiguration();
  setupQueueConfiguration(csConf);
  conf = new YarnConfiguration(csConf);
  conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
  ResourceScheduler.class);
  rm = new MockRM(conf);
  bind(ResourceManager.class).toInstance(rm);
  serve("/*").with(GuiceContainer.class);
}
 
Example 24
Source Project: hadoop   Source File: UserMetricsInfo.java    License: Apache License 2.0 5 votes vote down vote up
public UserMetricsInfo(final ResourceManager rm, final String user) {
  ResourceScheduler rs = rm.getResourceScheduler();
  QueueMetrics metrics = rs.getRootQueueMetrics();
  QueueMetrics userMetrics = metrics.getUserMetrics(user);
  this.userMetricsAvailable = false;

  if (userMetrics != null) {
    this.userMetricsAvailable = true;

    this.appsSubmitted = userMetrics.getAppsSubmitted();
    this.appsCompleted = userMetrics.getAppsCompleted();
    this.appsPending = userMetrics.getAppsPending();
    this.appsRunning = userMetrics.getAppsRunning();
    this.appsFailed = userMetrics.getAppsFailed();
    this.appsKilled = userMetrics.getAppsKilled();

    this.runningContainers = userMetrics.getAllocatedContainers();
    this.pendingContainers = userMetrics.getPendingContainers();
    this.reservedContainers = userMetrics.getReservedContainers();

    this.reservedMB = userMetrics.getReservedMB();
    this.pendingMB = userMetrics.getPendingMB();
    this.allocatedMB = userMetrics.getAllocatedMB();

    this.reservedVirtualCores = userMetrics.getReservedVirtualCores();
    this.pendingVirtualCores = userMetrics.getPendingVirtualCores();
    this.allocatedVirtualCores = userMetrics.getAllocatedVirtualCores();

    this.reservedGpuCores = userMetrics.getReservedGpuCores();
    this.pendingGpuCores = userMetrics.getPendingGpuCores();
    this.allocatedGpuCores = userMetrics.getAllocatedGpuCores();
  }
}
 
Example 25
Source Project: hadoop   Source File: SchedulerInfo.java    License: Apache License 2.0 5 votes vote down vote up
public SchedulerInfo(final ResourceManager rm) {
  ResourceScheduler rs = rm.getResourceScheduler();

  if (rs instanceof CapacityScheduler) {
    this.schedulerName = "Capacity Scheduler";
  } else if (rs instanceof FairScheduler) {
    this.schedulerName = "Fair Scheduler";
  } else if (rs instanceof FifoScheduler) {
    this.schedulerName = "Fifo Scheduler";
  }
  this.minAllocResource = new ResourceInfo(rs.getMinimumResourceCapability());
  this.maxAllocResource = new ResourceInfo(rs.getMaximumResourceCapability());
  this.schedulingResourceTypes = rs.getSchedulingResourceTypes();
}
 
Example 26
Source Project: big-c   Source File: FifoSchedulerInfo.java    License: Apache License 2.0 5 votes vote down vote up
public FifoSchedulerInfo(final ResourceManager rm) {

    RMContext rmContext = rm.getRMContext();

    FifoScheduler fs = (FifoScheduler) rm.getResourceScheduler();
    qName = fs.getQueueInfo("", false, false).getQueueName();
    QueueInfo qInfo = fs.getQueueInfo(qName, true, true);

    this.usedCapacity = qInfo.getCurrentCapacity();
    this.capacity = qInfo.getCapacity();
    this.minQueueMemoryCapacity = fs.getMinimumResourceCapability().getMemory();
    this.maxQueueMemoryCapacity = fs.getMaximumResourceCapability().getMemory();
    this.qstate = qInfo.getQueueState();

    this.numNodes = rmContext.getRMNodes().size();
    this.usedNodeCapacity = 0;
    this.availNodeCapacity = 0;
    this.totalNodeCapacity = 0;
    this.numContainers = 0;

    for (RMNode ni : rmContext.getRMNodes().values()) {
      SchedulerNodeReport report = fs.getNodeReport(ni.getNodeID());
      this.usedNodeCapacity += report.getUsedResource().getMemory();
      this.availNodeCapacity += report.getAvailableResource().getMemory();
      this.totalNodeCapacity += ni.getTotalCapability().getMemory();
      this.numContainers += fs.getNodeReport(ni.getNodeID()).getNumContainers();
    }
  }
 
Example 27
Source Project: big-c   Source File: TestRMWebServices.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configureServlets() {
  bind(JAXBContextResolver.class);
  bind(RMWebServices.class);
  bind(GenericExceptionHandler.class);
  Configuration conf = new Configuration();
  conf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class,
      ResourceScheduler.class);
  rm = new MockRM(conf);
  bind(ResourceManager.class).toInstance(rm);
  serve("/*").with(GuiceContainer.class);
}
 
Example 28
Source Project: hadoop   Source File: TestRMWebServicesFairScheduler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configureServlets() {
  bind(JAXBContextResolver.class);
  bind(RMWebServices.class);
  bind(GenericExceptionHandler.class);
  conf = new YarnConfiguration();
  conf.setClass(YarnConfiguration.RM_SCHEDULER, FairScheduler.class,
    ResourceScheduler.class);
  rm = new MockRM(conf);
  bind(ResourceManager.class).toInstance(rm);
  serve("/*").with(GuiceContainer.class);
}
 
Example 29
Source Project: hadoop   Source File: TestRMWebServices.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configureServlets() {
  bind(JAXBContextResolver.class);
  bind(RMWebServices.class);
  bind(GenericExceptionHandler.class);
  Configuration conf = new Configuration();
  conf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class,
      ResourceScheduler.class);
  rm = new MockRM(conf);
  bind(ResourceManager.class).toInstance(rm);
  serve("/*").with(GuiceContainer.class);
}
 
Example 30
Source Project: hadoop   Source File: TestRMWebServices.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAppsRace() throws Exception {
  // mock up an RM that returns app reports for apps that don't exist
  // in the RMApps list
  ApplicationId appId = ApplicationId.newInstance(1, 1);
  ApplicationReport mockReport = mock(ApplicationReport.class);
  when(mockReport.getApplicationId()).thenReturn(appId);
  GetApplicationsResponse mockAppsResponse =
      mock(GetApplicationsResponse.class);
  when(mockAppsResponse.getApplicationList())
    .thenReturn(Arrays.asList(new ApplicationReport[] { mockReport }));
  ClientRMService mockClientSvc = mock(ClientRMService.class);
  when(mockClientSvc.getApplications(isA(GetApplicationsRequest.class),
      anyBoolean())).thenReturn(mockAppsResponse);
  ResourceManager mockRM = mock(ResourceManager.class);
  RMContextImpl rmContext = new RMContextImpl(null, null, null, null, null,
      null, null, null, null, null);
  when(mockRM.getRMContext()).thenReturn(rmContext);
  when(mockRM.getClientRMService()).thenReturn(mockClientSvc);

  RMWebServices webSvc = new RMWebServices(mockRM, new Configuration(),
      mock(HttpServletResponse.class));

  final Set<String> emptySet =
      Collections.unmodifiableSet(Collections.<String>emptySet());

  // verify we don't get any apps when querying
  HttpServletRequest mockHsr = mock(HttpServletRequest.class);
  AppsInfo appsInfo = webSvc.getApps(mockHsr, null, emptySet, null,
      null, null, null, null, null, null, null, emptySet, emptySet);
  assertTrue(appsInfo.getApps().isEmpty());

  // verify we don't get an NPE when specifying a final status query
  appsInfo = webSvc.getApps(mockHsr, null, emptySet, "FAILED",
      null, null, null, null, null, null, null, emptySet, emptySet);
  assertTrue(appsInfo.getApps().isEmpty());
}