Search in sources :

Example 1 with QueueManager

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.QueueManager in project hadoop by apache.

the class TestFairSchedulerQueueInfo method testEmptyChildQueues.

@Test
public void testEmptyChildQueues() throws Exception {
    FairSchedulerConfiguration conf = new FairSchedulerConfiguration();
    FairScheduler scheduler = mock(FairScheduler.class);
    AllocationConfiguration allocConf = new AllocationConfiguration(conf);
    when(scheduler.getAllocationConfiguration()).thenReturn(allocConf);
    when(scheduler.getConf()).thenReturn(conf);
    when(scheduler.getClusterResource()).thenReturn(Resource.newInstance(1, 1));
    SystemClock clock = SystemClock.getInstance();
    when(scheduler.getClock()).thenReturn(clock);
    QueueManager queueManager = new QueueManager(scheduler);
    queueManager.initialize(conf);
    FSQueue testQueue = queueManager.getLeafQueue("test", true);
    FairSchedulerQueueInfo queueInfo = new FairSchedulerQueueInfo(testQueue, scheduler);
    Collection<FairSchedulerQueueInfo> childQueues = queueInfo.getChildQueues();
    Assert.assertNotNull(childQueues);
    Assert.assertEquals("Child QueueInfo was not empty", 0, childQueues.size());
}
Also used : FairSchedulerConfiguration(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairSchedulerConfiguration) FairScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler) SystemClock(org.apache.hadoop.yarn.util.SystemClock) FSQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSQueue) AllocationConfiguration(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.AllocationConfiguration) QueueManager(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.QueueManager) Test(org.junit.Test)

Example 2 with QueueManager

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.QueueManager in project hadoop by apache.

the class TestRMWebServicesFairScheduler method testClusterSchedulerWithSubQueues.

@Test
public void testClusterSchedulerWithSubQueues() throws JSONException, Exception {
    FairScheduler scheduler = (FairScheduler) rm.getResourceScheduler();
    QueueManager queueManager = scheduler.getQueueManager();
    // create LeafQueue
    queueManager.getLeafQueue("root.q.subqueue1", true);
    queueManager.getLeafQueue("root.q.subqueue2", true);
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("cluster").path("scheduler").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    JSONObject json = response.getEntity(JSONObject.class);
    JSONArray subQueueInfo = json.getJSONObject("scheduler").getJSONObject("schedulerInfo").getJSONObject("rootQueue").getJSONObject("childQueues").getJSONArray("queue").getJSONObject(1).getJSONObject("childQueues").getJSONArray("queue");
    // subQueueInfo is consist of subqueue1 and subqueue2 info
    assertEquals(2, subQueueInfo.length());
    // Verify 'childQueues' field is omitted from FairSchedulerLeafQueueInfo.
    try {
        subQueueInfo.getJSONObject(1).getJSONObject("childQueues");
        fail("FairSchedulerQueueInfo should omit field 'childQueues'" + "if child queue is empty.");
    } catch (JSONException je) {
        assertEquals("JSONObject[\"childQueues\"] not found.", je.getMessage());
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) FairScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler) JSONObject(org.codehaus.jettison.json.JSONObject) JSONArray(org.codehaus.jettison.json.JSONArray) WebResource(com.sun.jersey.api.client.WebResource) JSONException(org.codehaus.jettison.json.JSONException) QueueManager(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.QueueManager) Test(org.junit.Test)

Aggregations

FairScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler)2 QueueManager (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.QueueManager)2 Test (org.junit.Test)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 WebResource (com.sun.jersey.api.client.WebResource)1 AllocationConfiguration (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.AllocationConfiguration)1 FSQueue (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSQueue)1 FairSchedulerConfiguration (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairSchedulerConfiguration)1 SystemClock (org.apache.hadoop.yarn.util.SystemClock)1 JSONArray (org.codehaus.jettison.json.JSONArray)1 JSONException (org.codehaus.jettison.json.JSONException)1 JSONObject (org.codehaus.jettison.json.JSONObject)1