Author: vinodkv
Date: Tue Nov 5 18:25:30 2013
New Revision: 1539089
URL: http://svn.apache.org/r1539089
Log:
YARN-1374. Changed ResourceManager to start the preemption policy monitors as
active services. Contributed by Karthik Kambatla.
Added:
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/TestSchedulingMonitor.java
Modified:
hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java
Modified: hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt?rev=1539089&r1=1539088&r2=1539089&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt Tue Nov 5 18:25:30 2013
@@ -109,6 +109,9 @@ Release 2.3.0 - UNRELEASED
YARN-1305. RMHAProtocolService#serviceInit should handle HAUtil's
IllegalArgumentException (Tsuyoshi Ozawa via bikas)
+ YARN-1374. Changed ResourceManager to start the preemption policy monitors
+ as active services. (Karthik Kambatla via vinodkv)
+
Release 2.2.1 - UNRELEASED
INCOMPATIBLE CHANGES
Modified:
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java?rev=1539089&r1=1539088&r2=1539089&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java
(original)
+++
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java
Tue Nov 5 18:25:30 2013
@@ -501,6 +501,36 @@ public class ResourceManager extends Com
super.serviceStop();
}
+
+ protected void createPolicyMonitors() {
+ if (scheduler instanceof PreemptableResourceScheduler
+ && conf.getBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS,
+ YarnConfiguration.DEFAULT_RM_SCHEDULER_ENABLE_MONITORS)) {
+ LOG.info("Loading policy monitors");
+ List<SchedulingEditPolicy> policies = conf.getInstances(
+ YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES,
+ SchedulingEditPolicy.class);
+ if (policies.size() > 0) {
+ rmDispatcher.register(ContainerPreemptEventType.class,
+ new RMContainerPreemptEventDispatcher(
+ (PreemptableResourceScheduler) scheduler));
+ for (SchedulingEditPolicy policy : policies) {
+ LOG.info("LOADING SchedulingEditPolicy:" + policy.getPolicyName());
+ policy.init(conf, rmContext.getDispatcher().getEventHandler(),
+ (PreemptableResourceScheduler) scheduler);
+ // periodically check whether we need to take action to guarantee
+ // constraints
+ SchedulingMonitor mon = new SchedulingMonitor(policy);
+ addService(mon);
+ }
+ } else {
+ LOG.warn("Policy monitors configured (" +
+ YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS +
+ ") but none specified (" +
+ YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES + ")");
+ }
+ }
+ }
}
@Private
@@ -829,37 +859,6 @@ public class ResourceManager extends Com
return new ApplicationMasterService(this.rmContext, scheduler);
}
- protected void createPolicyMonitors() {
- if (scheduler instanceof PreemptableResourceScheduler
- && conf.getBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS,
- YarnConfiguration.DEFAULT_RM_SCHEDULER_ENABLE_MONITORS)) {
- LOG.info("Loading policy monitors");
- List<SchedulingEditPolicy> policies = conf.getInstances(
- YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES,
- SchedulingEditPolicy.class);
- if (policies.size() > 0) {
- this.rmDispatcher.register(ContainerPreemptEventType.class,
- new RMContainerPreemptEventDispatcher(
- (PreemptableResourceScheduler) scheduler));
- for (SchedulingEditPolicy policy : policies) {
- LOG.info("LOADING SchedulingEditPolicy:" + policy.getPolicyName());
- policy.init(conf, this.rmContext.getDispatcher().getEventHandler(),
- (PreemptableResourceScheduler) scheduler);
- // periodically check whether we need to take action to guarantee
- // constraints
- SchedulingMonitor mon = new SchedulingMonitor(policy);
- addService(mon);
-
- }
- } else {
- LOG.warn("Policy monitors configured (" +
- YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS +
- ") but none specified (" +
- YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES + ")");
- }
- }
- }
-
protected AdminService createAdminService(
ClientRMService clientRMService,
ApplicationMasterService applicationMasterService,
Added:
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/TestSchedulingMonitor.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/TestSchedulingMonitor.java?rev=1539089&view=auto
==============================================================================
---
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/TestSchedulingMonitor.java
(added)
+++
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/TestSchedulingMonitor.java
Tue Nov 5 18:25:30 2013
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.monitor;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
+import
org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity.ProportionalCapacityPreemptionPolicy;
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
+
+public class TestSchedulingMonitor {
+
+ @Test(timeout = 10000)
+ public void testRMStarts() {
+ Configuration conf = new YarnConfiguration();
+ conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true);
+ conf.set(YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES,
+ ProportionalCapacityPreemptionPolicy.class.getCanonicalName());
+
+ ResourceManager rm = new ResourceManager();
+ try {
+ rm.init(conf);
+ } catch (Exception e) {
+ fail("ResourceManager does not start when " +
+ YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS + " is set to true");
+ }
+ }
+}