1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package org.apache.hadoop.yarn.server.resourcemanager.webapp; 20 21 import static org.apache.hadoop.yarn.util.StringHelper.join; 22 import static org.apache.hadoop.yarn.webapp.YarnWebParams.QUEUE_NAME; 23 24 import org.apache.hadoop.yarn.api.records.YarnApplicationState; 25 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; 26 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; 27 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; 28 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler; 29 import org.apache.hadoop.yarn.util.StringHelper; 30 import org.apache.hadoop.yarn.webapp.Controller; 31 import org.apache.hadoop.yarn.webapp.YarnWebParams; 32 33 import com.google.inject.Inject; 34 35 // Do NOT rename/refactor this to RMView as it will wreak havoc 36 // on Mac OS HFS as its case-insensitive! 37 public class RmController extends Controller { 38 39 @Inject RmController(RequestContext ctx)40 RmController(RequestContext ctx) { 41 super(ctx); 42 } 43 index()44 @Override public void index() { 45 setTitle("Applications"); 46 } 47 about()48 public void about() { 49 setTitle("About the Cluster"); 50 render(AboutPage.class); 51 } 52 app()53 public void app() { 54 render(AppPage.class); 55 } 56 appattempt()57 public void appattempt() { 58 render(AppAttemptPage.class); 59 } 60 container()61 public void container() { 62 render(ContainerPage.class); 63 } 64 nodes()65 public void nodes() { 66 render(NodesPage.class); 67 } 68 scheduler()69 public void scheduler() { 70 // limit applications to those in states relevant to scheduling 71 set(YarnWebParams.APP_STATE, StringHelper.cjoin( 72 YarnApplicationState.NEW.toString(), 73 YarnApplicationState.NEW_SAVING.toString(), 74 YarnApplicationState.SUBMITTED.toString(), 75 YarnApplicationState.ACCEPTED.toString(), 76 YarnApplicationState.RUNNING.toString())); 77 78 ResourceManager rm = getInstance(ResourceManager.class); 79 ResourceScheduler rs = rm.getResourceScheduler(); 80 if (rs == null || rs instanceof CapacityScheduler) { 81 setTitle("Capacity Scheduler"); 82 render(CapacitySchedulerPage.class); 83 return; 84 } 85 86 if (rs instanceof FairScheduler) { 87 setTitle("Fair Scheduler"); 88 render(FairSchedulerPage.class); 89 return; 90 } 91 92 setTitle("Default Scheduler"); 93 render(DefaultSchedulerPage.class); 94 } 95 queue()96 public void queue() { 97 setTitle(join("Queue ", get(QUEUE_NAME, "unknown"))); 98 } 99 submit()100 public void submit() { 101 setTitle("Application Submission Not Allowed"); 102 } 103 nodelabels()104 public void nodelabels() { 105 setTitle("Node Labels"); 106 render(NodeLabelsPage.class); 107 } 108 } 109