Search in sources :

Example 1 with FifoScheduler

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler in project hadoop by apache.

the class RMWebServices method getSchedulerInfo.

@GET
@Path("/scheduler")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public SchedulerTypeInfo getSchedulerInfo() {
    init();
    ResourceScheduler rs = rm.getResourceScheduler();
    SchedulerInfo sinfo;
    if (rs instanceof CapacityScheduler) {
        CapacityScheduler cs = (CapacityScheduler) rs;
        CSQueue root = cs.getRootQueue();
        sinfo = new CapacitySchedulerInfo(root, cs);
    } else if (rs instanceof FairScheduler) {
        FairScheduler fs = (FairScheduler) rs;
        sinfo = new FairSchedulerInfo(fs);
    } else if (rs instanceof FifoScheduler) {
        sinfo = new FifoSchedulerInfo(this.rm);
    } else {
        throw new NotFoundException("Unknown scheduler configured");
    }
    return new SchedulerTypeInfo(sinfo);
}
Also used : FairSchedulerInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerInfo) CapacitySchedulerInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.CapacitySchedulerInfo) FifoSchedulerInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FifoSchedulerInfo) SchedulerInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedulerInfo) SchedulerTypeInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedulerTypeInfo) FairScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler) CapacitySchedulerInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.CapacitySchedulerInfo) FairSchedulerInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerInfo) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) ResourceScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler) FifoScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler) FifoSchedulerInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FifoSchedulerInfo) CapacityScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler) CSQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with FifoScheduler

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler in project hadoop by apache.

the class TestSchedulerApplicationAttempt method testAppPercentages.

@Test
public void testAppPercentages() throws Exception {
    FifoScheduler scheduler = mock(FifoScheduler.class);
    when(scheduler.getClusterResource()).thenReturn(Resource.newInstance(10 * 1024, 10));
    when(scheduler.getResourceCalculator()).thenReturn(new DefaultResourceCalculator());
    ApplicationAttemptId appAttId = createAppAttemptId(0, 0);
    RMContext rmContext = mock(RMContext.class);
    when(rmContext.getEpoch()).thenReturn(3L);
    when(rmContext.getScheduler()).thenReturn(scheduler);
    final String user = "user1";
    Queue queue = createQueue("test", null);
    SchedulerApplicationAttempt app = new SchedulerApplicationAttempt(appAttId, user, queue, queue.getAbstractUsersManager(), rmContext);
    // Resource request
    Resource requestedResource = Resource.newInstance(1536, 2);
    app.attemptResourceUsage.incUsed(requestedResource);
    assertEquals(15.0f, app.getResourceUsageReport().getQueueUsagePercentage(), 0.01f);
    assertEquals(15.0f, app.getResourceUsageReport().getClusterUsagePercentage(), 0.01f);
    queue = createQueue("test2", null, 0.5f);
    app = new SchedulerApplicationAttempt(appAttId, user, queue, queue.getAbstractUsersManager(), rmContext);
    app.attemptResourceUsage.incUsed(requestedResource);
    assertEquals(30.0f, app.getResourceUsageReport().getQueueUsagePercentage(), 0.01f);
    assertEquals(15.0f, app.getResourceUsageReport().getClusterUsagePercentage(), 0.01f);
    app.attemptResourceUsage.incUsed(requestedResource);
    app.attemptResourceUsage.incUsed(requestedResource);
    app.attemptResourceUsage.incUsed(requestedResource);
    assertEquals(120.0f, app.getResourceUsageReport().getQueueUsagePercentage(), 0.01f);
    assertEquals(60.0f, app.getResourceUsageReport().getClusterUsagePercentage(), 0.01f);
    queue = createQueue("test3", null, 0.0f);
    app = new SchedulerApplicationAttempt(appAttId, user, queue, queue.getAbstractUsersManager(), rmContext);
    // Resource request
    app.attemptResourceUsage.incUsed(requestedResource);
    assertEquals(0.0f, app.getResourceUsageReport().getQueueUsagePercentage(), 0.01f);
    assertEquals(15.0f, app.getResourceUsageReport().getClusterUsagePercentage(), 0.01f);
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) DefaultResourceCalculator(org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator) Resource(org.apache.hadoop.yarn.api.records.Resource) FifoScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) Test(org.junit.Test)

Example 3 with FifoScheduler

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler in project hadoop by apache.

the class TestSchedulerApplicationAttempt method testAppPercentagesOnswitch.

@Test
public void testAppPercentagesOnswitch() throws Exception {
    FifoScheduler scheduler = mock(FifoScheduler.class);
    when(scheduler.getClusterResource()).thenReturn(Resource.newInstance(0, 0));
    when(scheduler.getResourceCalculator()).thenReturn(new DefaultResourceCalculator());
    ApplicationAttemptId appAttId = createAppAttemptId(0, 0);
    RMContext rmContext = mock(RMContext.class);
    when(rmContext.getEpoch()).thenReturn(3L);
    when(rmContext.getScheduler()).thenReturn(scheduler);
    final String user = "user1";
    Queue queue = createQueue("test", null);
    SchedulerApplicationAttempt app = new SchedulerApplicationAttempt(appAttId, user, queue, queue.getAbstractUsersManager(), rmContext);
    // Resource request
    Resource requestedResource = Resource.newInstance(1536, 2);
    app.attemptResourceUsage.incUsed(requestedResource);
    assertEquals(0.0f, app.getResourceUsageReport().getQueueUsagePercentage(), 0.0f);
    assertEquals(0.0f, app.getResourceUsageReport().getClusterUsagePercentage(), 0.0f);
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) DefaultResourceCalculator(org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator) Resource(org.apache.hadoop.yarn.api.records.Resource) FifoScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) Test(org.junit.Test)

Example 4 with FifoScheduler

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler in project hadoop by apache.

the class TestRMWebApp method mockFifoScheduler.

public static FifoScheduler mockFifoScheduler(RMContext rmContext) throws Exception {
    CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();
    setupFifoQueueConfiguration(conf);
    FifoScheduler fs = new FifoScheduler();
    fs.setConf(new YarnConfiguration());
    fs.setRMContext(rmContext);
    fs.init(conf);
    return fs;
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) FifoScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler) CapacitySchedulerConfiguration(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration)

Example 5 with FifoScheduler

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler in project hadoop by apache.

the class FifoSchedulerMetrics method trackQueue.

@Override
public void trackQueue(String queueName) {
    trackedQueues.add(queueName);
    FifoScheduler fifo = (FifoScheduler) scheduler;
    // for FifoScheduler, only DEFAULT_QUEUE
    // here the three parameters doesn't affect results
    final QueueInfo queue = fifo.getQueueInfo(queueName, false, false);
    // track currentCapacity, maximumCapacity (always 1.0f)
    metrics.register("variable.queue." + queueName + ".currentcapacity", new Gauge<Float>() {

        @Override
        public Float getValue() {
            return queue.getCurrentCapacity();
        }
    });
    metrics.register("variable.queue." + queueName + ".", new Gauge<Float>() {

        @Override
        public Float getValue() {
            return queue.getCurrentCapacity();
        }
    });
}
Also used : QueueInfo(org.apache.hadoop.yarn.api.records.QueueInfo) FifoScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler)

Aggregations

FifoScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler)5 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)2 Resource (org.apache.hadoop.yarn.api.records.Resource)2 RMContext (org.apache.hadoop.yarn.server.resourcemanager.RMContext)2 DefaultResourceCalculator (org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator)2 Test (org.junit.Test)2 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 QueueInfo (org.apache.hadoop.yarn.api.records.QueueInfo)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 ResourceScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler)1 CSQueue (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue)1 CapacityScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler)1 CapacitySchedulerConfiguration (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration)1 FairScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler)1 CapacitySchedulerInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.CapacitySchedulerInfo)1 FairSchedulerInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerInfo)1 FifoSchedulerInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FifoSchedulerInfo)1 SchedulerInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedulerInfo)1