You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ka...@apache.org on 2016/11/11 00:10:28 UTC
[01/50] [abbrv] hadoop git commit: YARN-5772. [YARN-3368] Replace old
Hadoop logo with new one (Akhil P B Tan via Sunil G) [Forced Update!]
Repository: hadoop
Updated Branches:
refs/heads/YARN-4752 9568f41e5 -> cda677655 (forced update)
YARN-5772. [YARN-3368] Replace old Hadoop logo with new one (Akhil P B Tan via Sunil G)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/e93f900b
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/e93f900b
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/e93f900b
Branch: refs/heads/YARN-4752
Commit: e93f900b5544b4c7fc1b5279baff81ded6be56f5
Parents: 825de90
Author: sunilg <su...@apache.org>
Authored: Thu Oct 27 10:45:47 2016 +0530
Committer: Wangda Tan <wa...@apache.org>
Committed: Sun Nov 6 13:13:31 2016 -0800
----------------------------------------------------------------------
.../webapp/public/assets/images/hadoop_logo.png | Bin 26495 -> 31716 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e93f900b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/public/assets/images/hadoop_logo.png
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/public/assets/images/hadoop_logo.png b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/public/assets/images/hadoop_logo.png
index 275d39e..d481395 100644
Binary files a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/public/assets/images/hadoop_logo.png and b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/public/assets/images/hadoop_logo.png differ
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[41/50] [abbrv] hadoop git commit: YARN-5862.
TestDiskFailures.testLocalDirsFailures failed (Yufei Gu via Varun Saxena)
Posted by ka...@apache.org.
YARN-5862. TestDiskFailures.testLocalDirsFailures failed (Yufei Gu via Varun Saxena)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c202a109
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c202a109
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c202a109
Branch: refs/heads/YARN-4752
Commit: c202a10923a46a6e7f7f518e6e3dbb6545dbb971
Parents: 71adf44
Author: Varun Saxena <va...@apache.org>
Authored: Thu Nov 10 11:41:34 2016 +0530
Committer: Varun Saxena <va...@apache.org>
Committed: Thu Nov 10 11:41:34 2016 +0530
----------------------------------------------------------------------
.../java/org/apache/hadoop/yarn/server/TestDiskFailures.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/c202a109/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestDiskFailures.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestDiskFailures.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestDiskFailures.java
index c7e34d8..bf82ec5 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestDiskFailures.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestDiskFailures.java
@@ -244,7 +244,9 @@ public class TestDiskFailures {
for (int i = 0; i < 10; i++) {
Iterator<RMNode> iter = yarnCluster.getResourceManager().getRMContext()
.getRMNodes().values().iterator();
- if ((iter.next().getState() != NodeState.UNHEALTHY) == isHealthy) {
+ // RMNode # might be zero because of timing related issue.
+ if (iter.hasNext() &&
+ (iter.next().getState() != NodeState.UNHEALTHY) == isHealthy) {
break;
}
// wait for the node health info to go to RM
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[30/50] [abbrv] hadoop git commit: HADOOP-13800. Remove unused
HADOOP_AUDIT_LOGGER from hadoop-env.sh. Contributed by Yiqun Lin.
Posted by ka...@apache.org.
HADOOP-13800. Remove unused HADOOP_AUDIT_LOGGER from hadoop-env.sh. Contributed by Yiqun Lin.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c0748800
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c0748800
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c0748800
Branch: refs/heads/YARN-4752
Commit: c074880096bd41470a3358f6002f30b57a725375
Parents: 09f43fa
Author: Akira Ajisaka <aa...@apache.org>
Authored: Wed Nov 9 22:02:40 2016 +0900
Committer: Akira Ajisaka <aa...@apache.org>
Committed: Wed Nov 9 22:02:40 2016 +0900
----------------------------------------------------------------------
.../hadoop-common/src/main/conf/hadoop-env.sh | 6 ------
1 file changed, 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/c0748800/hadoop-common-project/hadoop-common/src/main/conf/hadoop-env.sh
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/conf/hadoop-env.sh b/hadoop-common-project/hadoop-common/src/main/conf/hadoop-env.sh
index a78f3f6..4fb9be9 100644
--- a/hadoop-common-project/hadoop-common/src/main/conf/hadoop-env.sh
+++ b/hadoop-common-project/hadoop-common/src/main/conf/hadoop-env.sh
@@ -223,12 +223,6 @@ esac
# Java property: hadoop.security.logger
# export HADOOP_SECURITY_LOGGER=INFO,NullAppender
-# Default log level for file system audit messages.
-# Generally, this is specifically set in the namenode-specific
-# options line.
-# Java property: hdfs.audit.logger
-# export HADOOP_AUDIT_LOGGER=INFO,NullAppender
-
# Default process priority level
# Note that sub-processes will also run at this level!
# export HADOOP_NICENESS=0
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[43/50] [abbrv] hadoop git commit: YARN-5453. FairScheduler#update
may skip update demand resource of child queue/app if current demand reached
maxResource. (sandflee via kasha)
Posted by ka...@apache.org.
YARN-5453. FairScheduler#update may skip update demand resource of child queue/app if current demand reached maxResource. (sandflee via kasha)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/86ac1ad9
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/86ac1ad9
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/86ac1ad9
Branch: refs/heads/YARN-4752
Commit: 86ac1ad9fd65c7dd12278372b369de38dc4616db
Parents: c8bc7a8
Author: Karthik Kambatla <ka...@apache.org>
Authored: Wed Nov 9 23:44:02 2016 -0800
Committer: Karthik Kambatla <ka...@apache.org>
Committed: Wed Nov 9 23:44:02 2016 -0800
----------------------------------------------------------------------
.../scheduler/fair/FSLeafQueue.java | 15 +++----
.../scheduler/fair/FSParentQueue.java | 6 +--
.../scheduler/fair/TestFairScheduler.java | 41 ++++++++++++++++++++
3 files changed, 48 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/86ac1ad9/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java
index 9d5bbe5..c393759 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java
@@ -268,20 +268,16 @@ public class FSLeafQueue extends FSQueue {
readLock.lock();
try {
for (FSAppAttempt sched : runnableApps) {
- if (Resources.equals(demand, maxShare)) {
- break;
- }
- updateDemandForApp(sched, maxShare);
+ updateDemandForApp(sched);
}
for (FSAppAttempt sched : nonRunnableApps) {
- if (Resources.equals(demand, maxShare)) {
- break;
- }
- updateDemandForApp(sched, maxShare);
+ updateDemandForApp(sched);
}
} finally {
readLock.unlock();
}
+ // Cap demand to maxShare to limit allocation to maxShare
+ demand = Resources.componentwiseMin(demand, maxShare);
if (LOG.isDebugEnabled()) {
LOG.debug("The updated demand for " + getName() + " is " + demand
+ "; the max is " + maxShare);
@@ -290,7 +286,7 @@ public class FSLeafQueue extends FSQueue {
}
}
- private void updateDemandForApp(FSAppAttempt sched, Resource maxRes) {
+ private void updateDemandForApp(FSAppAttempt sched) {
sched.updateDemand();
Resource toAdd = sched.getDemand();
if (LOG.isDebugEnabled()) {
@@ -299,7 +295,6 @@ public class FSLeafQueue extends FSQueue {
+ demand);
}
demand = Resources.add(demand, toAdd);
- demand = Resources.componentwiseMin(demand, maxRes);
}
@Override
http://git-wip-us.apache.org/repos/asf/hadoop/blob/86ac1ad9/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java
index d05390b..53ac8c9 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java
@@ -159,16 +159,14 @@ public class FSParentQueue extends FSQueue {
childQueue.updateDemand();
Resource toAdd = childQueue.getDemand();
demand = Resources.add(demand, toAdd);
- demand = Resources.componentwiseMin(demand, maxShare);
if (LOG.isDebugEnabled()) {
LOG.debug("Counting resource from " + childQueue.getName() + " " +
toAdd + "; Total resource demand for " + getName() +
" now " + demand);
}
- if (Resources.equals(demand, maxShare)) {
- break;
- }
}
+ // Cap demand to maxShare to limit allocation to maxShare
+ demand = Resources.componentwiseMin(demand, maxShare);
} finally {
writeLock.unlock();
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/86ac1ad9/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java
index f17726c..21d22c3 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java
@@ -4813,4 +4813,45 @@ public class TestFairScheduler extends FairSchedulerTestBase {
assertEquals(0, metrics.getReservedMB());
assertEquals(0, metrics.getReservedVirtualCores());
}
+
+
+ @Test
+ public void testUpdateDemand() throws IOException {
+ scheduler.init(conf);
+ scheduler.start();
+ scheduler.reinitialize(conf, resourceManager.getRMContext());
+
+ Resource maxResource = Resources.createResource(1024 * 8);
+
+ FSAppAttempt app1 = mock(FSAppAttempt.class);
+ Mockito.when(app1.getDemand()).thenReturn(maxResource);
+ FSAppAttempt app2 = mock(FSAppAttempt.class);
+ Mockito.when(app2.getDemand()).thenReturn(maxResource);
+
+ QueueManager queueManager = scheduler.getQueueManager();
+ FSParentQueue queue1 = queueManager.getParentQueue("queue1", true);
+
+ FSLeafQueue aQueue =
+ new FSLeafQueue("root.queue1.a", scheduler, queue1);
+ aQueue.setMaxShare(maxResource);
+ aQueue.addAppSchedulable(app1);
+
+ FSLeafQueue bQueue =
+ new FSLeafQueue("root.queue1.b", scheduler, queue1);
+ bQueue.setMaxShare(maxResource);
+ bQueue.addAppSchedulable(app2);
+
+ queue1.setMaxShare(maxResource);
+ queue1.addChildQueue(aQueue);
+ queue1.addChildQueue(bQueue);
+
+ queue1.updateDemand();
+
+ assertTrue("Demand is greater than max allowed ",
+ Resources.equals(queue1.getDemand(), maxResource));
+ assertTrue("Demand of child queue not updated ",
+ Resources.equals(aQueue.getDemand(), maxResource) &&
+ Resources.equals(bQueue.getDemand(), maxResource));
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[11/50] [abbrv] hadoop git commit: YARN-5716. Add global scheduler
interface definition and update CapacityScheduler to use it. Contributed by
Wangda Tan
Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAsyncScheduling.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAsyncScheduling.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAsyncScheduling.java
new file mode 100644
index 0000000..9854a15
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAsyncScheduling.java
@@ -0,0 +1,143 @@
+/**
+ * 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.scheduler.capacity;
+
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.server.resourcemanager.MockAM;
+import org.apache.hadoop.yarn.server.resourcemanager.MockNM;
+import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
+import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.NullRMNodeLabelsManager;
+import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
+import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestCapacitySchedulerAsyncScheduling {
+ private final int GB = 1024;
+
+ private YarnConfiguration conf;
+
+ RMNodeLabelsManager mgr;
+
+ @Before
+ public void setUp() throws Exception {
+ conf = new YarnConfiguration();
+ conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
+ ResourceScheduler.class);
+ conf.setBoolean(
+ CapacitySchedulerConfiguration.SCHEDULE_ASYNCHRONOUSLY_ENABLE, true);
+ mgr = new NullRMNodeLabelsManager();
+ mgr.init(conf);
+ }
+
+ @Test(timeout = 300000)
+ public void testSingleThreadAsyncContainerAllocation() throws Exception {
+ testAsyncContainerAllocation(1);
+ }
+
+ @Test(timeout = 300000)
+ public void testTwoThreadsAsyncContainerAllocation() throws Exception {
+ testAsyncContainerAllocation(2);
+ }
+
+ @Test(timeout = 300000)
+ public void testThreeThreadsAsyncContainerAllocation() throws Exception {
+ testAsyncContainerAllocation(3);
+ }
+
+ public void testAsyncContainerAllocation(int numThreads) throws Exception {
+ conf.setInt(
+ CapacitySchedulerConfiguration.SCHEDULE_ASYNCHRONOUSLY_MAXIMUM_THREAD,
+ numThreads);
+ conf.setInt(CapacitySchedulerConfiguration.SCHEDULE_ASYNCHRONOUSLY_PREFIX
+ + ".scheduling-interval-ms", 100);
+
+ final RMNodeLabelsManager mgr = new NullRMNodeLabelsManager();
+ mgr.init(conf);
+
+ // inject node label manager
+ MockRM rm = new MockRM(TestUtils.getConfigurationWithMultipleQueues(conf)) {
+ @Override
+ public RMNodeLabelsManager createNodeLabelManager() {
+ return mgr;
+ }
+ };
+
+ rm.getRMContext().setNodeLabelManager(mgr);
+ rm.start();
+
+ List<MockNM> nms = new ArrayList<>();
+ // Add 10 nodes to the cluster, in the cluster we have 200 GB resource
+ for (int i = 0; i < 10; i++) {
+ nms.add(rm.registerNode("h-" + i + ":1234", 20 * GB));
+ }
+
+ List<MockAM> ams = new ArrayList<>();
+ // Add 3 applications to the cluster, one app in one queue
+ // the i-th app ask (20 * i) containers. So in total we will have
+ // 123G container allocated
+ int totalAsked = 3 * GB; // 3 AMs
+
+ for (int i = 0; i < 3; i++) {
+ RMApp rmApp = rm.submitApp(1024, "app", "user", null, false,
+ Character.toString((char) (i % 34 + 97)), 1, null, null, false);
+ MockAM am = MockRM.launchAMWhenAsyncSchedulingEnabled(rmApp, rm);
+ am.registerAppAttempt();
+ ams.add(am);
+ }
+
+ for (int i = 0; i < 3; i++) {
+ ams.get(i).allocate("*", 1024, 20 * (i + 1), new ArrayList<>());
+ totalAsked += 20 * (i + 1) * GB;
+ }
+
+ // Wait for at most 15000 ms
+ int waitTime = 15000; // ms
+ while (waitTime > 0) {
+ if (rm.getResourceScheduler().getRootQueueMetrics().getAllocatedMB()
+ == totalAsked) {
+ break;
+ }
+ Thread.sleep(50);
+ waitTime -= 50;
+ }
+
+ Assert.assertEquals(
+ rm.getResourceScheduler().getRootQueueMetrics().getAllocatedMB(),
+ totalAsked);
+
+ // Wait for another 2 sec to make sure we will not allocate more than
+ // required
+ waitTime = 2000; // ms
+ while (waitTime > 0) {
+ Assert.assertEquals(
+ rm.getResourceScheduler().getRootQueueMetrics().getAllocatedMB(),
+ totalAsked);
+ waitTime -= 50;
+ Thread.sleep(50);
+ }
+
+ rm.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestChildQueueOrder.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestChildQueueOrder.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestChildQueueOrder.java
index 7f4fc2c..40e5d2a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestChildQueueOrder.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestChildQueueOrder.java
@@ -54,6 +54,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.preemption.PreemptionManager;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
@@ -110,15 +111,16 @@ public class TestChildQueueOrder {
return application;
}
- private void stubQueueAllocation(final CSQueue queue,
- final Resource clusterResource, final FiCaSchedulerNode node,
+ private void stubQueueAllocation(final CSQueue queue,
+ final Resource clusterResource, final FiCaSchedulerNode node,
final int allocation) {
- stubQueueAllocation(queue, clusterResource, node, allocation,
+ stubQueueAllocation(queue, clusterResource, node, allocation,
NodeType.NODE_LOCAL);
}
- private void stubQueueAllocation(final CSQueue queue,
- final Resource clusterResource, final FiCaSchedulerNode node,
+ @SuppressWarnings("unchecked")
+ private void stubQueueAllocation(final CSQueue queue,
+ final Resource clusterResource, final FiCaSchedulerNode node,
final int allocation, final NodeType type) {
// Simulate the queue allocation
@@ -145,7 +147,7 @@ public class TestChildQueueOrder {
if (allocation > 0) {
doReturn(new CSAssignment(Resources.none(), type)).
when(queue)
- .assignContainers(eq(clusterResource), eq(node),
+ .assignContainers(eq(clusterResource), any(PlacementSet.class),
any(ResourceLimits.class), any(SchedulingMode.class));
// Mock the node's resource availability
@@ -157,7 +159,7 @@ public class TestChildQueueOrder {
return new CSAssignment(allocatedResource, type);
}
}).
- when(queue).assignContainers(eq(clusterResource), eq(node),
+ when(queue).assignContainers(eq(clusterResource), any(PlacementSet.class),
any(ResourceLimits.class), any(SchedulingMode.class));
doNothing().when(node).releaseContainer(any(Container.class));
}
@@ -214,6 +216,7 @@ public class TestChildQueueOrder {
}
@Test
+ @SuppressWarnings("unchecked")
public void testSortedQueues() throws Exception {
// Setup queue configs
setupSortedQueues(csConf);
@@ -418,10 +421,10 @@ public class TestChildQueueOrder {
clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
InOrder allocationOrder = inOrder(d,b);
allocationOrder.verify(d).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), any(ResourceLimits.class),
+ any(PlacementSet.class), any(ResourceLimits.class),
any(SchedulingMode.class));
allocationOrder.verify(b).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), any(ResourceLimits.class),
+ any(PlacementSet.class), any(ResourceLimits.class),
any(SchedulingMode.class));
verifyQueueMetrics(a, 3*GB, clusterResource);
verifyQueueMetrics(b, 2*GB, clusterResource);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java
index e2b4952..555e0fd 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java
@@ -81,7 +81,7 @@ public class TestContainerAllocation {
mgr.init(conf);
}
- @Test(timeout = 3000000)
+ @Test(timeout = 60000)
public void testExcessReservationThanNodeManagerCapacity() throws Exception {
@SuppressWarnings("resource")
MockRM rm = new MockRM(conf);
@@ -598,4 +598,47 @@ public class TestContainerAllocation {
rm1.close();
}
+
+ @Test(timeout = 60000)
+ public void testAssignMultipleOffswitchContainers() throws Exception {
+ MockRM rm1 = new MockRM();
+
+ rm1.getRMContext().setNodeLabelManager(mgr);
+ rm1.start();
+ MockNM nm1 = rm1.registerNode("h1:1234", 80 * GB);
+
+ // launch an app to queue, AM container should be launched in nm1
+ RMApp app1 = rm1.submitApp(1 * GB, "app", "user", null, "default");
+ MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1);
+
+ am1.allocate("*", 1 * GB, 5, new ArrayList<ContainerId>());
+
+ CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
+ RMNode rmNode1 = rm1.getRMContext().getRMNodes().get(nm1.getNodeId());
+
+ // Do node heartbeats once
+ cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
+
+ FiCaSchedulerApp schedulerApp1 =
+ cs.getApplicationAttempt(am1.getApplicationAttemptId());
+
+ // App1 will get one container allocated (plus AM container
+ Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
+
+ // Set assign multiple off-switch containers to 3
+ CapacitySchedulerConfiguration newCSConf = new CapacitySchedulerConfiguration();
+ newCSConf.setInt(
+ CapacitySchedulerConfiguration.OFFSWITCH_PER_HEARTBEAT_LIMIT, 3);
+
+ cs.reinitialize(newCSConf, rm1.getRMContext());
+
+ // Do node heartbeats once
+ cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
+
+ // App1 will get 3 new container allocated (plus 2 previously allocated
+ // container)
+ Assert.assertEquals(5, schedulerApp1.getLiveContainers().size());
+
+ rm1.close();
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerResizing.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerResizing.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerResizing.java
index 2614630..0696f57 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerResizing.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerResizing.java
@@ -59,9 +59,12 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica
.FiCaSchedulerNode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptRemovedSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimplePlacementSet;
import org.apache.hadoop.yarn.util.resource.Resources;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
public class TestContainerResizing {
@@ -97,13 +100,14 @@ public class TestContainerResizing {
}
@Override
- public synchronized void allocateContainersToNode(FiCaSchedulerNode node) {
+ public CSAssignment allocateContainersToNode(
+ PlacementSet<FiCaSchedulerNode> ps, boolean withNodeHeartbeat) {
try {
Thread.sleep(1000);
} catch(InterruptedException e) {
LOG.debug("Thread interrupted.");
}
- super.allocateContainersToNode(node);
+ return super.allocateContainersToNode(ps, withNodeHeartbeat);
}
}
@@ -452,7 +456,7 @@ public class TestContainerResizing {
ContainerId.newContainerId(am1.getApplicationAttemptId(), 1);
sentRMContainerLaunched(rm1, containerId1);
- // am1 asks to change its AM container from 1GB to 3GB
+ // am1 asks to change its AM container from 1GB to 7GB
am1.sendContainerResizingRequest(Arrays.asList(
UpdateContainerRequest
.newInstance(0, containerId1,
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[21/50] [abbrv] hadoop git commit: YARN-5356. NodeManager should
communicate physical resource capability to ResourceManager. Contributed by
Inigo Goiri
Posted by ka...@apache.org.
YARN-5356. NodeManager should communicate physical resource capability to ResourceManager. Contributed by Inigo Goiri
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3f93ac07
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3f93ac07
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3f93ac07
Branch: refs/heads/YARN-4752
Commit: 3f93ac0733058238a2c8f23960c986c71dca0e02
Parents: dbb133c
Author: Jason Lowe <jl...@apache.org>
Authored: Tue Nov 8 22:01:26 2016 +0000
Committer: Jason Lowe <jl...@apache.org>
Committed: Tue Nov 8 22:01:26 2016 +0000
----------------------------------------------------------------------
.../hadoop/yarn/sls/nodemanager/NodeInfo.java | 5 +++
.../yarn/sls/scheduler/RMNodeWrapper.java | 5 +++
.../yarn/util/ResourceCalculatorPlugin.java | 39 ++++++++++++++++++++
.../RegisterNodeManagerRequest.java | 24 ++++++++++++
.../pb/RegisterNodeManagerRequestPBImpl.java | 30 ++++++++++++++-
.../yarn_server_common_service_protos.proto | 1 +
.../hadoop/yarn/TestYarnServerApiClasses.java | 3 ++
.../nodemanager/NodeResourceMonitorImpl.java | 6 +--
.../nodemanager/NodeStatusUpdaterImpl.java | 17 ++++++++-
.../monitor/ContainersMonitorImpl.java | 9 +----
.../resourcemanager/ResourceTrackerService.java | 3 +-
.../server/resourcemanager/rmnode/RMNode.java | 6 +++
.../resourcemanager/rmnode/RMNodeImpl.java | 23 +++++++++++-
.../yarn/server/resourcemanager/MockNodes.java | 17 ++++++---
14 files changed, 166 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/nodemanager/NodeInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/nodemanager/NodeInfo.java b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/nodemanager/NodeInfo.java
index b18fb4a..8962aba 100644
--- a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/nodemanager/NodeInfo.java
+++ b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/nodemanager/NodeInfo.java
@@ -218,6 +218,11 @@ public class NodeInfo {
public Integer getDecommissioningTimeout() {
return null;
}
+
+ @Override
+ public Resource getPhysicalResource() {
+ return null;
+ }
}
public static RMNode newNodeInfo(String rackName, String hostName,
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/scheduler/RMNodeWrapper.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/scheduler/RMNodeWrapper.java b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/scheduler/RMNodeWrapper.java
index 4edc216..d7b159c 100644
--- a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/scheduler/RMNodeWrapper.java
+++ b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/scheduler/RMNodeWrapper.java
@@ -207,4 +207,9 @@ public class RMNodeWrapper implements RMNode {
public Integer getDecommissioningTimeout() {
return null;
}
+
+ @Override
+ public Resource getPhysicalResource() {
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ResourceCalculatorPlugin.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ResourceCalculatorPlugin.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ResourceCalculatorPlugin.java
index 7b2ea56..e7e4c8a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ResourceCalculatorPlugin.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ResourceCalculatorPlugin.java
@@ -25,6 +25,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.util.ReflectionUtils;
import org.apache.hadoop.util.SysInfo;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
/**
* Plugin to calculate resource information on the system.
@@ -195,4 +196,42 @@ public class ResourceCalculatorPlugin extends Configured {
return null;
}
+ /**
+ * Create the ResourceCalculatorPlugin for the containers monitor in the Node
+ * Manager and configure it. If the plugin is not configured, this method
+ * will try and return a memory calculator plugin available for this system.
+ *
+ * @param conf Configure the plugin with this.
+ * @return ResourceCalculatorPlugin or null if ResourceCalculatorPlugin is
+ * not available for current system.
+ */
+ public static ResourceCalculatorPlugin getContainersMonitorPlugin(
+ Configuration conf) {
+ Class<? extends ResourceCalculatorPlugin> clazzNM = conf.getClass(
+ YarnConfiguration.NM_MON_RESOURCE_CALCULATOR, null,
+ ResourceCalculatorPlugin.class);
+ Class<? extends ResourceCalculatorPlugin> clazz = conf.getClass(
+ YarnConfiguration.NM_CONTAINER_MON_RESOURCE_CALCULATOR, clazzNM,
+ ResourceCalculatorPlugin.class);
+ return ResourceCalculatorPlugin.getResourceCalculatorPlugin(clazz, conf);
+ }
+
+ /**
+ * Create the ResourceCalculatorPlugin for the node resource monitor in the
+ * Node Manager and configure it. If the plugin is not configured, this
+ * method will try and return a memory calculator plugin available for this
+ * system.
+ *
+ * @param conf Configure the plugin with this.
+ * @return ResourceCalculatorPlugin or null if ResourceCalculatorPlugin is
+ * not available for current system.
+ */
+ public static ResourceCalculatorPlugin getNodeResourceMonitorPlugin(
+ Configuration conf) {
+ Class<? extends ResourceCalculatorPlugin> clazz = conf.getClass(
+ YarnConfiguration.NM_MON_RESOURCE_CALCULATOR, null,
+ ResourceCalculatorPlugin.class);
+ return ResourceCalculatorPlugin.getResourceCalculatorPlugin(clazz, conf);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/RegisterNodeManagerRequest.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/RegisterNodeManagerRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/RegisterNodeManagerRequest.java
index 7798ba9..fc30a80 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/RegisterNodeManagerRequest.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/RegisterNodeManagerRequest.java
@@ -41,6 +41,15 @@ public abstract class RegisterNodeManagerRequest {
int httpPort, Resource resource, String nodeManagerVersionId,
List<NMContainerStatus> containerStatuses,
List<ApplicationId> runningApplications, Set<NodeLabel> nodeLabels) {
+ return newInstance(nodeId, httpPort, resource, nodeManagerVersionId,
+ containerStatuses, runningApplications, nodeLabels, null);
+ }
+
+ public static RegisterNodeManagerRequest newInstance(NodeId nodeId,
+ int httpPort, Resource resource, String nodeManagerVersionId,
+ List<NMContainerStatus> containerStatuses,
+ List<ApplicationId> runningApplications, Set<NodeLabel> nodeLabels,
+ Resource physicalResource) {
RegisterNodeManagerRequest request =
Records.newRecord(RegisterNodeManagerRequest.class);
request.setHttpPort(httpPort);
@@ -50,6 +59,7 @@ public abstract class RegisterNodeManagerRequest {
request.setContainerStatuses(containerStatuses);
request.setRunningApplications(runningApplications);
request.setNodeLabels(nodeLabels);
+ request.setPhysicalResource(physicalResource);
return request;
}
@@ -88,4 +98,18 @@ public abstract class RegisterNodeManagerRequest {
*/
public abstract void setRunningApplications(
List<ApplicationId> runningApplications);
+
+ /**
+ * Get the physical resources in the node to properly estimate resource
+ * utilization.
+ * @return Physical resources in the node.
+ */
+ public abstract Resource getPhysicalResource();
+
+ /**
+ * Set the physical resources in the node to properly estimate resource
+ * utilization.
+ * @param physicalResource Physical resources in the node.
+ */
+ public abstract void setPhysicalResource(Resource physicalResource);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/RegisterNodeManagerRequestPBImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/RegisterNodeManagerRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/RegisterNodeManagerRequestPBImpl.java
index 2a1a268..0291e0b 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/RegisterNodeManagerRequestPBImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/RegisterNodeManagerRequestPBImpl.java
@@ -56,6 +56,9 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
private List<ApplicationId> runningApplications = null;
private Set<NodeLabel> labels = null;
+ /** Physical resources in the node. */
+ private Resource physicalResource = null;
+
public RegisterNodeManagerRequestPBImpl() {
builder = RegisterNodeManagerRequestProto.newBuilder();
}
@@ -93,6 +96,9 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
}
builder.setNodeLabels(newBuilder.build());
}
+ if (this.physicalResource != null) {
+ builder.setPhysicalResource(convertToProtoFormat(this.physicalResource));
+ }
}
private synchronized void addNMContainerStatusesToProto() {
@@ -269,7 +275,29 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
initContainerRecoveryReports();
this.containerStatuses.addAll(containerReports);
}
-
+
+ @Override
+ public synchronized Resource getPhysicalResource() {
+ RegisterNodeManagerRequestProtoOrBuilder p = viaProto ? proto : builder;
+ if (this.physicalResource != null) {
+ return this.physicalResource;
+ }
+ if (!p.hasPhysicalResource()) {
+ return null;
+ }
+ this.physicalResource = convertFromProtoFormat(p.getPhysicalResource());
+ return this.physicalResource;
+ }
+
+ @Override
+ public synchronized void setPhysicalResource(Resource pPhysicalResource) {
+ maybeInitBuilder();
+ if (pPhysicalResource == null) {
+ builder.clearPhysicalResource();
+ }
+ this.physicalResource = pPhysicalResource;
+ }
+
@Override
public int hashCode() {
return getProto().hashCode();
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_service_protos.proto
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_service_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_service_protos.proto
index 4350fc5..edb2d9c 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_service_protos.proto
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_service_protos.proto
@@ -63,6 +63,7 @@ message RegisterNodeManagerRequestProto {
repeated NMContainerStatusProto container_statuses = 6;
repeated ApplicationIdProto runningApplications = 7;
optional NodeLabelsProto nodeLabels = 8;
+ optional ResourceProto physicalResource = 9;
}
message RegisterNodeManagerResponseProto {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java
index be350e2..b670c36 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java
@@ -204,6 +204,7 @@ public class TestYarnServerApiClasses {
resource.setMemorySize(10000);
resource.setVirtualCores(2);
original.setResource(resource);
+ original.setPhysicalResource(resource);
RegisterNodeManagerRequestPBImpl copy = new RegisterNodeManagerRequestPBImpl(
original.getProto());
@@ -211,6 +212,8 @@ public class TestYarnServerApiClasses {
assertEquals(9090, copy.getNodeId().getPort());
assertEquals(10000, copy.getResource().getMemorySize());
assertEquals(2, copy.getResource().getVirtualCores());
+ assertEquals(10000, copy.getPhysicalResource().getMemorySize());
+ assertEquals(2, copy.getPhysicalResource().getVirtualCores());
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeResourceMonitorImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeResourceMonitorImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeResourceMonitorImpl.java
index 3a78d87..8ee27de 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeResourceMonitorImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeResourceMonitorImpl.java
@@ -66,12 +66,8 @@ public class NodeResourceMonitorImpl extends AbstractService implements
conf.getLong(YarnConfiguration.NM_RESOURCE_MON_INTERVAL_MS,
YarnConfiguration.DEFAULT_NM_RESOURCE_MON_INTERVAL_MS);
- Class<? extends ResourceCalculatorPlugin> clazz =
- conf.getClass(YarnConfiguration.NM_MON_RESOURCE_CALCULATOR, null,
- ResourceCalculatorPlugin.class);
-
this.resourceCalculatorPlugin =
- ResourceCalculatorPlugin.getResourceCalculatorPlugin(clazz, conf);
+ ResourceCalculatorPlugin.getNodeResourceMonitorPlugin(conf);
LOG.info(" Using ResourceCalculatorPlugin : "
+ this.resourceCalculatorPlugin);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java
index ec7e1d9..6e50d24 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java
@@ -91,6 +91,7 @@ import org.apache.hadoop.yarn.server.nodemanager.timelineservice.NMTimelinePubli
import org.apache.hadoop.yarn.server.nodemanager.util.NodeManagerHardwareUtils;
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
import org.apache.hadoop.yarn.util.resource.Resources;
+import org.apache.hadoop.yarn.util.ResourceCalculatorPlugin;
import org.apache.hadoop.yarn.util.YarnVersionInfo;
import com.google.common.annotations.VisibleForTesting;
@@ -113,6 +114,7 @@ public class NodeStatusUpdaterImpl extends AbstractService implements
private long nextHeartBeatInterval;
private ResourceTracker resourceTracker;
private Resource totalResource;
+ private Resource physicalResource;
private int httpPort;
private String nodeManagerVersionId;
private String minimumResourceManagerVersion;
@@ -187,6 +189,19 @@ public class NodeStatusUpdaterImpl extends AbstractService implements
this.totalResource = Resource.newInstance(memoryMb, virtualCores);
metrics.addResource(totalResource);
+
+ // Get actual node physical resources
+ int physicalMemoryMb = memoryMb;
+ int physicalCores = virtualCores;
+ ResourceCalculatorPlugin rcp =
+ ResourceCalculatorPlugin.getNodeResourceMonitorPlugin(conf);
+ if (rcp != null) {
+ physicalMemoryMb = (int) (rcp.getPhysicalMemorySize() / (1024 * 1024));
+ physicalCores = rcp.getNumProcessors();
+ }
+ this.physicalResource =
+ Resource.newInstance(physicalMemoryMb, physicalCores);
+
this.tokenKeepAliveEnabled = isTokenKeepAliveEnabled(conf);
this.tokenRemovalDelayMs =
conf.getInt(YarnConfiguration.RM_NM_EXPIRY_INTERVAL_MS,
@@ -343,7 +358,7 @@ public class NodeStatusUpdaterImpl extends AbstractService implements
RegisterNodeManagerRequest request =
RegisterNodeManagerRequest.newInstance(nodeId, httpPort, totalResource,
nodeManagerVersionId, containerReports, getRunningApplications(),
- nodeLabels);
+ nodeLabels, physicalResource);
if (containerReports != null) {
LOG.info("Registering with RM using containers :" + containerReports);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
index 72e99d0..fad2b6a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
@@ -125,15 +125,8 @@ public class ContainersMonitorImpl extends AbstractService implements
this.conf.getLong(YarnConfiguration.NM_RESOURCE_MON_INTERVAL_MS,
YarnConfiguration.DEFAULT_NM_RESOURCE_MON_INTERVAL_MS));
- Class<? extends ResourceCalculatorPlugin> clazz =
- this.conf.getClass(YarnConfiguration
- .NM_CONTAINER_MON_RESOURCE_CALCULATOR,
- this.conf.getClass(
- YarnConfiguration.NM_MON_RESOURCE_CALCULATOR, null,
- ResourceCalculatorPlugin.class),
- ResourceCalculatorPlugin.class);
this.resourceCalculatorPlugin =
- ResourceCalculatorPlugin.getResourceCalculatorPlugin(clazz, this.conf);
+ ResourceCalculatorPlugin.getContainersMonitorPlugin(this.conf);
LOG.info(" Using ResourceCalculatorPlugin : "
+ this.resourceCalculatorPlugin);
processTreeClass = this.conf.getClass(
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java
index 51fc0bd..40bd610 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java
@@ -318,6 +318,7 @@ public class ResourceTrackerService extends AbstractService implements
int httpPort = request.getHttpPort();
Resource capability = request.getResource();
String nodeManagerVersion = request.getNMVersion();
+ Resource physicalResource = request.getPhysicalResource();
RegisterNodeManagerResponse response = recordFactory
.newRecordInstance(RegisterNodeManagerResponse.class);
@@ -387,7 +388,7 @@ public class ResourceTrackerService extends AbstractService implements
.getCurrentKey());
RMNode rmNode = new RMNodeImpl(nodeId, rmContext, host, cmPort, httpPort,
- resolve(host), capability, nodeManagerVersion);
+ resolve(host), capability, nodeManagerVersion, physicalResource);
RMNode oldNode = this.rmContext.getRMNodes().putIfAbsent(nodeId, rmNode);
if (oldNode == null) {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java
index 6d95b56..86f8679 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java
@@ -114,6 +114,12 @@ public interface RMNode {
public ResourceUtilization getNodeUtilization();
/**
+ * the physical resources in the node.
+ * @return the physical resources in the node.
+ */
+ Resource getPhysicalResource();
+
+ /**
* The rack name for this node manager.
* @return the rack name.
*/
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java
index 71ebddb..302743a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java
@@ -133,6 +133,9 @@ public class RMNodeImpl implements RMNode, EventHandler<RMNodeEvent> {
/* Resource utilization for the node. */
private ResourceUtilization nodeUtilization;
+ /** Physical resources in the node. */
+ private volatile Resource physicalResource;
+
/* Container Queue Information for the node.. Used by Distributed Scheduler */
private OpportunisticContainersStatus opportunisticContainersStatus;
@@ -353,7 +356,15 @@ public class RMNodeImpl implements RMNode, EventHandler<RMNodeEvent> {
RMNodeEvent> stateMachine;
public RMNodeImpl(NodeId nodeId, RMContext context, String hostName,
- int cmPort, int httpPort, Node node, Resource capability, String nodeManagerVersion) {
+ int cmPort, int httpPort, Node node, Resource capability,
+ String nodeManagerVersion) {
+ this(nodeId, context, hostName, cmPort, httpPort, node, capability,
+ nodeManagerVersion, null);
+ }
+
+ public RMNodeImpl(NodeId nodeId, RMContext context, String hostName,
+ int cmPort, int httpPort, Node node, Resource capability,
+ String nodeManagerVersion, Resource physResource) {
this.nodeId = nodeId;
this.context = context;
this.hostName = hostName;
@@ -367,6 +378,7 @@ public class RMNodeImpl implements RMNode, EventHandler<RMNodeEvent> {
this.lastHealthReportTime = System.currentTimeMillis();
this.nodeManagerVersion = nodeManagerVersion;
this.timeStamp = 0;
+ this.physicalResource = physResource;
this.latestNodeHeartBeatResponse.setResponseId(0);
@@ -527,6 +539,15 @@ public class RMNodeImpl implements RMNode, EventHandler<RMNodeEvent> {
}
@Override
+ public Resource getPhysicalResource() {
+ return this.physicalResource;
+ }
+
+ public void setPhysicalResource(Resource physicalResource) {
+ this.physicalResource = physicalResource;
+ }
+
+ @Override
public NodeState getState() {
this.readLock.lock();
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f93ac07/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java
index 7959e74..91170d1 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java
@@ -112,12 +112,13 @@ public class MockNodes {
private Set<String> labels;
private ResourceUtilization containersUtilization;
private ResourceUtilization nodeUtilization;
+ private Resource physicalResource;
public MockRMNodeImpl(NodeId nodeId, String nodeAddr, String httpAddress,
Resource perNode, String rackName, String healthReport,
long lastHealthReportTime, int cmdPort, String hostName, NodeState state,
Set<String> labels, ResourceUtilization containersUtilization,
- ResourceUtilization nodeUtilization) {
+ ResourceUtilization nodeUtilization, Resource pPhysicalResource) {
this.nodeId = nodeId;
this.nodeAddr = nodeAddr;
this.httpAddress = httpAddress;
@@ -131,6 +132,7 @@ public class MockNodes {
this.labels = labels;
this.containersUtilization = containersUtilization;
this.nodeUtilization = nodeUtilization;
+ this.physicalResource = pPhysicalResource;
}
@Override
@@ -277,6 +279,11 @@ public class MockNodes {
public Integer getDecommissioningTimeout() {
return null;
}
+
+ @Override
+ public Resource getPhysicalResource() {
+ return this.physicalResource;
+ }
};
private static RMNode buildRMNode(int rack, final Resource perNode,
@@ -287,19 +294,19 @@ public class MockNodes {
private static RMNode buildRMNode(int rack, final Resource perNode,
NodeState state, String httpAddr, Set<String> labels) {
return buildRMNode(rack, perNode, state, httpAddr, NODE_ID++, null, 123,
- labels, null, null);
+ labels, null, null, null);
}
private static RMNode buildRMNode(int rack, final Resource perNode,
NodeState state, String httpAddr, int hostnum, String hostName, int port) {
return buildRMNode(rack, perNode, state, httpAddr, hostnum, hostName, port,
- null, null, null);
+ null, null, null, null);
}
private static RMNode buildRMNode(int rack, final Resource perNode,
NodeState state, String httpAddr, int hostnum, String hostName, int port,
Set<String> labels, ResourceUtilization containersUtilization,
- ResourceUtilization nodeUtilization) {
+ ResourceUtilization nodeUtilization, Resource physicalResource) {
final String rackName = "rack"+ rack;
final int nid = hostnum;
final String nodeAddr = hostName + ":" + nid;
@@ -312,7 +319,7 @@ public class MockNodes {
String healthReport = (state == NodeState.UNHEALTHY) ? null : "HealthyMe";
return new MockRMNodeImpl(nodeID, nodeAddr, httpAddress, perNode,
rackName, healthReport, 0, nid, hostName, state, labels,
- containersUtilization, nodeUtilization);
+ containersUtilization, nodeUtilization, physicalResource);
}
public static RMNode nodeInfo(int rack, final Resource perNode,
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[45/50] [abbrv] hadoop git commit: HADOOP-13687. Provide a unified
dependency artifact that transitively includes the cloud storage modules
shipped with Hadoop. Contributed by Chris Nauroth
Posted by ka...@apache.org.
HADOOP-13687. Provide a unified dependency artifact that transitively includes the cloud storage modules shipped with Hadoop. Contributed by Chris Nauroth
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/89354f04
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/89354f04
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/89354f04
Branch: refs/heads/YARN-4752
Commit: 89354f0475efa8e393697b1ddc227c94a76b5923
Parents: ca68f9c
Author: Mingliang Liu <li...@apache.org>
Authored: Thu Nov 10 08:58:37 2016 -0800
Committer: Mingliang Liu <li...@apache.org>
Committed: Thu Nov 10 08:58:37 2016 -0800
----------------------------------------------------------------------
.../hadoop-cloud-storage/pom.xml | 127 +++++++++++++++++++
hadoop-cloud-storage-project/pom.xml | 54 ++++++++
hadoop-project/pom.xml | 5 +
hadoop-tools/hadoop-openstack/pom.xml | 2 +-
4 files changed, 187 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/89354f04/hadoop-cloud-storage-project/hadoop-cloud-storage/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-cloud-storage-project/hadoop-cloud-storage/pom.xml b/hadoop-cloud-storage-project/hadoop-cloud-storage/pom.xml
new file mode 100644
index 0000000..7993b83
--- /dev/null
+++ b/hadoop-cloud-storage-project/hadoop-cloud-storage/pom.xml
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed 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. See accompanying LICENSE file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-project</artifactId>
+ <version>3.0.0-alpha2-SNAPSHOT</version>
+ <relativePath>../../hadoop-project</relativePath>
+ </parent>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-cloud-storage</artifactId>
+ <version>3.0.0-alpha2-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <description>Apache Hadoop Cloud Storage</description>
+ <name>Apache Hadoop Cloud Storage</name>
+
+ <properties>
+ <hadoop.component>cloud-storage</hadoop.component>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-annotations</artifactId>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>jdk.tools</groupId>
+ <artifactId>jdk.tools</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-common</artifactId>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jetty</groupId>
+ <artifactId>org.mortbay.jetty</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>servlet-api-2.5</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.jdt</groupId>
+ <artifactId>core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.avro</groupId>
+ <artifactId>avro-ipc</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>net.sf.kosmosfs</groupId>
+ <artifactId>kfs</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>net.java.dev.jets3t</groupId>
+ <artifactId>jets3t</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-aws</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-azure</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-openstack</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/89354f04/hadoop-cloud-storage-project/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-cloud-storage-project/pom.xml b/hadoop-cloud-storage-project/pom.xml
new file mode 100644
index 0000000..94d4c02
--- /dev/null
+++ b/hadoop-cloud-storage-project/pom.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed 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. See accompanying LICENSE file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-project</artifactId>
+ <version>3.0.0-alpha2-SNAPSHOT</version>
+ <relativePath>../hadoop-project</relativePath>
+ </parent>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-cloud-storage-project</artifactId>
+ <version>3.0.0-alpha2-SNAPSHOT</version>
+ <description>Apache Hadoop Cloud Storage Project</description>
+ <name>Apache Hadoop Cloud Storage Project</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>hadoop-cloud-storage</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/89354f04/hadoop-project/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-project/pom.xml b/hadoop-project/pom.xml
index ca567c5..5750a3f 100644
--- a/hadoop-project/pom.xml
+++ b/hadoop-project/pom.xml
@@ -983,6 +983,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-cloud-storage</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>${findbugs.version}</version>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/89354f04/hadoop-tools/hadoop-openstack/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-openstack/pom.xml b/hadoop-tools/hadoop-openstack/pom.xml
index f9a4df0..d04a9a3 100644
--- a/hadoop-tools/hadoop-openstack/pom.xml
+++ b/hadoop-tools/hadoop-openstack/pom.xml
@@ -114,7 +114,7 @@
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
- <scope>compile</scope>
+ <scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[07/50] [abbrv] hadoop git commit: HADOOP-13797 Remove hardcoded
absolute path for ls. Contributed by Christine Koppelt
Posted by ka...@apache.org.
HADOOP-13797 Remove hardcoded absolute path for ls. Contributed by Christine Koppelt
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f7689557
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f7689557
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f7689557
Branch: refs/heads/YARN-4752
Commit: f76895573d0166b4b582ff69c3f9c159ab14661f
Parents: b970446
Author: Steve Loughran <st...@apache.org>
Authored: Mon Nov 7 12:36:10 2016 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Mon Nov 7 12:36:10 2016 +0000
----------------------------------------------------------------------
.../hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/f7689557/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java
index 0745057..5fc9869 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java
@@ -237,7 +237,7 @@ public abstract class Shell {
/** Return a command to get permission information. */
public static String[] getGetPermissionCommand() {
return (WINDOWS) ? new String[] { getWinUtilsPath(), "ls", "-F" }
- : new String[] { "/bin/ls", "-ld" };
+ : new String[] { "ls", "-ld" };
}
/** Return a command to set permission. */
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[38/50] [abbrv] hadoop git commit: YARN-5611. Provide an API to
update lifetime of an application. Contributed by Rohith Sharma K S
Posted by ka...@apache.org.
YARN-5611. Provide an API to update lifetime of an application. Contributed by Rohith Sharma K S
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/bcc15c62
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/bcc15c62
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/bcc15c62
Branch: refs/heads/YARN-4752
Commit: bcc15c6290b3912a054323695a6a931b0de163bd
Parents: edbee9e
Author: Jian He <ji...@apache.org>
Authored: Wed Nov 9 14:33:58 2016 -0800
Committer: Jian He <ji...@apache.org>
Committed: Wed Nov 9 16:08:05 2016 -0800
----------------------------------------------------------------------
.../hadoop/mapred/TestClientRedirect.java | 9 +
.../yarn/api/ApplicationClientProtocol.java | 23 ++
.../UpdateApplicationTimeoutsRequest.java | 81 +++++++
.../UpdateApplicationTimeoutsResponse.java | 46 ++++
.../records/ApplicationSubmissionContext.java | 4 +
.../hadoop/yarn/conf/YarnConfiguration.java | 6 +-
.../main/proto/applicationclient_protocol.proto | 1 +
.../src/main/proto/yarn_protos.proto | 5 +
.../src/main/proto/yarn_service_protos.proto | 9 +
.../ApplicationClientProtocolPBClientImpl.java | 21 +-
.../ApplicationClientProtocolPBServiceImpl.java | 22 ++
.../UpdateApplicationTimeoutsRequestPBImpl.java | 220 +++++++++++++++++++
...UpdateApplicationTimeoutsResponsePBImpl.java | 73 ++++++
.../yarn/util/AbstractLivelinessMonitor.java | 17 +-
.../java/org/apache/hadoop/yarn/util/Times.java | 33 +++
.../src/main/resources/yarn-default.xml | 4 +-
.../amrmproxy/MockResourceManagerFacade.java | 9 +
.../server/resourcemanager/ClientRMService.java | 137 +++++++++---
.../server/resourcemanager/RMAppManager.java | 37 ++++
.../server/resourcemanager/RMAuditLogger.java | 4 +-
.../server/resourcemanager/RMServerUtils.java | 48 +++-
.../resourcemanager/recovery/RMStateStore.java | 28 ++-
.../recovery/RMStateUpdateAppEvent.java | 15 +-
.../recovery/records/ApplicationStateData.java | 27 +++
.../impl/pb/ApplicationStateDataPBImpl.java | 86 ++++++++
.../server/resourcemanager/rmapp/RMApp.java | 3 +
.../server/resourcemanager/rmapp/RMAppImpl.java | 64 +++++-
.../rmapp/monitor/RMAppLifetimeMonitor.java | 72 +++---
.../scheduler/capacity/CapacityScheduler.java | 3 +-
.../yarn_server_resourcemanager_recovery.proto | 1 +
.../applicationsmanager/MockAsm.java | 6 +
.../server/resourcemanager/rmapp/MockRMApp.java | 6 +
.../rmapp/TestApplicationLifetimeMonitor.java | 150 ++++++++++++-
33 files changed, 1149 insertions(+), 121 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestClientRedirect.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestClientRedirect.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestClientRedirect.java
index 255f998..65eac65 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestClientRedirect.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestClientRedirect.java
@@ -124,6 +124,8 @@ import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityRequest;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
@@ -485,6 +487,13 @@ public class TestClientRedirect {
SignalContainerRequest request) throws IOException {
return null;
}
+
+ @Override
+ public UpdateApplicationTimeoutsResponse updateApplicationTimeouts(
+ UpdateApplicationTimeoutsRequest request)
+ throws YarnException, IOException {
+ return null;
+ }
}
class HistoryService extends AMService implements HSClientProtocol {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocol.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocol.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocol.java
index 8ee43fb..394454f 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocol.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocol.java
@@ -59,6 +59,8 @@ import org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest;
import org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityRequest;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse;
import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest;
import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse;
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
@@ -566,4 +568,25 @@ public interface ApplicationClientProtocol extends ApplicationBaseProtocol {
SignalContainerResponse signalToContainer(
SignalContainerRequest request) throws YarnException,
IOException;
+
+ /**
+ * <p>
+ * The interface used by client to set ApplicationTimeouts of an application.
+ * The UpdateApplicationTimeoutsRequest should have timeout value with
+ * absolute time with ISO8601 format <b>yyyy-MM-dd'T'HH:mm:ss.SSSZ</b>.
+ * </p>
+ * <b>Note:</b> If application timeout value is less than or equal to current
+ * time then update application throws YarnException.
+ * @param request to set ApplicationTimeouts of an application
+ * @return an empty response that the update has completed successfully.
+ * @throws YarnException if update request has empty values or application is
+ * in completing states.
+ * @throws IOException on IO failures
+ */
+ @Public
+ @Unstable
+ @Idempotent
+ public UpdateApplicationTimeoutsResponse updateApplicationTimeouts(
+ UpdateApplicationTimeoutsRequest request)
+ throws YarnException, IOException;
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/UpdateApplicationTimeoutsRequest.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/UpdateApplicationTimeoutsRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/UpdateApplicationTimeoutsRequest.java
new file mode 100644
index 0000000..0e81e7e
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/UpdateApplicationTimeoutsRequest.java
@@ -0,0 +1,81 @@
+/**
+ * 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.api.protocolrecords;
+
+import java.util.Map;
+
+import org.apache.hadoop.classification.InterfaceAudience.Public;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
+import org.apache.hadoop.yarn.util.Records;
+
+/**
+ * <p>
+ * The request sent by the client to the <code>ResourceManager</code> to set or
+ * update the application timeout.
+ * </p>
+ * <p>
+ * The request includes the {@link ApplicationId} of the application and timeout
+ * to be set for an application
+ * </p>
+ */
+@Public
+@Unstable
+public abstract class UpdateApplicationTimeoutsRequest {
+ public static UpdateApplicationTimeoutsRequest newInstance(
+ ApplicationId applicationId,
+ Map<ApplicationTimeoutType, String> applicationTimeouts) {
+ UpdateApplicationTimeoutsRequest request =
+ Records.newRecord(UpdateApplicationTimeoutsRequest.class);
+ request.setApplicationId(applicationId);
+ request.setApplicationTimeouts(applicationTimeouts);
+ return request;
+ }
+
+ /**
+ * Get the <code>ApplicationId</code> of the application.
+ * @return <code>ApplicationId</code> of the application
+ */
+ public abstract ApplicationId getApplicationId();
+
+ /**
+ * Set the <code>ApplicationId</code> of the application.
+ * @param applicationId <code>ApplicationId</code> of the application
+ */
+ public abstract void setApplicationId(ApplicationId applicationId);
+
+ /**
+ * Get <code>ApplicationTimeouts</code> of the application. Timeout value is
+ * in ISO8601 standard with format <b>yyyy-MM-dd'T'HH:mm:ss.SSSZ</b>.
+ * @return all <code>ApplicationTimeouts</code> of the application.
+ */
+ public abstract Map<ApplicationTimeoutType, String> getApplicationTimeouts();
+
+ /**
+ * Set the <code>ApplicationTimeouts</code> for the application. Timeout value
+ * is absolute. Timeout value should meet ISO8601 format. Support ISO8601
+ * format is <b>yyyy-MM-dd'T'HH:mm:ss.SSSZ</b>. All pre-existing Map entries
+ * are cleared before adding the new Map.
+ * @param applicationTimeouts <code>ApplicationTimeouts</code>s for the
+ * application
+ */
+ public abstract void setApplicationTimeouts(
+ Map<ApplicationTimeoutType, String> applicationTimeouts);
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/UpdateApplicationTimeoutsResponse.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/UpdateApplicationTimeoutsResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/UpdateApplicationTimeoutsResponse.java
new file mode 100644
index 0000000..bd02bb8
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/UpdateApplicationTimeoutsResponse.java
@@ -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.api.protocolrecords;
+
+import java.util.Map;
+
+import org.apache.hadoop.classification.InterfaceAudience.Public;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.util.Records;
+
+/**
+ * <p>
+ * The response sent by the <code>ResourceManager</code> to the client on update
+ * application timeout.
+ * </p>
+ * <p>
+ * A response without exception means that the update has completed
+ * successfully.
+ * </p>
+ */
+@Public
+@Unstable
+public abstract class UpdateApplicationTimeoutsResponse {
+
+ public static UpdateApplicationTimeoutsResponse newInstance() {
+ UpdateApplicationTimeoutsResponse response =
+ Records.newRecord(UpdateApplicationTimeoutsResponse.class);
+ return response;
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationSubmissionContext.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationSubmissionContext.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationSubmissionContext.java
index 83f601a..e562aaa 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationSubmissionContext.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationSubmissionContext.java
@@ -549,6 +549,10 @@ public abstract class ApplicationSubmissionContext {
/**
* Set the <code>ApplicationTimeouts</code> for the application in seconds.
* All pre-existing Map entries are cleared before adding the new Map.
+ * <p>
+ * <b>Note:</b> If application timeout value is less than or equal to zero
+ * then application submission will throw an exception.
+ * </p>
* @param applicationTimeouts <code>ApplicationTimeouts</code>s for the
* application
*/
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
index 1fd25a7..b95bd1a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
@@ -1540,10 +1540,10 @@ public class YarnConfiguration extends Configuration {
// Configurations for applicaiton life time monitor feature
- public static final String RM_APPLICATION_LIFETIME_MONITOR_INTERVAL_MS =
- RM_PREFIX + "application-timeouts.lifetime-monitor.interval-ms";
+ public static final String RM_APPLICATION_MONITOR_INTERVAL_MS =
+ RM_PREFIX + "application-timeouts.monitor.interval-ms";
- public static final long DEFAULT_RM_APPLICATION_LIFETIME_MONITOR_INTERVAL_MS =
+ public static final long DEFAULT_RM_APPLICATION_MONITOR_INTERVAL_MS =
60000;
/**
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/applicationclient_protocol.proto
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/applicationclient_protocol.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/applicationclient_protocol.proto
index f1c3839..ba79db0 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/applicationclient_protocol.proto
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/applicationclient_protocol.proto
@@ -60,4 +60,5 @@ service ApplicationClientProtocolService {
rpc getClusterNodeLabels (GetClusterNodeLabelsRequestProto) returns (GetClusterNodeLabelsResponseProto);
rpc updateApplicationPriority (UpdateApplicationPriorityRequestProto) returns (UpdateApplicationPriorityResponseProto);
rpc signalToContainer(SignalContainerRequestProto) returns (SignalContainerResponseProto);
+ rpc updateApplicationTimeouts (UpdateApplicationTimeoutsRequestProto) returns (UpdateApplicationTimeoutsResponseProto);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto
index 9c746fd..b59d02b 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto
@@ -377,6 +377,11 @@ message ApplicationTimeoutMapProto {
optional int64 timeout = 2;
}
+message ApplicationUpdateTimeoutMapProto {
+ optional ApplicationTimeoutTypeProto application_timeout_type = 1;
+ optional string expire_time = 2;
+}
+
message LogAggregationContextProto {
optional string include_pattern = 1 [default = ".*"];
optional string exclude_pattern = 2 [default = ""];
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto
index 6526bf9..d9230d4 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto
@@ -267,6 +267,15 @@ message SignalContainerRequestProto {
message SignalContainerResponseProto {
}
+message UpdateApplicationTimeoutsRequestProto {
+ required ApplicationIdProto applicationId = 1;
+ repeated ApplicationUpdateTimeoutMapProto application_timeouts = 2;
+}
+
+message UpdateApplicationTimeoutsResponseProto {
+ repeated ApplicationUpdateTimeoutMapProto application_timeouts = 1;
+}
+
//////////////////////////////////////////////////////
/////// client_NM_Protocol ///////////////////////////
//////////////////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ApplicationClientProtocolPBClientImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ApplicationClientProtocolPBClientImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ApplicationClientProtocolPBClientImpl.java
index 2d755a2..ad7cb29 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ApplicationClientProtocolPBClientImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ApplicationClientProtocolPBClientImpl.java
@@ -83,6 +83,8 @@ import org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest;
import org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityRequest;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse;
import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest;
import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse;
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
@@ -139,6 +141,8 @@ import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationUpdateReque
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationUpdateResponsePBImpl;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.UpdateApplicationPriorityRequestPBImpl;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.UpdateApplicationPriorityResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.UpdateApplicationTimeoutsRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.UpdateApplicationTimeoutsResponsePBImpl;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SignalContainerRequestPBImpl;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SignalContainerResponsePBImpl;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SubmitApplicationRequestPBImpl;
@@ -165,7 +169,7 @@ import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationDeleteRequestPr
import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationSubmissionRequestProto;
import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationUpdateRequestProto;
import org.apache.hadoop.yarn.proto.YarnServiceProtos.UpdateApplicationPriorityRequestProto;
-import org.apache.hadoop.yarn.proto.YarnServiceProtos.UpdateApplicationPriorityResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.UpdateApplicationTimeoutsRequestProto;
import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationRequestProto;
import com.google.protobuf.ServiceException;
@@ -600,4 +604,19 @@ public class ApplicationClientProtocolPBClientImpl implements ApplicationClientP
return null;
}
}
+
+ @Override
+ public UpdateApplicationTimeoutsResponse updateApplicationTimeouts(
+ UpdateApplicationTimeoutsRequest request)
+ throws YarnException, IOException {
+ UpdateApplicationTimeoutsRequestProto requestProto =
+ ((UpdateApplicationTimeoutsRequestPBImpl) request).getProto();
+ try {
+ return new UpdateApplicationTimeoutsResponsePBImpl(
+ proxy.updateApplicationTimeouts(null, requestProto));
+ } catch (ServiceException e) {
+ RPCUtil.unwrapAndThrowException(e);
+ return null;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ApplicationClientProtocolPBServiceImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ApplicationClientProtocolPBServiceImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ApplicationClientProtocolPBServiceImpl.java
index 300ef57..93ce6a3 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ApplicationClientProtocolPBServiceImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ApplicationClientProtocolPBServiceImpl.java
@@ -55,6 +55,7 @@ import org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse;
import org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse;
import org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse;
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse;
import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.CancelDelegationTokenRequestPBImpl;
@@ -111,6 +112,8 @@ import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SignalContainerRequest
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SignalContainerResponsePBImpl;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.UpdateApplicationPriorityRequestPBImpl;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.UpdateApplicationPriorityResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.UpdateApplicationTimeoutsRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.UpdateApplicationTimeoutsResponsePBImpl;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SubmitApplicationRequestPBImpl;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SubmitApplicationResponsePBImpl;
import org.apache.hadoop.yarn.exceptions.YarnException;
@@ -162,6 +165,8 @@ import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationListResponsePro
import org.apache.hadoop.yarn.proto.YarnServiceProtos.SignalContainerResponseProto;
import org.apache.hadoop.yarn.proto.YarnServiceProtos.UpdateApplicationPriorityRequestProto;
import org.apache.hadoop.yarn.proto.YarnServiceProtos.UpdateApplicationPriorityResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.UpdateApplicationTimeoutsRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.UpdateApplicationTimeoutsResponseProto;
import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationRequestProto;
import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationResponseProto;
@@ -609,4 +614,21 @@ public class ApplicationClientProtocolPBServiceImpl implements ApplicationClient
throw new ServiceException(e);
}
}
+
+ @Override
+ public UpdateApplicationTimeoutsResponseProto updateApplicationTimeouts(
+ RpcController controller, UpdateApplicationTimeoutsRequestProto proto)
+ throws ServiceException {
+ UpdateApplicationTimeoutsRequestPBImpl request =
+ new UpdateApplicationTimeoutsRequestPBImpl(proto);
+ try {
+ UpdateApplicationTimeoutsResponse response =
+ real.updateApplicationTimeouts(request);
+ return ((UpdateApplicationTimeoutsResponsePBImpl) response).getProto();
+ } catch (YarnException e) {
+ throw new ServiceException(e);
+ } catch (IOException e) {
+ throw new ServiceException(e);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/UpdateApplicationTimeoutsRequestPBImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/UpdateApplicationTimeoutsRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/UpdateApplicationTimeoutsRequestPBImpl.java
new file mode 100644
index 0000000..1f86c55
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/UpdateApplicationTimeoutsRequestPBImpl.java
@@ -0,0 +1,220 @@
+/**
+ * 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.api.protocolrecords.impl.pb;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
+import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl;
+import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationUpdateTimeoutMapProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.UpdateApplicationTimeoutsRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.UpdateApplicationTimeoutsRequestProtoOrBuilder;
+
+import com.google.protobuf.TextFormat;
+
+@Private
+@Unstable
+public class UpdateApplicationTimeoutsRequestPBImpl
+ extends UpdateApplicationTimeoutsRequest {
+
+ UpdateApplicationTimeoutsRequestProto proto =
+ UpdateApplicationTimeoutsRequestProto.getDefaultInstance();
+ UpdateApplicationTimeoutsRequestProto.Builder builder = null;
+ boolean viaProto = false;
+
+ private ApplicationId applicationId = null;
+ private Map<ApplicationTimeoutType, String> applicationTimeouts = null;
+
+ public UpdateApplicationTimeoutsRequestPBImpl() {
+ builder = UpdateApplicationTimeoutsRequestProto.newBuilder();
+ }
+
+ public UpdateApplicationTimeoutsRequestPBImpl(
+ UpdateApplicationTimeoutsRequestProto proto) {
+ this.proto = proto;
+ viaProto = true;
+ }
+
+ public UpdateApplicationTimeoutsRequestProto getProto() {
+ mergeLocalToProto();
+ proto = viaProto ? proto : builder.build();
+ viaProto = true;
+ return proto;
+ }
+
+ private void mergeLocalToProto() {
+ if (viaProto)
+ maybeInitBuilder();
+ mergeLocalToBuilder();
+ proto = builder.build();
+ viaProto = true;
+ }
+
+ private void maybeInitBuilder() {
+ if (viaProto || builder == null) {
+ builder = UpdateApplicationTimeoutsRequestProto.newBuilder(proto);
+ }
+ viaProto = false;
+ }
+
+ private void mergeLocalToBuilder() {
+ if (this.applicationId != null) {
+ builder.setApplicationId(convertToProtoFormat(this.applicationId));
+ }
+ if (this.applicationTimeouts != null) {
+ addApplicationTimeouts();
+ }
+ }
+
+ @Override
+ public ApplicationId getApplicationId() {
+ UpdateApplicationTimeoutsRequestProtoOrBuilder p =
+ viaProto ? proto : builder;
+ if (this.applicationId != null) {
+ return applicationId;
+ } // Else via proto
+ if (!p.hasApplicationId()) {
+ return null;
+ }
+ applicationId = convertFromProtoFormat(p.getApplicationId());
+ return applicationId;
+ }
+
+ @Override
+ public void setApplicationId(ApplicationId applicationId) {
+ maybeInitBuilder();
+ if (applicationId == null) {
+ builder.clearApplicationId();
+ }
+ this.applicationId = applicationId;
+ }
+
+ private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) {
+ return new ApplicationIdPBImpl(p);
+ }
+
+ private ApplicationIdProto convertToProtoFormat(ApplicationId t) {
+ return ((ApplicationIdPBImpl) t).getProto();
+ }
+
+ @Override
+ public int hashCode() {
+ return getProto().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
+ if (other.getClass().isAssignableFrom(this.getClass())) {
+ return this.getProto().equals(this.getClass().cast(other).getProto());
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return TextFormat.shortDebugString(getProto());
+ }
+
+ @Override
+ public Map<ApplicationTimeoutType, String> getApplicationTimeouts() {
+ initApplicationTimeout();
+ return this.applicationTimeouts;
+ }
+
+ private void initApplicationTimeout() {
+ if (this.applicationTimeouts != null) {
+ return;
+ }
+ UpdateApplicationTimeoutsRequestProtoOrBuilder p =
+ viaProto ? proto : builder;
+ List<ApplicationUpdateTimeoutMapProto> lists =
+ p.getApplicationTimeoutsList();
+ this.applicationTimeouts =
+ new HashMap<ApplicationTimeoutType, String>(lists.size());
+ for (ApplicationUpdateTimeoutMapProto timeoutProto : lists) {
+ this.applicationTimeouts.put(
+ ProtoUtils
+ .convertFromProtoFormat(timeoutProto.getApplicationTimeoutType()),
+ timeoutProto.getExpireTime());
+ }
+ }
+
+ @Override
+ public void setApplicationTimeouts(
+ Map<ApplicationTimeoutType, String> appTimeouts) {
+ if (appTimeouts == null) {
+ return;
+ }
+ initApplicationTimeout();
+ this.applicationTimeouts.clear();
+ this.applicationTimeouts.putAll(appTimeouts);
+ }
+
+ private void addApplicationTimeouts() {
+ maybeInitBuilder();
+ builder.clearApplicationTimeouts();
+ if (applicationTimeouts == null) {
+ return;
+ }
+ Iterable<? extends ApplicationUpdateTimeoutMapProto> values =
+ new Iterable<ApplicationUpdateTimeoutMapProto>() {
+
+ @Override
+ public Iterator<ApplicationUpdateTimeoutMapProto> iterator() {
+ return new Iterator<ApplicationUpdateTimeoutMapProto>() {
+ private Iterator<ApplicationTimeoutType> iterator =
+ applicationTimeouts.keySet().iterator();
+
+ @Override
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ @Override
+ public ApplicationUpdateTimeoutMapProto next() {
+ ApplicationTimeoutType key = iterator.next();
+ return ApplicationUpdateTimeoutMapProto.newBuilder()
+ .setExpireTime(applicationTimeouts.get(key))
+ .setApplicationTimeoutType(
+ ProtoUtils.convertToProtoFormat(key))
+ .build();
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+ };
+ this.builder.addAllApplicationTimeouts(values);
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/UpdateApplicationTimeoutsResponsePBImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/UpdateApplicationTimeoutsResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/UpdateApplicationTimeoutsResponsePBImpl.java
new file mode 100644
index 0000000..74f1715
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/UpdateApplicationTimeoutsResponsePBImpl.java
@@ -0,0 +1,73 @@
+/**
+ * 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.api.protocolrecords.impl.pb;
+
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.UpdateApplicationTimeoutsResponseProto;
+
+import com.google.protobuf.TextFormat;
+
+@Private
+@Unstable
+public class UpdateApplicationTimeoutsResponsePBImpl
+ extends UpdateApplicationTimeoutsResponse {
+ UpdateApplicationTimeoutsResponseProto proto =
+ UpdateApplicationTimeoutsResponseProto.getDefaultInstance();
+ UpdateApplicationTimeoutsResponseProto.Builder builder = null;
+ boolean viaProto = false;
+
+ public UpdateApplicationTimeoutsResponsePBImpl() {
+ builder = UpdateApplicationTimeoutsResponseProto.newBuilder();
+ }
+
+ public UpdateApplicationTimeoutsResponsePBImpl(
+ UpdateApplicationTimeoutsResponseProto proto) {
+ this.proto = proto;
+ viaProto = true;
+ }
+
+ public UpdateApplicationTimeoutsResponseProto getProto() {
+ proto = viaProto ? proto : builder.build();
+ viaProto = true;
+ return proto;
+ }
+
+ @Override
+ public int hashCode() {
+ return getProto().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
+ if (other.getClass().isAssignableFrom(this.getClass())) {
+ return this.getProto().equals(this.getClass().cast(other).getProto());
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return TextFormat.shortDebugString(getProto());
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/AbstractLivelinessMonitor.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/AbstractLivelinessMonitor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/AbstractLivelinessMonitor.java
index b605026..638128e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/AbstractLivelinessMonitor.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/AbstractLivelinessMonitor.java
@@ -46,6 +46,7 @@ public abstract class AbstractLivelinessMonitor<O> extends AbstractService {
public static final int DEFAULT_EXPIRE = 5*60*1000;//5 mins
private long expireInterval = DEFAULT_EXPIRE;
private long monitorInterval = expireInterval / 3;
+ private volatile boolean resetTimerOnStart = true;
private final Clock clock;
@@ -105,8 +106,8 @@ public abstract class AbstractLivelinessMonitor<O> extends AbstractService {
register(ob, clock.getTime());
}
- public synchronized void register(O ob, long monitorStartTime) {
- running.put(ob, monitorStartTime);
+ public synchronized void register(O ob, long expireTime) {
+ running.put(ob, expireTime);
}
public synchronized void unregister(O ob) {
@@ -114,12 +115,18 @@ public abstract class AbstractLivelinessMonitor<O> extends AbstractService {
}
public synchronized void resetTimer() {
- long time = clock.getTime();
- for (O ob : running.keySet()) {
- running.put(ob, time);
+ if (resetTimerOnStart) {
+ long time = clock.getTime();
+ for (O ob : running.keySet()) {
+ running.put(ob, time);
+ }
}
}
+ protected void setResetTimeOnStart(boolean resetTimeOnStart) {
+ this.resetTimerOnStart = resetTimeOnStart;
+ }
+
private class PingChecker implements Runnable {
@Override
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/Times.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/Times.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/Times.java
index 8ae3842..f113bd3 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/Times.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/Times.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.yarn.util;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -29,6 +30,8 @@ import org.apache.hadoop.classification.InterfaceAudience.Private;
public class Times {
private static final Log LOG = LogFactory.getLog(Times.class);
+ static final String ISO8601DATEFORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
+
// This format should match the one used in yarn.dt.plugins.js
static final ThreadLocal<SimpleDateFormat> dateFormat =
new ThreadLocal<SimpleDateFormat>() {
@@ -37,6 +40,14 @@ public class Times {
}
};
+ static final ThreadLocal<SimpleDateFormat> isoFormat =
+ new ThreadLocal<SimpleDateFormat>() {
+ @Override
+ protected SimpleDateFormat initialValue() {
+ return new SimpleDateFormat(ISO8601DATEFORMAT);
+ }
+ };
+
public static long elapsed(long started, long finished) {
return Times.elapsed(started, finished, true);
}
@@ -74,4 +85,26 @@ public class Times {
return ts > 0 ? String.valueOf(dateFormat.get().format(new Date(ts)))
: "N/A";
}
+
+ /**
+ * Given a time stamp returns ISO-8601 formated string in format
+ * "yyyy-MM-dd'T'HH:mm:ss.SSSZ".
+ * @param ts to be formatted in ISO format.
+ * @return ISO 8601 formatted string.
+ */
+ public static String formatISO8601(long ts) {
+ return isoFormat.get().format(new Date(ts));
+ }
+
+ /**
+ * Given ISO formatted string with format "yyyy-MM-dd'T'HH:mm:ss.SSSZ", return
+ * epoch time for local Time zone.
+ * @param isoString in format of "yyyy-MM-dd'T'HH:mm:ss.SSSZ".
+ * @return epoch time for local time zone.
+ * @throws ParseException if given ISO formatted string can not be parsed.
+ */
+ public static long parseISO8601ToLocalTimeInMillis(String isoString)
+ throws ParseException {
+ return isoFormat.get().parse(isoString).getTime();
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
index 834ead7..019166b 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
@@ -3048,9 +3048,9 @@
<property>
<description>
- The RMAppLifetimeMonitor Service uses this value as lifetime monitor interval
+ The RMAppLifetimeMonitor Service uses this value as monitor interval
</description>
- <name>yarn.resourcemanager.application-timeouts.lifetime-monitor.interval-ms</name>
+ <name>yarn.resourcemanager.application-timeouts.monitor.interval-ms</name>
<value>60000</value>
</property>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/MockResourceManagerFacade.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/MockResourceManagerFacade.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/MockResourceManagerFacade.java
index f02e306..c69313f 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/MockResourceManagerFacade.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/MockResourceManagerFacade.java
@@ -91,6 +91,8 @@ import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityRequest;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse;
import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
import org.apache.hadoop.yarn.api.records.AMCommand;
@@ -497,4 +499,11 @@ return null;
FailApplicationAttemptRequest request) throws YarnException, IOException {
throw new NotImplementedException();
}
+
+ @Override
+ public UpdateApplicationTimeoutsResponse updateApplicationTimeouts(
+ UpdateApplicationTimeoutsRequest request)
+ throws YarnException, IOException {
+ throw new NotImplementedException();
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java
index e9bd230..c8af526 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java
@@ -108,12 +108,15 @@ import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityRequest;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse;
import org.apache.hadoop.yarn.api.records.ApplicationAccessType;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.api.records.NodeReport;
@@ -1589,37 +1592,11 @@ public class ClientRMService extends AbstractService implements
ApplicationId applicationId = request.getApplicationId();
Priority newAppPriority = request.getApplicationPriority();
- UserGroupInformation callerUGI;
- try {
- callerUGI = UserGroupInformation.getCurrentUser();
- } catch (IOException ie) {
- LOG.info("Error getting UGI ", ie);
- RMAuditLogger.logFailure("UNKNOWN", AuditConstants.UPDATE_APP_PRIORITY,
- "UNKNOWN", "ClientRMService", "Error getting UGI", applicationId);
- throw RPCUtil.getRemoteException(ie);
- }
-
- RMApp application = this.rmContext.getRMApps().get(applicationId);
- if (application == null) {
- RMAuditLogger.logFailure(callerUGI.getUserName(),
- AuditConstants.UPDATE_APP_PRIORITY, "UNKNOWN", "ClientRMService",
- "Trying to update priority of an absent application", applicationId);
- throw new ApplicationNotFoundException(
- "Trying to update priority of an absent application "
- + applicationId);
- }
- if (!checkAccess(callerUGI, application.getUser(),
- ApplicationAccessType.MODIFY_APP, application)) {
- RMAuditLogger.logFailure(callerUGI.getShortUserName(),
- AuditConstants.UPDATE_APP_PRIORITY,
- "User doesn't have permissions to "
- + ApplicationAccessType.MODIFY_APP.toString(), "ClientRMService",
- AuditConstants.UNAUTHORIZED_USER, applicationId);
- throw RPCUtil.getRemoteException(new AccessControlException("User "
- + callerUGI.getShortUserName() + " cannot perform operation "
- + ApplicationAccessType.MODIFY_APP.name() + " on " + applicationId));
- }
+ UserGroupInformation callerUGI =
+ getCallerUgi(applicationId, AuditConstants.UPDATE_APP_PRIORITY);
+ RMApp application = verifyUserAccessForRMApp(applicationId, callerUGI,
+ AuditConstants.UPDATE_APP_PRIORITY);
UpdateApplicationPriorityResponse response = recordFactory
.newRecordInstance(UpdateApplicationPriorityResponse.class);
@@ -1724,4 +1701,104 @@ public class ClientRMService extends AbstractService implements
.newRecordInstance(SignalContainerResponse.class);
}
+ @Override
+ public UpdateApplicationTimeoutsResponse updateApplicationTimeouts(
+ UpdateApplicationTimeoutsRequest request)
+ throws YarnException, IOException {
+
+ ApplicationId applicationId = request.getApplicationId();
+ Map<ApplicationTimeoutType, String> applicationTimeouts =
+ request.getApplicationTimeouts();
+
+ UserGroupInformation callerUGI =
+ getCallerUgi(applicationId, AuditConstants.UPDATE_APP_TIMEOUTS);
+ RMApp application = verifyUserAccessForRMApp(applicationId, callerUGI,
+ AuditConstants.UPDATE_APP_TIMEOUTS);
+
+ if (applicationTimeouts.isEmpty()) {
+ String message =
+ "At least one ApplicationTimeoutType should be configured"
+ + " for updating timeouts.";
+ RMAuditLogger.logFailure(callerUGI.getShortUserName(),
+ AuditConstants.UPDATE_APP_TIMEOUTS, "UNKNOWN", "ClientRMService",
+ message, applicationId);
+ throw RPCUtil.getRemoteException(message);
+ }
+
+ UpdateApplicationTimeoutsResponse response = recordFactory
+ .newRecordInstance(UpdateApplicationTimeoutsResponse.class);
+
+ RMAppState state = application.getState();
+ if (!EnumSet
+ .of(RMAppState.SUBMITTED, RMAppState.ACCEPTED, RMAppState.RUNNING)
+ .contains(state)) {
+ if (COMPLETED_APP_STATES.contains(state)) {
+ // If Application is in any of the final states, update timeout
+ // can be skipped rather throwing exception.
+ RMAuditLogger.logSuccess(callerUGI.getShortUserName(),
+ AuditConstants.UPDATE_APP_TIMEOUTS, "ClientRMService",
+ applicationId);
+ return response;
+ }
+ String msg =
+ "Application is in " + state + " state can not update timeout.";
+ RMAuditLogger.logFailure(callerUGI.getShortUserName(),
+ AuditConstants.UPDATE_APP_TIMEOUTS, "UNKNOWN", "ClientRMService",
+ msg);
+ throw RPCUtil.getRemoteException(msg);
+ }
+
+ try {
+ rmAppManager.updateApplicationTimeout(application, applicationTimeouts);
+ } catch (YarnException ex) {
+ RMAuditLogger.logFailure(callerUGI.getShortUserName(),
+ AuditConstants.UPDATE_APP_TIMEOUTS, "UNKNOWN", "ClientRMService",
+ ex.getMessage());
+ throw RPCUtil.getRemoteException(ex);
+ }
+
+ RMAuditLogger.logSuccess(callerUGI.getShortUserName(),
+ AuditConstants.UPDATE_APP_TIMEOUTS, "ClientRMService", applicationId);
+ return response;
+ }
+
+ private UserGroupInformation getCallerUgi(ApplicationId applicationId,
+ String operation) throws YarnException {
+ UserGroupInformation callerUGI;
+ try {
+ callerUGI = UserGroupInformation.getCurrentUser();
+ } catch (IOException ie) {
+ LOG.info("Error getting UGI ", ie);
+ RMAuditLogger.logFailure("UNKNOWN", operation, "UNKNOWN",
+ "ClientRMService", "Error getting UGI", applicationId);
+ throw RPCUtil.getRemoteException(ie);
+ }
+ return callerUGI;
+ }
+
+ private RMApp verifyUserAccessForRMApp(ApplicationId applicationId,
+ UserGroupInformation callerUGI, String operation) throws YarnException {
+ RMApp application = this.rmContext.getRMApps().get(applicationId);
+ if (application == null) {
+ RMAuditLogger.logFailure(callerUGI.getUserName(), operation, "UNKNOWN",
+ "ClientRMService",
+ "Trying to " + operation + " of an absent application",
+ applicationId);
+ throw new ApplicationNotFoundException("Trying to " + operation
+ + " of an absent application " + applicationId);
+ }
+
+ if (!checkAccess(callerUGI, application.getUser(),
+ ApplicationAccessType.MODIFY_APP, application)) {
+ RMAuditLogger.logFailure(callerUGI.getShortUserName(), operation,
+ "User doesn't have permissions to "
+ + ApplicationAccessType.MODIFY_APP.toString(),
+ "ClientRMService", AuditConstants.UNAUTHORIZED_USER, applicationId);
+ throw RPCUtil.getRemoteException(new AccessControlException("User "
+ + callerUGI.getShortUserName() + " cannot perform operation "
+ + ApplicationAccessType.MODIFY_APP.name() + " on " + applicationId));
+ }
+ return application;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java
index c065b60..7144421 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.api.records.ApplicationAccessType;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.api.records.QueueACL;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
@@ -66,6 +67,8 @@ import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.SettableFuture;
/**
* This class manages the list of applications for the resource manager.
@@ -509,4 +512,38 @@ public class RMAppManager implements EventHandler<RMAppManagerEvent>,
LOG.error("Invalid eventtype " + event.getType() + ". Ignoring!");
}
}
+
+ // transaction method.
+ public void updateApplicationTimeout(RMApp app,
+ Map<ApplicationTimeoutType, String> newTimeoutInISO8601Format)
+ throws YarnException {
+ ApplicationId applicationId = app.getApplicationId();
+ synchronized (applicationId) {
+ Map<ApplicationTimeoutType, Long> newExpireTime = RMServerUtils
+ .validateISO8601AndConvertToLocalTimeEpoch(newTimeoutInISO8601Format);
+
+ SettableFuture<Object> future = SettableFuture.create();
+
+ Map<ApplicationTimeoutType, Long> currentExpireTimeouts =
+ app.getApplicationTimeouts();
+ currentExpireTimeouts.putAll(newExpireTime);
+
+ ApplicationStateData appState =
+ ApplicationStateData.newInstance(app.getSubmitTime(),
+ app.getStartTime(), app.getApplicationSubmissionContext(),
+ app.getUser(), app.getCallerContext());
+ appState.setApplicationTimeouts(currentExpireTimeouts);
+
+ // update to state store. Though it synchronous call, update via future to
+ // know any exception has been set. It is required because in non-HA mode,
+ // state-store errors are skipped.
+ this.rmContext.getStateStore()
+ .updateApplicationStateSynchronously(appState, false, future);
+
+ Futures.get(future, YarnException.class);
+
+ // update in-memory
+ ((RMAppImpl) app).updateApplicationTimeout(newExpireTime);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAuditLogger.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAuditLogger.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAuditLogger.java
index 0361059..d52e002 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAuditLogger.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAuditLogger.java
@@ -63,7 +63,9 @@ public class RMAuditLogger {
public static final String ALLOC_CONTAINER = "AM Allocated Container";
public static final String RELEASE_CONTAINER = "AM Released Container";
public static final String UPDATE_APP_PRIORITY =
- "Update Application Priority Request";
+ "Update Application Priority";
+ public static final String UPDATE_APP_TIMEOUTS =
+ "Update Application Timeouts";
public static final String CHANGE_CONTAINER_RESOURCE =
"AM Changed Container Resource";
public static final String SIGNAL_CONTAINER = "Signal Container Request";
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMServerUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMServerUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMServerUtils.java
index b2a085a..7e31e70 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMServerUtils.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMServerUtils.java
@@ -19,6 +19,7 @@
package org.apache.hadoop.yarn.server.resourcemanager;
import java.io.IOException;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
@@ -69,6 +70,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler;
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
+import org.apache.hadoop.yarn.util.Clock;
+import org.apache.hadoop.yarn.util.SystemClock;
+import org.apache.hadoop.yarn.util.Times;
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
import org.apache.hadoop.yarn.util.resource.Resources;
@@ -89,6 +93,8 @@ public class RMServerUtils {
protected static final RecordFactory RECORD_FACTORY =
RecordFactoryProvider.getRecordFactory(null);
+ private static Clock clock = SystemClock.getInstance();
+
public static List<RMNode> queryRMNodes(RMContext context,
EnumSet<NodeState> acceptedStates) {
// nodes contains nodes that are NEW, RUNNING, UNHEALTHY or DECOMMISSIONING.
@@ -398,6 +404,7 @@ public class RMServerUtils {
case FINISHING:
case FINISHED:
return YarnApplicationState.FINISHED;
+ case KILLING:
case KILLED:
return YarnApplicationState.KILLED;
case FAILED:
@@ -475,7 +482,7 @@ public class RMServerUtils {
if (timeouts != null) {
for (Map.Entry<ApplicationTimeoutType, Long> timeout : timeouts
.entrySet()) {
- if (timeout.getValue() < 0) {
+ if (timeout.getValue() <= 0) {
String message = "Invalid application timeout, value="
+ timeout.getValue() + " for type=" + timeout.getKey();
throw new YarnException(message);
@@ -483,4 +490,43 @@ public class RMServerUtils {
}
}
}
+
+ /**
+ * Validate ISO8601 format with epoch time.
+ * @param timeoutsInISO8601 format
+ * @return expire time in local epoch
+ * @throws YarnException if given application timeout value is lesser than
+ * current time.
+ */
+ public static Map<ApplicationTimeoutType, Long> validateISO8601AndConvertToLocalTimeEpoch(
+ Map<ApplicationTimeoutType, String> timeoutsInISO8601)
+ throws YarnException {
+ long currentTimeMillis = clock.getTime();
+ Map<ApplicationTimeoutType, Long> newApplicationTimeout =
+ new HashMap<ApplicationTimeoutType, Long>();
+ if (timeoutsInISO8601 != null) {
+ for (Map.Entry<ApplicationTimeoutType, String> timeout : timeoutsInISO8601
+ .entrySet()) {
+ long expireTime = 0L;
+ try {
+ expireTime =
+ Times.parseISO8601ToLocalTimeInMillis(timeout.getValue());
+ } catch (ParseException ex) {
+ String message =
+ "Expire time is not in ISO8601 format. ISO8601 supported "
+ + "format is yyyy-MM-dd'T'HH:mm:ss.SSSZ";
+ throw new YarnException(message);
+ }
+ if (expireTime < currentTimeMillis) {
+ String message =
+ "Expire time is less than current time, current-time="
+ + Times.formatISO8601(currentTimeMillis) + " expire-time="
+ + Times.formatISO8601(expireTime);
+ throw new YarnException(message);
+ }
+ newApplicationTimeout.put(timeout.getKey(), expireTime);
+ }
+ }
+ return newApplicationTimeout;
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java
index de273c4..d1f8b40 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java
@@ -31,13 +31,14 @@ import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
import javax.crypto.SecretKey;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.util.concurrent.SettableFuture;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
-import org.apache.hadoop.ipc.CallerContext;
import org.apache.hadoop.security.Credentials;
import org.apache.hadoop.security.token.delegation.DelegationKey;
import org.apache.hadoop.service.AbstractService;
@@ -51,6 +52,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.event.AsyncDispatcher;
import org.apache.hadoop.yarn.event.Dispatcher;
import org.apache.hadoop.yarn.event.EventHandler;
+import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto;
import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier;
import org.apache.hadoop.yarn.server.records.Version;
@@ -237,6 +239,8 @@ public abstract class RMStateStore extends AbstractService {
boolean isFenced = false;
ApplicationStateData appState =
((RMStateUpdateAppEvent) event).getAppState();
+ SettableFuture<Object> result =
+ ((RMStateUpdateAppEvent) event).getResult();
ApplicationId appId =
appState.getApplicationSubmissionContext().getApplicationId();
LOG.info("Updating info for app: " + appId);
@@ -246,9 +250,18 @@ public abstract class RMStateStore extends AbstractService {
store.notifyApplication(new RMAppEvent(appId,
RMAppEventType.APP_UPDATE_SAVED));
}
+
+ if (result != null) {
+ result.set(null);
+ }
+
} catch (Exception e) {
- LOG.error("Error updating app: " + appId, e);
+ String msg = "Error updating app: " + appId;
+ LOG.error(msg, e);
isFenced = store.notifyStoreOperationFailedInternal(e);
+ if (result != null) {
+ result.setException(new YarnException(msg, e));
+ }
}
return finalState(isFenced);
};
@@ -774,18 +787,19 @@ public abstract class RMStateStore extends AbstractService {
ApplicationStateData appState =
ApplicationStateData.newInstance(app.getSubmitTime(),
app.getStartTime(), context, app.getUser(), app.getCallerContext());
+ appState.setApplicationTimeouts(app.getApplicationTimeouts());
dispatcher.getEventHandler().handle(new RMStateStoreAppEvent(appState));
}
@SuppressWarnings("unchecked")
- public void updateApplicationState(
- ApplicationStateData appState) {
+ public void updateApplicationState(ApplicationStateData appState) {
dispatcher.getEventHandler().handle(new RMStateUpdateAppEvent(appState));
}
- public void updateApplicationStateSynchronously(
- ApplicationStateData appState, boolean notifyApp) {
- handleStoreEvent(new RMStateUpdateAppEvent(appState, notifyApp));
+ public void updateApplicationStateSynchronously(ApplicationStateData appState,
+ boolean notifyApp, SettableFuture<Object> resultFuture) {
+ handleStoreEvent(
+ new RMStateUpdateAppEvent(appState, notifyApp, resultFuture));
}
public void updateFencedState() {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateUpdateAppEvent.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateUpdateAppEvent.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateUpdateAppEvent.java
index 69169dd..0a6220b 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateUpdateAppEvent.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateUpdateAppEvent.java
@@ -20,21 +20,28 @@ package org.apache.hadoop.yarn.server.resourcemanager.recovery;
import org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData;
+import com.google.common.util.concurrent.SettableFuture;
+
public class RMStateUpdateAppEvent extends RMStateStoreEvent {
private final ApplicationStateData appState;
// After application state is updated in state store,
// should notify back to application or not
private boolean notifyApplication;
+ private SettableFuture<Object> future;
public RMStateUpdateAppEvent(ApplicationStateData appState) {
super(RMStateStoreEventType.UPDATE_APP);
this.appState = appState;
this.notifyApplication = true;
+ this.future = null;
}
- public RMStateUpdateAppEvent(ApplicationStateData appState, boolean notifyApp) {
- this(appState);
+ public RMStateUpdateAppEvent(ApplicationStateData appState, boolean notifyApp,
+ SettableFuture<Object> future) {
+ super(RMStateStoreEventType.UPDATE_APP);
+ this.appState = appState;
this.notifyApplication = notifyApp;
+ this.future = future;
}
public ApplicationStateData getAppState() {
@@ -44,4 +51,8 @@ public class RMStateUpdateAppEvent extends RMStateStoreEvent {
public boolean isNotifyApplication() {
return notifyApplication;
}
+
+ public SettableFuture<Object> getResult() {
+ return future;
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/records/ApplicationStateData.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/records/ApplicationStateData.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/records/ApplicationStateData.java
index 2348380..79a5de2 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/records/ApplicationStateData.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/records/ApplicationStateData.java
@@ -29,6 +29,7 @@ import org.apache.hadoop.ipc.CallerContext;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
import org.apache.hadoop.yarn.proto.YarnServerResourceManagerRecoveryProtos.ApplicationStateDataProto;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
import org.apache.hadoop.yarn.util.Records;
@@ -60,6 +61,25 @@ public abstract class ApplicationStateData {
}
public static ApplicationStateData newInstance(long submitTime,
+ long startTime, String user,
+ ApplicationSubmissionContext submissionContext, RMAppState state,
+ String diagnostics, long finishTime, CallerContext callerContext,
+ Map<ApplicationTimeoutType, Long> applicationTimeouts) {
+ ApplicationStateData appState =
+ Records.newRecord(ApplicationStateData.class);
+ appState.setSubmitTime(submitTime);
+ appState.setStartTime(startTime);
+ appState.setUser(user);
+ appState.setApplicationSubmissionContext(submissionContext);
+ appState.setState(state);
+ appState.setDiagnostics(diagnostics);
+ appState.setFinishTime(finishTime);
+ appState.setCallerContext(callerContext);
+ appState.setApplicationTimeouts(applicationTimeouts);
+ return appState;
+ }
+
+ public static ApplicationStateData newInstance(long submitTime,
long startTime, ApplicationSubmissionContext context, String user,
CallerContext callerContext) {
return newInstance(submitTime, startTime, user, context, null, "", 0,
@@ -168,4 +188,11 @@ public abstract class ApplicationStateData {
public abstract CallerContext getCallerContext();
public abstract void setCallerContext(CallerContext callerContext);
+
+ @Public
+ public abstract Map<ApplicationTimeoutType, Long> getApplicationTimeouts();
+
+ @Public
+ public abstract void setApplicationTimeouts(
+ Map<ApplicationTimeoutType, Long> applicationTimeouts);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/records/impl/pb/ApplicationStateDataPBImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/records/impl/pb/ApplicationStateDataPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/records/impl/pb/ApplicationStateDataPBImpl.java
index 15ed770..d037e68 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/records/impl/pb/ApplicationStateDataPBImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/records/impl/pb/ApplicationStateDataPBImpl.java
@@ -18,10 +18,18 @@
package org.apache.hadoop.yarn.server.resourcemanager.recovery.records.impl.pb;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
import org.apache.hadoop.ipc.CallerContext;
import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationSubmissionContextPBImpl;
+import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationTimeoutMapProto;
import org.apache.hadoop.yarn.proto.YarnServerResourceManagerRecoveryProtos.ApplicationStateDataProto;
import org.apache.hadoop.yarn.proto.YarnServerResourceManagerRecoveryProtos.ApplicationStateDataProtoOrBuilder;
import org.apache.hadoop.yarn.proto.YarnServerResourceManagerRecoveryProtos.RMAppStateProto;
@@ -38,6 +46,7 @@ public class ApplicationStateDataPBImpl extends ApplicationStateData {
boolean viaProto = false;
private ApplicationSubmissionContext applicationSubmissionContext = null;
+ private Map<ApplicationTimeoutType, Long> applicationTimeouts = null;
public ApplicationStateDataPBImpl() {
builder = ApplicationStateDataProto.newBuilder();
@@ -63,6 +72,10 @@ public class ApplicationStateDataPBImpl extends ApplicationStateData {
((ApplicationSubmissionContextPBImpl)applicationSubmissionContext)
.getProto());
}
+
+ if (this.applicationTimeouts != null) {
+ addApplicationTimeouts();
+ }
}
private void mergeLocalToProto() {
@@ -256,4 +269,77 @@ public class ApplicationStateDataPBImpl extends ApplicationStateData {
public static RMAppState convertFromProtoFormat(RMAppStateProto e) {
return RMAppState.valueOf(e.name().replace(RM_APP_PREFIX, ""));
}
+
+ @Override
+ public Map<ApplicationTimeoutType, Long> getApplicationTimeouts() {
+ initApplicationTimeout();
+ return this.applicationTimeouts;
+ }
+
+ private void initApplicationTimeout() {
+ if (this.applicationTimeouts != null) {
+ return;
+ }
+ ApplicationStateDataProtoOrBuilder p = viaProto ? proto : builder;
+ List<ApplicationTimeoutMapProto> lists = p.getApplicationTimeoutsList();
+ this.applicationTimeouts =
+ new HashMap<ApplicationTimeoutType, Long>(lists.size());
+ for (ApplicationTimeoutMapProto timeoutProto : lists) {
+ this.applicationTimeouts.put(
+ ProtoUtils
+ .convertFromProtoFormat(timeoutProto.getApplicationTimeoutType()),
+ timeoutProto.getTimeout());
+ }
+ }
+
+ @Override
+ public void setApplicationTimeouts(
+ Map<ApplicationTimeoutType, Long> appTimeouts) {
+ if (appTimeouts == null) {
+ return;
+ }
+ initApplicationTimeout();
+ this.applicationTimeouts.clear();
+ this.applicationTimeouts.putAll(appTimeouts);
+ }
+
+ private void addApplicationTimeouts() {
+ maybeInitBuilder();
+ builder.clearApplicationTimeouts();
+ if (applicationTimeouts == null) {
+ return;
+ }
+ Iterable<? extends ApplicationTimeoutMapProto> values =
+ new Iterable<ApplicationTimeoutMapProto>() {
+
+ @Override
+ public Iterator<ApplicationTimeoutMapProto> iterator() {
+ return new Iterator<ApplicationTimeoutMapProto>() {
+ private Iterator<ApplicationTimeoutType> iterator =
+ applicationTimeouts.keySet().iterator();
+
+ @Override
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ @Override
+ public ApplicationTimeoutMapProto next() {
+ ApplicationTimeoutType key = iterator.next();
+ return ApplicationTimeoutMapProto.newBuilder()
+ .setTimeout(applicationTimeouts.get(key))
+ .setApplicationTimeoutType(
+ ProtoUtils.convertToProtoFormat(key))
+ .build();
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+ };
+ this.builder.addAllApplicationTimeouts(values);
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMApp.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMApp.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMApp.java
index 98cbd92..cd08743 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMApp.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMApp.java
@@ -28,6 +28,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.LogAggregationStatus;
import org.apache.hadoop.yarn.api.records.NodeId;
@@ -280,4 +281,6 @@ public interface RMApp extends EventHandler<RMAppEvent> {
String getAppNodeLabelExpression();
CallerContext getCallerContext();
+
+ Map<ApplicationTimeoutType, Long> getApplicationTimeouts();
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMAppImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMAppImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMAppImpl.java
index 0fdc311..74e641d 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMAppImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMAppImpl.java
@@ -121,6 +121,9 @@ public class RMAppImpl implements RMApp, Recoverable {
private static final Log LOG = LogFactory.getLog(RMAppImpl.class);
private static final String UNAVAILABLE = "N/A";
+ private static final EnumSet<RMAppState> COMPLETED_APP_STATES =
+ EnumSet.of(RMAppState.FINISHED, RMAppState.FINISHING, RMAppState.FAILED,
+ RMAppState.KILLED, RMAppState.FINAL_SAVING, RMAppState.KILLING);
// Immutable fields
private final ApplicationId applicationId;
@@ -179,6 +182,8 @@ public class RMAppImpl implements RMApp, Recoverable {
private Map<NodeId, List<String>> logAggregationFailureMessagesForNMs =
new HashMap<NodeId, List<String>>();
private final int maxLogAggregationDiagnosticsInMemory;
+ private Map<ApplicationTimeoutType, Long> applicationTimeouts =
+ new HashMap<ApplicationTimeoutType, Long>();
// These states stored are only valid when app is at killing or final_saving.
private RMAppState stateBeforeKilling;
@@ -897,6 +902,7 @@ public class RMAppImpl implements RMApp, Recoverable {
this.storedFinishTime = appState.getFinishTime();
this.startTime = appState.getStartTime();
this.callerContext = appState.getCallerContext();
+ this.applicationTimeouts = appState.getApplicationTimeouts();
// If interval > 0, some attempts might have been deleted.
if (this.attemptFailuresValidityInterval > 0) {
this.firstAttemptIdInStateStore = appState.getFirstAttemptId();
@@ -1109,17 +1115,16 @@ public class RMAppImpl implements RMApp, Recoverable {
}
}
- long applicationLifetime =
- app.getApplicationLifetime(ApplicationTimeoutType.LIFETIME);
- if (applicationLifetime > 0) {
+ for (Map.Entry<ApplicationTimeoutType, Long> timeout :
+ app.applicationTimeouts.entrySet()) {
app.rmContext.getRMAppLifetimeMonitor().registerApp(app.applicationId,
- ApplicationTimeoutType.LIFETIME, app.submitTime,
- applicationLifetime * 1000);
+ timeout.getKey(), timeout.getValue());
if (LOG.isDebugEnabled()) {
+ long remainingTime = timeout.getValue() - app.systemClock.getTime();
LOG.debug("Application " + app.applicationId
- + " is registered for timeout monitor, type="
- + ApplicationTimeoutType.LIFETIME + " value="
- + applicationLifetime + " seconds");
+ + " is registered for timeout monitor, type=" + timeout.getKey()
+ + " remaining timeout="
+ + (remainingTime > 0 ? remainingTime / 1000 : 0) + " seconds");
}
}
@@ -1235,10 +1240,17 @@ public class RMAppImpl implements RMApp, Recoverable {
long applicationLifetime =
app.getApplicationLifetime(ApplicationTimeoutType.LIFETIME);
if (applicationLifetime > 0) {
+ // calculate next timeout value
+ Long newTimeout =
+ Long.valueOf(app.submitTime + (applicationLifetime * 1000));
app.rmContext.getRMAppLifetimeMonitor().registerApp(app.applicationId,
- ApplicationTimeoutType.LIFETIME, app.submitTime,
- applicationLifetime * 1000);
- LOG.debug("Application " + app.applicationId
+ ApplicationTimeoutType.LIFETIME, newTimeout);
+
+ // update applicationTimeouts with new absolute value.
+ app.applicationTimeouts.put(ApplicationTimeoutType.LIFETIME,
+ newTimeout);
+
+ LOG.info("Application " + app.applicationId
+ " is registered for timeout monitor, type="
+ ApplicationTimeoutType.LIFETIME + " value=" + applicationLifetime
+ " seconds");
@@ -1292,6 +1304,7 @@ public class RMAppImpl implements RMApp, Recoverable {
ApplicationStateData.newInstance(this.submitTime, this.startTime,
this.user, this.submissionContext,
stateToBeStored, diags, this.storedFinishTime, this.callerContext);
+ appState.setApplicationTimeouts(this.applicationTimeouts);
this.rmContext.getStateStore().updateApplicationState(appState);
}
@@ -1967,4 +1980,31 @@ public class RMAppImpl implements RMApp, Recoverable {
}
return applicationLifetime;
}
-}
+
+ @Override
+ public Map<ApplicationTimeoutType, Long> getApplicationTimeouts() {
+ this.readLock.lock();
+ try {
+ return new HashMap(this.applicationTimeouts);
+ } finally {
+ this.readLock.unlock();
+ }
+ }
+
+ public void updateApplicationTimeout(
+ Map<ApplicationTimeoutType, Long> updateTimeout) {
+ this.writeLock.lock();
+ try {
+ if (COMPLETED_APP_STATES.contains(getState())) {
+ return;
+ }
+ // update monitoring service
+ this.rmContext.getRMAppLifetimeMonitor()
+ .updateApplicationTimeouts(getApplicationId(), updateTimeout);
+ this.applicationTimeouts.putAll(updateTimeout);
+
+ } finally {
+ this.writeLock.unlock();
+ }
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[17/50] [abbrv] hadoop git commit: HDFS-11114. Support for running
async disk checks in DataNode.
Posted by ka...@apache.org.
HDFS-11114. Support for running async disk checks in DataNode.
This closes #153.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3fff1585
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3fff1585
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3fff1585
Branch: refs/heads/YARN-4752
Commit: 3fff1585875ad322ce6e8acb485275e6a4360823
Parents: 3dbad5d
Author: Arpit Agarwal <ar...@apache.org>
Authored: Mon Nov 7 18:45:53 2016 -0800
Committer: Arpit Agarwal <ar...@apache.org>
Committed: Mon Nov 7 18:45:53 2016 -0800
----------------------------------------------------------------------
.../server/datanode/checker/AsyncChecker.java | 63 +++++
.../hdfs/server/datanode/checker/Checkable.java | 49 ++++
.../datanode/checker/ThrottledAsyncChecker.java | 224 +++++++++++++++
.../server/datanode/checker/package-info.java | 26 ++
.../checker/TestThrottledAsyncChecker.java | 276 +++++++++++++++++++
5 files changed, 638 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3fff1585/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/AsyncChecker.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/AsyncChecker.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/AsyncChecker.java
new file mode 100644
index 0000000..1d534a3
--- /dev/null
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/AsyncChecker.java
@@ -0,0 +1,63 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.hdfs.server.datanode.checker;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A class that can be used to schedule an asynchronous check on a given
+ * {@link Checkable}. If the check is successfully scheduled then a
+ * {@link ListenableFuture} is returned.
+ *
+ */
+@InterfaceAudience.Private
+@InterfaceStability.Unstable
+public interface AsyncChecker<K, V> {
+
+ /**
+ * Schedule an asynchronous check for the given object.
+ *
+ * @param target object to be checked.
+ *
+ * @param context the interpretation of the context depends on the
+ * target.
+ *
+ * @return returns a {@link ListenableFuture} that can be used to
+ * retrieve the result of the asynchronous check.
+ */
+ ListenableFuture<V> schedule(Checkable<K, V> target, K context);
+
+ /**
+ * Cancel all executing checks and wait for them to complete.
+ * First attempts a graceful cancellation, then cancels forcefully.
+ * Waits for the supplied timeout after both attempts.
+ *
+ * See {@link ExecutorService#awaitTermination} for a description of
+ * the parameters.
+ *
+ * @throws InterruptedException
+ */
+ void shutdownAndWait(long timeout, TimeUnit timeUnit)
+ throws InterruptedException;
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3fff1585/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/Checkable.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/Checkable.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/Checkable.java
new file mode 100644
index 0000000..833ebda
--- /dev/null
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/Checkable.java
@@ -0,0 +1,49 @@
+/**
+ * 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.hdfs.server.datanode.checker;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+
+
+/**
+ * A Checkable is an object whose health can be probed by invoking its
+ * {@link #check} method.
+ *
+ * e.g. a {@link Checkable} instance may represent a single hardware
+ * resource.
+ */
+@InterfaceAudience.Private
+@InterfaceStability.Unstable
+public interface Checkable<K, V> {
+
+ /**
+ * Query the health of this object. This method may hang
+ * indefinitely depending on the status of the target resource.
+ *
+ * @param context for the probe operation. May be null depending
+ * on the implementation.
+ *
+ * @return result of the check operation.
+ *
+ * @throws Exception encountered during the check operation. An
+ * exception indicates that the check failed.
+ */
+ V check(K context) throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3fff1585/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/ThrottledAsyncChecker.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/ThrottledAsyncChecker.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/ThrottledAsyncChecker.java
new file mode 100644
index 0000000..d0ee3d2
--- /dev/null
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/ThrottledAsyncChecker.java
@@ -0,0 +1,224 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.hdfs.server.datanode.checker;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.util.Timer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * An implementation of {@link AsyncChecker} that skips checking recently
+ * checked objects. It will enforce at least {@link minMsBetweenChecks}
+ * milliseconds between two successive checks of any one object.
+ *
+ * It is assumed that the total number of Checkable objects in the system
+ * is small, (not more than a few dozen) since the checker uses O(Checkables)
+ * storage and also potentially O(Checkables) threads.
+ *
+ * {@link minMsBetweenChecks} should be configured reasonably
+ * by the caller to avoid spinning up too many threads frequently.
+ */
+@InterfaceAudience.Private
+@InterfaceStability.Unstable
+public class ThrottledAsyncChecker<K, V> implements AsyncChecker<K, V> {
+ public static final Logger LOG =
+ LoggerFactory.getLogger(ThrottledAsyncChecker.class);
+
+ private final Timer timer;
+
+ /**
+ * The ExecutorService used to schedule asynchronous checks.
+ */
+ private final ListeningExecutorService executorService;
+
+ /**
+ * The minimum gap in milliseconds between two successive checks
+ * of the same object. This is the throttle.
+ */
+ private final long minMsBetweenChecks;
+
+ /**
+ * Map of checks that are currently in progress. Protected by the object
+ * lock.
+ */
+ private final Map<Checkable, ListenableFuture<V>> checksInProgress;
+
+ /**
+ * Maps Checkable objects to a future that can be used to retrieve
+ * the results of the operation.
+ * Protected by the object lock.
+ */
+ private final Map<Checkable, LastCheckResult<V>> completedChecks;
+
+ ThrottledAsyncChecker(final Timer timer,
+ final long minMsBetweenChecks,
+ final ExecutorService executorService) {
+ this.timer = timer;
+ this.minMsBetweenChecks = minMsBetweenChecks;
+ this.executorService = MoreExecutors.listeningDecorator(executorService);
+ this.checksInProgress = new HashMap<>();
+ this.completedChecks = new WeakHashMap<>();
+ }
+
+ /**
+ * See {@link AsyncChecker#schedule}
+ *
+ * If the object has been checked recently then the check will
+ * be skipped. Multiple concurrent checks for the same object
+ * will receive the same Future.
+ */
+ @Override
+ public synchronized ListenableFuture<V> schedule(
+ final Checkable<K, V> target,
+ final K context) {
+ LOG.debug("Scheduling a check of {}", target);
+
+ if (checksInProgress.containsKey(target)) {
+ return checksInProgress.get(target);
+ }
+
+ if (completedChecks.containsKey(target)) {
+ final LastCheckResult<V> result = completedChecks.get(target);
+ final long msSinceLastCheck = timer.monotonicNow() - result.completedAt;
+ if (msSinceLastCheck < minMsBetweenChecks) {
+ LOG.debug("Skipped checking {}. Time since last check {}ms " +
+ "is less than the min gap {}ms.",
+ target, msSinceLastCheck, minMsBetweenChecks);
+ return result.result != null ?
+ Futures.immediateFuture(result.result) :
+ Futures.immediateFailedFuture(result.exception);
+ }
+ }
+
+ final ListenableFuture<V> lf = executorService.submit(
+ new Callable<V>() {
+ @Override
+ public V call() throws Exception {
+ return target.check(context);
+ }
+ });
+ checksInProgress.put(target, lf);
+ addResultCachingCallback(target, lf);
+ return lf;
+ }
+
+ /**
+ * Register a callback to cache the result of a check.
+ * @param target
+ * @param lf
+ */
+ private void addResultCachingCallback(
+ Checkable<K, V> target, ListenableFuture<V> lf) {
+ Futures.addCallback(lf, new FutureCallback<V>() {
+ @Override
+ public void onSuccess(@Nullable V result) {
+ synchronized (ThrottledAsyncChecker.this) {
+ checksInProgress.remove(target);
+ completedChecks.put(target, new LastCheckResult<>(
+ result, timer.monotonicNow()));
+ }
+ }
+
+ @Override
+ public void onFailure(@Nonnull Throwable t) {
+ synchronized (ThrottledAsyncChecker.this) {
+ checksInProgress.remove(target);
+ completedChecks.put(target, new LastCheckResult<>(
+ t, timer.monotonicNow()));
+ }
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void shutdownAndWait(long timeout, TimeUnit timeUnit)
+ throws InterruptedException {
+ // Try orderly shutdown.
+ executorService.shutdown();
+
+ if (!executorService.awaitTermination(timeout, timeUnit)) {
+ // Interrupt executing tasks and wait again.
+ executorService.shutdownNow();
+ executorService.awaitTermination(timeout, timeUnit);
+ }
+ }
+
+ /**
+ * Status of running a check. It can either be a result or an
+ * exception, depending on whether the check completed or threw.
+ */
+ private static final class LastCheckResult<V> {
+ /**
+ * Timestamp at which the check completed.
+ */
+ private final long completedAt;
+
+ /**
+ * Result of running the check if it completed. null if it threw.
+ */
+ @Nullable
+ private final V result;
+
+ /**
+ * Exception thrown by the check. null if it returned a result.
+ */
+ private final Throwable exception; // null on success.
+
+ /**
+ * Initialize with a result.
+ * @param result
+ */
+ private LastCheckResult(V result, long completedAt) {
+ this.result = result;
+ this.exception = null;
+ this.completedAt = completedAt;
+ }
+
+ /**
+ * Initialize with an exception.
+ * @param completedAt
+ * @param t
+ */
+ private LastCheckResult(Throwable t, long completedAt) {
+ this.result = null;
+ this.exception = t;
+ this.completedAt = completedAt;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3fff1585/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/package-info.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/package-info.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/package-info.java
new file mode 100644
index 0000000..52822e9
--- /dev/null
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+/**
+ * Datanode support for running disk checks.
+ */
+@InterfaceAudience.LimitedPrivate({"HDFS"})
+@InterfaceStability.Evolving
+package org.apache.hadoop.hdfs.server.datanode.checker;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3fff1585/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestThrottledAsyncChecker.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestThrottledAsyncChecker.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestThrottledAsyncChecker.java
new file mode 100644
index 0000000..70795ca
--- /dev/null
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestThrottledAsyncChecker.java
@@ -0,0 +1,276 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.hdfs.server.datanode.checker;
+
+import com.google.common.base.Supplier;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.hadoop.test.GenericTestUtils;
+import org.apache.hadoop.util.FakeTimer;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nonnull;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.core.Is.isA;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Verify functionality of {@link ThrottledAsyncChecker}.
+ */
+public class TestThrottledAsyncChecker {
+ public static final Logger LOG =
+ LoggerFactory.getLogger(TestThrottledAsyncChecker.class);
+ private static final long MIN_ERROR_CHECK_GAP = 1000;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * Test various scheduling combinations to ensure scheduling and
+ * throttling behave as expected.
+ */
+ @Test(timeout=60000)
+ public void testScheduler() throws Exception {
+ final NoOpCheckable target1 = new NoOpCheckable();
+ final NoOpCheckable target2 = new NoOpCheckable();
+ final FakeTimer timer = new FakeTimer();
+ ThrottledAsyncChecker<Boolean, Boolean> checker =
+ new ThrottledAsyncChecker<>(timer, MIN_ERROR_CHECK_GAP,
+ getExecutorService());
+
+ // check target1 and ensure we get back the expected result.
+ assertTrue(checker.schedule(target1, true).get());
+ assertThat(target1.numChecks.get(), is(1L));
+
+ // Check target1 again without advancing the timer. target1 should not
+ // be checked again and the cached result should be returned.
+ assertTrue(checker.schedule(target1, true).get());
+ assertThat(target1.numChecks.get(), is(1L));
+
+ // Schedule target2 scheduled without advancing the timer.
+ // target2 should be checked as it has never been checked before.
+ assertTrue(checker.schedule(target2, true).get());
+ assertThat(target2.numChecks.get(), is(1L));
+
+ // Advance the timer but just short of the min gap.
+ // Neither target1 nor target2 should be checked again.
+ timer.advance(MIN_ERROR_CHECK_GAP - 1);
+ assertTrue(checker.schedule(target1, true).get());
+ assertThat(target1.numChecks.get(), is(1L));
+ assertTrue(checker.schedule(target2, true).get());
+ assertThat(target2.numChecks.get(), is(1L));
+
+ // Advance the timer again.
+ // Both targets should be checked now.
+ timer.advance(MIN_ERROR_CHECK_GAP);
+ assertTrue(checker.schedule(target1, true).get());
+ assertThat(target1.numChecks.get(), is(2L));
+ assertTrue(checker.schedule(target2, true).get());
+ assertThat(target1.numChecks.get(), is(2L));
+ }
+
+ @Test (timeout=60000)
+ public void testCancellation() throws Exception {
+ LatchedCheckable target = new LatchedCheckable();
+ final FakeTimer timer = new FakeTimer();
+ final LatchedCallback callback = new LatchedCallback(target);
+ ThrottledAsyncChecker<Boolean, Boolean> checker =
+ new ThrottledAsyncChecker<>(timer, MIN_ERROR_CHECK_GAP,
+ getExecutorService());
+
+ ListenableFuture<Boolean> lf = checker.schedule(target, true);
+ Futures.addCallback(lf, callback);
+
+ // Request immediate cancellation.
+ checker.shutdownAndWait(0, TimeUnit.MILLISECONDS);
+ try {
+ assertFalse(lf.get());
+ fail("Failed to get expected InterruptedException");
+ } catch (ExecutionException ee) {
+ assertTrue(ee.getCause() instanceof InterruptedException);
+ }
+ callback.failureLatch.await();
+ }
+
+ @Test (timeout=60000)
+ public void testConcurrentChecks() throws Exception {
+ LatchedCheckable target = new LatchedCheckable();
+ final FakeTimer timer = new FakeTimer();
+ ThrottledAsyncChecker<Boolean, Boolean> checker =
+ new ThrottledAsyncChecker<>(timer, MIN_ERROR_CHECK_GAP,
+ getExecutorService());
+ final ListenableFuture<Boolean> lf1 = checker.schedule(target, true);
+ final ListenableFuture<Boolean> lf2 = checker.schedule(target, true);
+
+ // Ensure that concurrent requests return the same future object.
+ assertTrue(lf1 == lf2);
+
+ // Unblock the latch and wait for it to finish execution.
+ target.latch.countDown();
+ lf1.get();
+
+ GenericTestUtils.waitFor(new Supplier<Boolean>() {
+ @Override
+ public Boolean get() {
+ // We should not get back the same future as before.
+ // This can take a short while until the internal callback in
+ // ThrottledAsyncChecker is scheduled for execution.
+ // Also this should not trigger a new check operation as the timer
+ // was not advanced. If it does trigger a new check then the test
+ // will fail with a timeout.
+ final ListenableFuture<Boolean> lf3 = checker.schedule(target, true);
+ return lf3 != lf2;
+ }
+ }, 100, 10000);
+ }
+
+ /**
+ * Ensure that the context is passed through to the Checkable#check
+ * method.
+ * @throws Exception
+ */
+ @Test(timeout=60000)
+ public void testContextIsPassed() throws Exception {
+ final NoOpCheckable target1 = new NoOpCheckable();
+ final FakeTimer timer = new FakeTimer();
+ ThrottledAsyncChecker<Boolean, Boolean> checker =
+ new ThrottledAsyncChecker<>(timer, MIN_ERROR_CHECK_GAP,
+ getExecutorService());
+
+ assertTrue(checker.schedule(target1, true).get());
+ assertThat(target1.numChecks.get(), is(1L));
+ timer.advance(MIN_ERROR_CHECK_GAP + 1);
+ assertFalse(checker.schedule(target1, false).get());
+ assertThat(target1.numChecks.get(), is(2L));
+ }
+
+ /**
+ * Ensure that the exeption from a failed check is cached
+ * and returned without re-running the check when the minimum
+ * gap has not elapsed.
+ *
+ * @throws Exception
+ */
+ @Test(timeout=60000)
+ public void testExceptionCaching() throws Exception {
+ final ThrowingCheckable target1 = new ThrowingCheckable();
+ final FakeTimer timer = new FakeTimer();
+ ThrottledAsyncChecker<Boolean, Boolean> checker =
+ new ThrottledAsyncChecker<>(timer, MIN_ERROR_CHECK_GAP,
+ getExecutorService());
+
+ thrown.expectCause(isA(DummyException.class));
+ checker.schedule(target1, true).get();
+ assertThat(target1.numChecks.get(), is(1L));
+
+ thrown.expectCause(isA(DummyException.class));
+ checker.schedule(target1, true).get();
+ assertThat(target1.numChecks.get(), is(2L));
+ }
+
+ /**
+ * A simple ExecutorService for testing.
+ */
+ private ExecutorService getExecutorService() {
+ return new ScheduledThreadPoolExecutor(1);
+ }
+
+ /**
+ * A Checkable that just returns its input.
+ */
+ private static class NoOpCheckable
+ implements Checkable<Boolean, Boolean> {
+ private final AtomicLong numChecks = new AtomicLong(0);
+ @Override
+ public Boolean check(Boolean context) {
+ numChecks.incrementAndGet();
+ return context;
+ }
+ }
+
+ private static class ThrowingCheckable
+ implements Checkable<Boolean, Boolean> {
+ private final AtomicLong numChecks = new AtomicLong(0);
+ @Override
+ public Boolean check(Boolean context) throws DummyException {
+ numChecks.incrementAndGet();
+ throw new DummyException();
+ }
+
+ }
+
+ private static class DummyException extends Exception {
+ }
+
+ /**
+ * A checkable that hangs until signaled.
+ */
+ private static class LatchedCheckable
+ implements Checkable<Boolean, Boolean> {
+ private final CountDownLatch latch = new CountDownLatch(1);
+
+ @Override
+ public Boolean check(Boolean ignored) throws InterruptedException {
+ LOG.info("LatchedCheckable {} waiting.", this);
+ latch.await();
+ return true; // Unreachable.
+ }
+ }
+
+ /**
+ * A {@link FutureCallback} that counts its invocations.
+ */
+ private static final class LatchedCallback
+ implements FutureCallback<Boolean> {
+ private final CountDownLatch successLatch = new CountDownLatch(1);
+ private final CountDownLatch failureLatch = new CountDownLatch(1);
+ private final Checkable target;
+
+ private LatchedCallback(Checkable target) {
+ this.target = target;
+ }
+
+ @Override
+ public void onSuccess(@Nonnull Boolean result) {
+ LOG.info("onSuccess callback invoked for {}", target);
+ successLatch.countDown();
+ }
+
+ @Override
+ public void onFailure(@Nonnull Throwable t) {
+ LOG.info("onFailure callback invoked for {} with exception", target, t);
+ failureLatch.countDown();
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[03/50] [abbrv] hadoop git commit: YARN-5779. [YARN-3368] Addendum
patch to document limits/notes of the new YARN UI . (Sunil G via Sreenath
Somarajapuram)
Posted by ka...@apache.org.
YARN-5779. [YARN-3368] Addendum patch to document limits/notes of the new YARN UI . (Sunil G via Sreenath Somarajapuram)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/fad392a2
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/fad392a2
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/fad392a2
Branch: refs/heads/YARN-4752
Commit: fad392a22f1007e6b6e7f6af55051ebd912a6e4a
Parents: 64c7cda
Author: Sreenath Somarajapuram <sr...@apache.org>
Authored: Fri Oct 28 18:20:55 2016 +0530
Committer: Wangda Tan <wa...@apache.org>
Committed: Sun Nov 6 13:13:31 2016 -0800
----------------------------------------------------------------------
.../hadoop-yarn/hadoop-yarn-site/src/site/markdown/YarnUI2.md | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/fad392a2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/YarnUI2.md
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/YarnUI2.md b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/YarnUI2.md
index 9f82031..e7853bf 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/YarnUI2.md
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/YarnUI2.md
@@ -38,6 +38,9 @@ origin (CORS) support.
| `yarn.resourcemanager.webapp.cross-origin.enabled` | true | Enable CORS support for Resource Manager |
| `yarn.nodemanager.webapp.cross-origin.enabled` | true | Enable CORS support for Node Manager |
+Also please ensure that CORS related configurations are enabled in `core-site.xml`.
+Kindly refer [here](https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-common/HttpAuthentication.html)
+
Use it
-------------
Open your browser, go to `rm-address:8088/ui2` and try it!
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[10/50] [abbrv] hadoop git commit: YARN-5716. Add global scheduler
interface definition and update CapacityScheduler to use it. Contributed by
Wangda Tan
Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java
index 51b567b..8694efb 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java
@@ -41,6 +41,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CyclicBarrier;
+import com.google.common.collect.ImmutableMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.security.UserGroupInformation;
@@ -49,6 +50,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ContainerExitStatus;
import org.apache.hadoop.yarn.api.records.ContainerState;
import org.apache.hadoop.yarn.api.records.ContainerStatus;
+import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.api.records.QueueACL;
import org.apache.hadoop.yarn.api.records.QueueInfo;
@@ -78,6 +80,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerRequestK
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.preemption.PreemptionManager;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue.User;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAddedSchedulerEvent;
@@ -196,6 +199,7 @@ public class TestLeafQueue {
cs.setRMContext(spyRMContext);
cs.init(csConf);
+ cs.setResourceCalculator(rC);
cs.start();
when(spyRMContext.getScheduler()).thenReturn(cs);
@@ -268,6 +272,12 @@ public class TestLeafQueue {
any(Resource.class), any(FiCaSchedulerApp.class), any(FiCaSchedulerNode.class),
any(RMContainer.class), any(ContainerStatus.class),
any(RMContainerEventType.class), any(CSQueue.class), anyBoolean());
+
+ // Stub out parent queue's accept and apply.
+ doReturn(true).when(parent).accept(any(Resource.class),
+ any(ResourceCommitRequest.class));
+ doNothing().when(parent).apply(any(Resource.class),
+ any(ResourceCommitRequest.class));
return queue;
}
@@ -339,6 +349,12 @@ public class TestLeafQueue {
FiCaSchedulerNode node_0 = TestUtils.getMockNode(host_0, DEFAULT_RACK, 0,
8*GB);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0);
+
final int numNodes = 1;
Resource clusterResource =
Resources.createResource(numNodes * (8*GB), numNodes * 16);
@@ -353,8 +369,10 @@ public class TestLeafQueue {
// Start testing...
// Only 1 container
- a.assignContainers(clusterResource, node_0, new ResourceLimits(
- clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(
(int)(node_0.getTotalResource().getMemorySize() * a.getCapacity()) - (1*GB),
a.getMetrics().getAvailableMB());
@@ -526,6 +544,12 @@ public class TestLeafQueue {
FiCaSchedulerNode node_0 = TestUtils.getMockNode(host_0, DEFAULT_RACK, 0,
8*GB);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0);
+
final int numNodes = 1;
Resource clusterResource =
Resources.createResource(numNodes * (8*GB), numNodes * 16);
@@ -544,8 +568,10 @@ public class TestLeafQueue {
// Start testing...
// Only 1 container
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(1*GB, a.getUsedResources().getMemorySize());
assertEquals(1*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -555,8 +581,10 @@ public class TestLeafQueue {
// Also 2nd -> minCapacity = 1024 since (.1 * 8G) < minAlloc, also
// you can get one container more than user-limit
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(2*GB, a.getUsedResources().getMemorySize());
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -564,8 +592,10 @@ public class TestLeafQueue {
assertEquals(2*GB, a.getMetrics().getAllocatedMB());
// Can't allocate 3rd due to user-limit
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(2*GB, a.getUsedResources().getMemorySize());
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -574,8 +604,10 @@ public class TestLeafQueue {
// Bump up user-limit-factor, now allocate should work
a.setUserLimitFactor(10);
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(3*GB, a.getUsedResources().getMemorySize());
assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -583,8 +615,10 @@ public class TestLeafQueue {
assertEquals(3*GB, a.getMetrics().getAllocatedMB());
// One more should work, for app_1, due to user-limit-factor
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(4*GB, a.getUsedResources().getMemorySize());
assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -594,8 +628,10 @@ public class TestLeafQueue {
// Test max-capacity
// Now - no more allocs since we are at max-cap
a.setMaxCapacity(0.5f);
- a.assignContainers(clusterResource, node_0, new ResourceLimits(
- clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(4*GB, a.getUsedResources().getMemorySize());
assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -687,6 +723,13 @@ public class TestLeafQueue {
assign.getResource().getMemorySize() > 0);
}
+ private void applyCSAssignment(Resource clusterResource, CSAssignment assign,
+ LeafQueue q, final Map<NodeId, FiCaSchedulerNode> nodes,
+ final Map<ApplicationAttemptId, FiCaSchedulerApp> apps)
+ throws IOException {
+ TestUtils.applyResourceCommitRequest(clusterResource, assign, nodes, apps);
+ }
+
@Test
public void testDRFUserLimits() throws Exception {
setUpWithDominantResourceCalculator();
@@ -723,6 +766,12 @@ public class TestLeafQueue {
FiCaSchedulerNode node1 =
TestUtils.getMockNode(host1, DEFAULT_RACK, 0, 8 * GB, 100);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node0.getNodeID(),
+ node0, node1.getNodeID(), node1);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app0.getApplicationAttemptId(), app0, app2.getApplicationAttemptId(),
+ app2);
+
int numNodes = 2;
Resource clusterResource =
Resources.createResource(numNodes * (8 * GB), numNodes * 100);
@@ -758,12 +807,14 @@ public class TestLeafQueue {
b.assignContainers(clusterResource, node0, new ResourceLimits(
clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
LOG.info(assign.toString());
+ applyCSAssignment(clusterResource, assign, b, nodes, apps);
} while (assign.getResource().getMemorySize() > 0 &&
assign.getAssignmentInformation().getNumReservations() == 0);
do {
assign =
b.assignContainers(clusterResource, node1, new ResourceLimits(
clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assign, b, nodes, apps);
} while (assign.getResource().getMemorySize() > 0 &&
assign.getAssignmentInformation().getNumReservations() == 0);
//LOG.info("user_0: " + queueUser0.getUsed());
@@ -847,6 +898,12 @@ public class TestLeafQueue {
TestUtils.createResourceRequest(ResourceRequest.ANY, 1*GB, 2, true,
priority, recordFactory)));
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1);
+
/**
* Start testing...
*/
@@ -859,8 +916,10 @@ public class TestLeafQueue {
assertEquals(2, a.getActiveUsersManager().getNumActiveUsers());
// 1 container to user_0
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(3*GB, a.getUsedResources().getMemorySize());
assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -868,8 +927,10 @@ public class TestLeafQueue {
// Allocate one container to app_1. Even if app_0
// submit earlier, it cannot get this container assigned since user_0
// exceeded user-limit already.
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(4*GB, a.getUsedResources().getMemorySize());
assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -877,8 +938,10 @@ public class TestLeafQueue {
// Allocate one container to app_0, before allocating this container,
// user-limit = ceil((4 + 1) / 2) = 3G. app_0's used resource (3G) <=
// user-limit.
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(7*GB, a.getUsedResources().getMemorySize());
assertEquals(6*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -890,7 +953,7 @@ public class TestLeafQueue {
}
@Test
- public void testComputeUserLimitAndSetHeadroom(){
+ public void testComputeUserLimitAndSetHeadroom() throws IOException {
LeafQueue qb = stubLeafQueue((LeafQueue)queues.get(B));
qb.setMaxCapacity(1.0f);
// Users
@@ -903,6 +966,9 @@ public class TestLeafQueue {
String host_1 = "127.0.0.2";
FiCaSchedulerNode node_1 = TestUtils.getMockNode(host_1, DEFAULT_RACK, 0, 8*GB);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1);
+
final int numNodes = 2;
Resource clusterResource = Resources.createResource(numNodes * (8*GB), 1);
when(csContext.getNumClusterNodes()).thenReturn(numNodes);
@@ -925,6 +991,8 @@ public class TestLeafQueue {
FiCaSchedulerApp app_0 =
new FiCaSchedulerApp(appAttemptId_0, user_0, qb,
qb.getActiveUsersManager(), spyRMContext);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = new HashMap<>();
+ apps.put(app_0.getApplicationAttemptId(), app_0);
qb.submitApplicationAttempt(app_0, user_0);
Priority u0Priority = TestUtils.createMockPriority(1);
SchedulerRequestKey u0SchedKey = toSchedulerKey(u0Priority);
@@ -935,8 +1003,10 @@ public class TestLeafQueue {
assertEquals("There should only be 1 active user!",
1, qb.getActiveUsersManager().getNumActiveUsers());
//get headroom
- qb.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ qb.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), qb, nodes, apps);
qb.computeUserLimitAndSetHeadroom(app_0, clusterResource,
"", SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
@@ -949,14 +1019,17 @@ public class TestLeafQueue {
FiCaSchedulerApp app_2 =
new FiCaSchedulerApp(appAttemptId_2, user_1, qb,
qb.getActiveUsersManager(), spyRMContext);
+ apps.put(app_2.getApplicationAttemptId(), app_2);
Priority u1Priority = TestUtils.createMockPriority(2);
SchedulerRequestKey u1SchedKey = toSchedulerKey(u1Priority);
app_2.updateResourceRequests(Collections.singletonList(
TestUtils.createResourceRequest(ResourceRequest.ANY, 4*GB, 1, true,
u1Priority, recordFactory)));
qb.submitApplicationAttempt(app_2, user_1);
- qb.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ qb.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), qb, nodes, apps);
qb.computeUserLimitAndSetHeadroom(app_0, clusterResource,
"", SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
@@ -984,11 +1057,13 @@ public class TestLeafQueue {
FiCaSchedulerApp app_1 =
new FiCaSchedulerApp(appAttemptId_1, user_0, qb,
qb.getActiveUsersManager(), spyRMContext);
+ apps.put(app_1.getApplicationAttemptId(), app_1);
final ApplicationAttemptId appAttemptId_3 =
TestUtils.getMockApplicationAttemptId(3, 0);
FiCaSchedulerApp app_3 =
new FiCaSchedulerApp(appAttemptId_3, user_1, qb,
qb.getActiveUsersManager(), spyRMContext);
+ apps.put(app_3.getApplicationAttemptId(), app_3);
app_1.updateResourceRequests(Collections.singletonList(
TestUtils.createResourceRequest(ResourceRequest.ANY, 2*GB, 1, true,
u0Priority, recordFactory)));
@@ -997,10 +1072,14 @@ public class TestLeafQueue {
u1Priority, recordFactory)));
qb.submitApplicationAttempt(app_1, user_0);
qb.submitApplicationAttempt(app_3, user_1);
- qb.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
- qb.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ qb.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), qb, nodes, apps);
+ applyCSAssignment(clusterResource,
+ qb.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), qb, nodes, apps);
qb.computeUserLimitAndSetHeadroom(app_3, clusterResource,
"", SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
assertEquals(4*GB, qb.getUsedResources().getMemorySize());
@@ -1013,12 +1092,15 @@ public class TestLeafQueue {
FiCaSchedulerApp app_4 =
new FiCaSchedulerApp(appAttemptId_4, user_0, qb,
qb.getActiveUsersManager(), spyRMContext);
+ apps.put(app_4.getApplicationAttemptId(), app_4);
qb.submitApplicationAttempt(app_4, user_0);
app_4.updateResourceRequests(Collections.singletonList(
TestUtils.createResourceRequest(ResourceRequest.ANY, 6*GB, 1, true,
u0Priority, recordFactory)));
- qb.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ qb.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), qb, nodes, apps);
qb.computeUserLimitAndSetHeadroom(app_4, clusterResource,
"", SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
qb.computeUserLimitAndSetHeadroom(app_3, clusterResource,
@@ -1078,6 +1160,12 @@ public class TestLeafQueue {
FiCaSchedulerNode node_1 = TestUtils.getMockNode(host_1, DEFAULT_RACK,
0, 16*GB);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1, app_2.getApplicationAttemptId(), app_2);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1);
+
final int numNodes = 2;
Resource clusterResource = Resources.createResource(numNodes * (16*GB), 1);
when(csContext.getNumClusterNodes()).thenReturn(numNodes);
@@ -1088,8 +1176,10 @@ public class TestLeafQueue {
TestUtils.createResourceRequest(ResourceRequest.ANY, 1*GB, 1, true,
priority, recordFactory)));
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(1*GB, a.getUsedResources().getMemorySize());
assertEquals(1*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1105,8 +1195,10 @@ public class TestLeafQueue {
TestUtils.createResourceRequest(ResourceRequest.ANY, 1*GB, 2, true,
priority, recordFactory)));
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(2*GB, a.getUsedResources().getMemorySize());
assertEquals(1*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1165,6 +1257,12 @@ public class TestLeafQueue {
FiCaSchedulerNode node_0 = TestUtils.getMockNode(host_0, DEFAULT_RACK, 0, 8*GB);
String host_1 = "127.0.0.2";
FiCaSchedulerNode node_1 = TestUtils.getMockNode(host_1, DEFAULT_RACK, 0, 8*GB);
+
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1, app_2.getApplicationAttemptId(), app_2);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1);
final int numNodes = 2;
Resource clusterResource = Resources.createResource(numNodes * (8*GB), 1);
@@ -1194,8 +1292,10 @@ public class TestLeafQueue {
1, a.getActiveUsersManager().getNumActiveUsers());
// 1 container to user_0
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(2*GB, a.getUsedResources().getMemorySize());
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1206,8 +1306,10 @@ public class TestLeafQueue {
// the application is not yet active
// Again one to user_0 since he hasn't exceeded user limit yet
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(3*GB, a.getUsedResources().getMemorySize());
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1223,8 +1325,10 @@ public class TestLeafQueue {
// No more to user_0 since he is already over user-limit
// and no more containers to queue since it's already at max-cap
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(3*GB, a.getUsedResources().getMemorySize());
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1237,8 +1341,10 @@ public class TestLeafQueue {
TestUtils.createResourceRequest(ResourceRequest.ANY, 1*GB, 0, true,
priority, recordFactory)));
assertEquals(1, a.getActiveUsersManager().getNumActiveUsers());
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(0*GB, app_2.getHeadroom().getMemorySize()); // hit queue max-cap
}
@@ -1283,10 +1389,17 @@ public class TestLeafQueue {
new FiCaSchedulerApp(appAttemptId_3, user_2, a,
a.getActiveUsersManager(), spyRMContext);
a.submitApplicationAttempt(app_3, user_2);
+
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1, app_2.getApplicationAttemptId(), app_2,
+ app_3.getApplicationAttemptId(), app_3);
// Setup some nodes
String host_0 = "127.0.0.1";
FiCaSchedulerNode node_0 = TestUtils.getMockNode(host_0, DEFAULT_RACK, 0, 8*GB);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0);
final int numNodes = 1;
Resource clusterResource =
@@ -1308,24 +1421,30 @@ public class TestLeafQueue {
*/
// Only 1 container
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(1*GB, a.getUsedResources().getMemorySize());
assertEquals(1*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
// Also 2nd -> minCapacity = 1024 since (.1 * 8G) < minAlloc, also
// you can get one container more than user-limit
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(2*GB, a.getUsedResources().getMemorySize());
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
// Can't allocate 3rd due to user-limit
a.setUserLimit(25);
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(2*GB, a.getUsedResources().getMemorySize());
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1343,8 +1462,10 @@ public class TestLeafQueue {
// Now allocations should goto app_2 since
// user_0 is at limit inspite of high user-limit-factor
a.setUserLimitFactor(10);
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(5*GB, a.getUsedResources().getMemorySize());
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1353,8 +1474,10 @@ public class TestLeafQueue {
// Now allocations should goto app_0 since
// user_0 is at user-limit not above it
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(6*GB, a.getUsedResources().getMemorySize());
assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1364,8 +1487,10 @@ public class TestLeafQueue {
// Test max-capacity
// Now - no more allocs since we are at max-cap
a.setMaxCapacity(0.5f);
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(6*GB, a.getUsedResources().getMemorySize());
assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1376,8 +1501,10 @@ public class TestLeafQueue {
// Now, allocations should goto app_3 since it's under user-limit
a.setMaxCapacity(1.0f);
a.setUserLimitFactor(1);
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(7*GB, a.getUsedResources().getMemorySize());
assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1385,8 +1512,10 @@ public class TestLeafQueue {
assertEquals(1*GB, app_3.getCurrentConsumption().getMemorySize());
// Now we should assign to app_3 again since user_2 is under user-limit
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(8*GB, a.getUsedResources().getMemorySize());
assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1466,6 +1595,12 @@ public class TestLeafQueue {
// Setup some nodes
String host_0 = "127.0.0.1";
FiCaSchedulerNode node_0 = TestUtils.getMockNode(host_0, DEFAULT_RACK, 0, 4*GB);
+
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0);
final int numNodes = 2;
Resource clusterResource =
@@ -1485,8 +1620,10 @@ public class TestLeafQueue {
// Start testing...
// Only 1 container
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(1*GB, a.getUsedResources().getMemorySize());
assertEquals(1*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1496,8 +1633,10 @@ public class TestLeafQueue {
// Also 2nd -> minCapacity = 1024 since (.1 * 8G) < minAlloc, also
// you can get one container more than user-limit
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(2*GB, a.getUsedResources().getMemorySize());
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1505,8 +1644,10 @@ public class TestLeafQueue {
assertEquals(2*GB, a.getMetrics().getAllocatedMB());
// Now, reservation should kick in for app_1
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(6*GB, a.getUsedResources().getMemorySize());
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1522,8 +1663,10 @@ public class TestLeafQueue {
ContainerState.COMPLETE, "",
ContainerExitStatus.KILLED_BY_RESOURCEMANAGER),
RMContainerEventType.KILL, null, true);
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(5*GB, a.getUsedResources().getMemorySize());
assertEquals(1*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1539,8 +1682,10 @@ public class TestLeafQueue {
ContainerState.COMPLETE, "",
ContainerExitStatus.KILLED_BY_RESOURCEMANAGER),
RMContainerEventType.KILL, null, true);
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(4*GB, a.getUsedResources().getMemorySize());
assertEquals(0*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(4*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1587,6 +1732,12 @@ public class TestLeafQueue {
when(csContext.getNode(node_0.getNodeID())).thenReturn(node_0);
when(csContext.getNode(node_1.getNodeID())).thenReturn(node_1);
+
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1);
final int numNodes = 3;
Resource clusterResource =
@@ -1613,23 +1764,29 @@ public class TestLeafQueue {
// Start testing...
// Only 1 container
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(1*GB, a.getUsedResources().getMemorySize());
assertEquals(1*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
// Also 2nd -> minCapacity = 1024 since (.1 * 8G) < minAlloc, also
// you can get one container more than user-limit
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(2*GB, a.getUsedResources().getMemorySize());
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
// Now, reservation should kick in for app_1
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(6*GB, a.getUsedResources().getMemorySize());
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1643,8 +1800,10 @@ public class TestLeafQueue {
ContainerState.COMPLETE, "",
ContainerExitStatus.KILLED_BY_RESOURCEMANAGER),
RMContainerEventType.KILL, null, true);
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(5*GB, a.getUsedResources().getMemorySize());
assertEquals(1*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1653,8 +1812,10 @@ public class TestLeafQueue {
assertEquals(1, app_1.getReReservations(toSchedulerKey(priority)));
// Re-reserve
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(5*GB, a.getUsedResources().getMemorySize());
assertEquals(1*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1663,8 +1824,10 @@ public class TestLeafQueue {
assertEquals(2, app_1.getReReservations(toSchedulerKey(priority)));
// Try to schedule on node_1 now, should *move* the reservation
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(9*GB, a.getUsedResources().getMemorySize());
assertEquals(1*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(4*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1681,8 +1844,10 @@ public class TestLeafQueue {
ContainerState.COMPLETE, "",
ContainerExitStatus.KILLED_BY_RESOURCEMANAGER),
RMContainerEventType.KILL, null, true);
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
assertEquals(4*GB, a.getUsedResources().getMemorySize());
assertEquals(0*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(4*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -1735,6 +1900,15 @@ public class TestLeafQueue {
String rack_2 = "rack_2";
FiCaSchedulerNode node_2 = TestUtils.getMockNode(host_2, rack_2, 0, 8*GB);
+ String host_3 = "127.0.0.4"; // on rack_1
+ FiCaSchedulerNode node_3 = TestUtils.getMockNode(host_3, rack_1, 0, 8*GB);
+
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1, node_2.getNodeID(), node_2,
+ node_3.getNodeID(), node_3);
+
final int numNodes = 3;
Resource clusterResource =
Resources.createResource(numNodes * (8*GB), numNodes * 16);
@@ -1767,6 +1941,7 @@ public class TestLeafQueue {
// Start with off switch, shouldn't allocate due to delay scheduling
assignment = a.assignContainers(clusterResource, node_2,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
assertEquals(1, app_0.getSchedulingOpportunities(schedulerKey));
assertEquals(3, app_0.getTotalRequiredResources(schedulerKey));
@@ -1775,6 +1950,7 @@ public class TestLeafQueue {
// Another off switch, shouldn't allocate due to delay scheduling
assignment = a.assignContainers(clusterResource, node_2,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
assertEquals(2, app_0.getSchedulingOpportunities(schedulerKey));
assertEquals(3, app_0.getTotalRequiredResources(schedulerKey));
@@ -1783,6 +1959,7 @@ public class TestLeafQueue {
// Another off switch, shouldn't allocate due to delay scheduling
assignment = a.assignContainers(clusterResource, node_2,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
assertEquals(3, app_0.getSchedulingOpportunities(schedulerKey));
assertEquals(3, app_0.getTotalRequiredResources(schedulerKey));
@@ -1792,6 +1969,7 @@ public class TestLeafQueue {
// since missedOpportunities=3 and reqdContainers=3
assignment = a.assignContainers(clusterResource, node_2,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.OFF_SWITCH);
// should NOT reset
assertEquals(4, app_0.getSchedulingOpportunities(schedulerKey));
@@ -1800,6 +1978,7 @@ public class TestLeafQueue {
// NODE_LOCAL - node_0
assignment = a.assignContainers(clusterResource, node_0,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.NODE_LOCAL);
// should reset
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey));
@@ -1808,6 +1987,7 @@ public class TestLeafQueue {
// NODE_LOCAL - node_1
assignment = a.assignContainers(clusterResource, node_1,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.NODE_LOCAL);
// should reset
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey));
@@ -1828,9 +2008,6 @@ public class TestLeafQueue {
app_0.updateResourceRequests(app_0_requests_0);
assertEquals(4, app_0.getTotalRequiredResources(schedulerKey));
- String host_3 = "127.0.0.4"; // on rack_1
- FiCaSchedulerNode node_3 = TestUtils.getMockNode(host_3, rack_1, 0, 8*GB);
-
// Rack-delay
doReturn(true).when(a).getRackLocalityFullReset();
doReturn(1).when(a).getNodeLocalityDelay();
@@ -1838,12 +2015,14 @@ public class TestLeafQueue {
// Shouldn't assign RACK_LOCAL yet
assignment = a.assignContainers(clusterResource, node_3,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
assertEquals(1, app_0.getSchedulingOpportunities(schedulerKey));
assertEquals(4, app_0.getTotalRequiredResources(schedulerKey));
// Should assign RACK_LOCAL now
assignment = a.assignContainers(clusterResource, node_3,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.RACK_LOCAL);
// should reset
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey));
@@ -1852,6 +2031,7 @@ public class TestLeafQueue {
// Shouldn't assign RACK_LOCAL because schedulingOpportunities should have gotten reset.
assignment = a.assignContainers(clusterResource, node_3,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
assertEquals(1, app_0.getSchedulingOpportunities(schedulerKey));
assertEquals(3, app_0.getTotalRequiredResources(schedulerKey));
@@ -1861,6 +2041,7 @@ public class TestLeafQueue {
// Should assign RACK_LOCAL now
assignment = a.assignContainers(clusterResource, node_3,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.RACK_LOCAL);
// should NOT reset
assertEquals(2, app_0.getSchedulingOpportunities(schedulerKey));
@@ -1869,6 +2050,7 @@ public class TestLeafQueue {
// Another RACK_LOCAL since schedulingOpportunities not reset
assignment = a.assignContainers(clusterResource, node_3,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.RACK_LOCAL);
// should NOT reset
assertEquals(3, app_0.getSchedulingOpportunities(schedulerKey));
@@ -1894,12 +2076,14 @@ public class TestLeafQueue {
assignment =
a.assignContainers(clusterResource, node_2, new ResourceLimits(
clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
assertEquals(i+1, app_0.getSchedulingOpportunities(schedulerKey));
}
// delay should be capped at numNodes so next one should allocate
assignment = a.assignContainers(clusterResource, node_2,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.OFF_SWITCH);
assertEquals(numNodes+1, app_0.getSchedulingOpportunities(schedulerKey));
}
@@ -1933,6 +2117,11 @@ public class TestLeafQueue {
String rack_2 = "rack_2";
FiCaSchedulerNode node_2 = TestUtils.getMockNode(host_2, rack_2, 0, 8*GB);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1, node_2.getNodeID(), node_2);
+
final int numNodes = 3;
Resource clusterResource =
Resources.createResource(numNodes * (8*GB), 1);
@@ -1981,6 +2170,7 @@ public class TestLeafQueue {
// thus, no P2 either!
CSAssignment assignment = a.assignContainers(clusterResource, node_2,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
assertEquals(1, app_0.getSchedulingOpportunities(schedulerKey1));
assertEquals(2, app_0.getTotalRequiredResources(schedulerKey1));
@@ -1991,6 +2181,7 @@ public class TestLeafQueue {
// thus, no P2 either!
assignment = a.assignContainers(clusterResource, node_2,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
assertEquals(2, app_0.getSchedulingOpportunities(schedulerKey1));
assertEquals(2, app_0.getTotalRequiredResources(schedulerKey1));
@@ -2000,6 +2191,7 @@ public class TestLeafQueue {
// Another off-switch, shouldn't allocate OFF_SWITCH P1
assignment = a.assignContainers(clusterResource, node_2,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.OFF_SWITCH);
assertEquals(3, app_0.getSchedulingOpportunities(schedulerKey1));
assertEquals(1, app_0.getTotalRequiredResources(schedulerKey1));
@@ -2009,6 +2201,7 @@ public class TestLeafQueue {
// Now, DATA_LOCAL for P1
assignment = a.assignContainers(clusterResource, node_0,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.NODE_LOCAL);
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey1));
assertEquals(0, app_0.getTotalRequiredResources(schedulerKey1));
@@ -2018,6 +2211,7 @@ public class TestLeafQueue {
// Now, OFF_SWITCH for P2
assignment = a.assignContainers(clusterResource, node_1,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.OFF_SWITCH);
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey1));
assertEquals(0, app_0.getTotalRequiredResources(schedulerKey1));
@@ -2054,6 +2248,12 @@ public class TestLeafQueue {
String host_1_0 = "127.0.0.3";
String rack_1 = "rack_1";
FiCaSchedulerNode node_1_0 = TestUtils.getMockNode(host_1_0, rack_1, 0, 8*GB);
+
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0_0.getNodeID(),
+ node_0_0, node_0_1.getNodeID(), node_0_1, node_1_0.getNodeID(),
+ node_1_0);
final int numNodes = 3;
Resource clusterResource = Resources.createResource(
@@ -2093,6 +2293,7 @@ public class TestLeafQueue {
// NODE_LOCAL - node_0_1
CSAssignment assignment = a.assignContainers(clusterResource, node_0_0,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.NODE_LOCAL);
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey));
// should reset
@@ -2102,6 +2303,7 @@ public class TestLeafQueue {
// required(ANY) == 0
assignment = a.assignContainers(clusterResource, node_1_0,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
// Still zero
// since #req=0
@@ -2119,6 +2321,7 @@ public class TestLeafQueue {
// required(rack_1) == 0
assignment = a.assignContainers(clusterResource, node_0_1,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
assertEquals(1, app_0.getSchedulingOpportunities(schedulerKey));
assertEquals(1, app_0.getTotalRequiredResources(schedulerKey));
@@ -2126,6 +2329,7 @@ public class TestLeafQueue {
// NODE_LOCAL - node_1
assignment = a.assignContainers(clusterResource, node_1_0,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.NODE_LOCAL);
// should reset
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey));
@@ -2319,18 +2523,25 @@ public class TestLeafQueue {
mock(ActiveUsersManager.class), spyRMContext);
a.submitApplicationAttempt(app_1, user_0);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+
// Setup some nodes and racks
String host_0_0 = "127.0.0.1";
String rack_0 = "rack_0";
String host_0_1 = "127.0.0.2";
FiCaSchedulerNode node_0_1 = TestUtils.getMockNode(host_0_1, rack_0, 0, 8*GB);
-
-
+
String host_1_0 = "127.0.0.3";
String rack_1 = "rack_1";
FiCaSchedulerNode node_1_0 = TestUtils.getMockNode(host_1_0, rack_1, 0, 8*GB);
String host_1_1 = "127.0.0.4";
FiCaSchedulerNode node_1_1 = TestUtils.getMockNode(host_1_1, rack_1, 0, 8*GB);
+
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0_1.getNodeID(),
+ node_0_1, node_1_0.getNodeID(), node_1_0, node_1_1.getNodeID(),
+ node_1_1);
final int numNodes = 4;
Resource clusterResource = Resources.createResource(
@@ -2380,6 +2591,7 @@ public class TestLeafQueue {
CSAssignment assignment =
a.assignContainers(clusterResource, node_0_1, new ResourceLimits(
clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
// should be 0
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey));
@@ -2403,6 +2615,7 @@ public class TestLeafQueue {
// Shouldn't allocate since RR(rack_1) = relax: false
assignment = a.assignContainers(clusterResource, node_1_1,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
// should be 0
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey));
@@ -2434,6 +2647,7 @@ public class TestLeafQueue {
// Shouldn't allocate since node_1_1 is blacklisted
assignment = a.assignContainers(clusterResource, node_1_1,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
// should be 0
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey));
@@ -2461,8 +2675,10 @@ public class TestLeafQueue {
// node_1_1
// Shouldn't allocate since rack_1 is blacklisted
- assignment = a.assignContainers(clusterResource, node_1_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ assignment = a.assignContainers(clusterResource, node_1_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
// should be 0
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey));
@@ -2490,6 +2706,7 @@ public class TestLeafQueue {
// Now, should allocate since RR(rack_1) = relax: true
assignment = a.assignContainers(clusterResource, node_1_1,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyNoContainerAllocated(assignment);
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey));
assertEquals(1, app_0.getTotalRequiredResources(schedulerKey));
@@ -2520,6 +2737,7 @@ public class TestLeafQueue {
assignment = a.assignContainers(clusterResource, node_1_0,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.NODE_LOCAL);
assertEquals(0, app_0.getSchedulingOpportunities(schedulerKey));
assertEquals(0, app_0.getTotalRequiredResources(schedulerKey));
@@ -2590,6 +2808,12 @@ public class TestLeafQueue {
FiCaSchedulerNode node_0 =
TestUtils.getMockNode(host_0, DEFAULT_RACK, 0, 8 * GB);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0);
+
final int numNodes = 1;
Resource clusterResource =
Resources.createResource(numNodes * (8 * GB), numNodes * 16);
@@ -2603,91 +2827,111 @@ public class TestLeafQueue {
recordFactory)));
try {
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
} catch (NullPointerException e) {
Assert.fail("NPE when allocating container on node but "
+ "forget to set off-switch request should be handled");
}
}
-
- @Test
+
+ @Test
public void testFifoAssignment() throws Exception {
- LeafQueue a = stubLeafQueue((LeafQueue)queues.get(A));
-
+ LeafQueue a = stubLeafQueue((LeafQueue) queues.get(A));
+
a.setOrderingPolicy(new FifoOrderingPolicy<FiCaSchedulerApp>());
String host_0_0 = "127.0.0.1";
String rack_0 = "rack_0";
- FiCaSchedulerNode node_0_0 = TestUtils.getMockNode(host_0_0, rack_0, 0, 16*GB);
-
+ FiCaSchedulerNode node_0_0 = TestUtils.getMockNode(host_0_0, rack_0, 0,
+ 16 * GB);
+
final int numNodes = 4;
- Resource clusterResource = Resources.createResource(
- numNodes * (16*GB), numNodes * 16);
+ Resource clusterResource = Resources.createResource(numNodes * (16 * GB),
+ numNodes * 16);
when(csContext.getNumClusterNodes()).thenReturn(numNodes);
String user_0 = "user_0";
-
- final ApplicationAttemptId appAttemptId_0 =
- TestUtils.getMockApplicationAttemptId(0, 0);
- FiCaSchedulerApp app_0 =
- spy(new FiCaSchedulerApp(appAttemptId_0, user_0, a,
- mock(ActiveUsersManager.class), spyRMContext,
- Priority.newInstance(3), false));
+
+ final ApplicationAttemptId appAttemptId_0 =
+ TestUtils.getMockApplicationAttemptId(0, 0);
+ FiCaSchedulerApp app_0 = spy(new FiCaSchedulerApp(appAttemptId_0, user_0, a,
+ mock(ActiveUsersManager.class), spyRMContext, Priority.newInstance(3),
+ false));
a.submitApplicationAttempt(app_0, user_0);
-
- final ApplicationAttemptId appAttemptId_1 =
- TestUtils.getMockApplicationAttemptId(1, 0);
- FiCaSchedulerApp app_1 =
- spy(new FiCaSchedulerApp(appAttemptId_1, user_0, a,
- mock(ActiveUsersManager.class), spyRMContext,
- Priority.newInstance(5), false));
+
+ final ApplicationAttemptId appAttemptId_1 =
+ TestUtils.getMockApplicationAttemptId(1, 0);
+ FiCaSchedulerApp app_1 = spy(new FiCaSchedulerApp(appAttemptId_1, user_0, a,
+ mock(ActiveUsersManager.class), spyRMContext, Priority.newInstance(5),
+ false));
a.submitApplicationAttempt(app_1, user_0);
-
+
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0_0.getNodeID(),
+ node_0_0);
+
Priority priority = TestUtils.createMockPriority(1);
List<ResourceRequest> app_0_requests_0 = new ArrayList<ResourceRequest>();
List<ResourceRequest> app_1_requests_0 = new ArrayList<ResourceRequest>();
-
+
app_0_requests_0.clear();
- app_0_requests_0.add(
- TestUtils.createResourceRequest(ResourceRequest.ANY, 2*GB, 1,
- true, priority, recordFactory));
+ app_0_requests_0.add(TestUtils
+ .createResourceRequest(ResourceRequest.ANY, 2 * GB, 1, true, priority,
+ recordFactory));
app_0.updateResourceRequests(app_0_requests_0);
-
+
app_1_requests_0.clear();
- app_1_requests_0.add(
- TestUtils.createResourceRequest(ResourceRequest.ANY, 1*GB, 1,
- true, priority, recordFactory));
+ app_1_requests_0.add(TestUtils
+ .createResourceRequest(ResourceRequest.ANY, 1 * GB, 1, true, priority,
+ recordFactory));
app_1.updateResourceRequests(app_1_requests_0);
// app_1 will get containers as it has high priority
- a.assignContainers(clusterResource, node_0_0, new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
- Assert.assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
- a.assignContainers(clusterResource, node_0_0, new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
- Assert.assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
+ Assert.assertEquals(1 * GB, app_1.getCurrentConsumption().getMemorySize());
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
+ Assert.assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
app_0_requests_0.clear();
- app_0_requests_0.add(
- TestUtils.createResourceRequest(ResourceRequest.ANY, 1*GB, 1,
- true, priority, recordFactory));
+ app_0_requests_0.add(TestUtils
+ .createResourceRequest(ResourceRequest.ANY, 1 * GB, 1, true, priority,
+ recordFactory));
app_0.updateResourceRequests(app_0_requests_0);
app_1_requests_0.clear();
- app_1_requests_0.add(
- TestUtils.createResourceRequest(ResourceRequest.ANY, 1*GB, 1,
- true, priority, recordFactory));
+ app_1_requests_0.add(TestUtils
+ .createResourceRequest(ResourceRequest.ANY, 1 * GB, 1, true, priority,
+ recordFactory));
app_1.updateResourceRequests(app_1_requests_0);
//app_1 will still get assigned first as priority is more.
- a.assignContainers(clusterResource, node_0_0, new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
- Assert.assertEquals(2*GB, app_1.getCurrentConsumption().getMemorySize());
- Assert.assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
+ Assert.assertEquals(2 * GB, app_1.getCurrentConsumption().getMemorySize());
+ Assert.assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
//and only then will app_2
- a.assignContainers(clusterResource, node_0_0, new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
- Assert.assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
-}
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
+ Assert.assertEquals(3 * GB, app_0.getCurrentConsumption().getMemorySize());
+ }
+
@Test
public void testConcurrentAccess() throws Exception {
YarnConfiguration conf = new YarnConfiguration();
@@ -2792,6 +3036,12 @@ public class TestLeafQueue {
mock(ActiveUsersManager.class), spyRMContext));
a.submitApplicationAttempt(app_1, user_0);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0_0.getNodeID(),
+ node_0_0);
+
Priority priority = TestUtils.createMockPriority(1);
List<ResourceRequest> app_0_requests_0 = new ArrayList<ResourceRequest>();
List<ResourceRequest> app_1_requests_0 = new ArrayList<ResourceRequest>();
@@ -2809,9 +3059,15 @@ public class TestLeafQueue {
app_1.updateResourceRequests(app_1_requests_0);
// app_0 will get containers as its submitted first.
- a.assignContainers(clusterResource, node_0_0, new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
Assert.assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
- a.assignContainers(clusterResource, node_0_0, new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
Assert.assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
app_0_requests_0.clear();
@@ -2828,12 +3084,18 @@ public class TestLeafQueue {
//Since it already has more resources, app_0 will not get
//assigned first, but app_1 will
- a.assignContainers(clusterResource, node_0_0, new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
Assert.assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
Assert.assertEquals(2*GB, app_1.getCurrentConsumption().getMemorySize());
//and only then will app_0
- a.assignContainers(clusterResource, node_0_0, new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ a.assignContainers(clusterResource, node_0_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
Assert.assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
}
@@ -2874,6 +3136,12 @@ public class TestLeafQueue {
String rack_2 = "rack_2";
FiCaSchedulerNode node_2 = TestUtils.getMockNode(host_2, rack_2, 0, 8*GB);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1, node_2.getNodeID(), node_2);
+
final int numNodes = 3;
Resource clusterResource =
Resources.createResource(numNodes * (8*GB), numNodes * 16);
@@ -2922,6 +3190,7 @@ public class TestLeafQueue {
// Check app_0's scheduling opportunities increased and app_1 get allocated
assignment = a.assignContainers(clusterResource, node_2,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource, assignment, a, nodes, apps);
verifyContainerAllocated(assignment, NodeType.NODE_LOCAL);
assertEquals(1, app_0.getSchedulingOpportunities(schedulerKey));
assertEquals(3, app_0.getTotalRequiredResources(schedulerKey));
@@ -2965,6 +3234,12 @@ public class TestLeafQueue {
FiCaSchedulerNode node_0 = TestUtils.getMockNode(host_0, DEFAULT_RACK, 0,
100*GB);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0);
+
final int numNodes = 1;
Resource clusterResource =
Resources.createResource(numNodes * (100*GB), numNodes * 128);
@@ -2983,9 +3258,10 @@ public class TestLeafQueue {
// Start testing...
// Assign 1st Container of 1GB
- e.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
// With queue capacity set at 1% of 100GB and user-limit-factor set to 1.0,
// all users (only user_0) queue 'e' should be able to consume 1GB.
// The first container should be assigned to app_0 with no headroom left
@@ -2996,9 +3272,10 @@ public class TestLeafQueue {
clusterResource, RMNodeLabelsManager.NO_LABEL).getMemorySize());
// Assign 2nd container of 1GB
- e.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
// user_0 has no headroom due to user-limit-factor of 1.0. However capacity
// scheduler will assign one container more than user-limit-factor.
// This container also went to app_0. Still with no neadroom even though
@@ -3009,9 +3286,10 @@ public class TestLeafQueue {
clusterResource, RMNodeLabelsManager.NO_LABEL).getMemorySize());
// Can't allocate 3rd container due to user-limit. Headroom still 0.
- e.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, e.getTotalPendingResourcesConsideringUserLimit(
@@ -3025,9 +3303,10 @@ public class TestLeafQueue {
assertEquals(3*GB, e.getTotalPendingResourcesConsideringUserLimit(
clusterResource, RMNodeLabelsManager.NO_LABEL).getMemorySize());
- e.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
// app_0 is now satisified, app_1 is still asking for 2GB.
assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemorySize());
@@ -3035,12 +3314,14 @@ public class TestLeafQueue {
clusterResource, RMNodeLabelsManager.NO_LABEL).getMemorySize());
// Get the last 2 containers for app_1, no more pending requests.
- e.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
- e.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(2*GB, app_1.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, e.getTotalPendingResourcesConsideringUserLimit(
@@ -3112,10 +3393,17 @@ public class TestLeafQueue {
mock(ActiveUsersManager.class), spyRMContext);
e.submitApplicationAttempt(app_3, user_1);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1, app_2.getApplicationAttemptId(), app_2,
+ app_3.getApplicationAttemptId(), app_3);
+
// Setup 1 node with 100GB of memory resources.
String host_0 = "127.0.0.1";
FiCaSchedulerNode node_0 = TestUtils.getMockNode(host_0, DEFAULT_RACK, 0,
100*GB);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0);
final int numNodes = 1;
Resource clusterResource =
@@ -3156,9 +3444,10 @@ public class TestLeafQueue {
assertEquals(0*GB, app_3.getCurrentConsumption().getMemorySize());
// Assign 1st Container of 1GB
- e.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
// The first container was assigned to user_0's app_0. Queues total headroom
// has 1GB left for user_1.
assertEquals(1*GB, e.getTotalPendingResourcesConsideringUserLimit(
@@ -3171,9 +3460,10 @@ public class TestLeafQueue {
assertEquals(0*GB, app_3.getCurrentConsumption().getMemorySize());
// Assign 2nd container of 1GB
- e.assignContainers(clusterResource, node_0,
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
// user_0 has no headroom due to user-limit-factor of 1.0. However capacity
// scheduler will assign one container more than user-limit-factor. So,
// this container went to user_0's app_1. so, headroom for queue 'e'e is
@@ -3188,9 +3478,10 @@ public class TestLeafQueue {
assertEquals(0*GB, app_3.getCurrentConsumption().getMemorySize());
// Assign 3rd container.
- e.assignContainers(clusterResource, node_0,
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
// Container was allocated to user_1's app_2 since user_1, Now, no headroom
// is left.
assertEquals(0*GB, e.getTotalPendingResourcesConsideringUserLimit(
@@ -3203,9 +3494,10 @@ public class TestLeafQueue {
assertEquals(0*GB, app_3.getCurrentConsumption().getMemorySize());
// Assign 4th container.
- e.assignContainers(clusterResource, node_0,
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
// Allocated to user_1's app_2 since scheduler allocates 1 container
// above user resource limit. Available headroom still 0.
assertEquals(0*GB, e.getTotalPendingResourcesConsideringUserLimit(
@@ -3222,9 +3514,10 @@ public class TestLeafQueue {
assertEquals(0*GB, app_3_consumption);
// Attempt to assign 5th container. Will be a no-op.
- e.assignContainers(clusterResource, node_0,
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
// Cannot allocate 5th container because both users are above their allowed
// user resource limit. Values should be the same as previously.
assertEquals(0*GB, e.getTotalPendingResourcesConsideringUserLimit(
@@ -3241,9 +3534,10 @@ public class TestLeafQueue {
// factor is no longer the limiting factor.
e.setUserLimitFactor(10.0f);
- e.assignContainers(clusterResource, node_0,
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
// Next container goes to user_0's app_1, since it still wanted 1GB.
assertEquals(1*GB, e.getTotalPendingResourcesConsideringUserLimit(
clusterResource, RMNodeLabelsManager.NO_LABEL).getMemorySize());
@@ -3254,9 +3548,10 @@ public class TestLeafQueue {
assertEquals(2*GB, app_2.getCurrentConsumption().getMemorySize());
assertEquals(0*GB, app_3.getCurrentConsumption().getMemorySize());
- e.assignContainers(clusterResource, node_0,
+ applyCSAssignment(clusterResource,
+ e.assignContainers(clusterResource, node_0,
new ResourceLimits(clusterResource),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), e, nodes, apps);
// Last container goes to user_1's app_3, since it still wanted 1GB.
// user_0's apps:
assertEquals(0*GB, e.getTotalPendingResourcesConsideringUserLimit(
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[39/50] [abbrv] hadoop git commit: YARN-5856. Unnecessary duplicate
start container request sent to NM State store. Contributed by Varun Saxena.
Posted by ka...@apache.org.
YARN-5856. Unnecessary duplicate start container request sent to NM State store. Contributed by Varun Saxena.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/de3a5f8d
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/de3a5f8d
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/de3a5f8d
Branch: refs/heads/YARN-4752
Commit: de3a5f8d08f64d0c2021a84b40e63e716da2321c
Parents: bcc15c6
Author: Naganarasimha <na...@apache.org>
Authored: Thu Nov 10 05:39:20 2016 +0530
Committer: Naganarasimha <na...@apache.org>
Committed: Thu Nov 10 05:42:30 2016 +0530
----------------------------------------------------------------------
.../server/nodemanager/containermanager/ContainerManagerImpl.java | 2 --
1 file changed, 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3a5f8d/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java
index ab5827e..c7810f9 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java
@@ -1034,8 +1034,6 @@ public class ContainerManagerImpl extends CompositeService implements
containerTokenIdentifier.getVersion(), request);
dispatcher.getEventHandler().handle(
new ApplicationContainerInitEvent(container));
- this.context.getNMStateStore().storeContainer(containerId,
- containerTokenIdentifier.getVersion(), request);
this.context.getContainerTokenSecretManager().startContainerSuccessful(
containerTokenIdentifier);
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[12/50] [abbrv] hadoop git commit: YARN-5716. Add global scheduler
interface definition and update CapacityScheduler to use it. Contributed by
Wangda Tan
Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/SchedulerContainer.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/SchedulerContainer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/SchedulerContainer.java
new file mode 100644
index 0000000..8b4907b
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/SchedulerContainer.java
@@ -0,0 +1,80 @@
+/**
+ * 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.scheduler.common;
+
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerState;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerRequestKey;
+
+/**
+ * Contexts for a container inside scheduler
+ */
+public class SchedulerContainer<A extends SchedulerApplicationAttempt,
+ N extends SchedulerNode> {
+ private RMContainer rmContainer;
+ private String nodePartition;
+ private A schedulerApplicationAttempt;
+ private N schedulerNode;
+ private boolean allocated; // Allocated (True) or reserved (False)
+
+ public SchedulerContainer(A app, N node, RMContainer rmContainer,
+ String nodePartition, boolean allocated) {
+ this.schedulerApplicationAttempt = app;
+ this.schedulerNode = node;
+ this.rmContainer = rmContainer;
+ this.nodePartition = nodePartition;
+ this.allocated = allocated;
+ }
+
+ public String getNodePartition() {
+ return nodePartition;
+ }
+
+ public RMContainer getRmContainer() {
+ return rmContainer;
+ }
+
+ public A getSchedulerApplicationAttempt() {
+ return schedulerApplicationAttempt;
+ }
+
+ public N getSchedulerNode() {
+ return schedulerNode;
+ }
+
+ public boolean isAllocated() {
+ return allocated;
+ }
+
+ public SchedulerRequestKey getSchedulerRequestKey() {
+ if (rmContainer.getState() == RMContainerState.RESERVED) {
+ return rmContainer.getReservedSchedulerKey();
+ }
+ return rmContainer.getAllocatedSchedulerKey();
+ }
+
+ @Override
+ public String toString() {
+ return "(Application=" + schedulerApplicationAttempt
+ .getApplicationAttemptId() + "; Node=" + schedulerNode.getNodeID()
+ + "; Resource=" + rmContainer.getAllocatedOrReservedResource() + ")";
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java
index ebe70d4..6d9dda8 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java
@@ -18,14 +18,7 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
+import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience.Private;
@@ -51,12 +44,13 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEven
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEventType;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerFinishedEvent;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerState;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ActiveUsersManager;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeType;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Queue;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedContainerChangeRequest;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerRequestKey;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivitiesManager;
@@ -70,11 +64,25 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCap
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.SchedulingMode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.allocator.AbstractContainerAllocator;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.allocator.ContainerAllocator;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.SchedulerContainer;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SchedulingPlacementSet;
+import org.apache.hadoop.yarn.server.utils.BuilderUtils;
import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
import org.apache.hadoop.yarn.util.resource.Resources;
-import com.google.common.annotations.VisibleForTesting;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Represents an application attempt from the viewpoint of the FIFO or Capacity
@@ -101,6 +109,9 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
*/
private String appSkipNodeDiagnostics;
+ private Map<ContainerId, SchedContainerChangeRequest> toBeRemovedIncRequests =
+ new ConcurrentHashMap<>();
+
public FiCaSchedulerApp(ApplicationAttemptId applicationAttemptId,
String user, Queue queue, ActiveUsersManager activeUsersManager,
RMContext rmContext) {
@@ -193,11 +204,11 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
}
}
- public RMContainer allocate(NodeType type, FiCaSchedulerNode node,
+ public RMContainer allocate(FiCaSchedulerNode node,
SchedulerRequestKey schedulerKey, ResourceRequest request,
Container container) {
try {
- writeLock.lock();
+ readLock.lock();
if (isStopped) {
return null;
@@ -216,41 +227,408 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
request.getNodeLabelExpression());
((RMContainerImpl) rmContainer).setQueueName(this.getQueueName());
+ // FIXME, should set when confirmed
updateAMContainerDiagnostics(AMState.ASSIGNED, null);
- // Add it to allContainers list.
- newlyAllocatedContainers.add(rmContainer);
+ return rmContainer;
+ } finally {
+ readLock.unlock();
+ }
+ }
- ContainerId containerId = container.getId();
- liveContainers.put(containerId, rmContainer);
+ private boolean rmContainerInFinalState(RMContainer rmContainer) {
+ if (null == rmContainer) {
+ return false;
+ }
- // Update consumption and track allocations
- List<ResourceRequest> resourceRequestList = appSchedulingInfo.allocate(
- type, node, schedulerKey, request, container);
+ return rmContainer.completed();
+ }
- attemptResourceUsage.incUsed(node.getPartition(),
- container.getResource());
+ private boolean anyContainerInFinalState(
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request) {
+ for (SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> c : request
+ .getContainersToRelease()) {
+ if (rmContainerInFinalState(c.getRmContainer())) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("To-release container=" + c.getRmContainer()
+ + " is in final state");
+ }
+ return true;
+ }
+ }
- // Update resource requests related to "request" and store in RMContainer
- ((RMContainerImpl) rmContainer).setResourceRequests(resourceRequestList);
+ for (ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> c : request
+ .getContainersToAllocate()) {
+ for (SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> r : c
+ .getToRelease()) {
+ if (rmContainerInFinalState(r.getRmContainer())) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("To-release container=" + r.getRmContainer()
+ + ", for to a new allocated container, is in final state");
+ }
+ return true;
+ }
+ }
- // Inform the container
- rmContainer.handle(
- new RMContainerEvent(containerId, RMContainerEventType.START));
+ if (null != c.getAllocateFromReservedContainer()) {
+ if (rmContainerInFinalState(
+ c.getAllocateFromReservedContainer().getRmContainer())) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Allocate from reserved container" + c
+ .getAllocateFromReservedContainer().getRmContainer()
+ + " is in final state");
+ }
+ return true;
+ }
+ }
+ }
+ for (ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> c : request
+ .getContainersToReserve()) {
+ for (SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> r : c
+ .getToRelease()) {
+ if (rmContainerInFinalState(r.getRmContainer())) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("To-release container=" + r.getRmContainer()
+ + ", for a reserved container, is in final state");
+ }
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private SchedContainerChangeRequest getResourceChangeRequest(
+ SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> schedulerContainer) {
+ return appSchedulingInfo.getIncreaseRequest(
+ schedulerContainer.getSchedulerNode().getNodeID(),
+ schedulerContainer.getSchedulerRequestKey(),
+ schedulerContainer.getRmContainer().getContainerId());
+ }
+
+ private boolean checkIncreaseContainerAllocation(
+ ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> allocation,
+ SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> schedulerContainer) {
+ // When increase a container
+ if (schedulerContainer.getRmContainer().getState()
+ != RMContainerState.RUNNING) {
if (LOG.isDebugEnabled()) {
- LOG.debug("allocate: applicationAttemptId=" + containerId
- .getApplicationAttemptId() + " container=" + containerId + " host="
- + container.getNodeId().getHost() + " type=" + type);
+ LOG.debug("Trying to increase a container, but container="
+ + schedulerContainer.getRmContainer().getContainerId()
+ + " is not in running state.");
}
- RMAuditLogger.logSuccess(getUser(), AuditConstants.ALLOC_CONTAINER,
- "SchedulerApp", getApplicationId(), containerId,
- container.getResource());
+ return false;
+ }
- return rmContainer;
+ // Check if increase request is still valid
+ SchedContainerChangeRequest increaseRequest = getResourceChangeRequest(
+ schedulerContainer);
+
+ if (null == increaseRequest || !Resources.equals(
+ increaseRequest.getDeltaCapacity(),
+ allocation.getAllocatedOrReservedResource())) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Increase request has been changed, reject this proposal");
+ }
+ return false;
+ }
+
+ if (allocation.getAllocateFromReservedContainer() != null) {
+ // In addition, if allocation is from a reserved container, check
+ // if the reserved container has enough reserved space
+ if (!Resources.equals(
+ allocation.getAllocateFromReservedContainer().getRmContainer()
+ .getReservedResource(), increaseRequest.getDeltaCapacity())) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private boolean commonCheckContainerAllocation(
+ Resource cluster,
+ ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> allocation,
+ SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> schedulerContainer) {
+ // Make sure node is not reserved by anyone else
+ RMContainer reservedContainerOnNode =
+ schedulerContainer.getSchedulerNode().getReservedContainer();
+ if (reservedContainerOnNode != null) {
+ RMContainer fromReservedContainer =
+ allocation.getAllocateFromReservedContainer().getRmContainer();
+
+ if (fromReservedContainer != reservedContainerOnNode) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(
+ "Try to allocate from a non-existed reserved container");
+ }
+ return false;
+ }
+ }
+
+ // Do we have enough space on this node?
+ Resource availableResource = Resources.clone(
+ schedulerContainer.getSchedulerNode().getUnallocatedResource());
+
+ // If we have any to-release container in non-reserved state, they are
+ // from lazy-preemption, add their consumption to available resource
+ // of this node
+ if (allocation.getToRelease() != null && !allocation.getToRelease()
+ .isEmpty()) {
+ for (SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode>
+ releaseContainer : allocation.getToRelease()) {
+ // Only consider non-reserved container (reserved container will
+ // not affect available resource of node) on the same node
+ if (releaseContainer.getRmContainer().getState()
+ != RMContainerState.RESERVED
+ && releaseContainer.getSchedulerNode() == schedulerContainer
+ .getSchedulerNode()) {
+ Resources.addTo(availableResource,
+ releaseContainer.getRmContainer().getAllocatedResource());
+ }
+ }
+ }
+ if (!Resources.fitsIn(rc, cluster,
+ allocation.getAllocatedOrReservedResource(),
+ availableResource)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Node doesn't have enough available resource, asked="
+ + allocation.getAllocatedOrReservedResource() + " available="
+ + availableResource);
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean accept(Resource cluster,
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request) {
+ List<ResourceRequest> resourceRequests = null;
+ boolean reReservation = false;
+
+ try {
+ readLock.lock();
+
+ // First make sure no container in release list in final state
+ if (anyContainerInFinalState(request)) {
+ return false;
+ }
+
+ // TODO, make sure all scheduler nodes are existed
+ // TODO, make sure all node labels are not changed
+
+ if (request.anythingAllocatedOrReserved()) {
+ /*
+ * 1) If this is a newly allocated container, check if the node is reserved
+ * / not-reserved by any other application
+ * 2) If this is a newly reserved container, check if the node is reserved or not
+ */
+ // Assume we have only one container allocated or reserved
+ ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode>
+ allocation = request.getFirstAllocatedOrReservedContainer();
+ SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode>
+ schedulerContainer = allocation.getAllocatedOrReservedContainer();
+
+ if (schedulerContainer.isAllocated()) {
+ if (!allocation.isIncreasedAllocation()) {
+ // When allocate a new container
+ resourceRequests =
+ schedulerContainer.getRmContainer().getResourceRequests();
+
+ // Check pending resource request
+ if (!appSchedulingInfo.checkAllocation(allocation.getAllocationLocalityType(),
+ schedulerContainer.getSchedulerNode(),
+ schedulerContainer.getSchedulerRequestKey())) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("No pending resource for: nodeType=" + allocation
+ .getAllocationLocalityType() + ", node=" + schedulerContainer
+ .getSchedulerNode() + ", requestKey=" + schedulerContainer
+ .getSchedulerRequestKey() + ", application="
+ + getApplicationAttemptId());
+ }
+
+ return false;
+ }
+ } else {
+ if (!checkIncreaseContainerAllocation(allocation,
+ schedulerContainer)) {
+ return false;
+ }
+ }
+
+ // Common part of check container allocation regardless if it is a
+ // increase container or regular container
+ commonCheckContainerAllocation(cluster, allocation,
+ schedulerContainer);
+ } else {
+ // Container reserved first time will be NEW, after the container
+ // accepted & confirmed, it will become RESERVED state
+ if (schedulerContainer.getRmContainer().getState()
+ == RMContainerState.RESERVED) {
+ // Set reReservation == true
+ reReservation = true;
+ } else {
+ // When reserve a resource (state == NEW is for new container,
+ // state == RUNNING is for increase container).
+ // Just check if the node is not already reserved by someone
+ if (schedulerContainer.getSchedulerNode().getReservedContainer()
+ != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Try to reserve a container, but the node is "
+ + "already reserved by another container="
+ + schedulerContainer.getSchedulerNode()
+ .getReservedContainer().getContainerId());
+ }
+ return false;
+ }
+ }
+ }
+ }
+ } finally {
+ readLock.unlock();
+ }
+
+ // Skip check parent if this is a re-reservation container
+ boolean accepted = true;
+ if (!reReservation) {
+ // Check parent if anything allocated or reserved
+ if (request.anythingAllocatedOrReserved()) {
+ accepted = getCSLeafQueue().accept(cluster, request);
+ }
+ }
+
+ // When rejected, recover resource requests for this app
+ if (!accepted && resourceRequests != null) {
+ recoverResourceRequestsForContainer(resourceRequests);
+ }
+
+ return accepted;
+ }
+
+ public void apply(Resource cluster,
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request) {
+ boolean reReservation = false;
+
+ try {
+ writeLock.lock();
+
+ // If we allocated something
+ if (request.anythingAllocatedOrReserved()) {
+ ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode>
+ allocation = request.getFirstAllocatedOrReservedContainer();
+ SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode>
+ schedulerContainer = allocation.getAllocatedOrReservedContainer();
+ RMContainer rmContainer = schedulerContainer.getRmContainer();
+
+ reReservation =
+ (!schedulerContainer.isAllocated()) && (rmContainer.getState()
+ == RMContainerState.RESERVED);
+
+ // Generate new containerId if it is not an allocation for increasing
+ // Or re-reservation
+ if (!allocation.isIncreasedAllocation()) {
+ if (rmContainer.getContainer().getId() == null) {
+ rmContainer.setContainerId(BuilderUtils
+ .newContainerId(getApplicationAttemptId(),
+ getNewContainerId()));
+ }
+ }
+ ContainerId containerId = rmContainer.getContainerId();
+
+ if (schedulerContainer.isAllocated()) {
+ // This allocation is from a reserved container
+ // Unreserve it first
+ if (allocation.getAllocateFromReservedContainer() != null) {
+ RMContainer reservedContainer =
+ allocation.getAllocateFromReservedContainer().getRmContainer();
+ // Handling container allocation
+ // Did we previously reserve containers at this 'priority'?
+ unreserve(schedulerContainer.getSchedulerRequestKey(),
+ schedulerContainer.getSchedulerNode(), reservedContainer);
+ }
+
+ // Update this application for the allocated container
+ if (!allocation.isIncreasedAllocation()) {
+ // Allocate a new container
+ newlyAllocatedContainers.add(rmContainer);
+ liveContainers.put(containerId, rmContainer);
+
+ // Deduct pending resource requests
+ List<ResourceRequest> requests = appSchedulingInfo.allocate(
+ allocation.getAllocationLocalityType(), schedulerContainer.getSchedulerNode(),
+ schedulerContainer.getSchedulerRequestKey(),
+ schedulerContainer.getRmContainer().getContainer());
+ ((RMContainerImpl) rmContainer).setResourceRequests(requests);
+
+ attemptResourceUsage.incUsed(schedulerContainer.getNodePartition(),
+ allocation.getAllocatedOrReservedResource());
+
+ rmContainer.handle(
+ new RMContainerEvent(containerId, RMContainerEventType.START));
+
+ // Inform the node
+ schedulerContainer.getSchedulerNode().allocateContainer(
+ rmContainer);
+
+ // update locality statistics,
+ incNumAllocatedContainers(allocation.getAllocationLocalityType(),
+ allocation.getRequestLocalityType());
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("allocate: applicationAttemptId=" + containerId
+ .getApplicationAttemptId() + " container=" + containerId
+ + " host=" + rmContainer.getAllocatedNode().getHost()
+ + " type=" + allocation.getAllocationLocalityType());
+ }
+ RMAuditLogger.logSuccess(getUser(), AuditConstants.ALLOC_CONTAINER,
+ "SchedulerApp", getApplicationId(), containerId,
+ allocation.getAllocatedOrReservedResource());
+ } else{
+ SchedContainerChangeRequest increaseRequest =
+ getResourceChangeRequest(schedulerContainer);
+
+ // allocate resource for an increase request
+ // Notify node
+ schedulerContainer.getSchedulerNode().increaseContainer(
+ increaseRequest.getContainerId(),
+ increaseRequest.getDeltaCapacity());
+
+ // OK, we can allocate this increase request
+ // Notify application
+ increaseContainer(increaseRequest);
+ }
+ } else {
+ if (!allocation.isIncreasedAllocation()) {
+ // If the rmContainer's state is already updated to RESERVED, this is
+ // a reReservation
+ reserve(schedulerContainer.getSchedulerRequestKey(),
+ schedulerContainer.getSchedulerNode(),
+ schedulerContainer.getRmContainer(),
+ schedulerContainer.getRmContainer().getContainer(),
+ reReservation);
+ } else{
+ SchedContainerChangeRequest increaseRequest =
+ getResourceChangeRequest(schedulerContainer);
+
+ reserveIncreasedContainer(
+ schedulerContainer.getSchedulerRequestKey(),
+ schedulerContainer.getSchedulerNode(),
+ increaseRequest.getRMContainer(),
+ increaseRequest.getDeltaCapacity());
+ }
+ }
+ }
} finally {
writeLock.unlock();
}
+
+ // Don't bother CS leaf queue if it is a re-reservation
+ if (!reReservation) {
+ getCSLeafQueue().apply(cluster, request);
+ }
}
public boolean unreserve(SchedulerRequestKey schedulerKey,
@@ -347,9 +725,9 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
* of the resources that will be allocated to and preempted from this
* application.
*
- * @param resourceCalculator
- * @param clusterResource
- * @param minimumAllocation
+ * @param resourceCalculator resourceCalculator
+ * @param clusterResource clusterResource
+ * @param minimumAllocation minimumAllocation
* @return an allocation
*/
public Allocation getAllocation(ResourceCalculator resourceCalculator,
@@ -386,45 +764,40 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
public NodeId getNodeIdToUnreserve(
SchedulerRequestKey schedulerKey, Resource resourceNeedUnreserve,
ResourceCalculator rc, Resource clusterResource) {
- try {
- writeLock.lock();
- // first go around make this algorithm simple and just grab first
- // reservation that has enough resources
- Map<NodeId, RMContainer> reservedContainers = this.reservedContainers.get(
- schedulerKey);
-
- if ((reservedContainers != null) && (!reservedContainers.isEmpty())) {
- for (Map.Entry<NodeId, RMContainer> entry : reservedContainers
- .entrySet()) {
- NodeId nodeId = entry.getKey();
- RMContainer reservedContainer = entry.getValue();
- if (reservedContainer.hasIncreaseReservation()) {
- // Currently, only regular container allocation supports continuous
- // reservation looking, we don't support canceling increase request
- // reservation when allocating regular container.
- continue;
- }
-
- Resource reservedResource = reservedContainer.getReservedResource();
+ // first go around make this algorithm simple and just grab first
+ // reservation that has enough resources
+ Map<NodeId, RMContainer> reservedContainers = this.reservedContainers.get(
+ schedulerKey);
+
+ if ((reservedContainers != null) && (!reservedContainers.isEmpty())) {
+ for (Map.Entry<NodeId, RMContainer> entry : reservedContainers
+ .entrySet()) {
+ NodeId nodeId = entry.getKey();
+ RMContainer reservedContainer = entry.getValue();
+ if (reservedContainer.hasIncreaseReservation()) {
+ // Currently, only regular container allocation supports continuous
+ // reservation looking, we don't support canceling increase request
+ // reservation when allocating regular container.
+ continue;
+ }
- // make sure we unreserve one with at least the same amount of
- // resources, otherwise could affect capacity limits
- if (Resources.fitsIn(rc, clusterResource, resourceNeedUnreserve,
- reservedResource)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(
- "unreserving node with reservation size: " + reservedResource
- + " in order to allocate container with size: "
- + resourceNeedUnreserve);
- }
- return nodeId;
+ Resource reservedResource = reservedContainer.getReservedResource();
+
+ // make sure we unreserve one with at least the same amount of
+ // resources, otherwise could affect capacity limits
+ if (Resources.fitsIn(rc, clusterResource, resourceNeedUnreserve,
+ reservedResource)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(
+ "unreserving node with reservation size: " + reservedResource
+ + " in order to allocate container with size: "
+ + resourceNeedUnreserve);
}
+ return nodeId;
}
}
- return null;
- } finally {
- writeLock.unlock();
}
+ return null;
}
public void setHeadroomProvider(
@@ -482,10 +855,11 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
return false;
}
- public void reserve(SchedulerRequestKey schedulerKey,
- FiCaSchedulerNode node, RMContainer rmContainer, Container container) {
+ public void reserve(SchedulerRequestKey schedulerKey, FiCaSchedulerNode node,
+ RMContainer rmContainer, Container container, boolean reReservation) {
// Update reserved metrics if this is the first reservation
- if (rmContainer == null) {
+ // rmContainer will be moved to reserved in the super.reserve
+ if (!reReservation) {
queue.getMetrics().reserveResource(
getUser(), container.getResource());
}
@@ -501,35 +875,39 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
public RMContainer findNodeToUnreserve(Resource clusterResource,
FiCaSchedulerNode node, SchedulerRequestKey schedulerKey,
Resource minimumUnreservedResource) {
- // need to unreserve some other container first
- NodeId idToUnreserve =
- getNodeIdToUnreserve(schedulerKey, minimumUnreservedResource,
- rc, clusterResource);
- if (idToUnreserve == null) {
+ try {
+ readLock.lock();
+ // need to unreserve some other container first
+ NodeId idToUnreserve = getNodeIdToUnreserve(schedulerKey,
+ minimumUnreservedResource, rc, clusterResource);
+ if (idToUnreserve == null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("checked to see if could unreserve for app but nothing "
+ + "reserved that matches for this app");
+ }
+ return null;
+ }
+ FiCaSchedulerNode nodeToUnreserve =
+ ((CapacityScheduler) scheduler).getNode(idToUnreserve);
+ if (nodeToUnreserve == null) {
+ LOG.error("node to unreserve doesn't exist, nodeid: " + idToUnreserve);
+ return null;
+ }
if (LOG.isDebugEnabled()) {
- LOG.debug("checked to see if could unreserve for app but nothing "
- + "reserved that matches for this app");
+ LOG.debug("unreserving for app: " + getApplicationId() + " on nodeId: "
+ + idToUnreserve
+ + " in order to replace reserved application and place it on node: "
+ + node.getNodeID() + " needing: " + minimumUnreservedResource);
}
- return null;
- }
- FiCaSchedulerNode nodeToUnreserve =
- ((CapacityScheduler) scheduler).getNode(idToUnreserve);
- if (nodeToUnreserve == null) {
- LOG.error("node to unreserve doesn't exist, nodeid: " + idToUnreserve);
- return null;
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("unreserving for app: " + getApplicationId()
- + " on nodeId: " + idToUnreserve
- + " in order to replace reserved application and place it on node: "
- + node.getNodeID() + " needing: " + minimumUnreservedResource);
- }
- // headroom
- Resources.addTo(getHeadroom(), nodeToUnreserve
- .getReservedContainer().getReservedResource());
+ // headroom
+ Resources.addTo(getHeadroom(),
+ nodeToUnreserve.getReservedContainer().getReservedResource());
- return nodeToUnreserve.getReservedContainer();
+ return nodeToUnreserve.getReservedContainer();
+ } finally {
+ readLock.unlock();
+ }
}
public LeafQueue getCSLeafQueue() {
@@ -537,7 +915,7 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
}
public CSAssignment assignContainers(Resource clusterResource,
- FiCaSchedulerNode node, ResourceLimits currentResourceLimits,
+ PlacementSet<FiCaSchedulerNode> ps, ResourceLimits currentResourceLimits,
SchedulingMode schedulingMode, RMContainer reservedContainer) {
if (LOG.isDebugEnabled()) {
LOG.debug("pre-assignContainers for application "
@@ -545,13 +923,8 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
showRequests();
}
- try {
- writeLock.lock();
- return containerAllocator.assignContainers(clusterResource, node,
- schedulingMode, currentResourceLimits, reservedContainer);
- } finally {
- writeLock.unlock();
- }
+ return containerAllocator.assignContainers(clusterResource, ps,
+ schedulingMode, currentResourceLimits, reservedContainer);
}
public void nodePartitionUpdated(RMContainer rmContainer, String oldPartition,
@@ -626,13 +999,18 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
/**
* Set the message temporarily if the reason is known for why scheduling did
* not happen for a given node, if not message will be over written
- * @param message
+ * @param message Message of app skip diagnostics
*/
public void updateAppSkipNodeDiagnostics(String message) {
this.appSkipNodeDiagnostics = message;
}
public void updateNodeInfoForAMDiagnostics(FiCaSchedulerNode node) {
+ // FIXME, update AM diagnostics when global scheduling is enabled
+ if (null == node) {
+ return;
+ }
+
if (isWaitingForAMContainer()) {
StringBuilder diagnosticMessageBldr = new StringBuilder();
if (appSkipNodeDiagnostics != null) {
@@ -653,6 +1031,13 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
}
}
+ @Override
+ @SuppressWarnings("unchecked")
+ public SchedulingPlacementSet<FiCaSchedulerNode> getSchedulingPlacementSet(
+ SchedulerRequestKey schedulerRequestKey) {
+ return super.getSchedulingPlacementSet(schedulerRequestKey);
+ }
+
/**
* Recalculates the per-app, percent of queue metric, specific to the
* Capacity Scheduler.
@@ -690,4 +1075,29 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
public ReentrantReadWriteLock.WriteLock getWriteLock() {
return this.writeLock;
}
+
+ public void addToBeRemovedIncreaseRequest(
+ SchedContainerChangeRequest request) {
+ toBeRemovedIncRequests.put(request.getContainerId(), request);
+ }
+
+ public void removedToBeRemovedIncreaseRequests() {
+ // Remove invalid in request requests
+ if (!toBeRemovedIncRequests.isEmpty()) {
+ try {
+ writeLock.lock();
+ Iterator<Map.Entry<ContainerId, SchedContainerChangeRequest>> iter =
+ toBeRemovedIncRequests.entrySet().iterator();
+ while (iter.hasNext()) {
+ SchedContainerChangeRequest req = iter.next().getValue();
+ appSchedulingInfo.removeIncreaseRequest(req.getNodeId(),
+ req.getRMContainer().getAllocatedSchedulerKey(),
+ req.getContainerId());
+ iter.remove();
+ }
+ } finally {
+ writeLock.unlock();
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoAppAttempt.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoAppAttempt.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoAppAttempt.java
new file mode 100644
index 0000000..d275bfd
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoAppAttempt.java
@@ -0,0 +1,110 @@
+/**
+ * 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.scheduler.fifo;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.ResourceRequest;
+import org.apache.hadoop.yarn.server.resourcemanager.RMAuditLogger;
+import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEvent;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ActiveUsersManager;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeType;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Queue;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerRequestKey;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+
+import java.util.List;
+
+public class FifoAppAttempt extends FiCaSchedulerApp {
+ private static final Log LOG = LogFactory.getLog(FifoAppAttempt.class);
+
+ FifoAppAttempt(ApplicationAttemptId appAttemptId, String user,
+ Queue queue, ActiveUsersManager activeUsersManager,
+ RMContext rmContext) {
+ super(appAttemptId, user, queue, activeUsersManager, rmContext);
+ }
+
+ public RMContainer allocate(NodeType type, FiCaSchedulerNode node,
+ SchedulerRequestKey schedulerKey, ResourceRequest request,
+ Container container) {
+ try {
+ writeLock.lock();
+
+ if (isStopped) {
+ return null;
+ }
+
+ // Required sanity check - AM can call 'allocate' to update resource
+ // request without locking the scheduler, hence we need to check
+ if (getTotalRequiredResources(schedulerKey) <= 0) {
+ return null;
+ }
+
+ // Create RMContainer
+ RMContainer rmContainer = new RMContainerImpl(container,
+ this.getApplicationAttemptId(), node.getNodeID(),
+ appSchedulingInfo.getUser(), this.rmContext,
+ request.getNodeLabelExpression());
+ ((RMContainerImpl) rmContainer).setQueueName(this.getQueueName());
+
+ updateAMContainerDiagnostics(AMState.ASSIGNED, null);
+
+ // Add it to allContainers list.
+ newlyAllocatedContainers.add(rmContainer);
+
+ ContainerId containerId = container.getId();
+ liveContainers.put(containerId, rmContainer);
+
+ // Update consumption and track allocations
+ List<ResourceRequest> resourceRequestList = appSchedulingInfo.allocate(
+ type, node, schedulerKey, request, container);
+
+ attemptResourceUsage.incUsed(node.getPartition(),
+ container.getResource());
+
+ // Update resource requests related to "request" and store in RMContainer
+ ((RMContainerImpl) rmContainer).setResourceRequests(resourceRequestList);
+
+ // Inform the container
+ rmContainer.handle(
+ new RMContainerEvent(containerId, RMContainerEventType.START));
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("allocate: applicationAttemptId=" + containerId
+ .getApplicationAttemptId() + " container=" + containerId + " host="
+ + container.getNodeId().getHost() + " type=" + type);
+ }
+ RMAuditLogger.logSuccess(getUser(),
+ RMAuditLogger.AuditConstants.ALLOC_CONTAINER, "SchedulerApp",
+ getApplicationId(), containerId, container.getResource());
+
+ return rmContainer;
+ } finally {
+ writeLock.unlock();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java
index 92acf75..5ccde19 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java
@@ -79,7 +79,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicat
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerRequestKey;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAddedSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptAddedSchedulerEvent;
@@ -103,7 +102,7 @@ import com.google.common.annotations.VisibleForTesting;
@Evolving
@SuppressWarnings("unchecked")
public class FifoScheduler extends
- AbstractYarnScheduler<FiCaSchedulerApp, FiCaSchedulerNode> implements
+ AbstractYarnScheduler<FifoAppAttempt, FiCaSchedulerNode> implements
Configurable {
private static final Log LOG = LogFactory.getLog(FifoScheduler.class);
@@ -239,7 +238,7 @@ public class FifoScheduler extends
validateConf(conf);
//Use ConcurrentSkipListMap because applications need to be ordered
this.applications =
- new ConcurrentSkipListMap<ApplicationId, SchedulerApplication<FiCaSchedulerApp>>();
+ new ConcurrentSkipListMap<>();
this.minimumAllocation =
Resources.createResource(conf.getInt(
YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB,
@@ -328,7 +327,7 @@ public class FifoScheduler extends
List<String> blacklistAdditions, List<String> blacklistRemovals,
List<UpdateContainerRequest> increaseRequests,
List<UpdateContainerRequest> decreaseRequests) {
- FiCaSchedulerApp application = getApplicationAttempt(applicationAttemptId);
+ FifoAppAttempt application = getApplicationAttempt(applicationAttemptId);
if (application == null) {
LOG.error("Calling allocate on removed " +
"or non existant application " + applicationAttemptId);
@@ -384,8 +383,8 @@ public class FifoScheduler extends
@VisibleForTesting
public synchronized void addApplication(ApplicationId applicationId,
String queue, String user, boolean isAppRecovering) {
- SchedulerApplication<FiCaSchedulerApp> application =
- new SchedulerApplication<FiCaSchedulerApp>(DEFAULT_QUEUE, user);
+ SchedulerApplication<FifoAppAttempt> application =
+ new SchedulerApplication<>(DEFAULT_QUEUE, user);
applications.put(applicationId, application);
metrics.submitApp(user);
LOG.info("Accepted application " + applicationId + " from user: " + user
@@ -405,12 +404,12 @@ public class FifoScheduler extends
addApplicationAttempt(ApplicationAttemptId appAttemptId,
boolean transferStateFromPreviousAttempt,
boolean isAttemptRecovering) {
- SchedulerApplication<FiCaSchedulerApp> application =
+ SchedulerApplication<FifoAppAttempt> application =
applications.get(appAttemptId.getApplicationId());
String user = application.getUser();
// TODO: Fix store
- FiCaSchedulerApp schedulerApp =
- new FiCaSchedulerApp(appAttemptId, user, DEFAULT_QUEUE,
+ FifoAppAttempt schedulerApp =
+ new FifoAppAttempt(appAttemptId, user, DEFAULT_QUEUE,
activeUsersManager, this.rmContext);
if (transferStateFromPreviousAttempt) {
@@ -436,7 +435,7 @@ public class FifoScheduler extends
private synchronized void doneApplication(ApplicationId applicationId,
RMAppState finalState) {
- SchedulerApplication<FiCaSchedulerApp> application =
+ SchedulerApplication<FifoAppAttempt> application =
applications.get(applicationId);
if (application == null){
LOG.warn("Couldn't find application " + applicationId);
@@ -454,8 +453,8 @@ public class FifoScheduler extends
ApplicationAttemptId applicationAttemptId,
RMAppAttemptState rmAppAttemptFinalState, boolean keepContainers)
throws IOException {
- FiCaSchedulerApp attempt = getApplicationAttempt(applicationAttemptId);
- SchedulerApplication<FiCaSchedulerApp> application =
+ FifoAppAttempt attempt = getApplicationAttempt(applicationAttemptId);
+ SchedulerApplication<FifoAppAttempt> application =
applications.get(applicationAttemptId.getApplicationId());
if (application == null || attempt == null) {
throw new IOException("Unknown application " + applicationAttemptId +
@@ -492,9 +491,9 @@ public class FifoScheduler extends
" #applications=" + applications.size());
// Try to assign containers to applications in fifo order
- for (Map.Entry<ApplicationId, SchedulerApplication<FiCaSchedulerApp>> e : applications
+ for (Map.Entry<ApplicationId, SchedulerApplication<FifoAppAttempt>> e : applications
.entrySet()) {
- FiCaSchedulerApp application = e.getValue().getCurrentAppAttempt();
+ FifoAppAttempt application = e.getValue().getCurrentAppAttempt();
if (application == null) {
continue;
}
@@ -536,9 +535,9 @@ public class FifoScheduler extends
// Update the applications' headroom to correctly take into
// account the containers assigned in this update.
- for (SchedulerApplication<FiCaSchedulerApp> application : applications.values()) {
- FiCaSchedulerApp attempt =
- (FiCaSchedulerApp) application.getCurrentAppAttempt();
+ for (SchedulerApplication<FifoAppAttempt> application : applications.values()) {
+ FifoAppAttempt attempt =
+ (FifoAppAttempt) application.getCurrentAppAttempt();
if (attempt == null) {
continue;
}
@@ -546,7 +545,7 @@ public class FifoScheduler extends
}
}
- private int getMaxAllocatableContainers(FiCaSchedulerApp application,
+ private int getMaxAllocatableContainers(FifoAppAttempt application,
SchedulerRequestKey schedulerKey, FiCaSchedulerNode node, NodeType type) {
int maxContainers = 0;
@@ -585,7 +584,7 @@ public class FifoScheduler extends
private int assignContainersOnNode(FiCaSchedulerNode node,
- FiCaSchedulerApp application, SchedulerRequestKey schedulerKey
+ FifoAppAttempt application, SchedulerRequestKey schedulerKey
) {
// Data-local
int nodeLocalContainers =
@@ -612,7 +611,7 @@ public class FifoScheduler extends
}
private int assignNodeLocalContainers(FiCaSchedulerNode node,
- FiCaSchedulerApp application, SchedulerRequestKey schedulerKey) {
+ FifoAppAttempt application, SchedulerRequestKey schedulerKey) {
int assignedContainers = 0;
ResourceRequest request =
application.getResourceRequest(schedulerKey, node.getNodeName());
@@ -638,7 +637,7 @@ public class FifoScheduler extends
}
private int assignRackLocalContainers(FiCaSchedulerNode node,
- FiCaSchedulerApp application, SchedulerRequestKey schedulerKey) {
+ FifoAppAttempt application, SchedulerRequestKey schedulerKey) {
int assignedContainers = 0;
ResourceRequest request =
application.getResourceRequest(schedulerKey, node.getRMNode()
@@ -664,7 +663,7 @@ public class FifoScheduler extends
}
private int assignOffSwitchContainers(FiCaSchedulerNode node,
- FiCaSchedulerApp application, SchedulerRequestKey schedulerKey) {
+ FifoAppAttempt application, SchedulerRequestKey schedulerKey) {
int assignedContainers = 0;
ResourceRequest request =
application.getResourceRequest(schedulerKey, ResourceRequest.ANY);
@@ -676,7 +675,7 @@ public class FifoScheduler extends
return assignedContainers;
}
- private int assignContainer(FiCaSchedulerNode node, FiCaSchedulerApp application,
+ private int assignContainer(FiCaSchedulerNode node, FifoAppAttempt application,
SchedulerRequestKey schedulerKey, int assignableContainers,
ResourceRequest request, NodeType type) {
LOG.debug("assignContainers:" +
@@ -710,8 +709,8 @@ public class FifoScheduler extends
// Allocate!
// Inform the application
- RMContainer rmContainer =
- application.allocate(type, node, schedulerKey, request, container);
+ RMContainer rmContainer = application.allocate(type, node, schedulerKey,
+ request, container);
// Inform the node
node.allocateContainer(rmContainer);
@@ -836,7 +835,7 @@ public class FifoScheduler extends
// Get the application for the finished container
Container container = rmContainer.getContainer();
- FiCaSchedulerApp application =
+ FifoAppAttempt application =
getCurrentAttemptForContainer(container.getId());
ApplicationId appId =
container.getId().getApplicationAttemptId().getApplicationId();
@@ -916,7 +915,7 @@ public class FifoScheduler extends
@Override
public RMContainer getRMContainer(ContainerId containerId) {
- FiCaSchedulerApp attempt = getCurrentAttemptForContainer(containerId);
+ FifoAppAttempt attempt = getCurrentAttemptForContainer(containerId);
return (attempt == null) ? null : attempt.getRMContainer(containerId);
}
@@ -937,7 +936,7 @@ public class FifoScheduler extends
if (queueName.equals(DEFAULT_QUEUE.getQueueName())) {
List<ApplicationAttemptId> attempts =
new ArrayList<ApplicationAttemptId>(applications.size());
- for (SchedulerApplication<FiCaSchedulerApp> app : applications.values()) {
+ for (SchedulerApplication<FifoAppAttempt> app : applications.values()) {
attempts.add(app.getCurrentAppAttempt().getApplicationAttemptId());
}
return attempts;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/PlacementSet.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/PlacementSet.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/PlacementSet.java
new file mode 100644
index 0000000..2e6c3ca
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/PlacementSet.java
@@ -0,0 +1,65 @@
+/**
+ * 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.scheduler.placement;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.yarn.api.records.NodeId;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
+
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * <p>
+ * PlacementSet is the central place that decide the order of node to fit
+ * asks by application.
+ * </p>
+ *
+ * <p>
+ * Also, PlacementSet can cache results (for example, ordered list) for
+ * better performance.
+ * </p>
+ *
+ * <p>
+ * PlacementSet can depend on one or more other PlacementSets.
+ * </p>
+ */
+@InterfaceAudience.Private
+@InterfaceStability.Unstable
+public interface PlacementSet<N extends SchedulerNode> {
+ /**
+ * Get all nodes for this PlacementSet
+ * @return all nodes for this PlacementSet
+ */
+ Map<NodeId, N> getAllNodes();
+
+ /**
+ * Version of the PlacementSet, can help other PlacementSet with dependencies
+ * deciding if update is required
+ * @return version
+ */
+ long getVersion();
+
+ /**
+ * Partition of the PlacementSet.
+ * @return node partition
+ */
+ String getPartition();
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/PlacementSetUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/PlacementSetUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/PlacementSetUtils.java
new file mode 100644
index 0000000..405122b
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/PlacementSetUtils.java
@@ -0,0 +1,36 @@
+/**
+ * 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.scheduler.placement;
+
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
+
+public class PlacementSetUtils {
+ /*
+ * If the {@link PlacementSet} only has one entry, return it. otherwise
+ * return null
+ */
+ public static <N extends SchedulerNode> N getSingleNode(PlacementSet<N> ps) {
+ N node = null;
+ if (1 == ps.getAllNodes().size()) {
+ node = ps.getAllNodes().values().iterator().next();
+ }
+
+ return node;
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/ResourceRequestUpdateResult.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/ResourceRequestUpdateResult.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/ResourceRequestUpdateResult.java
new file mode 100644
index 0000000..da356f5
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/ResourceRequestUpdateResult.java
@@ -0,0 +1,43 @@
+/**
+ * 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.scheduler.placement;
+
+import org.apache.hadoop.yarn.api.records.ResourceRequest;
+
+/**
+ * Result of ResourceRequest update
+ */
+public class ResourceRequestUpdateResult {
+ private final ResourceRequest lastAnyResourceRequest;
+ private final ResourceRequest newResourceRequest;
+
+ public ResourceRequestUpdateResult(ResourceRequest lastAnyResourceRequest,
+ ResourceRequest newResourceRequest) {
+ this.lastAnyResourceRequest = lastAnyResourceRequest;
+ this.newResourceRequest = newResourceRequest;
+ }
+
+ public ResourceRequest getLastAnyResourceRequest() {
+ return lastAnyResourceRequest;
+ }
+
+ public ResourceRequest getNewResourceRequest() {
+ return newResourceRequest;
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/SchedulingPlacementSet.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/SchedulingPlacementSet.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/SchedulingPlacementSet.java
new file mode 100644
index 0000000..f87f764
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/SchedulingPlacementSet.java
@@ -0,0 +1,90 @@
+/**
+ * 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.scheduler.placement;
+
+import org.apache.hadoop.yarn.api.records.ResourceRequest;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeType;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerRequestKey;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * In addition to {@link PlacementSet}, this also maintains
+ * pending ResourceRequests:
+ * - When new ResourceRequest(s) added to scheduler, or,
+ * - Or new container allocated, scheduler can notify corresponding
+ * PlacementSet.
+ * </p>
+ *
+ * <p>
+ * Different set of resource requests (E.g., resource requests with the
+ * same schedulerKey) can have one instance of PlacementSet, each PlacementSet
+ * can have different ways to order nodes depends on requests.
+ * </p>
+ */
+public interface SchedulingPlacementSet<N extends SchedulerNode>
+ extends PlacementSet<N> {
+ /**
+ * Get iterator of preferred node depends on requirement and/or availability
+ * @param clusterPlacementSet input cluster PlacementSet
+ * @return iterator of preferred node
+ */
+ Iterator<N> getPreferredNodeIterator(PlacementSet<N> clusterPlacementSet);
+
+ /**
+ * Replace existing ResourceRequest by the new requests
+ *
+ * @param requests new ResourceRequests
+ * @param recoverPreemptedRequestForAContainer if we're recovering resource
+ * requests for preempted container
+ * @return true if total pending resource changed
+ */
+ ResourceRequestUpdateResult updateResourceRequests(
+ List<ResourceRequest> requests,
+ boolean recoverPreemptedRequestForAContainer);
+
+ /**
+ * Get pending ResourceRequests by given schedulerRequestKey
+ * @return Map of resourceName to ResourceRequest
+ */
+ Map<String, ResourceRequest> getResourceRequests();
+
+ /**
+ * Get ResourceRequest by given schedulerKey and resourceName
+ * @param resourceName resourceName
+ * @param schedulerRequestKey schedulerRequestKey
+ * @return ResourceRequest
+ */
+ ResourceRequest getResourceRequest(String resourceName,
+ SchedulerRequestKey schedulerRequestKey);
+
+ /**
+ * Notify container allocated.
+ * @param type Type of the allocation
+ * @param node Which node this container allocated on
+ * @param request resource request
+ * @return list of ResourceRequests deducted
+ */
+ List<ResourceRequest> allocate(NodeType type, SchedulerNode node,
+ ResourceRequest request);
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/SimplePlacementSet.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/SimplePlacementSet.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/SimplePlacementSet.java
new file mode 100644
index 0000000..48efaa1
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/SimplePlacementSet.java
@@ -0,0 +1,70 @@
+/**
+ * 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.scheduler.placement;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.hadoop.yarn.api.records.NodeId;
+import org.apache.hadoop.yarn.api.records.NodeLabel;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * A simple PlacementSet which keeps an unordered map
+ */
+public class SimplePlacementSet<N extends SchedulerNode>
+ implements PlacementSet<N> {
+
+ private Map<NodeId, N> map;
+ private String partition;
+
+ public SimplePlacementSet(N node) {
+ if (null != node) {
+ // Only one node in the initial PlacementSet
+ this.map = ImmutableMap.of(node.getNodeID(), node);
+ this.partition = node.getPartition();
+ } else {
+ this.map = Collections.emptyMap();
+ this.partition = NodeLabel.DEFAULT_NODE_LABEL_PARTITION;
+ }
+ }
+
+ public SimplePlacementSet(Map<NodeId, N> map, String partition) {
+ this.map = map;
+ this.partition = partition;
+ }
+
+ @Override
+ public Map<NodeId, N> getAllNodes() {
+ return map;
+ }
+
+ @Override
+ public long getVersion() {
+ return 0L;
+ }
+
+ @Override
+ public String getPartition() {
+ return partition;
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/AbstractComparatorOrderingPolicy.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/AbstractComparatorOrderingPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/AbstractComparatorOrderingPolicy.java
index 7bec03a..b7cb1bf 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/AbstractComparatorOrderingPolicy.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/AbstractComparatorOrderingPolicy.java
@@ -19,6 +19,8 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.policy;
import java.util.*;
+import java.util.concurrent.ConcurrentSkipListSet;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
@@ -35,7 +37,7 @@ public abstract class AbstractComparatorOrderingPolicy<S extends SchedulableEnti
private static final Log LOG = LogFactory.getLog(OrderingPolicy.class);
- protected TreeSet<S> schedulableEntities;
+ protected ConcurrentSkipListSet<S> schedulableEntities;
protected Comparator<SchedulableEntity> comparator;
protected Map<String, S> entitiesToReorder = new HashMap<String, S>();
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FairOrderingPolicy.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FairOrderingPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FairOrderingPolicy.java
index 3cfcd7a..3371df8 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FairOrderingPolicy.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FairOrderingPolicy.java
@@ -19,6 +19,7 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.policy;
import java.util.*;
+import java.util.concurrent.ConcurrentSkipListSet;
import com.google.common.annotations.VisibleForTesting;
@@ -61,7 +62,7 @@ public class FairOrderingPolicy<S extends SchedulableEntity> extends AbstractCom
comparators
);
this.comparator = fairComparator;
- this.schedulableEntities = new TreeSet<S>(comparator);
+ this.schedulableEntities = new ConcurrentSkipListSet<S>(comparator);
}
private double getMagnitude(SchedulableEntity r) {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FifoOrderingPolicy.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FifoOrderingPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FifoOrderingPolicy.java
index 10f8eeb..2d066bb 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FifoOrderingPolicy.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FifoOrderingPolicy.java
@@ -19,6 +19,8 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.policy;
import java.util.*;
+import java.util.concurrent.ConcurrentSkipListSet;
+
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
/**
@@ -32,7 +34,7 @@ public class FifoOrderingPolicy<S extends SchedulableEntity> extends AbstractCom
comparators.add(new PriorityComparator());
comparators.add(new FifoComparator());
this.comparator = new CompoundComparator(comparators);
- this.schedulableEntities = new TreeSet<S>(comparator);
+ this.schedulableEntities = new ConcurrentSkipListSet<S>(comparator);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FifoOrderingPolicyForPendingApps.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FifoOrderingPolicyForPendingApps.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FifoOrderingPolicyForPendingApps.java
index 0891289..6ced9e2 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FifoOrderingPolicyForPendingApps.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/policy/FifoOrderingPolicyForPendingApps.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.policy;
import java.util.*;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
+import java.util.concurrent.ConcurrentSkipListSet;
/**
* This ordering policy is used for pending applications only.
@@ -46,7 +47,7 @@ public class FifoOrderingPolicyForPendingApps<S extends SchedulableEntity>
comparators.add(new PriorityComparator());
comparators.add(new FifoComparator());
this.comparator = new CompoundComparator(comparators);
- this.schedulableEntities = new TreeSet<S>(comparator);
+ this.schedulableEntities = new ConcurrentSkipListSet<S>(comparator);
}
@Override
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java
index 58bb721..3861624 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java
@@ -23,6 +23,7 @@ import java.nio.ByteBuffer;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.Collection;
+import java.util.EnumSet;
import java.util.List;
import java.util.Map;
@@ -167,6 +168,28 @@ public class MockRM extends ResourceManager {
}
}
+ private void waitForState(ApplicationId appId, EnumSet<RMAppState> finalStates)
+ throws InterruptedException {
+ RMApp app = getRMContext().getRMApps().get(appId);
+ Assert.assertNotNull("app shouldn't be null", app);
+ final int timeoutMsecs = 80 * SECOND;
+ int timeWaiting = 0;
+ while (!finalStates.contains(app.getState())) {
+ if (timeWaiting >= timeoutMsecs) {
+ break;
+ }
+
+ LOG.info("App : " + appId + " State is : " + app.getState() +
+ " Waiting for state : " + finalStates);
+ Thread.sleep(WAIT_MS_PER_LOOP);
+ timeWaiting += WAIT_MS_PER_LOOP;
+ }
+
+ LOG.info("App State is : " + app.getState());
+ Assert.assertTrue("App State is not correct (timeout).",
+ finalStates.contains(app.getState()));
+ }
+
/**
* Wait until an application has reached a specified state.
* The timeout is 80 seconds.
@@ -254,7 +277,7 @@ public class MockRM extends ResourceManager {
RMAppAttemptState finalState, int timeoutMsecs)
throws InterruptedException {
int timeWaiting = 0;
- while (!finalState.equals(attempt.getAppAttemptState())) {
+ while (finalState != attempt.getAppAttemptState()) {
if (timeWaiting >= timeoutMsecs) {
break;
}
@@ -267,7 +290,7 @@ public class MockRM extends ResourceManager {
LOG.info("Attempt State is : " + attempt.getAppAttemptState());
Assert.assertEquals("Attempt state is not correct (timeout).", finalState,
- attempt.getState());
+ attempt.getState());
}
public void waitForContainerToComplete(RMAppAttempt attempt,
@@ -966,6 +989,26 @@ public class MockRM extends ResourceManager {
rm.getResourceScheduler()).getApplicationAttempt(attemptId));
}
+ public static MockAM launchAMWhenAsyncSchedulingEnabled(RMApp app, MockRM rm)
+ throws Exception {
+ int i = 0;
+ while (app.getCurrentAppAttempt() == null) {
+ if (i < 100) {
+ i++;
+ }
+ Thread.sleep(50);
+ }
+
+ RMAppAttempt attempt = app.getCurrentAppAttempt();
+
+ rm.waitForState(attempt.getAppAttemptId(),
+ RMAppAttemptState.ALLOCATED);
+ MockAM am = rm.sendAMLaunched(attempt.getAppAttemptId());
+ rm.waitForState(attempt.getAppAttemptId(), RMAppAttemptState.LAUNCHED);
+
+ return am;
+ }
+
/**
* NOTE: nm.nodeHeartbeat is explicitly invoked,
* don't invoke it before calling launchAM
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java
index 884e236..e48d9d2 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java
@@ -1091,7 +1091,7 @@ public class TestClientRMService {
rmContext.getScheduler().getSchedulerAppInfo(attemptId)
.getLiveContainers()).thenReturn(rmContainers);
ContainerStatus cs = mock(ContainerStatus.class);
- when(containerimpl.getFinishedStatus()).thenReturn(cs);
+ when(containerimpl.completed()).thenReturn(false);
when(containerimpl.getDiagnosticsInfo()).thenReturn("N/A");
when(containerimpl.getContainerExitStatus()).thenReturn(0);
when(containerimpl.getContainerState()).thenReturn(ContainerState.COMPLETE);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerHealth.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerHealth.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerHealth.java
index 56d38fb..83a354d 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerHealth.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerHealth.java
@@ -238,8 +238,10 @@ public class TestSchedulerHealth {
SchedulerHealth sh =
((CapacityScheduler) resourceManager.getResourceScheduler())
.getSchedulerHealth();
- Assert.assertEquals(2, sh.getAllocationCount().longValue());
- Assert.assertEquals(Resource.newInstance(3 * 1024, 2),
+ // Now SchedulerHealth records last container allocated, aggregated
+ // allocation account will not be changed
+ Assert.assertEquals(1, sh.getAllocationCount().longValue());
+ Assert.assertEquals(Resource.newInstance(1 * 1024, 1),
sh.getResourcesAllocated());
Assert.assertEquals(2, sh.getAggregateAllocationCount().longValue());
Assert.assertEquals("host_0:1234", sh.getLastAllocationDetails()
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java
index 865449f..0aeedce 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java
@@ -134,6 +134,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSc
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeRemovedSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEvent;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimplePlacementSet;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.policy.FairOrderingPolicy;
import org.apache.hadoop.yarn.server.resourcemanager.security.ClientToAMTokenSecretManagerInRM;
import org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM;
@@ -3453,7 +3454,7 @@ public class TestCapacityScheduler {
scheduler.handle(new NodeRemovedSchedulerEvent(
rm.getRMContext().getRMNodes().get(nm2.getNodeId())));
// schedulerNode is removed, try allocate a container
- scheduler.allocateContainersToNode(node);
+ scheduler.allocateContainersToNode(new SimplePlacementSet<>(node), true);
AppAttemptRemovedSchedulerEvent appRemovedEvent1 =
new AppAttemptRemovedSchedulerEvent(
@@ -3699,4 +3700,57 @@ public class TestCapacityScheduler {
cs.handle(addAttemptEvent1);
return appAttemptId1;
}
+
+ @Test
+ public void testAppAttemptLocalityStatistics() throws Exception {
+ Configuration conf =
+ TestUtils.getConfigurationWithMultipleQueues(new Configuration(false));
+ conf.setBoolean(YarnConfiguration.NODE_LABELS_ENABLED, true);
+
+ final RMNodeLabelsManager mgr = new NullRMNodeLabelsManager();
+ mgr.init(conf);
+
+ MockRM rm = new MockRM(conf) {
+ protected RMNodeLabelsManager createNodeLabelManager() {
+ return mgr;
+ }
+ };
+
+ rm.start();
+ MockNM nm1 =
+ new MockNM("h1:1234", 200 * GB, rm.getResourceTrackerService());
+ nm1.registerNode();
+
+ // Launch app1 in queue=a1
+ RMApp app1 = rm.submitApp(1 * GB, "app", "user", null, "a");
+
+ // Got one offswitch request and offswitch allocation
+ MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm1);
+
+ // am1 asks for 1 GB resource on h1/default-rack/offswitch
+ am1.allocate(Arrays.asList(ResourceRequest
+ .newInstance(Priority.newInstance(1), "*",
+ Resources.createResource(1 * GB), 2), ResourceRequest
+ .newInstance(Priority.newInstance(1), "/default-rack",
+ Resources.createResource(1 * GB), 2), ResourceRequest
+ .newInstance(Priority.newInstance(1), "h1",
+ Resources.createResource(1 * GB), 1)), null);
+
+ CapacityScheduler cs = (CapacityScheduler) rm.getRMContext().getScheduler();
+
+ // Got one nodelocal request and nodelocal allocation
+ cs.nodeUpdate(rm.getRMContext().getRMNodes().get(nm1.getNodeId()));
+
+ // Got one nodelocal request and racklocal allocation
+ cs.nodeUpdate(rm.getRMContext().getRMNodes().get(nm1.getNodeId()));
+
+ RMAppAttemptMetrics attemptMetrics = rm.getRMContext().getRMApps().get(
+ app1.getApplicationId()).getCurrentAppAttempt()
+ .getRMAppAttemptMetrics();
+
+ // We should get one node-local allocation, one rack-local allocation
+ // And one off-switch allocation
+ Assert.assertArrayEquals(new int[][] { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } },
+ attemptMetrics.getLocalityStatistics());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[16/50] [abbrv] hadoop git commit: HADOOP-13804. MutableStat mean
loses accuracy if add(long, long) is used. Contributed by Erik Krogen.
Posted by ka...@apache.org.
HADOOP-13804. MutableStat mean loses accuracy if add(long, long) is used. Contributed by Erik Krogen.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3dbad5d8
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3dbad5d8
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3dbad5d8
Branch: refs/heads/YARN-4752
Commit: 3dbad5d823b8bf61b643dd1057165044138b99e0
Parents: de3b4aa
Author: Zhe Zhang <zh...@apache.org>
Authored: Mon Nov 7 16:08:10 2016 -0800
Committer: Zhe Zhang <zh...@apache.org>
Committed: Mon Nov 7 16:08:10 2016 -0800
----------------------------------------------------------------------
.../apache/hadoop/metrics2/lib/MutableStat.java | 4 ++++
.../apache/hadoop/metrics2/util/SampleStat.java | 19 +++++++++++++++----
.../hadoop/metrics2/lib/TestMutableMetrics.java | 17 +++++++++++++++++
3 files changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3dbad5d8/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableStat.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableStat.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableStat.java
index ae68874..92fe3d1 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableStat.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableStat.java
@@ -102,6 +102,10 @@ public class MutableStat extends MutableMetric {
/**
* Add a number of samples and their sum to the running stat
+ *
+ * Note that although use of this method will preserve accurate mean values,
+ * large values for numSamples may result in inaccurate variance values due
+ * to the use of a single step of the Welford method for variance calculation.
* @param numSamples number of samples
* @param sum of the samples
*/
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3dbad5d8/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/SampleStat.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/SampleStat.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/SampleStat.java
index cd9aaa4..23abfc4 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/SampleStat.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/SampleStat.java
@@ -27,29 +27,32 @@ import org.apache.hadoop.classification.InterfaceAudience;
public class SampleStat {
private final MinMax minmax = new MinMax();
private long numSamples = 0;
- private double a0, a1, s0, s1;
+ private double a0, a1, s0, s1, total;
/**
* Construct a new running sample stat
*/
public SampleStat() {
a0 = s0 = 0.0;
+ total = 0.0;
}
public void reset() {
numSamples = 0;
a0 = s0 = 0.0;
+ total = 0.0;
minmax.reset();
}
// We want to reuse the object, sometimes.
void reset(long numSamples, double a0, double a1, double s0, double s1,
- MinMax minmax) {
+ double total, MinMax minmax) {
this.numSamples = numSamples;
this.a0 = a0;
this.a1 = a1;
this.s0 = s0;
this.s1 = s1;
+ this.total = total;
this.minmax.reset(minmax);
}
@@ -58,7 +61,7 @@ public class SampleStat {
* @param other the destination to hold our values
*/
public void copyTo(SampleStat other) {
- other.reset(numSamples, a0, a1, s0, s1, minmax);
+ other.reset(numSamples, a0, a1, s0, s1, total, minmax);
}
/**
@@ -80,6 +83,7 @@ public class SampleStat {
*/
public SampleStat add(long nSamples, double x) {
numSamples += nSamples;
+ total += x;
if (numSamples == 1) {
a0 = a1 = x;
@@ -103,10 +107,17 @@ public class SampleStat {
}
/**
+ * @return the total of all samples added
+ */
+ public double total() {
+ return total;
+ }
+
+ /**
* @return the arithmetic mean of the samples
*/
public double mean() {
- return numSamples > 0 ? a1 : 0.0;
+ return numSamples > 0 ? (total / numSamples) : 0.0;
}
/**
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3dbad5d8/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java
index e9f4e10..9161df5 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java
@@ -130,6 +130,23 @@ public class TestMutableMetrics {
}
/**
+ * Tests that when using {@link MutableStat#add(long, long)}, even with a high
+ * sample count, the mean does not lose accuracy.
+ */
+ @Test public void testMutableStatWithBulkAdd() {
+ MetricsRecordBuilder rb = mockMetricsRecordBuilder();
+ MetricsRegistry registry = new MetricsRegistry("test");
+ MutableStat stat = registry.newStat("Test", "Test", "Ops", "Val", false);
+
+ stat.add(1000, 1000);
+ stat.add(1000, 2000);
+ registry.snapshot(rb, false);
+
+ assertCounter("TestNumOps", 2000L, rb);
+ assertGauge("TestAvgVal", 1.5, rb);
+ }
+
+ /**
* Ensure that quantile estimates from {@link MutableQuantiles} are within
* specified error bounds.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[19/50] [abbrv] hadoop git commit: MAPREDUCE-6782. JHS task page
search based on each individual column not working (Ajith S via Varun Saxena)
Posted by ka...@apache.org.
MAPREDUCE-6782. JHS task page search based on each individual column not working (Ajith S via Varun Saxena)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/026b39ad
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/026b39ad
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/026b39ad
Branch: refs/heads/YARN-4752
Commit: 026b39ad9d9336b1efdd8e2ffb9a508cb0db6259
Parents: f38a6d0
Author: Varun Saxena <va...@apache.org>
Authored: Tue Nov 8 14:57:56 2016 +0530
Committer: Varun Saxena <va...@apache.org>
Committed: Tue Nov 8 14:57:56 2016 +0530
----------------------------------------------------------------------
.../org/apache/hadoop/mapreduce/v2/hs/webapp/HsTasksPage.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/026b39ad/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsTasksPage.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsTasksPage.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsTasksPage.java
index 42507d0..3c3386e 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsTasksPage.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsTasksPage.java
@@ -96,7 +96,8 @@ public class HsTasksPage extends HsView {
private String jobsPostTableInit() {
return "var asInitVals = new Array();\n" +
"$('tfoot input').keyup( function () \n{"+
- " tasksDataTable.fnFilter( this.value, $('tfoot input').index(this) );\n"+
+ " $('.dt-tasks').dataTable().fnFilter("+
+ " this.value, $('tfoot input').index(this) );\n"+
"} );\n"+
"$('tfoot input').each( function (i) {\n"+
" asInitVals[i] = this.value;\n"+
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[50/50] [abbrv] hadoop git commit: YARN-5783. Verify identification
of starved applications. (kasha)
Posted by ka...@apache.org.
YARN-5783. Verify identification of starved applications. (kasha)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/cda67765
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/cda67765
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/cda67765
Branch: refs/heads/YARN-4752
Commit: cda677655b80ce8e58cdb75aa0e106d033d6d361
Parents: e3b5c48
Author: Karthik Kambatla <ka...@cloudera.com>
Authored: Tue Nov 8 18:09:23 2016 -0800
Committer: Karthik Kambatla <ka...@cloudera.com>
Committed: Thu Nov 10 14:48:15 2016 -0800
----------------------------------------------------------------------
.../scheduler/SchedulerApplicationAttempt.java | 16 ++
.../scheduler/common/fica/FiCaSchedulerApp.java | 16 ++
.../scheduler/fair/FSAppAttempt.java | 16 ++
.../scheduler/fair/FSPreemptionThread.java | 2 +-
.../scheduler/fair/FSStarvedApps.java | 56 +++--
.../scheduler/fair/FairScheduler.java | 7 +-
.../fair/FairSchedulerWithMockPreemption.java | 58 +++++
.../scheduler/fair/TestFSAppStarvation.java | 245 +++++++++++++++++++
8 files changed, 391 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/cda67765/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
index bb1d461..8b3f60c 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
@@ -1253,6 +1253,22 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
unconfirmedAllocatedVcores.addAndGet(-res.getVirtualCores());
}
+ @Override
+ public int hashCode() {
+ return getApplicationAttemptId().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (! (o instanceof SchedulerApplicationAttempt)) {
+ return false;
+ }
+
+ SchedulerApplicationAttempt other = (SchedulerApplicationAttempt) o;
+ return (this == other ||
+ this.getApplicationAttemptId().equals(other.getApplicationAttemptId()));
+ }
+
/**
* Different state for Application Master, user can see this state from web UI
*/
http://git-wip-us.apache.org/repos/asf/hadoop/blob/cda67765/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java
index 6d9dda8..636d5b4 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java
@@ -1100,4 +1100,20 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
}
}
}
+
+ /*
+ * Overriding to appease findbugs
+ */
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ /*
+ * Overriding to appease findbugs
+ */
+ @Override
+ public boolean equals(Object o) {
+ return super.equals(o);
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/cda67765/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
index 8b4627e..3f699b5 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
@@ -1181,4 +1181,20 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
updateAMContainerDiagnostics(AMState.INACTIVATED,
diagnosticMessageBldr.toString());
}
+
+ /*
+ * Overriding to appease findbugs
+ */
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ /*
+ * Overriding to appease findbugs
+ */
+ @Override
+ public boolean equals(Object o) {
+ return super.equals(o);
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/cda67765/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSPreemptionThread.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSPreemptionThread.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSPreemptionThread.java
index 3732086..905b6f2 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSPreemptionThread.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSPreemptionThread.java
@@ -38,7 +38,7 @@ import java.util.TimerTask;
*/
public class FSPreemptionThread extends Thread {
private static final Log LOG = LogFactory.getLog(FSPreemptionThread.class);
- private final FSContext context;
+ protected final FSContext context;
private final FairScheduler scheduler;
private final long warnTimeBeforeKill;
private final Timer preemptionTimer;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/cda67765/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSStarvedApps.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSStarvedApps.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSStarvedApps.java
index 670a12d..4f28e41 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSStarvedApps.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSStarvedApps.java
@@ -17,7 +17,6 @@
*/
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair;
-import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.yarn.util.resource.Resources;
import java.io.Serializable;
@@ -25,28 +24,49 @@ import java.util.Comparator;
import java.util.concurrent.PriorityBlockingQueue;
/**
- * Helper class to track starved apps.
+ * Helper class to track starved applications.
*
* Initially, this uses a blocking queue. We could use other data structures
* in the future. This class also has some methods to simplify testing.
*/
-public class FSStarvedApps {
- private int numAppsAddedSoFar;
- private PriorityBlockingQueue<FSAppAttempt> apps;
+class FSStarvedApps {
- public FSStarvedApps() {
- apps = new PriorityBlockingQueue<>(10, new StarvationComparator());
+ // List of apps to be processed by the preemption thread.
+ private PriorityBlockingQueue<FSAppAttempt> appsToProcess;
+
+ // App being currently processed. This assumes a single reader.
+ private FSAppAttempt appBeingProcessed;
+
+ FSStarvedApps() {
+ appsToProcess = new PriorityBlockingQueue<>(10, new StarvationComparator());
}
- public void addStarvedApp(FSAppAttempt app) {
- if (!apps.contains(app)) {
- apps.add(app);
- numAppsAddedSoFar++;
+ /**
+ * Add a starved application if it is not already added.
+ * @param app application to add
+ */
+ void addStarvedApp(FSAppAttempt app) {
+ if (!app.equals(appBeingProcessed) && !appsToProcess.contains(app)) {
+ appsToProcess.add(app);
}
}
- public FSAppAttempt take() throws InterruptedException {
- return apps.take();
+ /**
+ * Blocking call to fetch the next app to process. The returned app is
+ * tracked until the next call to this method. This tracking assumes a
+ * single reader.
+ *
+ * @return starved application to process
+ * @throws InterruptedException if interrupted while waiting
+ */
+ FSAppAttempt take() throws InterruptedException {
+ // Reset appBeingProcessed before the blocking call
+ appBeingProcessed = null;
+
+ // Blocking call to fetch the next starved application
+ FSAppAttempt app = appsToProcess.take();
+ appBeingProcessed = app;
+ return app;
}
private static class StarvationComparator implements
@@ -62,14 +82,4 @@ public class FSStarvedApps {
return ret;
}
}
-
- @VisibleForTesting
- public int getNumAppsAddedSoFar() {
- return numAppsAddedSoFar;
- }
-
- @VisibleForTesting
- public int numStarvedApps() {
- return apps.size();
- }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/cda67765/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java
index f408e24..abe8a6a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java
@@ -1244,7 +1244,7 @@ public class FairScheduler extends
}
if (this.conf.getPreemptionEnabled()) {
- preemptionThread = new FSPreemptionThread(this);
+ createPreemptionThread();
}
} finally {
writeLock.unlock();
@@ -1262,6 +1262,11 @@ public class FairScheduler extends
}
}
+ @VisibleForTesting
+ protected void createPreemptionThread() {
+ preemptionThread = new FSPreemptionThread(this);
+ }
+
private void updateReservationThreshold() {
Resource newThreshold = Resources.multiply(
getIncrementResourceCapability(),
http://git-wip-us.apache.org/repos/asf/hadoop/blob/cda67765/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerWithMockPreemption.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerWithMockPreemption.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerWithMockPreemption.java
new file mode 100644
index 0000000..25780cd
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerWithMockPreemption.java
@@ -0,0 +1,58 @@
+/**
+ * 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.scheduler.fair;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class FairSchedulerWithMockPreemption extends FairScheduler {
+ @Override
+ protected void createPreemptionThread() {
+ preemptionThread = new MockPreemptionThread(this);
+ }
+
+ static class MockPreemptionThread extends FSPreemptionThread {
+ private Set<FSAppAttempt> appsAdded = new HashSet<>();
+ private int totalAppsAdded = 0;
+
+ MockPreemptionThread(FairScheduler scheduler) {
+ super(scheduler);
+ }
+
+ @Override
+ public void run() {
+ while (!Thread.interrupted()) {
+ try {
+ FSAppAttempt app = context.getStarvedApps().take();
+ appsAdded.add(app);
+ totalAppsAdded++;
+ } catch (InterruptedException e) {
+ return;
+ }
+ }
+ }
+
+ int uniqueAppsAdded() {
+ return appsAdded.size();
+ }
+
+ int totalAppsAdded() {
+ return totalAppsAdded;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/cda67765/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSAppStarvation.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSAppStarvation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSAppStarvation.java
new file mode 100644
index 0000000..0e5511b
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSAppStarvation.java
@@ -0,0 +1,245 @@
+/**
+ * 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.scheduler.fair;
+
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.server.resourcemanager.MockNodes;
+import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSchedulerEvent;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
+
+import org.apache.hadoop.yarn.util.resource.Resources;
+import org.junit.After;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Test class to verify identification of app starvation
+ */
+public class TestFSAppStarvation extends FairSchedulerTestBase {
+
+ private static final File ALLOC_FILE = new File(TEST_DIR, "test-queues");
+ private final List<RMNode> rmNodes = new ArrayList<>();
+
+ // Node Capacity = NODE_CAPACITY_MULTIPLE * (1 GB or 1 vcore)
+ private static final int NODE_CAPACITY_MULTIPLE = 4;
+
+ private FairSchedulerWithMockPreemption.MockPreemptionThread preemptionThread;
+
+ @Before
+ public void setup() {
+ createConfiguration();
+ conf.set(YarnConfiguration.RM_SCHEDULER,
+ FairSchedulerWithMockPreemption.class.getCanonicalName());
+ conf.set(FairSchedulerConfiguration.ALLOCATION_FILE,
+ ALLOC_FILE.getAbsolutePath());
+ conf.setBoolean(FairSchedulerConfiguration.PREEMPTION, true);
+ conf.setFloat(FairSchedulerConfiguration.PREEMPTION_THRESHOLD, 0f);
+ }
+
+ @After
+ public void teardown() {
+ ALLOC_FILE.delete();
+ conf = null;
+ if (resourceManager != null) {
+ resourceManager.stop();
+ resourceManager = null;
+ }
+ }
+
+ /*
+ * Test to verify application starvation is computed only when preemption
+ * is enabled.
+ */
+ @Test
+ public void testPreemptionDisabled() throws Exception {
+ conf.setBoolean(FairSchedulerConfiguration.PREEMPTION, false);
+
+ setupClusterAndSubmitJobs();
+
+ assertNull("Found starved apps even when preemption is turned off",
+ scheduler.getContext().getStarvedApps());
+ }
+
+ /*
+ * Test to verify application starvation is computed correctly when
+ * preemption is turned on.
+ */
+ @Test
+ public void testPreemptionEnabled() throws Exception {
+ setupClusterAndSubmitJobs();
+
+ assertNotNull("FSContext does not have an FSStarvedApps instance",
+ scheduler.getContext().getStarvedApps());
+ assertEquals("Expecting 2 starved applications, one each for the " +
+ "minshare and fairshare queues", 2,
+ preemptionThread.uniqueAppsAdded());
+
+ // Verify the apps get added again on a subsequent update
+ scheduler.update();
+ Thread.yield();
+ assertTrue("Each app is marked as starved exactly once",
+ preemptionThread.totalAppsAdded() > preemptionThread.uniqueAppsAdded());
+ }
+
+ /*
+ * Test to verify app starvation is computed only when the cluster
+ * utilization threshold is over the preemption threshold.
+ */
+ @Test
+ public void testClusterUtilizationThreshold() throws Exception {
+ // Set preemption threshold to 1.1, so the utilization is always lower
+ conf.setFloat(FairSchedulerConfiguration.PREEMPTION_THRESHOLD, 1.1f);
+
+ setupClusterAndSubmitJobs();
+
+ assertNotNull("FSContext does not have an FSStarvedApps instance",
+ scheduler.getContext().getStarvedApps());
+ assertEquals("Found starved apps when preemption threshold is over 100%", 0,
+ preemptionThread.totalAppsAdded());
+ }
+
+ private void setupClusterAndSubmitJobs() throws Exception {
+ setupStarvedCluster();
+ submitAppsToEachLeafQueue();
+ sendNodeUpdateEvents();
+
+ // Sleep to hit the preemption timeouts
+ Thread.sleep(10);
+
+ // Scheduler update to populate starved apps
+ scheduler.update();
+
+ // Wait for apps to be processed by MockPreemptionThread
+ Thread.yield();
+ }
+
+ /**
+ * Setup the cluster for starvation testing:
+ * 1. Create FS allocation file
+ * 2. Create and start MockRM
+ * 3. Add two nodes to the cluster
+ * 4. Submit an app that uses up all resources on the cluster
+ */
+ private void setupStarvedCluster() throws IOException {
+ PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
+ out.println("<?xml version=\"1.0\"?>");
+ out.println("<allocations>");
+
+ // Default queue
+ out.println("<queue name=\"default\">");
+ out.println("</queue>");
+
+ // Queue with preemption disabled
+ out.println("<queue name=\"no-preemption\">");
+ out.println("<fairSharePreemptionThreshold>0" +
+ "</fairSharePreemptionThreshold>");
+ out.println("</queue>");
+
+ // Queue with minshare preemption enabled
+ out.println("<queue name=\"minshare\">");
+ out.println("<fairSharePreemptionThreshold>0" +
+ "</fairSharePreemptionThreshold>");
+ out.println("<minSharePreemptionTimeout>0" +
+ "</minSharePreemptionTimeout>");
+ out.println("<minResources>2048mb,2vcores</minResources>");
+ out.println("</queue>");
+
+ // Queue with fairshare preemption enabled
+ out.println("<queue name=\"fairshare\">");
+ out.println("<fairSharePreemptionThreshold>1" +
+ "</fairSharePreemptionThreshold>");
+ out.println("<fairSharePreemptionTimeout>0" +
+ "</fairSharePreemptionTimeout>");
+
+ // Child queue under fairshare with same settings
+ out.println("<queue name=\"child\">");
+ out.println("<fairSharePreemptionThreshold>1" +
+ "</fairSharePreemptionThreshold>");
+ out.println("<fairSharePreemptionTimeout>0" +
+ "</fairSharePreemptionTimeout>");
+ out.println("</queue>");
+
+ out.println("</queue>");
+
+ out.println("</allocations>");
+ out.close();
+
+ assertTrue("Allocation file does not exist, not running the test",
+ ALLOC_FILE.exists());
+
+ resourceManager = new MockRM(conf);
+ resourceManager.start();
+ scheduler = (FairScheduler) resourceManager.getResourceScheduler();
+ preemptionThread = (FairSchedulerWithMockPreemption.MockPreemptionThread)
+ scheduler.preemptionThread;
+
+ // Create and add two nodes to the cluster
+ addNode(NODE_CAPACITY_MULTIPLE * 1024, NODE_CAPACITY_MULTIPLE);
+ addNode(NODE_CAPACITY_MULTIPLE * 1024, NODE_CAPACITY_MULTIPLE);
+
+ // Create an app that takes up all the resources on the cluster
+ ApplicationAttemptId app
+ = createSchedulingRequest(1024, 1, "root.default", "default", 8);
+
+ scheduler.update();
+ sendNodeUpdateEvents();
+
+ assertEquals(8, scheduler.getSchedulerApp(app).getLiveContainers().size());
+ }
+
+ private void submitAppsToEachLeafQueue() {
+ String queues[] = {"no-preemption", "minshare", "fairshare.child"};
+ for (String queue : queues) {
+ createSchedulingRequest(1024, 1, "root." + queue, "user", 1);
+ }
+ scheduler.update();
+ }
+
+ private void addNode(int memory, int cores) {
+ int id = rmNodes.size() + 1;
+ RMNode node =
+ MockNodes.newNodeInfo(1, Resources.createResource(memory, cores), id,
+ "127.0.0." + id);
+ scheduler.handle(new NodeAddedSchedulerEvent(node));
+ rmNodes.add(node);
+ }
+
+ private void sendNodeUpdateEvents() {
+ for (RMNode node : rmNodes) {
+ NodeUpdateSchedulerEvent nodeUpdateSchedulerEvent =
+ new NodeUpdateSchedulerEvent(node);
+ for (int i = 0; i < NODE_CAPACITY_MULTIPLE; i++) {
+ scheduler.handle(nodeUpdateSchedulerEvent);
+ }
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[36/50] [abbrv] hadoop git commit: YARN-4498. Application level node
labels stats to be available in REST (addendum patch). Contributed by Bibin A
Chundatt.
Posted by ka...@apache.org.
YARN-4498. Application level node labels stats to be available in REST (addendum patch). Contributed by Bibin A Chundatt.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/edbee9e6
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/edbee9e6
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/edbee9e6
Branch: refs/heads/YARN-4752
Commit: edbee9e609e7f31d188660717ff9d3fb9f606abb
Parents: 59ee8b7
Author: Naganarasimha <na...@apache.org>
Authored: Thu Nov 10 05:00:05 2016 +0530
Committer: Naganarasimha <na...@apache.org>
Committed: Thu Nov 10 05:00:05 2016 +0530
----------------------------------------------------------------------
.../server/resourcemanager/webapp/dao/AppInfo.java | 4 ++--
.../webapp/TestRMWebServiceAppsNodelabel.java | 14 +++++++++-----
2 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/edbee9e6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java
index 3bd6cff..19cbe43 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java
@@ -111,7 +111,7 @@ public class AppInfo {
protected String appNodeLabelExpression;
protected String amNodeLabelExpression;
- protected ResourcesInfo resourceInfo;
+ protected ResourcesInfo resourceInfo = null;
public AppInfo() {
} // JAXB needs this
@@ -232,7 +232,7 @@ public class AppInfo {
.getApplicationAttempt(attempt.getAppAttemptId());
resourceInfo = null != ficaAppAttempt
? new ResourcesInfo(ficaAppAttempt.getSchedulingResourceUsage())
- : new ResourcesInfo();
+ : null;
}
}
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/edbee9e6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServiceAppsNodelabel.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServiceAppsNodelabel.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServiceAppsNodelabel.java
index a931b0b..25a712c 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServiceAppsNodelabel.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServiceAppsNodelabel.java
@@ -19,10 +19,11 @@
package org.apache.hadoop.yarn.server.resourcemanager.webapp;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import javax.ws.rs.core.MediaType;
@@ -153,10 +154,13 @@ public class TestRMWebServiceAppsNodelabel extends JerseyTestBase {
JSONObject json = response.getEntity(JSONObject.class);
JSONObject apps = json.getJSONObject("apps");
assertEquals("incorrect number of elements", 1, apps.length());
- JSONObject jsonObject =
- apps.getJSONArray("app").getJSONObject(0).getJSONObject("resourceInfo");
- Iterator<?> keys = jsonObject.keys();
- assertEquals("For finshed app no values expected", false, keys.hasNext());
+ try {
+ apps.getJSONArray("app").getJSONObject(0).getJSONObject("resourceInfo");
+ fail("resourceInfo object shouldnt be available for finished apps");
+ } catch (Exception e) {
+ assertTrue("resourceInfo shouldn't be available for finished apps",
+ true);
+ }
rm.stop();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[29/50] [abbrv] hadoop git commit: YARN-5736. YARN container executor
config does not handle white space (miklos.szegedi@cloudera.com via rkanter)
Posted by ka...@apache.org.
YARN-5736. YARN container executor config does not handle white space (miklos.szegedi@cloudera.com via rkanter)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/09f43fa9
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/09f43fa9
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/09f43fa9
Branch: refs/heads/YARN-4752
Commit: 09f43fa9c089ebfc18401ce84755d3f2000ba033
Parents: 283fa33
Author: Robert Kanter <rk...@apache.org>
Authored: Wed Nov 9 13:34:40 2016 +0100
Committer: Robert Kanter <rk...@apache.org>
Committed: Wed Nov 9 13:34:40 2016 +0100
----------------------------------------------------------------------
.../container-executor/impl/configuration.c | 41 +++++++++--
.../container-executor/impl/configuration.h | 9 +++
.../main/native/container-executor/impl/main.c | 5 +-
.../test/test-container-executor.c | 77 +++++++++++++++++++-
4 files changed, 123 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/09f43fa9/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/configuration.c
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/configuration.c b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/configuration.c
index 69ceaf6..8da7d24 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/configuration.c
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/configuration.c
@@ -31,6 +31,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <limits.h>
+#include <ctype.h>
#define MAX_SIZE 10
@@ -126,6 +127,37 @@ int check_configuration_permissions(const char* file_name) {
return 0;
}
+/**
+ * Trim whitespace from beginning and end.
+*/
+char* trim(char* input)
+{
+ char *val_begin;
+ char *val_end;
+ char *ret;
+
+ if (input == NULL) {
+ return NULL;
+ }
+
+ val_begin = input;
+ val_end = input + strlen(input);
+
+ while (val_begin < val_end && isspace(*val_begin))
+ val_begin++;
+ while (val_end > val_begin && isspace(*(val_end - 1)))
+ val_end--;
+
+ ret = (char *) malloc(
+ sizeof(char) * (val_end - val_begin + 1));
+ if (ret == NULL) {
+ fprintf(ERRORFILE, "Allocation error\n");
+ exit(OUT_OF_MEMORY);
+ }
+
+ strncpy(ret, val_begin, val_end - val_begin);
+ return ret;
+}
void read_config(const char* file_name, struct configuration *cfg) {
FILE *conf_file;
@@ -202,9 +234,8 @@ void read_config(const char* file_name, struct configuration *cfg) {
#endif
memset(cfg->confdetails[cfg->size], 0, sizeof(struct confentry));
- cfg->confdetails[cfg->size]->key = (char *) malloc(
- sizeof(char) * (strlen(equaltok)+1));
- strcpy((char *)cfg->confdetails[cfg->size]->key, equaltok);
+ cfg->confdetails[cfg->size]->key = trim(equaltok);
+
equaltok = strtok_r(NULL, "=", &temp_equaltok);
if (equaltok == NULL) {
fprintf(LOGFILE, "configuration tokenization failed \n");
@@ -222,9 +253,7 @@ void read_config(const char* file_name, struct configuration *cfg) {
fprintf(LOGFILE, "read_config : Adding conf value : %s \n", equaltok);
#endif
- cfg->confdetails[cfg->size]->value = (char *) malloc(
- sizeof(char) * (strlen(equaltok)+1));
- strcpy((char *)cfg->confdetails[cfg->size]->value, equaltok);
+ cfg->confdetails[cfg->size]->value = trim(equaltok);
if((cfg->size + 1) % MAX_SIZE == 0) {
cfg->confdetails = (struct confentry **) realloc(cfg->confdetails,
sizeof(struct confentry **) * (MAX_SIZE + cfg->size));
http://git-wip-us.apache.org/repos/asf/hadoop/blob/09f43fa9/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/configuration.h
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/configuration.h b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/configuration.h
index eced13b..2d14867 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/configuration.h
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/configuration.h
@@ -105,3 +105,12 @@ int get_kv_key(const char *input, char *out, size_t out_len);
* 0 on success
*/
int get_kv_value(const char *input, char *out, size_t out_len);
+
+/**
+ * Trim whitespace from beginning and end.
+ *
+ * @param input Input string that needs to be trimmed
+ *
+ * @return the trimmed string allocated with malloc. I has to be freed by the caller
+*/
+char* trim(char* input);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/09f43fa9/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/main.c
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/main.c b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/main.c
index 47bb3b9..fdc0496 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/main.c
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/main.c
@@ -143,7 +143,8 @@ static void assert_valid_setup(char *argv0) {
int ret;
char *executable_file = get_executable(argv0);
if (!executable_file) {
- fprintf(ERRORFILE,"realpath of executable: %s\n",strerror(errno));
+ fprintf(ERRORFILE,"realpath of executable: %s\n",
+ errno != 0 ? strerror(errno) : "unknown");
flush_and_close_log_files();
exit(-1);
}
@@ -178,7 +179,7 @@ static void assert_valid_setup(char *argv0) {
if (group_info == NULL) {
free(executable_file);
fprintf(ERRORFILE, "Can't get group information for %s - %s.\n", nm_group,
- strerror(errno));
+ errno != 0 ? strerror(errno) : "unknown");
flush_and_close_log_files();
exit(INVALID_CONFIG_FILE);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/09f43fa9/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c
index f7d4975..0c9e496 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c
@@ -565,7 +565,7 @@ void test_list_as_user() {
}
// Test with empty dir string
- sprintf(buffer, "");
+ strcpy(buffer, "");
int ret = list_as_user(buffer);
if (ret == 0) {
@@ -1051,6 +1051,77 @@ void test_dir_permissions() {
free(container_dir);
}
+/**
+ * This test is used to verify that trim() works correctly
+ */
+void test_trim_function() {
+ char* trimmed = NULL;
+
+ printf("\nTesting trim function\n");
+
+ // Check NULL input
+ if (trim(NULL) != NULL) {
+ printf("FAIL: trim(NULL) should be NULL\n");
+ exit(1);
+ }
+
+ // Check empty input
+ trimmed = trim("");
+ if (strcmp(trimmed, "") != 0) {
+ printf("FAIL: trim(\"\") should be \"\"\n");
+ exit(1);
+ }
+ free(trimmed);
+
+ // Check single space input
+ trimmed = trim(" ");
+ if (strcmp(trimmed, "") != 0) {
+ printf("FAIL: trim(\" \") should be \"\"\n");
+ exit(1);
+ }
+ free(trimmed);
+
+ // Check multi space input
+ trimmed = trim(" ");
+ if (strcmp(trimmed, "") != 0) {
+ printf("FAIL: trim(\" \") should be \"\"\n");
+ exit(1);
+ }
+ free(trimmed);
+
+ // Check both side trim input
+ trimmed = trim(" foo ");
+ if (strcmp(trimmed, "foo") != 0) {
+ printf("FAIL: trim(\" foo \") should be \"foo\"\n");
+ exit(1);
+ }
+ free(trimmed);
+
+ // Check left side trim input
+ trimmed = trim("foo ");
+ if (strcmp(trimmed, "foo") != 0) {
+ printf("FAIL: trim(\"foo \") should be \"foo\"\n");
+ exit(1);
+ }
+ free(trimmed);
+
+ // Check right side trim input
+ trimmed = trim(" foo");
+ if (strcmp(trimmed, "foo") != 0) {
+ printf("FAIL: trim(\" foo\") should be \"foo\"\n");
+ exit(1);
+ }
+ free(trimmed);
+
+ // Check no trim input
+ trimmed = trim("foo");
+ if (strcmp(trimmed, "foo") != 0) {
+ printf("FAIL: trim(\"foo\") should be \"foo\"\n");
+ exit(1);
+ }
+ free(trimmed);
+}
+
// This test is expected to be executed either by a regular
// user or by root. If executed by a regular user it doesn't
// test all the functions that would depend on changing the
@@ -1218,9 +1289,13 @@ int main(int argc, char **argv) {
#endif
run("rm -fr " TEST_ROOT);
+
+ test_trim_function();
+
printf("\nFinished tests\n");
free(current_username);
free_executor_configurations();
+
return 0;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[26/50] [abbrv] hadoop git commit: HDFS-11083. Add unit test for
DFSAdmin -report command. Contributed by Xiaobing Zhou
Posted by ka...@apache.org.
HDFS-11083. Add unit test for DFSAdmin -report command. Contributed by Xiaobing Zhou
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/62d8c17d
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/62d8c17d
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/62d8c17d
Branch: refs/heads/YARN-4752
Commit: 62d8c17dfda75a6a6de06aedad2f22699a1cbad6
Parents: e1c6ef2
Author: Mingliang Liu <li...@apache.org>
Authored: Tue Nov 8 17:04:25 2016 -0800
Committer: Mingliang Liu <li...@apache.org>
Committed: Tue Nov 8 17:04:30 2016 -0800
----------------------------------------------------------------------
.../apache/hadoop/hdfs/tools/TestDFSAdmin.java | 140 +++++++++++++++++++
1 file changed, 140 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/62d8c17d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdmin.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdmin.java
index c7ba9d2..9486bd1 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdmin.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdmin.java
@@ -26,13 +26,22 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HEARTBEAT_RECHEC
import com.google.common.base.Supplier;
import com.google.common.collect.Lists;
+import org.apache.commons.lang.text.StrBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.ReconfigurationUtil;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.DFSClient;
import org.apache.hadoop.hdfs.DFSConfigKeys;
+import org.apache.hadoop.hdfs.DFSTestUtil;
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
+import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
+import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockManagerTestUtil;
import org.apache.hadoop.hdfs.server.common.Storage;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
import org.apache.hadoop.hdfs.server.datanode.StorageLocation;
@@ -452,4 +461,135 @@ public class TestDFSAdmin {
assertThat(outs.get(offset + 2),
is(allOf(containsString("To:"), containsString("6"))));
}
+
+ private static String scanIntoString(final ByteArrayOutputStream baos) {
+ final StrBuilder sb = new StrBuilder();
+ final Scanner scanner = new Scanner(baos.toString());
+ while (scanner.hasNextLine()) {
+ sb.appendln(scanner.nextLine());
+ }
+ scanner.close();
+ return sb.toString();
+ }
+
+ @Test(timeout = 30000)
+ public void testReportCommand() throws Exception {
+ redirectStream();
+
+ /* init conf */
+ final Configuration dfsConf = new HdfsConfiguration();
+ dfsConf.setInt(
+ DFSConfigKeys.DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY,
+ 500); // 0.5s
+ dfsConf.setLong(DFS_HEARTBEAT_INTERVAL_KEY, 1);
+ final Path baseDir = new Path(
+ PathUtils.getTestDir(getClass()).getAbsolutePath(),
+ GenericTestUtils.getMethodName());
+ dfsConf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, baseDir.toString());
+
+ final int numDn = 3;
+
+ /* init cluster */
+ try(MiniDFSCluster miniCluster = new MiniDFSCluster
+ .Builder(dfsConf)
+ .numDataNodes(numDn).build()) {
+
+ miniCluster.waitActive();
+ assertEquals(numDn, miniCluster.getDataNodes().size());
+
+ /* local vars */
+ final DFSAdmin dfsAdmin = new DFSAdmin(dfsConf);
+ final DFSClient client = miniCluster.getFileSystem().getClient();
+
+ /* run and verify report command */
+ resetStream();
+ assertEquals(0, ToolRunner.run(dfsAdmin, new String[] {"-report"}));
+ verifyNodesAndCorruptBlocks(numDn, numDn, 0, client);
+
+ /* shut down one DN */
+ final List<DataNode> datanodes = miniCluster.getDataNodes();
+ final DataNode last = datanodes.get(datanodes.size() - 1);
+ last.shutdown();
+ miniCluster.setDataNodeDead(last.getDatanodeId());
+
+ /* run and verify report command */
+ assertEquals(0, ToolRunner.run(dfsAdmin, new String[] {"-report"}));
+ verifyNodesAndCorruptBlocks(numDn, numDn - 1, 0, client);
+
+ /* corrupt one block */
+ final short replFactor = 1;
+ final long fileLength = 512L;
+ final FileSystem fs = miniCluster.getFileSystem();
+ final Path file = new Path(baseDir, "/corrupted");
+ DFSTestUtil.createFile(fs, file, fileLength, replFactor, 12345L);
+ DFSTestUtil.waitReplication(fs, file, replFactor);
+
+ final ExtendedBlock block = DFSTestUtil.getFirstBlock(fs, file);
+ final int blockFilesCorrupted = miniCluster
+ .corruptBlockOnDataNodes(block);
+ assertEquals("Fail to corrupt all replicas for block " + block,
+ replFactor, blockFilesCorrupted);
+
+ /*
+ * Increase replication factor, this should invoke transfer request.
+ * Receiving datanode fails on checksum and reports it to namenode
+ */
+ fs.setReplication(file, (short) (replFactor + 1));
+
+ /* get block details and check if the block is corrupt */
+ GenericTestUtils.waitFor(new Supplier<Boolean>() {
+ @Override
+ public Boolean get() {
+ LocatedBlocks blocks = null;
+ try {
+ blocks = client.getNamenode().getBlockLocations(file.toString(), 0,
+ Long.MAX_VALUE);
+ } catch (IOException e) {
+ return false;
+ }
+ return blocks != null && blocks.get(0).isCorrupt();
+ }
+ }, 100, 60000);
+
+ BlockManagerTestUtil.updateState(
+ miniCluster.getNameNode().getNamesystem().getBlockManager());
+
+ /* run and verify report command */
+ resetStream();
+ assertEquals(0, ToolRunner.run(dfsAdmin, new String[] {"-report"}));
+ verifyNodesAndCorruptBlocks(numDn, numDn - 1, 1, client);
+ }
+ }
+
+ private void verifyNodesAndCorruptBlocks(
+ final int numDn,
+ final int numLiveDn,
+ final int numCorruptBlocks,
+ final DFSClient client) throws IOException {
+
+ /* init vars */
+ final String outStr = scanIntoString(out);
+ final String expectedLiveNodesStr = String.format(
+ "Live datanodes (%d)",
+ numLiveDn);
+ final String expectedCorruptedBlocksStr = String.format(
+ "Blocks with corrupt replicas: %d",
+ numCorruptBlocks);
+
+ /* verify nodes and corrupt blocks */
+ assertThat(outStr, is(allOf(
+ containsString(expectedLiveNodesStr),
+ containsString(expectedCorruptedBlocksStr))));
+
+ assertEquals(
+ numDn,
+ client.getDatanodeStorageReport(DatanodeReportType.ALL).length);
+ assertEquals(
+ numLiveDn,
+ client.getDatanodeStorageReport(DatanodeReportType.LIVE).length);
+ assertEquals(
+ numDn - numLiveDn,
+ client.getDatanodeStorageReport(DatanodeReportType.DEAD).length);
+ assertEquals(numCorruptBlocks, client.getCorruptBlocksCount());
+ }
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[06/50] [abbrv] hadoop git commit: HADOOP-13798. TestHadoopArchives
times out.
Posted by ka...@apache.org.
HADOOP-13798. TestHadoopArchives times out.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b970446b
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b970446b
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b970446b
Branch: refs/heads/YARN-4752
Commit: b970446b2c59f8897bb2c3a562fa192ed3452db5
Parents: ca33bdd
Author: Akira Ajisaka <aa...@apache.org>
Authored: Mon Nov 7 19:53:43 2016 +0900
Committer: Akira Ajisaka <aa...@apache.org>
Committed: Mon Nov 7 19:53:43 2016 +0900
----------------------------------------------------------------------
.../src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/b970446b/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java b/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java
index 165c515..e9ecf04 100644
--- a/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java
+++ b/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java
@@ -444,7 +444,7 @@ public class TestHadoopArchives {
int read;
while (true) {
read = fsdis.read(buffer, readIntoBuffer, buffer.length - readIntoBuffer);
- if (read < 0) {
+ if (read <= 0) {
// end of stream:
if (readIntoBuffer > 0) {
baos.write(buffer, 0, readIntoBuffer);
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[32/50] [abbrv] hadoop git commit: HADOOP-13590. Retry until TGT
expires even if the UGI renewal thread encountered exception.
Posted by ka...@apache.org.
HADOOP-13590. Retry until TGT expires even if the UGI renewal thread encountered exception.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/367c3d41
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/367c3d41
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/367c3d41
Branch: refs/heads/YARN-4752
Commit: 367c3d41217728c2e61252c5a5235e5bc1f9822f
Parents: 280357c
Author: Xiao Chen <xi...@apache.org>
Authored: Wed Nov 9 09:07:12 2016 -0800
Committer: Xiao Chen <xi...@apache.org>
Committed: Wed Nov 9 09:07:12 2016 -0800
----------------------------------------------------------------------
.../hadoop/security/UserGroupInformation.java | 70 ++++++++-
.../hadoop/security/TestUGIWithMiniKdc.java | 144 +++++++++++++++++++
.../security/TestUserGroupInformation.java | 93 ++++++++++++
3 files changed, 303 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/367c3d41/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java
index 111c3f8..82603a4 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java
@@ -43,6 +43,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;
@@ -54,14 +55,18 @@ import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
+import org.apache.hadoop.io.retry.RetryPolicies;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.retry.RetryPolicy;
import org.apache.hadoop.metrics2.annotation.Metric;
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+import org.apache.hadoop.metrics2.lib.MutableGaugeInt;
+import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
import org.apache.hadoop.metrics2.lib.MutableQuantiles;
import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.security.SaslRpcServer.AuthMethod;
@@ -85,7 +90,8 @@ import org.slf4j.LoggerFactory;
@InterfaceAudience.LimitedPrivate({"HDFS", "MapReduce", "HBase", "Hive", "Oozie"})
@InterfaceStability.Evolving
public class UserGroupInformation {
- private static final Logger LOG = LoggerFactory.getLogger(
+ @VisibleForTesting
+ static final Logger LOG = LoggerFactory.getLogger(
UserGroupInformation.class);
/**
@@ -121,6 +127,10 @@ public class UserGroupInformation {
MutableRate loginFailure;
@Metric("GetGroups") MutableRate getGroups;
MutableQuantiles[] getGroupsQuantiles;
+ @Metric("Renewal failures since startup")
+ private MutableGaugeLong renewalFailuresTotal;
+ @Metric("Renewal failures since last successful login")
+ private MutableGaugeInt renewalFailures;
static UgiMetrics create() {
return DefaultMetricsSystem.instance().register(new UgiMetrics());
@@ -138,6 +148,10 @@ public class UserGroupInformation {
}
}
}
+
+ MutableGaugeInt getRenewalFailures() {
+ return renewalFailures;
+ }
}
/**
@@ -963,6 +977,7 @@ public class UserGroupInformation {
return;
}
long nextRefresh = getRefreshTime(tgt);
+ RetryPolicy rp = null;
while (true) {
try {
long now = Time.now();
@@ -986,13 +1001,40 @@ public class UserGroupInformation {
}
nextRefresh = Math.max(getRefreshTime(tgt),
now + kerberosMinSecondsBeforeRelogin);
+ metrics.renewalFailures.set(0);
+ rp = null;
} catch (InterruptedException ie) {
LOG.warn("Terminating renewal thread");
return;
} catch (IOException ie) {
- LOG.warn("Exception encountered while running the" +
- " renewal command. Aborting renew thread. " + ie);
- return;
+ metrics.renewalFailuresTotal.incr();
+ final long tgtEndTime = tgt.getEndTime().getTime();
+ LOG.warn("Exception encountered while running the renewal "
+ + "command for {}. (TGT end time:{}, renewalFailures: {},"
+ + "renewalFailuresTotal: {})", getUserName(), tgtEndTime,
+ metrics.renewalFailures, metrics.renewalFailuresTotal, ie);
+ final long now = Time.now();
+ if (rp == null) {
+ // Use a dummy maxRetries to create the policy. The policy will
+ // only be used to get next retry time with exponential back-off.
+ // The final retry time will be later limited within the
+ // tgt endTime in getNextTgtRenewalTime.
+ rp = RetryPolicies.exponentialBackoffRetry(Long.SIZE - 2,
+ kerberosMinSecondsBeforeRelogin, TimeUnit.MILLISECONDS);
+ }
+ try {
+ nextRefresh = getNextTgtRenewalTime(tgtEndTime, now, rp);
+ } catch (Exception e) {
+ LOG.error("Exception when calculating next tgt renewal time", e);
+ return;
+ }
+ metrics.renewalFailures.incr();
+ // retry until close enough to tgt endTime.
+ if (now > nextRefresh) {
+ LOG.error("TGT is expired. Aborting renew thread for {}.",
+ getUserName());
+ return;
+ }
}
}
}
@@ -1001,6 +1043,26 @@ public class UserGroupInformation {
t.setName("TGT Renewer for " + getUserName());
t.start();
}
+
+ /**
+ * Get time for next login retry. This will allow the thread to retry with
+ * exponential back-off, until tgt endtime.
+ * Last retry is {@link #kerberosMinSecondsBeforeRelogin} before endtime.
+ *
+ * @param tgtEndTime EndTime of the tgt.
+ * @param now Current time.
+ * @param rp The retry policy.
+ * @return Time for next login retry.
+ */
+ @VisibleForTesting
+ static long getNextTgtRenewalTime(final long tgtEndTime, final long now,
+ final RetryPolicy rp) throws Exception {
+ final long lastRetryTime = tgtEndTime - kerberosMinSecondsBeforeRelogin;
+ final RetryPolicy.RetryAction ra = rp.shouldRetry(null,
+ metrics.renewalFailures.value(), 0, false);
+ return Math.min(lastRetryTime, now + ra.delayMillis);
+ }
+
/**
* Log a user in from a keytab file. Loads a user identity from a keytab
* file and logs them in. They become the currently logged-in user.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/367c3d41/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUGIWithMiniKdc.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUGIWithMiniKdc.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUGIWithMiniKdc.java
new file mode 100644
index 0000000..0016a65
--- /dev/null
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUGIWithMiniKdc.java
@@ -0,0 +1,144 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.security;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.minikdc.MiniKdc;
+import org.apache.hadoop.security.authentication.util.KerberosUtil;
+import org.apache.hadoop.test.GenericTestUtils;
+import org.apache.hadoop.test.LambdaTestUtils;
+import org.apache.hadoop.util.PlatformName;
+import org.apache.log4j.Level;
+import org.junit.After;
+import org.junit.Test;
+
+import javax.security.auth.Subject;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.LoginContext;
+import java.io.File;
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN;
+
+/**
+ * Test {@link UserGroupInformation} with a minikdc.
+ */
+public class TestUGIWithMiniKdc {
+
+ private static MiniKdc kdc;
+
+ @After
+ public void teardown() {
+ UserGroupInformation.reset();
+ if (kdc != null) {
+ kdc.stop();
+ }
+ }
+
+ private void setupKdc() throws Exception {
+ Properties kdcConf = MiniKdc.createConf();
+ // tgt expire time = 30 seconds
+ kdcConf.setProperty(MiniKdc.MAX_TICKET_LIFETIME, "30");
+ kdcConf.setProperty(MiniKdc.MIN_TICKET_LIFETIME, "30");
+ File kdcDir = new File(System.getProperty("test.dir", "target"));
+ kdc = new MiniKdc(kdcConf, kdcDir);
+ kdc.start();
+ }
+
+ @Test(timeout = 120000)
+ public void testAutoRenewalThreadRetryWithKdc() throws Exception {
+ GenericTestUtils.setLogLevel(UserGroupInformation.LOG, Level.DEBUG);
+ final Configuration conf = new Configuration();
+ // Relogin every 1 second
+ conf.setLong(HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN, 1);
+ SecurityUtil.setAuthenticationMethod(
+ UserGroupInformation.AuthenticationMethod.KERBEROS, conf);
+ UserGroupInformation.setConfiguration(conf);
+
+ LoginContext loginContext = null;
+ try {
+ final String principal = "foo";
+ final File workDir = new File(System.getProperty("test.dir", "target"));
+ final File keytab = new File(workDir, "foo.keytab");
+ final Set<Principal> principals = new HashSet<>();
+ principals.add(new KerberosPrincipal(principal));
+ setupKdc();
+ kdc.createPrincipal(keytab, principal);
+
+ // client login
+ final Subject subject =
+ new Subject(false, principals, new HashSet<>(), new HashSet<>());
+
+ loginContext = new LoginContext("", subject, null,
+ new javax.security.auth.login.Configuration() {
+ @Override
+ public AppConfigurationEntry[] getAppConfigurationEntry(
+ String name) {
+ Map<String, String> options = new HashMap<>();
+ options.put("principal", principal);
+ options.put("refreshKrb5Config", "true");
+ if (PlatformName.IBM_JAVA) {
+ options.put("useKeytab", keytab.getPath());
+ options.put("credsType", "both");
+ } else {
+ options.put("keyTab", keytab.getPath());
+ options.put("useKeyTab", "true");
+ options.put("storeKey", "true");
+ options.put("doNotPrompt", "true");
+ options.put("useTicketCache", "true");
+ options.put("renewTGT", "true");
+ options.put("isInitiator", Boolean.toString(true));
+ }
+ String ticketCache = System.getenv("KRB5CCNAME");
+ if (ticketCache != null) {
+ options.put("ticketCache", ticketCache);
+ }
+ options.put("debug", "true");
+ return new AppConfigurationEntry[] {new AppConfigurationEntry(
+ KerberosUtil.getKrb5LoginModuleName(),
+ AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
+ options)};
+ }
+ });
+ loginContext.login();
+ final Subject loginSubject = loginContext.getSubject();
+ UserGroupInformation.loginUserFromSubject(loginSubject);
+
+ // Verify retry happens. Do not verify retry count to reduce flakiness.
+ // Detailed back-off logic is tested separately in
+ // TestUserGroupInformation#testGetNextRetryTime
+ LambdaTestUtils.await(30000, 500,
+ () -> {
+ final int count =
+ UserGroupInformation.metrics.getRenewalFailures().value();
+ UserGroupInformation.LOG.info("Renew failure count is {}", count);
+ return count > 0;
+ });
+ } finally {
+ if (loginContext != null) {
+ loginContext.logout();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/367c3d41/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUserGroupInformation.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUserGroupInformation.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUserGroupInformation.java
index a52cd46..ed0f58c 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUserGroupInformation.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUserGroupInformation.java
@@ -20,6 +20,8 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.retry.RetryPolicies;
+import org.apache.hadoop.io.retry.RetryPolicy;
import org.apache.hadoop.ipc.TestRpcBase.TestTokenIdentifier;
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
import org.apache.hadoop.security.SaslRpcServer.AuthMethod;
@@ -27,13 +29,18 @@ import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
import org.apache.hadoop.security.authentication.util.KerberosName;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
+import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.Shell;
import org.apache.hadoop.util.StringUtils;
+import org.apache.hadoop.util.Time;
+import org.apache.log4j.Level;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.security.auth.Subject;
import javax.security.auth.kerberos.KerberosPrincipal;
@@ -49,10 +56,13 @@ import java.lang.reflect.Method;
import java.security.PrivilegedExceptionAction;
import java.util.Collection;
import java.util.ConcurrentModificationException;
+import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import static org.apache.hadoop.fs.CommonConfigurationKeys.HADOOP_USER_GROUP_METRICS_PERCENTILES_INTERVALS;
+import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN;
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTH_TO_LOCAL;
import static org.apache.hadoop.test.MetricsAsserts.assertCounter;
import static org.apache.hadoop.test.MetricsAsserts.assertCounterGt;
@@ -74,6 +84,9 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class TestUserGroupInformation {
+
+ static final Logger LOG = LoggerFactory.getLogger(
+ TestUserGroupInformation.class);
final private static String USER_NAME = "user1@HADOOP.APACHE.ORG";
final private static String GROUP1_NAME = "group1";
final private static String GROUP2_NAME = "group2";
@@ -1027,6 +1040,86 @@ public class TestUserGroupInformation {
return null;
}
});
+ }
+
+ @Test
+ public void testGetNextRetryTime() throws Exception {
+ GenericTestUtils.setLogLevel(UserGroupInformation.LOG, Level.DEBUG);
+ final long reloginInterval = 1;
+ final long reloginIntervalMs = reloginInterval * 1000;
+ // Relogin happens every 1 second.
+ conf.setLong(HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN, reloginInterval);
+ SecurityUtil.setAuthenticationMethod(AuthenticationMethod.KERBEROS, conf);
+ UserGroupInformation.setConfiguration(conf);
+
+ // Suppose tgt start time is now, end time is 20 seconds from now.
+ final long now = Time.now();
+ final Date endDate = new Date(now + 20000);
+
+ // Explicitly test the exponential back-off logic.
+ // Suppose some time (10 seconds) passed.
+ // Verify exponential backoff and max=(login interval before endTime).
+ final long currentTime = now + 10000;
+ final long endTime = endDate.getTime();
+
+ assertEquals(0, UserGroupInformation.metrics.getRenewalFailures().value());
+ RetryPolicy rp = RetryPolicies.exponentialBackoffRetry(Long.SIZE - 2,
+ 1000, TimeUnit.MILLISECONDS);
+ long lastRetry =
+ UserGroupInformation.getNextTgtRenewalTime(endTime, currentTime, rp);
+ assertWithinBounds(
+ UserGroupInformation.metrics.getRenewalFailures().value(),
+ lastRetry, reloginIntervalMs, currentTime);
+
+ UserGroupInformation.metrics.getRenewalFailures().incr();
+ lastRetry =
+ UserGroupInformation.getNextTgtRenewalTime(endTime, currentTime, rp);
+ assertWithinBounds(
+ UserGroupInformation.metrics.getRenewalFailures().value(),
+ lastRetry, reloginIntervalMs, currentTime);
+
+ UserGroupInformation.metrics.getRenewalFailures().incr();
+ lastRetry =
+ UserGroupInformation.getNextTgtRenewalTime(endTime, currentTime, rp);
+ assertWithinBounds(
+ UserGroupInformation.metrics.getRenewalFailures().value(),
+ lastRetry, reloginIntervalMs, currentTime);
+
+ UserGroupInformation.metrics.getRenewalFailures().incr();
+ lastRetry =
+ UserGroupInformation.getNextTgtRenewalTime(endTime, currentTime, rp);
+ assertWithinBounds(
+ UserGroupInformation.metrics.getRenewalFailures().value(),
+ lastRetry, reloginIntervalMs, currentTime);
+
+ // last try should be right before expiry.
+ UserGroupInformation.metrics.getRenewalFailures().incr();
+ lastRetry =
+ UserGroupInformation.getNextTgtRenewalTime(endTime, currentTime, rp);
+ String str =
+ "5th retry, now:" + currentTime + ", retry:" + lastRetry;
+ LOG.info(str);
+ assertEquals(str, endTime - reloginIntervalMs, lastRetry);
+
+ // make sure no more retries after (tgt endTime - login interval).
+ UserGroupInformation.metrics.getRenewalFailures().incr();
+ lastRetry =
+ UserGroupInformation.getNextTgtRenewalTime(endTime, currentTime, rp);
+ str = "overflow retry, now:" + currentTime + ", retry:" + lastRetry;
+ LOG.info(str);
+ assertEquals(str, endTime - reloginIntervalMs, lastRetry);
+ }
+ private void assertWithinBounds(final int numFailures, final long lastRetry,
+ final long reloginIntervalMs, long now) {
+ // shift is 2 to the power of (numFailure).
+ int shift = numFailures + 1;
+ final long lower = now + reloginIntervalMs * (long)((1 << shift) * 0.5);
+ final long upper = now + reloginIntervalMs * (long)((1 << shift) * 1.5);
+ final String str = new String("Retry#" + (numFailures + 1) + ", now:" + now
+ + ", lower bound:" + lower + ", upper bound:" + upper
+ + ", retry:" + lastRetry);
+ LOG.info(str);
+ assertTrue(str, lower <= lastRetry && lastRetry < upper);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[22/50] [abbrv] hadoop git commit: YARN-5833. Add validation to
ensure default ports are unique in Configuration. (Konstantinos Karanasos via
Subru).
Posted by ka...@apache.org.
YARN-5833. Add validation to ensure default ports are unique in Configuration. (Konstantinos Karanasos via Subru).
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/29e3b341
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/29e3b341
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/29e3b341
Branch: refs/heads/YARN-4752
Commit: 29e3b3417c16c83dc8e753f94d7ca9957dddbedd
Parents: 3f93ac0
Author: Subru Krishnan <su...@apache.org>
Authored: Tue Nov 8 14:38:18 2016 -0800
Committer: Subru Krishnan <su...@apache.org>
Committed: Tue Nov 8 14:38:18 2016 -0800
----------------------------------------------------------------------
.../conf/TestConfigurationFieldsBase.java | 47 ++++++++++++++++++++
.../hadoop/yarn/conf/YarnConfiguration.java | 2 +-
.../yarn/conf/TestYarnConfigurationFields.java | 11 +++++
3 files changed, 59 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/29e3b341/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationFieldsBase.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationFieldsBase.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationFieldsBase.java
index eab0161..9007c20 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationFieldsBase.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationFieldsBase.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.conf;
+import org.apache.commons.lang.StringUtils;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -147,6 +148,14 @@ public abstract class TestConfigurationFieldsBase {
private Set<String> xmlFieldsMissingInConfiguration = null;
/**
+ * A set of strings used to check for collision of default values.
+ * For each of the set's strings, the default values containing that string
+ * in their name should not coincide.
+ */
+ @SuppressWarnings("checkstyle:visibilitymodifier")
+ protected Set<String> filtersForDefaultValueCollisionCheck = new HashSet<>();
+
+ /**
* Member variable for debugging base class operation
*/
protected boolean configDebug = false;
@@ -719,4 +728,42 @@ public abstract class TestConfigurationFieldsBase {
System.out.println("=====");
System.out.println();
}
+
+ /**
+ * For each specified string, get the default parameter values whose names
+ * contain the string. Then check whether any of these default values collide.
+ * This is, for example, useful to make sure there is no collision of default
+ * ports across different services.
+ */
+ @Test
+ public void testDefaultValueCollision() {
+ for (String filter : filtersForDefaultValueCollisionCheck) {
+ System.out.println("Checking if any of the default values whose name " +
+ "contains string \"" + filter + "\" collide.");
+
+ // Map from filtered default value to name of the corresponding parameter.
+ Map<String, String> filteredValues = new HashMap<>();
+
+ int valuesChecked = 0;
+ for (Map.Entry<String, String> ent :
+ configurationDefaultVariables.entrySet()) {
+ // Apply the name filter to the default parameters.
+ if (ent.getKey().contains(filter)) {
+ // Check only for numerical values.
+ if (StringUtils.isNumeric(ent.getValue())) {
+ String crtValue =
+ filteredValues.putIfAbsent(ent.getValue(), ent.getKey());
+ assertTrue("Parameters " + ent.getKey() + " and " + crtValue +
+ " are using the same default value!", crtValue == null);
+ }
+ valuesChecked++;
+ }
+ }
+
+ System.out.println(
+ "Checked " + valuesChecked + " default values for collision.");
+ }
+
+
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/29e3b341/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
index c16e1ea..1fd25a7 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
@@ -1744,7 +1744,7 @@ public class YarnConfiguration extends Configuration {
public static final String AMRM_PROXY_ADDRESS = NM_PREFIX
+ "amrmproxy.address";
- public static final int DEFAULT_AMRM_PROXY_PORT = 8048;
+ public static final int DEFAULT_AMRM_PROXY_PORT = 8049;
public static final String DEFAULT_AMRM_PROXY_ADDRESS = "0.0.0.0:"
+ DEFAULT_AMRM_PROXY_PORT;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/29e3b341/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/conf/TestYarnConfigurationFields.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/conf/TestYarnConfigurationFields.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/conf/TestYarnConfigurationFields.java
index 0c40fa9..db9364a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/conf/TestYarnConfigurationFields.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/conf/TestYarnConfigurationFields.java
@@ -147,5 +147,16 @@ public class TestYarnConfigurationFields extends TestConfigurationFieldsBase {
// Currently defined in RegistryConstants/core-site.xml
xmlPrefixToSkipCompare.add("hadoop.registry");
+
+ // Add the filters used for checking for collision of default values.
+ initDefaultValueCollisionCheck();
+ }
+
+ /**
+ * Add filters used to perform the check of default values collision by
+ * {@link TestConfigurationFieldsBase#filtersForDefaultValueCollisionCheck}.
+ */
+ private void initDefaultValueCollisionCheck() {
+ filtersForDefaultValueCollisionCheck.add("_PORT");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[35/50] [abbrv] hadoop git commit: YARN-4329. [YARN-5437] Allow
fetching exact reason as to why a submitted app is in ACCEPTED state in Fair
Scheduler (Contributed by Yufei Gu)
Posted by ka...@apache.org.
YARN-4329. [YARN-5437] Allow fetching exact reason as to why a submitted app
is in ACCEPTED state in Fair Scheduler (Contributed by Yufei Gu)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/59ee8b7a
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/59ee8b7a
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/59ee8b7a
Branch: refs/heads/YARN-4752
Commit: 59ee8b7a88603e94b5661a8d5d088f7aa99fe049
Parents: 822ae88
Author: Daniel Templeton <te...@apache.org>
Authored: Wed Nov 9 13:11:37 2016 -0800
Committer: Daniel Templeton <te...@apache.org>
Committed: Wed Nov 9 13:11:37 2016 -0800
----------------------------------------------------------------------
.../scheduler/fair/FSAppAttempt.java | 71 +++++++++++++++-----
.../scheduler/fair/FairScheduler.java | 4 +-
.../scheduler/fair/MaxRunningAppsEnforcer.java | 50 ++++++++++++--
.../fair/TestMaxRunningAppsEnforcer.java | 2 +-
4 files changed, 103 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/59ee8b7a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
index 11922d9..df20117 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
@@ -766,8 +766,18 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
// The desired container won't fit here, so reserve
if (isReservable(capability) &&
reserve(request, node, reservedContainer, type, schedulerKey)) {
+ if (isWaitingForAMContainer()) {
+ updateAMDiagnosticMsg(capability,
+ " exceed the available resources of the node and the request is"
+ + " reserved");
+ }
return FairScheduler.CONTAINER_RESERVED;
} else {
+ if (isWaitingForAMContainer()) {
+ updateAMDiagnosticMsg(capability,
+ " exceed the available resources of the node and the request cannot"
+ + " be reserved");
+ }
if (LOG.isDebugEnabled()) {
LOG.debug("Couldn't creating reservation for " +
getName() + ",at priority " + request.getPriority());
@@ -920,23 +930,31 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
ResourceRequest rackRequest = getResourceRequest(key, node.getRackName());
ResourceRequest nodeRequest = getResourceRequest(key, node.getNodeName());
- return
- // There must be outstanding requests at the given priority:
+ boolean ret = true;
+ if (!(// There must be outstanding requests at the given priority:
anyRequest != null && anyRequest.getNumContainers() > 0 &&
- // If locality relaxation is turned off at *-level, there must be a
- // non-zero request for the node's rack:
- (anyRequest.getRelaxLocality() ||
- (rackRequest != null && rackRequest.getNumContainers() > 0)) &&
- // If locality relaxation is turned off at rack-level, there must be a
- // non-zero request at the node:
- (rackRequest == null || rackRequest.getRelaxLocality() ||
- (nodeRequest != null && nodeRequest.getNumContainers() > 0)) &&
- // The requested container must be able to fit on the node:
- Resources.lessThanOrEqual(RESOURCE_CALCULATOR, null,
- anyRequest.getCapability(),
- node.getRMNode().getTotalCapability()) &&
- // The requested container must fit in queue maximum share:
- getQueue().fitsInMaxShare(anyRequest.getCapability());
+ // If locality relaxation is turned off at *-level, there must be a
+ // non-zero request for the node's rack:
+ (anyRequest.getRelaxLocality() ||
+ (rackRequest != null && rackRequest.getNumContainers() > 0)) &&
+ // If locality relaxation is turned off at rack-level, there must be a
+ // non-zero request at the node:
+ (rackRequest == null || rackRequest.getRelaxLocality() ||
+ (nodeRequest != null && nodeRequest.getNumContainers() > 0)) &&
+ // The requested container must be able to fit on the node:
+ Resources.lessThanOrEqual(RESOURCE_CALCULATOR, null,
+ anyRequest.getCapability(), node.getRMNode().getTotalCapability()))) {
+ ret = false;
+ } else if (!getQueue().fitsInMaxShare(anyRequest.getCapability())) {
+ // The requested container must fit in queue maximum share
+ if (isWaitingForAMContainer()) {
+ updateAMDiagnosticMsg(anyRequest.getCapability(),
+ " exceeds current queue or its parents maximum resource allowed).");
+ }
+ ret = false;
+ }
+
+ return ret;
}
private boolean isValidReservation(FSSchedulerNode node) {
@@ -1083,6 +1101,12 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
@Override
public Resource assignContainer(FSSchedulerNode node) {
if (isOverAMShareLimit()) {
+ if (isWaitingForAMContainer()) {
+ List<ResourceRequest> ask = appSchedulingInfo.getAllResourceRequests();
+ updateAMDiagnosticMsg(ask.get(0).getCapability(), " exceeds maximum "
+ + "AM resource allowed).");
+ }
+
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping allocation because maxAMShare limit would " +
"be exceeded");
@@ -1093,6 +1117,21 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
}
/**
+ * Build the diagnostic message and update it.
+ *
+ * @param resource resource request
+ * @param reason the reason why AM doesn't get the resource
+ */
+ private void updateAMDiagnosticMsg(Resource resource, String reason) {
+ StringBuilder diagnosticMessageBldr = new StringBuilder();
+ diagnosticMessageBldr.append(" (Resource request: ");
+ diagnosticMessageBldr.append(resource);
+ diagnosticMessageBldr.append(reason);
+ updateAMContainerDiagnostics(AMState.INACTIVATED,
+ diagnosticMessageBldr.toString());
+ }
+
+ /**
* Preempt a running container according to the priority
*/
@Override
http://git-wip-us.apache.org/repos/asf/hadoop/blob/59ee8b7a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java
index 94fdb7c..1d04710 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java
@@ -710,7 +710,7 @@ public class FairScheduler extends
}
application.setCurrentAppAttempt(attempt);
- boolean runnable = maxRunningEnforcer.canAppBeRunnable(queue, user);
+ boolean runnable = maxRunningEnforcer.canAppBeRunnable(queue, attempt);
queue.addApp(attempt, runnable);
if (runnable) {
maxRunningEnforcer.trackRunnableApp(attempt);
@@ -1714,7 +1714,7 @@ public class FairScheduler extends
boolean wasRunnable = oldQueue.removeApp(attempt);
// if app was not runnable before, it may be runnable now
boolean nowRunnable = maxRunningEnforcer.canAppBeRunnable(newQueue,
- attempt.getUser());
+ attempt);
if (wasRunnable && !nowRunnable) {
throw new IllegalStateException("Should have already verified that app "
+ attempt.getApplicationId() + " would be runnable in new queue");
http://git-wip-us.apache.org/repos/asf/hadoop/blob/59ee8b7a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/MaxRunningAppsEnforcer.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/MaxRunningAppsEnforcer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/MaxRunningAppsEnforcer.java
index 8592fa6..02e2d97 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/MaxRunningAppsEnforcer.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/MaxRunningAppsEnforcer.java
@@ -30,6 +30,7 @@ import org.apache.commons.logging.LogFactory;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt.AMState;
/**
* Handles tracking and enforcement for user and queue maxRunningApps
@@ -54,25 +55,64 @@ public class MaxRunningAppsEnforcer {
/**
* Checks whether making the application runnable would exceed any
* maxRunningApps limits.
+ *
+ * @param queue the current queue
+ * @param attempt the app attempt being checked
+ * @return true if the application is runnable; false otherwise
+ */
+ public boolean canAppBeRunnable(FSQueue queue, FSAppAttempt attempt) {
+ boolean ret = true;
+ if (exceedUserMaxApps(attempt.getUser())) {
+ attempt.updateAMContainerDiagnostics(AMState.INACTIVATED,
+ "The user \"" + attempt.getUser() + "\" has reached the maximum limit"
+ + " of runnable applications.");
+ ret = false;
+ } else if (exceedQueueMaxRunningApps(queue)) {
+ attempt.updateAMContainerDiagnostics(AMState.INACTIVATED,
+ "The queue \"" + queue.getName() + "\" has reached the maximum limit"
+ + " of runnable applications.");
+ ret = false;
+ }
+
+ return ret;
+ }
+
+ /**
+ * Checks whether the number of user runnable apps exceeds the limitation.
+ *
+ * @param user the user name
+ * @return true if the number hits the limit; false otherwise
*/
- public boolean canAppBeRunnable(FSQueue queue, String user) {
+ public boolean exceedUserMaxApps(String user) {
AllocationConfiguration allocConf = scheduler.getAllocationConfiguration();
Integer userNumRunnable = usersNumRunnableApps.get(user);
if (userNumRunnable == null) {
userNumRunnable = 0;
}
if (userNumRunnable >= allocConf.getUserMaxApps(user)) {
- return false;
+ return true;
}
+
+ return false;
+ }
+
+ /**
+ * Recursively checks whether the number of queue runnable apps exceeds the
+ * limitation.
+ *
+ * @param queue the current queue
+ * @return true if the number hits the limit; false otherwise
+ */
+ public boolean exceedQueueMaxRunningApps(FSQueue queue) {
// Check queue and all parent queues
while (queue != null) {
if (queue.getNumRunnableApps() >= queue.getMaxRunningApps()) {
- return false;
+ return true;
}
queue = queue.getParent();
}
- return true;
+ return false;
}
/**
@@ -198,7 +238,7 @@ public class MaxRunningAppsEnforcer {
continue;
}
- if (canAppBeRunnable(next.getQueue(), next.getUser())) {
+ if (canAppBeRunnable(next.getQueue(), next)) {
trackRunnableApp(next);
FSAppAttempt appSched = next;
next.getQueue().addApp(appSched, true);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/59ee8b7a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestMaxRunningAppsEnforcer.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestMaxRunningAppsEnforcer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestMaxRunningAppsEnforcer.java
index 3f17081..f77df1e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestMaxRunningAppsEnforcer.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestMaxRunningAppsEnforcer.java
@@ -68,9 +68,9 @@ public class TestMaxRunningAppsEnforcer {
private FSAppAttempt addApp(FSLeafQueue queue, String user) {
ApplicationId appId = ApplicationId.newInstance(0l, appNum++);
ApplicationAttemptId attId = ApplicationAttemptId.newInstance(appId, 0);
- boolean runnable = maxAppsEnforcer.canAppBeRunnable(queue, user);
FSAppAttempt app = new FSAppAttempt(scheduler, attId, user, queue, null,
rmContext);
+ boolean runnable = maxAppsEnforcer.canAppBeRunnable(queue, app);
queue.addApp(app, runnable);
if (runnable) {
maxAppsEnforcer.trackRunnableApp(app);
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[31/50] [abbrv] hadoop git commit: YARN-5833. Addendum patch to
include missing changes to yarn-default.xml
Posted by ka...@apache.org.
YARN-5833. Addendum patch to include missing changes to yarn-default.xml
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/280357c2
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/280357c2
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/280357c2
Branch: refs/heads/YARN-4752
Commit: 280357c29f867e3ef6386ea5bd0f7b7ca6fe04eb
Parents: c074880
Author: Arun Suresh <as...@apache.org>
Authored: Wed Nov 9 07:15:11 2016 -0800
Committer: Arun Suresh <as...@apache.org>
Committed: Wed Nov 9 07:15:11 2016 -0800
----------------------------------------------------------------------
.../hadoop-yarn-common/src/main/resources/yarn-default.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/280357c2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
index e890b40..834ead7 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
@@ -2724,7 +2724,7 @@
The address of the AMRMProxyService listener.
</description>
<name>yarn.nodemanager.amrmproxy.address</name>
- <value>0.0.0.0:8048</value>
+ <value>0.0.0.0:8049</value>
</property>
<property>
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[28/50] [abbrv] hadoop git commit: YARN-5823. Update NMTokens in case
of requests with only opportunistic containers. (Konstantinos Karanasos via
asuresh)
Posted by ka...@apache.org.
YARN-5823. Update NMTokens in case of requests with only opportunistic containers. (Konstantinos Karanasos via asuresh)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/283fa33f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/283fa33f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/283fa33f
Branch: refs/heads/YARN-4752
Commit: 283fa33febe043bd7b4fa87546be26c9c5a8f8b5
Parents: ed0beba
Author: Arun Suresh <as...@apache.org>
Authored: Wed Nov 9 00:11:25 2016 -0800
Committer: Arun Suresh <as...@apache.org>
Committed: Wed Nov 9 00:11:25 2016 -0800
----------------------------------------------------------------------
.../TestOpportunisticContainerAllocation.java | 71 +++++++++++++++++++-
.../OpportunisticContainerAllocator.java | 55 ++++++++-------
.../containermanager/ContainerManagerImpl.java | 2 +-
.../scheduler/DistributedScheduler.java | 19 ++++--
.../ApplicationMasterService.java | 3 +-
...pportunisticContainerAllocatorAMService.java | 23 ++++++-
6 files changed, 137 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/283fa33f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestOpportunisticContainerAllocation.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestOpportunisticContainerAllocation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestOpportunisticContainerAllocation.java
index b9b4b02..ace145d 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestOpportunisticContainerAllocation.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestOpportunisticContainerAllocation.java
@@ -229,6 +229,9 @@ public class TestOpportunisticContainerAllocation {
amClient.registerApplicationMaster("Host", 10000, "");
+ testOpportunisticAllocation(
+ (AMRMClientImpl<AMRMClient.ContainerRequest>) amClient);
+
testAllocation((AMRMClientImpl<AMRMClient.ContainerRequest>)amClient);
amClient
@@ -247,7 +250,6 @@ public class TestOpportunisticContainerAllocation {
final AMRMClientImpl<AMRMClient.ContainerRequest> amClient)
throws YarnException, IOException {
// setup container request
-
assertEquals(0, amClient.ask.size());
assertEquals(0, amClient.release.size());
@@ -388,6 +390,73 @@ public class TestOpportunisticContainerAllocation {
assertEquals(0, amClient.release.size());
}
+ /**
+ * Tests allocation with requests comprising only opportunistic containers.
+ */
+ private void testOpportunisticAllocation(
+ final AMRMClientImpl<AMRMClient.ContainerRequest> amClient)
+ throws YarnException, IOException {
+ // setup container request
+ assertEquals(0, amClient.ask.size());
+ assertEquals(0, amClient.release.size());
+
+ amClient.addContainerRequest(
+ new AMRMClient.ContainerRequest(capability, null, null, priority, 0,
+ true, null,
+ ExecutionTypeRequest.newInstance(
+ ExecutionType.OPPORTUNISTIC, true)));
+ amClient.addContainerRequest(
+ new AMRMClient.ContainerRequest(capability, null, null, priority, 0,
+ true, null,
+ ExecutionTypeRequest.newInstance(
+ ExecutionType.OPPORTUNISTIC, true)));
+
+ int oppContainersRequestedAny =
+ amClient.getTable(0).get(priority, ResourceRequest.ANY,
+ ExecutionType.OPPORTUNISTIC, capability).remoteRequest
+ .getNumContainers();
+
+ assertEquals(2, oppContainersRequestedAny);
+
+ assertEquals(1, amClient.ask.size());
+ assertEquals(0, amClient.release.size());
+
+ // RM should allocate container within 2 calls to allocate()
+ int allocatedContainerCount = 0;
+ int iterationsLeft = 10;
+ Set<ContainerId> releases = new TreeSet<>();
+
+ amClient.getNMTokenCache().clearCache();
+ Assert.assertEquals(0,
+ amClient.getNMTokenCache().numberOfTokensInCache());
+ HashMap<String, Token> receivedNMTokens = new HashMap<>();
+
+ while (allocatedContainerCount < oppContainersRequestedAny
+ && iterationsLeft-- > 0) {
+ AllocateResponse allocResponse = amClient.allocate(0.1f);
+ assertEquals(0, amClient.ask.size());
+ assertEquals(0, amClient.release.size());
+
+ for (Container container : allocResponse.getAllocatedContainers()) {
+ allocatedContainerCount++;
+ ContainerId rejectContainerId = container.getId();
+ releases.add(rejectContainerId);
+ }
+
+ for (NMToken token : allocResponse.getNMTokens()) {
+ String nodeID = token.getNodeId().toString();
+ receivedNMTokens.put(nodeID, token.getToken());
+ }
+
+ if (allocatedContainerCount < oppContainersRequestedAny) {
+ // sleep to let NM's heartbeat to RM and trigger allocations
+ sleep(100);
+ }
+ }
+
+ assertEquals(1, receivedNMTokens.values().size());
+ }
+
private void sleep(int sleepTime) {
try {
Thread.sleep(sleepTime);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/283fa33f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/scheduler/OpportunisticContainerAllocator.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/scheduler/OpportunisticContainerAllocator.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/scheduler/OpportunisticContainerAllocator.java
index 4410db1..16436bd 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/scheduler/OpportunisticContainerAllocator.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/scheduler/OpportunisticContainerAllocator.java
@@ -38,7 +38,6 @@ import org.apache.hadoop.yarn.util.resource.Resources;
import java.net.InetSocketAddress;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -157,12 +156,18 @@ public class OpportunisticContainerAllocator {
}
}
- static class PartitionedResourceRequests {
+ /**
+ * Class that includes two lists of {@link ResourceRequest}s: one for
+ * GUARANTEED and one for OPPORTUNISTIC {@link ResourceRequest}s.
+ */
+ public static class PartitionedResourceRequests {
private List<ResourceRequest> guaranteed = new ArrayList<>();
private List<ResourceRequest> opportunistic = new ArrayList<>();
+
public List<ResourceRequest> getGuaranteed() {
return guaranteed;
}
+
public List<ResourceRequest> getOpportunistic() {
return opportunistic;
}
@@ -186,10 +191,10 @@ public class OpportunisticContainerAllocator {
}
/**
- * Entry point into the Opportunistic Container Allocator.
+ * Allocate OPPORTUNISTIC containers.
* @param request AllocateRequest
* @param applicationAttemptId ApplicationAttemptId
- * @param appContext App Specific OpportunisticContainerContext
+ * @param opportContext App specific OpportunisticContainerContext
* @param rmIdentifier RM Identifier
* @param appSubmitter App Submitter
* @return List of Containers.
@@ -197,37 +202,31 @@ public class OpportunisticContainerAllocator {
*/
public List<Container> allocateContainers(
AllocateRequest request, ApplicationAttemptId applicationAttemptId,
- OpportunisticContainerContext appContext, long rmIdentifier,
+ OpportunisticContainerContext opportContext, long rmIdentifier,
String appSubmitter) throws YarnException {
- // Partition requests into GUARANTEED and OPPORTUNISTIC reqs
- PartitionedResourceRequests partitionedAsks =
- partitionAskList(request.getAskList());
-
- if (partitionedAsks.getOpportunistic().isEmpty()) {
- return Collections.emptyList();
- }
-
+ // Update released containers.
List<ContainerId> releasedContainers = request.getReleaseList();
int numReleasedContainers = releasedContainers.size();
if (numReleasedContainers > 0) {
LOG.info("AttemptID: " + applicationAttemptId + " released: "
+ numReleasedContainers);
- appContext.getContainersAllocated().removeAll(releasedContainers);
+ opportContext.getContainersAllocated().removeAll(releasedContainers);
}
- // Also, update black list
+ // Update black list.
ResourceBlacklistRequest rbr = request.getResourceBlacklistRequest();
if (rbr != null) {
- appContext.getBlacklist().removeAll(rbr.getBlacklistRemovals());
- appContext.getBlacklist().addAll(rbr.getBlacklistAdditions());
+ opportContext.getBlacklist().removeAll(rbr.getBlacklistRemovals());
+ opportContext.getBlacklist().addAll(rbr.getBlacklistAdditions());
}
- // Add OPPORTUNISTIC reqs to the outstanding reqs
- appContext.addToOutstandingReqs(partitionedAsks.getOpportunistic());
+ // Add OPPORTUNISTIC requests to the outstanding ones.
+ opportContext.addToOutstandingReqs(request.getAskList());
+ // Satisfy the outstanding OPPORTUNISTIC requests.
List<Container> allocatedContainers = new ArrayList<>();
for (Priority priority :
- appContext.getOutstandingOpReqs().descendingKeySet()) {
+ opportContext.getOutstandingOpReqs().descendingKeySet()) {
// Allocated containers :
// Key = Requested Capability,
// Value = List of Containers of given cap (the actual container size
@@ -235,16 +234,14 @@ public class OpportunisticContainerAllocator {
// we need the requested capability (key) to match against
// the outstanding reqs)
Map<Resource, List<Container>> allocated = allocate(rmIdentifier,
- appContext, priority, applicationAttemptId, appSubmitter);
+ opportContext, priority, applicationAttemptId, appSubmitter);
for (Map.Entry<Resource, List<Container>> e : allocated.entrySet()) {
- appContext.matchAllocationToOutstandingRequest(
+ opportContext.matchAllocationToOutstandingRequest(
e.getKey(), e.getValue());
allocatedContainers.addAll(e.getValue());
}
}
- // Send all the GUARANTEED Reqs to RM
- request.setAskList(partitionedAsks.getGuaranteed());
return allocatedContainers;
}
@@ -359,8 +356,14 @@ public class OpportunisticContainerAllocator {
return containerToken;
}
- private PartitionedResourceRequests partitionAskList(List<ResourceRequest>
- askList) {
+ /**
+ * Partitions a list of ResourceRequest to two separate lists, one for
+ * GUARANTEED and one for OPPORTUNISTIC ResourceRequests.
+ * @param askList the list of ResourceRequests to be partitioned
+ * @return the partitioned ResourceRequests
+ */
+ public PartitionedResourceRequests partitionAskList(
+ List<ResourceRequest> askList) {
PartitionedResourceRequests partitionedRequests =
new PartitionedResourceRequests();
for (ResourceRequest rr : askList) {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/283fa33f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java
index 76933ec..ab5827e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java
@@ -1523,7 +1523,7 @@ public class ContainerManagerImpl extends CompositeService implements
@Override
public OpportunisticContainersStatus getOpportunisticContainersStatus() {
- return null;
+ return OpportunisticContainersStatus.newInstance();
}
@Override
http://git-wip-us.apache.org/repos/asf/hadoop/blob/283fa33f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/scheduler/DistributedScheduler.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/scheduler/DistributedScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/scheduler/DistributedScheduler.java
index a12d16a..0f47c93 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/scheduler/DistributedScheduler.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/scheduler/DistributedScheduler.java
@@ -220,16 +220,27 @@ public final class DistributedScheduler extends AbstractRequestInterceptor {
public DistributedSchedulingAllocateResponse allocateForDistributedScheduling(
DistributedSchedulingAllocateRequest request)
throws YarnException, IOException {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Forwarding allocate request to the" +
- "Distributed Scheduler Service on YARN RM");
- }
+
+ // Partition requests to GUARANTEED and OPPORTUNISTIC.
+ OpportunisticContainerAllocator.PartitionedResourceRequests
+ partitionedAsks = containerAllocator
+ .partitionAskList(request.getAllocateRequest().getAskList());
+
+ // Allocate OPPORTUNISTIC containers.
+ request.getAllocateRequest().setAskList(partitionedAsks.getOpportunistic());
List<Container> allocatedContainers =
containerAllocator.allocateContainers(
request.getAllocateRequest(), applicationAttemptId,
oppContainerContext, rmIdentifier, appSubmitter);
+ // Prepare request for sending to RM for scheduling GUARANTEED containers.
request.setAllocatedContainers(allocatedContainers);
+ request.getAllocateRequest().setAskList(partitionedAsks.getGuaranteed());
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Forwarding allocate request to the" +
+ "Distributed Scheduler Service on YARN RM");
+ }
DistributedSchedulingAllocateResponse dsResp =
getNextInterceptor().allocateForDistributedScheduling(request);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/283fa33f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java
index 4d73ba2..4f952b7 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java
@@ -542,7 +542,8 @@ public class ApplicationMasterService extends AbstractService implements
RMAppAttempt appAttempt = app.getRMAppAttempt(appAttemptId);
AllocateResponse allocateResponse =
recordFactory.newRecordInstance(AllocateResponse.class);
- if (!allocation.getContainers().isEmpty()) {
+ if (allocation.getNMTokens() != null &&
+ !allocation.getNMTokens().isEmpty()) {
allocateResponse.setNMTokens(allocation.getNMTokens());
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/283fa33f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/OpportunisticContainerAllocatorAMService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/OpportunisticContainerAllocatorAMService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/OpportunisticContainerAllocatorAMService.java
index bdd5718..50a9c4d 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/OpportunisticContainerAllocatorAMService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/OpportunisticContainerAllocatorAMService.java
@@ -220,34 +220,51 @@ public class OpportunisticContainerAllocatorAMService
public AllocateResponse allocate(AllocateRequest request) throws
YarnException, IOException {
+ // Partition requests to GUARANTEED and OPPORTUNISTIC.
+ OpportunisticContainerAllocator.PartitionedResourceRequests
+ partitionedAsks =
+ oppContainerAllocator.partitionAskList(request.getAskList());
+
+ // Allocate OPPORTUNISTIC containers.
+ request.setAskList(partitionedAsks.getOpportunistic());
final ApplicationAttemptId appAttemptId = getAppAttemptId();
SchedulerApplicationAttempt appAttempt = ((AbstractYarnScheduler)
rmContext.getScheduler()).getApplicationAttempt(appAttemptId);
+
OpportunisticContainerContext oppCtx =
appAttempt.getOpportunisticContainerContext();
oppCtx.updateNodeList(getLeastLoadedNodes());
+
List<Container> oppContainers =
oppContainerAllocator.allocateContainers(request, appAttemptId, oppCtx,
ResourceManager.getClusterTimeStamp(), appAttempt.getUser());
+ // Create RMContainers and update the NMTokens.
if (!oppContainers.isEmpty()) {
handleNewContainers(oppContainers, false);
appAttempt.updateNMTokens(oppContainers);
}
- // Allocate all guaranteed containers
+ // Allocate GUARANTEED containers.
+ request.setAskList(partitionedAsks.getGuaranteed());
AllocateResponse allocateResp = super.allocate(request);
+ // Add allocated OPPORTUNISTIC containers to the AllocateResponse.
+ if (!oppContainers.isEmpty()) {
+ allocateResp.getAllocatedContainers().addAll(oppContainers);
+ }
+
+ // Update opportunistic container context with the allocated GUARANTEED
+ // containers.
oppCtx.updateCompletedContainers(allocateResp);
// Add all opportunistic containers
- allocateResp.getAllocatedContainers().addAll(oppContainers);
return allocateResp;
}
@Override
public RegisterDistributedSchedulingAMResponse
- registerApplicationMasterForDistributedScheduling(
+ registerApplicationMasterForDistributedScheduling(
RegisterApplicationMasterRequest request) throws YarnException,
IOException {
RegisterApplicationMasterResponse response =
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[14/50] [abbrv] hadoop git commit: YARN-5716. Add global scheduler
interface definition and update CapacityScheduler to use it. Contributed by
Wangda Tan
Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
index d759d47..7e98f10 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
@@ -32,7 +32,9 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
+import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.lang.StringUtils;
@@ -112,7 +114,11 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.Alloca
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.preemption.KillableContainer;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.preemption.PreemptionManager;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.AssignmentInformation;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.QueueEntitlement;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceAllocationCommitter;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.SchedulerContainer;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAddedSchedulerEvent;
@@ -128,6 +134,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeResourc
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSetUtils;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimplePlacementSet;
import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager;
import org.apache.hadoop.yarn.server.utils.Lock;
import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
@@ -142,11 +151,12 @@ import com.google.common.base.Preconditions;
@SuppressWarnings("unchecked")
public class CapacityScheduler extends
AbstractYarnScheduler<FiCaSchedulerApp, FiCaSchedulerNode> implements
- PreemptableResourceScheduler, CapacitySchedulerContext, Configurable {
+ PreemptableResourceScheduler, CapacitySchedulerContext, Configurable,
+ ResourceAllocationCommitter {
private static final Log LOG = LogFactory.getLog(CapacityScheduler.class);
private YarnAuthorizationProvider authorizer;
-
+
private CSQueue root;
// timeout to join when we stop this service
protected final long THREAD_JOIN_TIMEOUT_MS = 1000;
@@ -155,6 +165,8 @@ public class CapacityScheduler extends
private volatile boolean isLazyPreemptionEnabled = false;
+ private int offswitchPerHeartbeatLimit;
+
static final Comparator<CSQueue> nonPartitionedQueueComparator =
new Comparator<CSQueue>() {
@Override
@@ -176,7 +188,7 @@ public class CapacityScheduler extends
public void setConf(Configuration conf) {
yarnConf = conf;
}
-
+
private void validateConf(Configuration conf) {
// validate scheduler memory allocation setting
int minMem = conf.getInt(
@@ -229,7 +241,8 @@ public class CapacityScheduler extends
private boolean usePortForNodeName;
private boolean scheduleAsynchronously;
- private AsyncScheduleThread asyncSchedulerThread;
+ private List<AsyncScheduleThread> asyncSchedulerThreads;
+ private ResourceCommitterService resourceCommitterService;
private RMNodeLabelsManager labelManager;
/**
@@ -253,7 +266,7 @@ public class CapacityScheduler extends
public CSQueue getRootQueue() {
return root;
}
-
+
@Override
public CapacitySchedulerConfiguration getConfiguration() {
return conf;
@@ -269,11 +282,16 @@ public class CapacityScheduler extends
return calculator;
}
+ @VisibleForTesting
+ public void setResourceCalculator(ResourceCalculator rc) {
+ this.calculator = rc;
+ }
+
@Override
public Comparator<CSQueue> getNonPartitionedQueueComparator() {
return nonPartitionedQueueComparator;
}
-
+
@Override
public PartitionedQueueComparator getPartitionedQueueComparator() {
return partitionedQueueComparator;
@@ -294,7 +312,8 @@ public class CapacityScheduler extends
this.rmContext = rmContext;
}
- private void initScheduler(Configuration configuration) throws
+ @VisibleForTesting
+ void initScheduler(Configuration configuration) throws
IOException {
try {
writeLock.lock();
@@ -315,10 +334,24 @@ public class CapacityScheduler extends
scheduleAsynchronously = this.conf.getScheduleAynschronously();
asyncScheduleInterval = this.conf.getLong(ASYNC_SCHEDULER_INTERVAL,
DEFAULT_ASYNC_SCHEDULER_INTERVAL);
+
+ // number of threads for async scheduling
+ int maxAsyncSchedulingThreads = this.conf.getInt(
+ CapacitySchedulerConfiguration.SCHEDULE_ASYNCHRONOUSLY_MAXIMUM_THREAD,
+ 1);
+ maxAsyncSchedulingThreads = Math.max(maxAsyncSchedulingThreads, 1);
+
if (scheduleAsynchronously) {
- asyncSchedulerThread = new AsyncScheduleThread(this);
+ asyncSchedulerThreads = new ArrayList<>();
+ for (int i = 0; i < maxAsyncSchedulingThreads; i++) {
+ asyncSchedulerThreads.add(new AsyncScheduleThread(this));
+ }
+ resourceCommitterService = new ResourceCommitterService(this);
}
+ // Setup how many containers we can allocate for each round
+ offswitchPerHeartbeatLimit = this.conf.getOffSwitchPerHeartbeatLimit();
+
LOG.info("Initialized CapacityScheduler with " + "calculator="
+ getResourceCalculator().getClass() + ", " + "minimumAllocation=<"
+ getMinimumResourceCapability() + ">, " + "maximumAllocation=<"
@@ -335,9 +368,13 @@ public class CapacityScheduler extends
writeLock.lock();
activitiesManager.start();
if (scheduleAsynchronously) {
- Preconditions.checkNotNull(asyncSchedulerThread,
- "asyncSchedulerThread is null");
- asyncSchedulerThread.start();
+ Preconditions.checkNotNull(asyncSchedulerThreads,
+ "asyncSchedulerThreads is null");
+ for (Thread t : asyncSchedulerThreads) {
+ t.start();
+ }
+
+ resourceCommitterService.start();
}
} finally {
writeLock.unlock();
@@ -361,9 +398,13 @@ public class CapacityScheduler extends
public void serviceStop() throws Exception {
try {
writeLock.lock();
- if (scheduleAsynchronously && asyncSchedulerThread != null) {
- asyncSchedulerThread.interrupt();
- asyncSchedulerThread.join(THREAD_JOIN_TIMEOUT_MS);
+ if (scheduleAsynchronously && asyncSchedulerThreads != null) {
+ for (Thread t : asyncSchedulerThreads) {
+ t.interrupt();
+ t.join(THREAD_JOIN_TIMEOUT_MS);
+ }
+ resourceCommitterService.interrupt();
+ resourceCommitterService.join(THREAD_JOIN_TIMEOUT_MS);
}
} finally {
writeLock.unlock();
@@ -393,17 +434,20 @@ public class CapacityScheduler extends
// update lazy preemption
this.isLazyPreemptionEnabled = this.conf.getLazyPreemptionEnabled();
+
+ // Setup how many containers we can allocate for each round
+ offswitchPerHeartbeatLimit = this.conf.getOffSwitchPerHeartbeatLimit();
} finally {
writeLock.unlock();
}
}
-
+
long getAsyncScheduleInterval() {
return asyncScheduleInterval;
}
private final static Random random = new Random(System.currentTimeMillis());
-
+
/**
* Schedule on all nodes by starting at a random point.
* @param cs
@@ -413,20 +457,22 @@ public class CapacityScheduler extends
int current = 0;
Collection<FiCaSchedulerNode> nodes = cs.nodeTracker.getAllNodes();
int start = random.nextInt(nodes.size());
+
for (FiCaSchedulerNode node : nodes) {
if (current++ >= start) {
- cs.allocateContainersToNode(node);
+ cs.allocateContainersToNode(node.getNodeID(), false);
}
}
// Now, just get everyone to be safe
for (FiCaSchedulerNode node : nodes) {
- cs.allocateContainersToNode(node);
+ cs.allocateContainersToNode(node.getNodeID(), false);
}
+
try {
Thread.sleep(cs.getAsyncScheduleInterval());
} catch (InterruptedException e) {}
}
-
+
static class AsyncScheduleThread extends Thread {
private final CapacityScheduler cs;
@@ -440,12 +486,19 @@ public class CapacityScheduler extends
@Override
public void run() {
while (true) {
- if (!runSchedules.get()) {
- try {
+ try {
+ if (!runSchedules.get() || Thread.currentThread().isInterrupted()) {
Thread.sleep(100);
- } catch (InterruptedException ie) {}
- } else {
- schedule(cs);
+ } else {
+ // Don't run schedule if we have some pending backlogs already
+ if (cs.getAsyncSchedulingPendingBacklogs() > 100) {
+ Thread.sleep(1);
+ } else{
+ schedule(cs);
+ }
+ }
+ } catch (InterruptedException ie) {
+ // Do nothing
}
}
}
@@ -460,6 +513,46 @@ public class CapacityScheduler extends
}
+ static class ResourceCommitterService extends Thread {
+ private final CapacityScheduler cs;
+ private BlockingQueue<ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode>>
+ backlogs = new LinkedBlockingQueue<>();
+
+ public ResourceCommitterService(CapacityScheduler cs) {
+ this.cs = cs;
+ setDaemon(true);
+ }
+
+ @Override
+ public void run() {
+ while (!Thread.currentThread().isInterrupted()) {
+ try {
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request =
+ backlogs.take();
+
+ try {
+ cs.writeLock.lock();
+ cs.tryCommit(cs.getClusterResource(), request);
+ } finally {
+ cs.writeLock.unlock();
+ }
+
+ } catch (InterruptedException e) {
+ LOG.error(e);
+ }
+ }
+ }
+
+ public void addNewCommitRequest(
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> proposal) {
+ backlogs.add(proposal);
+ }
+
+ public int getPendingBacklogs() {
+ return backlogs.size();
+ }
+ }
+
static class QueueHook {
public CSQueue hook(CSQueue queue) {
return queue;
@@ -507,14 +600,14 @@ public class CapacityScheduler extends
private void updatePlacementRules() throws IOException {
List<PlacementRule> placementRules = new ArrayList<>();
-
+
// Initialize UserGroupMappingPlacementRule
// TODO, need make this defineable by configuration.
UserGroupMappingPlacementRule ugRule = getUserGroupMappingPlacementRule();
if (null != ugRule) {
placementRules.add(ugRule);
}
-
+
rmContext.getQueuePlacementManager().updateRules(placementRules);
}
@@ -522,8 +615,8 @@ public class CapacityScheduler extends
private void initializeQueues(CapacitySchedulerConfiguration conf)
throws IOException {
- root =
- parseQueue(this, conf, null, CapacitySchedulerConfiguration.ROOT,
+ root =
+ parseQueue(this, conf, null, CapacitySchedulerConfiguration.ROOT,
queues, queues, noop);
labelManager.reinitializeQueueLabels(getQueueToLabels());
LOG.info("Initialized root queue " + root);
@@ -539,16 +632,16 @@ public class CapacityScheduler extends
throws IOException {
// Parse new queues
Map<String, CSQueue> newQueues = new HashMap<String, CSQueue>();
- CSQueue newRoot =
+ CSQueue newRoot =
parseQueue(this, newConf, null, CapacitySchedulerConfiguration.ROOT,
newQueues, queues, noop);
-
+
// Ensure all existing queues are still present
validateExistingQueues(queues, newQueues);
// Add new queues
addNewQueues(queues, newQueues);
-
+
// Re-configure queues
root.reinitialize(newRoot, getClusterResource());
updatePlacementRules();
@@ -592,14 +685,14 @@ public class CapacityScheduler extends
*/
@Lock(CapacityScheduler.class)
private void validateExistingQueues(
- Map<String, CSQueue> queues, Map<String, CSQueue> newQueues)
+ Map<String, CSQueue> queues, Map<String, CSQueue> newQueues)
throws IOException {
// check that all static queues are included in the newQueues list
for (Map.Entry<String, CSQueue> e : queues.entrySet()) {
if (!(e.getValue() instanceof ReservationQueue)) {
String queueName = e.getKey();
CSQueue oldQueue = e.getValue();
- CSQueue newQueue = newQueues.get(queueName);
+ CSQueue newQueue = newQueues.get(queueName);
if (null == newQueue) {
throw new IOException(queueName + " cannot be found during refresh!");
} else if (!oldQueue.getQueuePath().equals(newQueue.getQueuePath())) {
@@ -619,7 +712,7 @@ public class CapacityScheduler extends
*/
@Lock(CapacityScheduler.class)
private void addNewQueues(
- Map<String, CSQueue> queues, Map<String, CSQueue> newQueues)
+ Map<String, CSQueue> queues, Map<String, CSQueue> newQueues)
{
for (Map.Entry<String, CSQueue> e : newQueues.entrySet()) {
String queueName = e.getKey();
@@ -629,19 +722,19 @@ public class CapacityScheduler extends
}
}
}
-
+
@Lock(CapacityScheduler.class)
static CSQueue parseQueue(
CapacitySchedulerContext csContext,
- CapacitySchedulerConfiguration conf,
+ CapacitySchedulerConfiguration conf,
CSQueue parent, String queueName, Map<String, CSQueue> queues,
- Map<String, CSQueue> oldQueues,
+ Map<String, CSQueue> oldQueues,
QueueHook hook) throws IOException {
CSQueue queue;
String fullQueueName =
(parent == null) ? queueName
: (parent.getQueuePath() + "." + queueName);
- String[] childQueueNames =
+ String[] childQueueNames =
conf.getQueues(fullQueueName);
boolean isReservableQueue = conf.isReservable(fullQueueName);
if (childQueueNames == null || childQueueNames.length == 0) {
@@ -676,8 +769,8 @@ public class CapacityScheduler extends
List<CSQueue> childQueues = new ArrayList<CSQueue>();
for (String childQueueName : childQueueNames) {
- CSQueue childQueue =
- parseQueue(csContext, conf, queue, childQueueName,
+ CSQueue childQueue =
+ parseQueue(csContext, conf, queue, childQueueName,
queues, oldQueues, hook);
childQueues.add(childQueue);
}
@@ -960,6 +1053,9 @@ public class CapacityScheduler extends
private LeafQueue updateIncreaseRequests(
List<UpdateContainerRequest> increaseRequests, FiCaSchedulerApp app) {
+ // When application has some pending to-be-removed resource requests,
+ app.removedToBeRemovedIncreaseRequests();
+
if (null == increaseRequests || increaseRequests.isEmpty()) {
return null;
}
@@ -1068,8 +1164,8 @@ public class CapacityScheduler extends
@Override
@Lock(Lock.NoLock.class)
- public QueueInfo getQueueInfo(String queueName,
- boolean includeChildQueues, boolean recursive)
+ public QueueInfo getQueueInfo(String queueName,
+ boolean includeChildQueues, boolean recursive)
throws IOException {
CSQueue queue = null;
queue = this.queues.get(queueName);
@@ -1094,20 +1190,33 @@ public class CapacityScheduler extends
}
@Override
- protected synchronized void nodeUpdate(RMNode nm) {
+ protected synchronized void nodeUpdate(RMNode rmNode) {
try {
- writeLock.lock();
+ readLock.lock();
setLastNodeUpdateTime(Time.now());
- super.nodeUpdate(nm);
- if (!scheduleAsynchronously) {
+ super.nodeUpdate(rmNode);
+ } finally {
+ readLock.unlock();
+ }
+
+ // Try to do scheduling
+ if (!scheduleAsynchronously) {
+ try {
+ writeLock.lock();
ActivitiesLogger.NODE.startNodeUpdateRecording(activitiesManager,
- nm.getNodeID());
- allocateContainersToNode(getNode(nm.getNodeID()));
+ rmNode.getNodeID());
+
+ // reset allocation and reservation stats before we start doing any
+ // work
+ updateSchedulerHealth(lastNodeUpdateTime, rmNode.getNodeID(),
+ CSAssignment.NULL_ASSIGNMENT);
+
+ allocateContainersToNode(rmNode.getNodeID(), true);
ActivitiesLogger.NODE.finishNodeUpdateRecording(activitiesManager,
- nm.getNodeID());
+ rmNode.getNodeID());
+ } finally {
+ writeLock.unlock();
}
- } finally {
- writeLock.unlock();
}
}
@@ -1174,10 +1283,8 @@ public class CapacityScheduler extends
node.updateLabels(newLabels);
}
- private void updateSchedulerHealth(long now, FiCaSchedulerNode node,
+ private void updateSchedulerHealth(long now, NodeId nodeId,
CSAssignment assignment) {
-
- NodeId nodeId = node.getNodeID();
List<AssignmentInformation.AssignmentDetails> allocations =
assignment.getAssignmentInformation().getAllocationDetails();
List<AssignmentInformation.AssignmentDetails> reservations =
@@ -1203,137 +1310,248 @@ public class CapacityScheduler extends
schedulerHealth.updateSchedulerRunDetails(now, assignment
.getAssignmentInformation().getAllocated(), assignment
.getAssignmentInformation().getReserved());
- }
-
- @VisibleForTesting
- public void allocateContainersToNode(FiCaSchedulerNode node) {
- try {
- writeLock.lock();
- if (rmContext.isWorkPreservingRecoveryEnabled() && !rmContext
- .isSchedulerReadyForAllocatingContainers()) {
- return;
- }
+ }
- if (!nodeTracker.exists(node.getNodeID())) {
- LOG.info("Skipping scheduling as the node " + node.getNodeID()
- + " has been removed");
- return;
+ private boolean canAllocateMore(CSAssignment assignment, int offswitchCount) {
+ if (null != assignment && Resources.greaterThan(getResourceCalculator(),
+ getClusterResource(), assignment.getResource(), Resources.none())
+ && offswitchCount < offswitchPerHeartbeatLimit) {
+ // And it should not be a reserved container
+ if (assignment.getAssignmentInformation().getNumReservations() == 0) {
+ return true;
}
+ }
- // reset allocation and reservation stats before we start doing any work
- updateSchedulerHealth(lastNodeUpdateTime, node,
- new CSAssignment(Resources.none(), NodeType.NODE_LOCAL));
-
- CSAssignment assignment;
+ return false;
+ }
- // Assign new containers...
- // 1. Check for reserved applications
- // 2. Schedule if there are no reservations
+ /**
+ * We need to make sure when doing allocation, Node should be existed
+ * And we will construct a {@link PlacementSet} before proceeding
+ */
+ private void allocateContainersToNode(NodeId nodeId,
+ boolean withNodeHeartbeat) {
+ FiCaSchedulerNode node = getNode(nodeId);
+ if (null != node) {
+ int offswitchCount = 0;
+
+ PlacementSet<FiCaSchedulerNode> ps = new SimplePlacementSet<>(node);
+ CSAssignment assignment = allocateContainersToNode(ps, withNodeHeartbeat);
+ // Only check if we can allocate more container on the same node when
+ // scheduling is triggered by node heartbeat
+ if (null != assignment && withNodeHeartbeat) {
+ if (assignment.getType() == NodeType.OFF_SWITCH) {
+ offswitchCount++;
+ }
- RMContainer reservedContainer = node.getReservedContainer();
- if (reservedContainer != null) {
+ while (canAllocateMore(assignment, offswitchCount)) {
+ // Try to see if it is possible to allocate multiple container for
+ // the same node heartbeat
+ assignment = allocateContainersToNode(ps, true);
- FiCaSchedulerApp reservedApplication = getCurrentAttemptForContainer(
- reservedContainer.getContainerId());
-
- // Try to fulfill the reservation
- LOG.info("Trying to fulfill reservation for application "
- + reservedApplication.getApplicationId() + " on node: " + node
- .getNodeID());
-
- LeafQueue queue = ((LeafQueue) reservedApplication.getQueue());
- assignment = queue.assignContainers(getClusterResource(), node,
- // TODO, now we only consider limits for parent for non-labeled
- // resources, should consider labeled resources as well.
- new ResourceLimits(labelManager
- .getResourceByLabel(RMNodeLabelsManager.NO_LABEL,
- getClusterResource())),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
- if (assignment.isFulfilledReservation()) {
- CSAssignment tmp = new CSAssignment(
- reservedContainer.getReservedResource(), assignment.getType());
- Resources.addTo(assignment.getAssignmentInformation().getAllocated(),
- reservedContainer.getReservedResource());
- tmp.getAssignmentInformation().addAllocationDetails(
- reservedContainer.getContainerId(), queue.getQueuePath());
- tmp.getAssignmentInformation().incrAllocations();
- updateSchedulerHealth(lastNodeUpdateTime, node, tmp);
- schedulerHealth.updateSchedulerFulfilledReservationCounts(1);
-
- ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
- queue.getParent().getQueueName(), queue.getQueueName(),
- ActivityState.ACCEPTED, ActivityDiagnosticConstant.EMPTY);
- ActivitiesLogger.NODE.finishAllocatedNodeAllocation(activitiesManager,
- node, reservedContainer.getContainerId(),
- AllocationState.ALLOCATED_FROM_RESERVED);
- } else{
- ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
- queue.getParent().getQueueName(), queue.getQueueName(),
- ActivityState.ACCEPTED, ActivityDiagnosticConstant.EMPTY);
- ActivitiesLogger.NODE.finishAllocatedNodeAllocation(activitiesManager,
- node, reservedContainer.getContainerId(),
- AllocationState.SKIPPED);
+ if (null != assignment
+ && assignment.getType() == NodeType.OFF_SWITCH) {
+ offswitchCount++;
+ }
}
- }
-
- // Try to schedule more if there are no reservations to fulfill
- if (node.getReservedContainer() == null) {
- if (calculator.computeAvailableContainers(Resources
- .add(node.getUnallocatedResource(),
- node.getTotalKillableResources()), minimumAllocation) > 0) {
+ if (offswitchCount >= offswitchPerHeartbeatLimit) {
if (LOG.isDebugEnabled()) {
- LOG.debug("Trying to schedule on node: " + node.getNodeName()
- + ", available: " + node.getUnallocatedResource());
+ LOG.debug("Assigned maximum number of off-switch containers: "
+ + offswitchCount + ", assignments so far: " + assignment);
}
+ }
+ }
+ }
+ }
- assignment = root.assignContainers(getClusterResource(), node,
- new ResourceLimits(labelManager
- .getResourceByLabel(node.getPartition(),
- getClusterResource())),
- SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
- if (Resources.greaterThan(calculator, getClusterResource(),
- assignment.getResource(), Resources.none())) {
- updateSchedulerHealth(lastNodeUpdateTime, node, assignment);
- return;
- }
+ /*
+ * Logics of allocate container on a single node (Old behavior)
+ */
+ private CSAssignment allocateContainerOnSingleNode(PlacementSet<FiCaSchedulerNode> ps,
+ FiCaSchedulerNode node, boolean withNodeHeartbeat) {
+ // Backward compatible way to make sure previous behavior which allocation
+ // driven by node heartbeat works.
+ if (getNode(node.getNodeID()) != node) {
+ LOG.error("Trying to schedule on a removed node, please double check.");
+ return null;
+ }
- // Only do non-exclusive allocation when node has node-labels.
- if (StringUtils.equals(node.getPartition(),
- RMNodeLabelsManager.NO_LABEL)) {
- return;
- }
+ CSAssignment assignment;
- // Only do non-exclusive allocation when the node-label supports that
- try {
- if (rmContext.getNodeLabelManager().isExclusiveNodeLabel(
- node.getPartition())) {
- return;
- }
- } catch (IOException e) {
- LOG.warn(
- "Exception when trying to get exclusivity of node label=" + node
- .getPartition(), e);
- return;
- }
+ // Assign new containers...
+ // 1. Check for reserved applications
+ // 2. Schedule if there are no reservations
+ RMContainer reservedContainer = node.getReservedContainer();
+ if (reservedContainer != null) {
+ FiCaSchedulerApp reservedApplication = getCurrentAttemptForContainer(
+ reservedContainer.getContainerId());
- // Try to use NON_EXCLUSIVE
- assignment = root.assignContainers(getClusterResource(), node,
- // TODO, now we only consider limits for parent for non-labeled
- // resources, should consider labeled resources as well.
- new ResourceLimits(labelManager
- .getResourceByLabel(RMNodeLabelsManager.NO_LABEL,
- getClusterResource())),
- SchedulingMode.IGNORE_PARTITION_EXCLUSIVITY);
- updateSchedulerHealth(lastNodeUpdateTime, node, assignment);
+ // Try to fulfill the reservation
+ LOG.info(
+ "Trying to fulfill reservation for application " + reservedApplication
+ .getApplicationId() + " on node: " + node.getNodeID());
+
+ LeafQueue queue = ((LeafQueue) reservedApplication.getQueue());
+ assignment = queue.assignContainers(getClusterResource(), ps,
+ // TODO, now we only consider limits for parent for non-labeled
+ // resources, should consider labeled resources as well.
+ new ResourceLimits(labelManager
+ .getResourceByLabel(RMNodeLabelsManager.NO_LABEL,
+ getClusterResource())),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+
+ if (assignment.isFulfilledReservation()) {
+ if (withNodeHeartbeat) {
+ // Only update SchedulerHealth in sync scheduling, existing
+ // Data structure of SchedulerHealth need to be updated for
+ // Async mode
+ updateSchedulerHealth(lastNodeUpdateTime, node.getNodeID(),
+ assignment);
}
+
+ schedulerHealth.updateSchedulerFulfilledReservationCounts(1);
+
+ ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
+ queue.getParent().getQueueName(), queue.getQueueName(),
+ ActivityState.ACCEPTED, ActivityDiagnosticConstant.EMPTY);
+ ActivitiesLogger.NODE.finishAllocatedNodeAllocation(activitiesManager,
+ node, reservedContainer.getContainerId(),
+ AllocationState.ALLOCATED_FROM_RESERVED);
} else{
- LOG.info("Skipping scheduling since node " + node.getNodeID()
+ ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
+ queue.getParent().getQueueName(), queue.getQueueName(),
+ ActivityState.ACCEPTED, ActivityDiagnosticConstant.EMPTY);
+ ActivitiesLogger.NODE.finishAllocatedNodeAllocation(activitiesManager,
+ node, reservedContainer.getContainerId(), AllocationState.SKIPPED);
+ }
+
+ assignment.setSchedulingMode(
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ submitResourceCommitRequest(getClusterResource(), assignment);
+ }
+
+ // Do not schedule if there are any reservations to fulfill on the node
+ if (node.getReservedContainer() != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Skipping scheduling since node " + node.getNodeID()
+ " is reserved by application " + node.getReservedContainer()
.getContainerId().getApplicationAttemptId());
}
- } finally {
- writeLock.unlock();
+ return null;
+ }
+
+ // First check if we can schedule
+ // When this time look at one node only, try schedule if the node
+ // has any available or killable resource
+ if (calculator.computeAvailableContainers(Resources
+ .add(node.getUnallocatedResource(), node.getTotalKillableResources()),
+ minimumAllocation) <= 0) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("This node or this node partition doesn't have available or"
+ + "killable resource");
+ }
+ return null;
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(
+ "Trying to schedule on node: " + node.getNodeName() + ", available: "
+ + node.getUnallocatedResource());
+ }
+
+ return allocateOrReserveNewContainers(ps, withNodeHeartbeat);
+ }
+
+ private CSAssignment allocateOrReserveNewContainers(
+ PlacementSet<FiCaSchedulerNode> ps, boolean withNodeHeartbeat) {
+ CSAssignment assignment = root.assignContainers(getClusterResource(), ps,
+ new ResourceLimits(labelManager
+ .getResourceByLabel(ps.getPartition(), getClusterResource())),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+
+ assignment.setSchedulingMode(SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ submitResourceCommitRequest(getClusterResource(), assignment);
+
+ if (Resources.greaterThan(calculator, getClusterResource(),
+ assignment.getResource(), Resources.none())) {
+ if (withNodeHeartbeat) {
+ updateSchedulerHealth(lastNodeUpdateTime,
+ PlacementSetUtils.getSingleNode(ps).getNodeID(), assignment);
+ }
+ return assignment;
+ }
+
+ // Only do non-exclusive allocation when node has node-labels.
+ if (StringUtils.equals(ps.getPartition(), RMNodeLabelsManager.NO_LABEL)) {
+ return null;
+ }
+
+ // Only do non-exclusive allocation when the node-label supports that
+ try {
+ if (rmContext.getNodeLabelManager().isExclusiveNodeLabel(
+ ps.getPartition())) {
+ return null;
+ }
+ } catch (IOException e) {
+ LOG.warn("Exception when trying to get exclusivity of node label=" + ps
+ .getPartition(), e);
+ return null;
+ }
+
+ // Try to use NON_EXCLUSIVE
+ assignment = root.assignContainers(getClusterResource(), ps,
+ // TODO, now we only consider limits for parent for non-labeled
+ // resources, should consider labeled resources as well.
+ new ResourceLimits(labelManager
+ .getResourceByLabel(RMNodeLabelsManager.NO_LABEL,
+ getClusterResource())),
+ SchedulingMode.IGNORE_PARTITION_EXCLUSIVITY);
+ assignment.setSchedulingMode(SchedulingMode.IGNORE_PARTITION_EXCLUSIVITY);
+ submitResourceCommitRequest(getClusterResource(), assignment);
+
+ return assignment;
+ }
+
+ /*
+ * New behavior, allocate containers considering multiple nodes
+ */
+ private CSAssignment allocateContainersOnMultiNodes(
+ PlacementSet<FiCaSchedulerNode> ps) {
+ // When this time look at multiple nodes, try schedule if the
+ // partition has any available resource or killable resource
+ if (root.getQueueCapacities().getUsedCapacity(ps.getPartition()) >= 1.0f
+ && preemptionManager.getKillableResource(
+ CapacitySchedulerConfiguration.ROOT, ps.getPartition()) == Resources
+ .none()) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("This node or this node partition doesn't have available or"
+ + "killable resource");
+ }
+ return null;
+ }
+
+ return allocateOrReserveNewContainers(ps, false);
+ }
+
+ @VisibleForTesting
+ CSAssignment allocateContainersToNode(PlacementSet<FiCaSchedulerNode> ps,
+ boolean withNodeHeartbeat) {
+ if (rmContext.isWorkPreservingRecoveryEnabled() && !rmContext
+ .isSchedulerReadyForAllocatingContainers()) {
+ return null;
+ }
+
+ // Backward compatible way to make sure previous behavior which allocation
+ // driven by node heartbeat works.
+ FiCaSchedulerNode node = PlacementSetUtils.getSingleNode(ps);
+
+ // We have two different logics to handle allocation on single node / multi
+ // nodes.
+ if (null != node) {
+ return allocateContainerOnSingleNode(ps, node, withNodeHeartbeat);
+ } else {
+ return allocateContainersOnMultiNodes(ps);
}
}
@@ -1356,7 +1574,7 @@ public class CapacityScheduler extends
break;
case NODE_RESOURCE_UPDATE:
{
- NodeResourceUpdateSchedulerEvent nodeResourceUpdatedEvent =
+ NodeResourceUpdateSchedulerEvent nodeResourceUpdatedEvent =
(NodeResourceUpdateSchedulerEvent)event;
updateNodeAndQueueResource(nodeResourceUpdatedEvent.getRMNode(),
nodeResourceUpdatedEvent.getResourceOption());
@@ -1366,7 +1584,7 @@ public class CapacityScheduler extends
{
NodeLabelsUpdateSchedulerEvent labelUpdateEvent =
(NodeLabelsUpdateSchedulerEvent) event;
-
+
updateNodeLabelsAndQueueResource(labelUpdateEvent);
}
break;
@@ -1420,7 +1638,7 @@ public class CapacityScheduler extends
break;
case CONTAINER_EXPIRED:
{
- ContainerExpiredSchedulerEvent containerExpiredEvent =
+ ContainerExpiredSchedulerEvent containerExpiredEvent =
(ContainerExpiredSchedulerEvent) event;
ContainerId containerId = containerExpiredEvent.getContainerId();
if (containerExpiredEvent.isIncrease()) {
@@ -1515,7 +1733,9 @@ public class CapacityScheduler extends
+ clusterResource);
if (scheduleAsynchronously && getNumClusterNodes() == 1) {
- asyncSchedulerThread.beginSchedule();
+ for (AsyncScheduleThread t : asyncSchedulerThreads) {
+ t.beginSchedule();
+ }
}
} finally {
writeLock.unlock();
@@ -1561,7 +1781,9 @@ public class CapacityScheduler extends
int numNodes = nodeTracker.nodeCount();
if (scheduleAsynchronously && numNodes == 0) {
- asyncSchedulerThread.suspendSchedule();
+ for (AsyncScheduleThread t : asyncSchedulerThreads) {
+ t.suspendSchedule();
+ }
}
LOG.info(
@@ -1629,7 +1851,7 @@ public class CapacityScheduler extends
queue.completedContainer(getClusterResource(), application, node,
rmContainer, containerStatus, event, null, true);
}
-
+
@Override
protected void decreaseContainer(SchedContainerChangeRequest decreaseRequest,
SchedulerApplicationAttempt attempt) {
@@ -1673,7 +1895,7 @@ public class CapacityScheduler extends
public List<FiCaSchedulerNode> getAllNodes() {
return nodeTracker.getAllNodes();
}
-
+
@Override
@Lock(Lock.NoLock.class)
public void recover(RMState state) throws Exception {
@@ -2085,7 +2307,7 @@ public class CapacityScheduler extends
}
return EnumSet.of(SchedulerResourceTypes.MEMORY, SchedulerResourceTypes.CPU);
}
-
+
@Override
public Resource getMaximumResourceCapability(String queueName) {
CSQueue queue = getQueue(queueName);
@@ -2223,4 +2445,207 @@ public class CapacityScheduler extends
public ResourceUsage getClusterResourceUsage() {
return root.getQueueResourceUsage();
}
+
+ private SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> getSchedulerContainer(
+ RMContainer rmContainer, boolean allocated) {
+ if (null == rmContainer) {
+ return null;
+ }
+
+ FiCaSchedulerApp app = getApplicationAttempt(
+ rmContainer.getApplicationAttemptId());
+ if (null == app) { return null; }
+
+ NodeId nodeId;
+ // Get nodeId
+ if (rmContainer.getState() == RMContainerState.RESERVED) {
+ nodeId = rmContainer.getReservedNode();
+ } else {
+ nodeId = rmContainer.getNodeId();
+ }
+
+ FiCaSchedulerNode node = getNode(nodeId);
+ if (null == node) {
+ return null;
+ }
+ return new SchedulerContainer<>(app, node, rmContainer,
+ // TODO, node partition should come from CSAssignment to avoid partition
+ // get updated before submitting the commit
+ node.getPartition(), allocated);
+ }
+
+ private List<SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode>>
+ getSchedulerContainersToRelease(
+ CSAssignment csAssignment) {
+ List<SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode>> list = null;
+
+ if (csAssignment.getContainersToKill() != null && !csAssignment
+ .getContainersToKill().isEmpty()) {
+ list = new ArrayList<>();
+ for (RMContainer rmContainer : csAssignment.getContainersToKill()) {
+ list.add(getSchedulerContainer(rmContainer, false));
+ }
+ }
+
+ if (csAssignment.getExcessReservation() != null) {
+ if (null == list) {
+ list = new ArrayList<>();
+ }
+ list.add(
+ getSchedulerContainer(csAssignment.getExcessReservation(), false));
+ }
+
+ return list;
+ }
+
+ @VisibleForTesting
+ public void submitResourceCommitRequest(Resource cluster,
+ CSAssignment csAssignment) {
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request =
+ createResourceCommitRequest(csAssignment);
+
+ if (null == request) {
+ return;
+ }
+
+ if (scheduleAsynchronously) {
+ // Submit to a commit thread and commit it async-ly
+ resourceCommitterService.addNewCommitRequest(request);
+ } else{
+ // Otherwise do it sync-ly.
+ tryCommit(cluster, request);
+ }
+ }
+
+ @VisibleForTesting
+ public ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode>
+ createResourceCommitRequest(CSAssignment csAssignment) {
+ ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> allocated =
+ null;
+ ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> reserved =
+ null;
+ List<SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode>> released =
+ null;
+
+ if (Resources.greaterThan(calculator, getClusterResource(),
+ csAssignment.getResource(), Resources.none())) {
+ // Allocated something
+ List<AssignmentInformation.AssignmentDetails> allocations =
+ csAssignment.getAssignmentInformation().getAllocationDetails();
+ if (!allocations.isEmpty()) {
+ RMContainer rmContainer = allocations.get(0).rmContainer;
+ allocated = new ContainerAllocationProposal<>(
+ getSchedulerContainer(rmContainer, true),
+ getSchedulerContainersToRelease(csAssignment),
+ getSchedulerContainer(csAssignment.getFulfilledReservedContainer(),
+ false), csAssignment.isIncreasedAllocation(),
+ csAssignment.getType(), csAssignment.getRequestLocalityType(),
+ csAssignment.getSchedulingMode() != null ?
+ csAssignment.getSchedulingMode() :
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY,
+ csAssignment.getResource());
+ }
+
+ // Reserved something
+ List<AssignmentInformation.AssignmentDetails> reservation =
+ csAssignment.getAssignmentInformation().getReservationDetails();
+ if (!reservation.isEmpty()) {
+ RMContainer rmContainer = reservation.get(0).rmContainer;
+ reserved = new ContainerAllocationProposal<>(
+ getSchedulerContainer(rmContainer, false),
+ getSchedulerContainersToRelease(csAssignment),
+ getSchedulerContainer(csAssignment.getFulfilledReservedContainer(),
+ false), csAssignment.isIncreasedAllocation(),
+ csAssignment.getType(), csAssignment.getRequestLocalityType(),
+ csAssignment.getSchedulingMode() != null ?
+ csAssignment.getSchedulingMode() :
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY,
+ csAssignment.getResource());
+ }
+ }
+
+ // When we don't need to allocate/reserve anything, we can feel free to
+ // kill all to-release containers in the request.
+ if (null == allocated && null == reserved) {
+ released = getSchedulerContainersToRelease(csAssignment);
+ }
+
+ if (null != allocated || null != reserved || (null != released && !released
+ .isEmpty())) {
+ List<ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode>>
+ allocationsList = null;
+ if (allocated != null) {
+ allocationsList = new ArrayList<>();
+ allocationsList.add(allocated);
+ }
+
+ List<ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode>>
+ reservationsList = null;
+ if (reserved != null) {
+ reservationsList = new ArrayList<>();
+ reservationsList.add(reserved);
+ }
+
+ return new ResourceCommitRequest<>(allocationsList, reservationsList,
+ released);
+ }
+
+ return null;
+ }
+
+ @Override
+ public void tryCommit(Resource cluster, ResourceCommitRequest r) {
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request =
+ (ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode>) r;
+
+ ApplicationAttemptId attemptId = null;
+
+ // We need to update unconfirmed allocated resource of application when
+ // any container allocated.
+ boolean updateUnconfirmedAllocatedResource =
+ request.getContainersToAllocate() != null && !request
+ .getContainersToAllocate().isEmpty();
+
+ // find the application to accept and apply the ResourceCommitRequest
+ if (request.anythingAllocatedOrReserved()) {
+ ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> c =
+ request.getFirstAllocatedOrReservedContainer();
+ attemptId =
+ c.getAllocatedOrReservedContainer().getSchedulerApplicationAttempt()
+ .getApplicationAttemptId();
+ } else {
+ if (!request.getContainersToRelease().isEmpty()) {
+ attemptId = request.getContainersToRelease().get(0)
+ .getSchedulerApplicationAttempt().getApplicationAttemptId();
+ }
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Try to commit allocation proposal=" + request);
+ }
+
+ if (attemptId != null) {
+ FiCaSchedulerApp app = getApplicationAttempt(attemptId);
+ if (app != null) {
+ if (app.accept(cluster, request)) {
+ app.apply(cluster, request);
+ LOG.info("Allocation proposal accepted");
+ } else{
+ LOG.info("Failed to accept allocation proposal");
+ }
+
+ // Update unconfirmed allocated resource.
+ if (updateUnconfirmedAllocatedResource) {
+ app.decUnconfirmedRes(request.getTotalAllocatedResource());
+ }
+ }
+ }
+ }
+
+ public int getAsyncSchedulingPendingBacklogs() {
+ if (scheduleAsynchronously) {
+ return resourceCommitterService.getPendingBacklogs();
+ }
+ return 0;
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java
index cea5aa4..c153c26 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java
@@ -209,6 +209,10 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur
SCHEDULE_ASYNCHRONOUSLY_PREFIX + ".enable";
@Private
+ public static final String SCHEDULE_ASYNCHRONOUSLY_MAXIMUM_THREAD =
+ SCHEDULE_ASYNCHRONOUSLY_PREFIX + ".maximum-threads";
+
+ @Private
public static final boolean DEFAULT_SCHEDULE_ASYNCHRONOUSLY_ENABLE = false;
@Private
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java
index 8941fdf..161957f 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java
@@ -67,8 +67,13 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.Activi
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivityState;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt.AMState;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.preemption.KillableContainer;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.SchedulerContainer;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSetUtils;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.policy.FifoOrderingPolicyForPendingApps;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.policy.OrderingPolicy;
import org.apache.hadoop.yarn.server.utils.Lock;
@@ -914,54 +919,6 @@ public class LeafQueue extends AbstractCSQueue {
ApplicationAttemptId applicationAttemptId) {
return applicationAttemptMap.get(applicationAttemptId);
}
-
- private void handleExcessReservedContainer(Resource clusterResource,
- CSAssignment assignment, FiCaSchedulerNode node, FiCaSchedulerApp app) {
- if (assignment.getExcessReservation() != null) {
- RMContainer excessReservedContainer = assignment.getExcessReservation();
-
- if (excessReservedContainer.hasIncreaseReservation()) {
- unreserveIncreasedContainer(clusterResource,
- app, node, excessReservedContainer);
- } else {
- completedContainer(clusterResource, assignment.getApplication(),
- scheduler.getNode(excessReservedContainer.getAllocatedNode()),
- excessReservedContainer,
- SchedulerUtils.createAbnormalContainerStatus(
- excessReservedContainer.getContainerId(),
- SchedulerUtils.UNRESERVED_CONTAINER),
- RMContainerEventType.RELEASED, null, false);
- }
-
- assignment.setExcessReservation(null);
- }
- }
-
- private void killToPreemptContainers(Resource clusterResource,
- FiCaSchedulerNode node,
- CSAssignment assignment) {
- if (assignment.getContainersToKill() != null) {
- StringBuilder sb = new StringBuilder("Killing containers: [");
-
- for (RMContainer c : assignment.getContainersToKill()) {
- FiCaSchedulerApp application = csContext.getApplicationAttempt(
- c.getApplicationAttemptId());
- LeafQueue q = application.getCSLeafQueue();
- q.completedContainer(clusterResource, application, node, c, SchedulerUtils
- .createPreemptedContainerStatus(c.getContainerId(),
- SchedulerUtils.PREEMPTED_CONTAINER), RMContainerEventType.KILL,
- null, false);
- sb.append("(container=" + c.getContainerId() + " resource=" + c
- .getAllocatedResource() + ")");
- }
-
- sb.append("] for container=" + assignment.getAssignmentInformation()
- .getFirstAllocatedOrReservedContainerId() + " resource=" + assignment
- .getResource());
- LOG.info(sb.toString());
-
- }
- }
private void setPreemptionAllowed(ResourceLimits limits, String nodePartition) {
// Set preemption-allowed:
@@ -971,174 +928,312 @@ public class LeafQueue extends AbstractCSQueue {
limits.setIsAllowPreemption(usedCapacity < guaranteedCapacity);
}
+ private CSAssignment allocateFromReservedContainer(
+ Resource clusterResource, PlacementSet<FiCaSchedulerNode> ps,
+ ResourceLimits currentResourceLimits, SchedulingMode schedulingMode) {
+ FiCaSchedulerNode node = PlacementSetUtils.getSingleNode(ps);
+ if (null == node) {
+ return null;
+ }
+
+ RMContainer reservedContainer = node.getReservedContainer();
+ if (reservedContainer != null) {
+ FiCaSchedulerApp application = getApplication(
+ reservedContainer.getApplicationAttemptId());
+
+ if (null != application) {
+ ActivitiesLogger.APP.startAppAllocationRecording(activitiesManager,
+ node.getNodeID(), SystemClock.getInstance().getTime(), application);
+ CSAssignment assignment = application.assignContainers(clusterResource,
+ ps, currentResourceLimits, schedulingMode, reservedContainer);
+ return assignment;
+ }
+ }
+
+ return null;
+ }
+
@Override
public CSAssignment assignContainers(Resource clusterResource,
- FiCaSchedulerNode node, ResourceLimits currentResourceLimits,
- SchedulingMode schedulingMode) {
- try {
- writeLock.lock();
- updateCurrentResourceLimits(currentResourceLimits, clusterResource);
+ PlacementSet<FiCaSchedulerNode> ps, ResourceLimits currentResourceLimits,
+ SchedulingMode schedulingMode) {
+ updateCurrentResourceLimits(currentResourceLimits, clusterResource);
+ FiCaSchedulerNode node = PlacementSetUtils.getSingleNode(ps);
- if (LOG.isDebugEnabled()) {
- LOG.debug(
- "assignContainers: node=" + node.getNodeName() + " #applications="
- + orderingPolicy.getNumSchedulableEntities());
- }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("assignContainers: partition=" + ps.getPartition()
+ + " #applications=" + orderingPolicy.getNumSchedulableEntities());
+ }
- setPreemptionAllowed(currentResourceLimits, node.getPartition());
+ setPreemptionAllowed(currentResourceLimits, ps.getPartition());
- // Check for reserved resources
- RMContainer reservedContainer = node.getReservedContainer();
- if (reservedContainer != null) {
- FiCaSchedulerApp application = getApplication(
- reservedContainer.getApplicationAttemptId());
+ // Check for reserved resources, try to allocate reserved container first.
+ CSAssignment assignment = allocateFromReservedContainer(clusterResource,
+ ps, currentResourceLimits, schedulingMode);
+ if (null != assignment) {
+ return assignment;
+ }
- ActivitiesLogger.APP.startAppAllocationRecording(activitiesManager,
- node.getNodeID(), SystemClock.getInstance().getTime(), application);
+ // if our queue cannot access this node, just return
+ if (schedulingMode == SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY
+ && !accessibleToPartition(ps.getPartition())) {
+ ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
+ getParent().getQueueName(), getQueueName(), ActivityState.REJECTED,
+ ActivityDiagnosticConstant.NOT_ABLE_TO_ACCESS_PARTITION + ps
+ .getPartition());
+ return CSAssignment.NULL_ASSIGNMENT;
+ }
- CSAssignment assignment = application.assignContainers(clusterResource,
- node, currentResourceLimits, schedulingMode, reservedContainer);
- handleExcessReservedContainer(clusterResource, assignment, node,
- application);
- killToPreemptContainers(clusterResource, node, assignment);
- return assignment;
+ // Check if this queue need more resource, simply skip allocation if this
+ // queue doesn't need more resources.
+ if (!hasPendingResourceRequest(ps.getPartition(), clusterResource,
+ schedulingMode)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Skip this queue=" + getQueuePath()
+ + ", because it doesn't need more resource, schedulingMode="
+ + schedulingMode.name() + " node-partition=" + ps.getPartition());
}
+ ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
+ getParent().getQueueName(), getQueueName(), ActivityState.SKIPPED,
+ ActivityDiagnosticConstant.QUEUE_DO_NOT_NEED_MORE_RESOURCE);
+ return CSAssignment.NULL_ASSIGNMENT;
+ }
- // if our queue cannot access this node, just return
- if (schedulingMode == SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY
- && !accessibleToPartition(node.getPartition())) {
+ for (Iterator<FiCaSchedulerApp> assignmentIterator =
+ orderingPolicy.getAssignmentIterator();
+ assignmentIterator.hasNext(); ) {
+ FiCaSchedulerApp application = assignmentIterator.next();
+
+ ActivitiesLogger.APP.startAppAllocationRecording(activitiesManager,
+ node.getNodeID(), SystemClock.getInstance().getTime(), application);
+
+ // Check queue max-capacity limit
+ if (!super.canAssignToThisQueue(clusterResource, ps.getPartition(),
+ currentResourceLimits, application.getCurrentReservation(),
+ schedulingMode)) {
+ ActivitiesLogger.APP.recordRejectedAppActivityFromLeafQueue(
+ activitiesManager, node, application, application.getPriority(),
+ ActivityDiagnosticConstant.QUEUE_MAX_CAPACITY_LIMIT);
ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
- getParent().getQueueName(), getQueueName(), ActivityState.REJECTED,
- ActivityDiagnosticConstant.NOT_ABLE_TO_ACCESS_PARTITION + node
- .getPartition());
+ getParent().getQueueName(), getQueueName(), ActivityState.SKIPPED,
+ ActivityDiagnosticConstant.EMPTY);
return CSAssignment.NULL_ASSIGNMENT;
}
- // Check if this queue need more resource, simply skip allocation if this
- // queue doesn't need more resources.
- if (!hasPendingResourceRequest(node.getPartition(), clusterResource,
- schedulingMode)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Skip this queue=" + getQueuePath()
- + ", because it doesn't need more resource, schedulingMode="
- + schedulingMode.name() + " node-partition=" + node
- .getPartition());
- }
+ Resource userLimit = computeUserLimitAndSetHeadroom(application,
+ clusterResource, ps.getPartition(), schedulingMode);
+
+ // Check user limit
+ if (!canAssignToUser(clusterResource, application.getUser(), userLimit,
+ application, ps.getPartition(), currentResourceLimits)) {
+ application.updateAMContainerDiagnostics(AMState.ACTIVATED,
+ "User capacity has reached its maximum limit.");
+ ActivitiesLogger.APP.recordRejectedAppActivityFromLeafQueue(
+ activitiesManager, node, application, application.getPriority(),
+ ActivityDiagnosticConstant.USER_CAPACITY_MAXIMUM_LIMIT);
+ continue;
+ }
+
+ // Try to schedule
+ assignment = application.assignContainers(clusterResource,
+ ps, currentResourceLimits, schedulingMode, null);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("post-assignContainers for application " + application
+ .getApplicationId());
+ application.showRequests();
+ }
+
+ // Did we schedule or reserve a container?
+ Resource assigned = assignment.getResource();
+
+ if (Resources.greaterThan(resourceCalculator, clusterResource, assigned,
+ Resources.none())) {
+ ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
+ getParent().getQueueName(), getQueueName(),
+ ActivityState.ACCEPTED, ActivityDiagnosticConstant.EMPTY);
+ return assignment;
+ } else if (assignment.getSkippedType()
+ == CSAssignment.SkippedType.OTHER) {
+ ActivitiesLogger.APP.finishSkippedAppAllocationRecording(
+ activitiesManager, application.getApplicationId(),
+ ActivityState.SKIPPED, ActivityDiagnosticConstant.EMPTY);
+ application.updateNodeInfoForAMDiagnostics(node);
+ } else if (assignment.getSkippedType()
+ == CSAssignment.SkippedType.QUEUE_LIMIT) {
+ return assignment;
+ } else{
+ // If we don't allocate anything, and it is not skipped by application,
+ // we will return to respect FIFO of applications
ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
getParent().getQueueName(), getQueueName(), ActivityState.SKIPPED,
- ActivityDiagnosticConstant.QUEUE_DO_NOT_NEED_MORE_RESOURCE);
+ ActivityDiagnosticConstant.RESPECT_FIFO);
+ ActivitiesLogger.APP.finishSkippedAppAllocationRecording(
+ activitiesManager, application.getApplicationId(),
+ ActivityState.SKIPPED, ActivityDiagnosticConstant.EMPTY);
return CSAssignment.NULL_ASSIGNMENT;
}
+ }
+ ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
+ getParent().getQueueName(), getQueueName(), ActivityState.SKIPPED,
+ ActivityDiagnosticConstant.EMPTY);
- for (Iterator<FiCaSchedulerApp> assignmentIterator =
- orderingPolicy.getAssignmentIterator();
- assignmentIterator.hasNext(); ) {
- FiCaSchedulerApp application = assignmentIterator.next();
-
- ActivitiesLogger.APP.startAppAllocationRecording(activitiesManager,
- node.getNodeID(), SystemClock.getInstance().getTime(), application);
+ return CSAssignment.NULL_ASSIGNMENT;
+ }
- // Check queue max-capacity limit
- if (!super.canAssignToThisQueue(clusterResource, node.getPartition(),
- currentResourceLimits, application.getCurrentReservation(),
- schedulingMode)) {
- ActivitiesLogger.APP.recordRejectedAppActivityFromLeafQueue(
- activitiesManager, node, application, application.getPriority(),
- ActivityDiagnosticConstant.QUEUE_MAX_CAPACITY_LIMIT);
- ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
- getParent().getQueueName(), getQueueName(), ActivityState.SKIPPED,
- ActivityDiagnosticConstant.EMPTY);
- return CSAssignment.NULL_ASSIGNMENT;
+ @Override
+ public boolean accept(Resource cluster,
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request) {
+ ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> allocation =
+ request.getFirstAllocatedOrReservedContainer();
+ SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> schedulerContainer =
+ allocation.getAllocatedOrReservedContainer();
+
+ // Do not check limits when allocation from a reserved container
+ if (allocation.getAllocateFromReservedContainer() == null) {
+ try {
+ readLock.lock();
+ FiCaSchedulerApp app =
+ schedulerContainer.getSchedulerApplicationAttempt();
+ String username = app.getUser();
+ String p = schedulerContainer.getNodePartition();
+
+ // check user-limit
+ Resource userLimit = computeUserLimitAndSetHeadroom(app, cluster, p,
+ allocation.getSchedulingMode());
+
+ // Deduct resources that we can release
+ Resource usedResource = Resources.clone(getUser(username).getUsed(p));
+ Resources.subtractFrom(usedResource,
+ request.getTotalReleasedResource());
+
+ if (Resources.greaterThan(resourceCalculator, cluster, usedResource,
+ userLimit)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Used resource=" + usedResource + " exceeded user-limit="
+ + userLimit);
+ }
+ return false;
}
+ } finally {
+ readLock.unlock();
+ }
+ }
- Resource userLimit = computeUserLimitAndSetHeadroom(application,
- clusterResource, node.getPartition(), schedulingMode);
-
- // Check user limit
- if (!canAssignToUser(clusterResource, application.getUser(), userLimit,
- application, node.getPartition(), currentResourceLimits)) {
- application.updateAMContainerDiagnostics(AMState.ACTIVATED,
- "User capacity has reached its maximum limit.");
- ActivitiesLogger.APP.recordRejectedAppActivityFromLeafQueue(
- activitiesManager, node, application, application.getPriority(),
- ActivityDiagnosticConstant.USER_CAPACITY_MAXIMUM_LIMIT);
- continue;
- }
+ return super.accept(cluster, request);
+ }
- // Try to schedule
- CSAssignment assignment = application.assignContainers(clusterResource,
- node, currentResourceLimits, schedulingMode, null);
+ private void internalReleaseContainer(Resource clusterResource,
+ SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> schedulerContainer) {
+ RMContainer rmContainer = schedulerContainer.getRmContainer();
- if (LOG.isDebugEnabled()) {
- LOG.debug("post-assignContainers for application " + application
- .getApplicationId());
- application.showRequests();
+ LeafQueue targetLeafQueue =
+ schedulerContainer.getSchedulerApplicationAttempt().getCSLeafQueue();
+
+ if (targetLeafQueue == this) {
+ // When trying to preempt containers from the same queue
+ if (rmContainer.hasIncreaseReservation()) {
+ // Increased container reservation
+ unreserveIncreasedContainer(clusterResource,
+ schedulerContainer.getSchedulerApplicationAttempt(),
+ schedulerContainer.getSchedulerNode(), rmContainer);
+ } else if (rmContainer.getState() == RMContainerState.RESERVED) {
+ // For other reserved containers
+ // This is a reservation exchange, complete previous reserved container
+ completedContainer(clusterResource,
+ schedulerContainer.getSchedulerApplicationAttempt(),
+ schedulerContainer.getSchedulerNode(), rmContainer, SchedulerUtils
+ .createAbnormalContainerStatus(rmContainer.getContainerId(),
+ SchedulerUtils.UNRESERVED_CONTAINER),
+ RMContainerEventType.RELEASED, null, false);
+ }
+ } else{
+ // When trying to preempt containers from different queue -- this
+ // is for lazy preemption feature (kill preemption candidate in scheduling
+ // cycle).
+ targetLeafQueue.completedContainer(clusterResource,
+ schedulerContainer.getSchedulerApplicationAttempt(),
+ schedulerContainer.getSchedulerNode(),
+ schedulerContainer.getRmContainer(), SchedulerUtils
+ .createPreemptedContainerStatus(rmContainer.getContainerId(),
+ SchedulerUtils.PREEMPTED_CONTAINER),
+ RMContainerEventType.KILL, null, false);
+ }
+ }
+
+ private void releaseContainers(Resource clusterResource,
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request) {
+ for (SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> c : request
+ .getContainersToRelease()) {
+ internalReleaseContainer(clusterResource, c);
+ }
+
+ // Handle container reservation looking, or lazy preemption case:
+ if (null != request.getContainersToAllocate() && !request
+ .getContainersToAllocate().isEmpty()) {
+ for (ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> context : request
+ .getContainersToAllocate()) {
+ if (null != context.getToRelease()) {
+ for (SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> c : context
+ .getToRelease()) {
+ internalReleaseContainer(clusterResource, c);
+ }
}
+ }
+ }
+ }
- // Did we schedule or reserve a container?
- Resource assigned = assignment.getResource();
+ public void apply(Resource cluster,
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request) {
+ // Do we need to call parent queue's apply?
+ boolean applyToParentQueue = false;
- handleExcessReservedContainer(clusterResource, assignment, node,
- application);
- killToPreemptContainers(clusterResource, node, assignment);
+ releaseContainers(cluster, request);
- if (Resources.greaterThan(resourceCalculator, clusterResource, assigned,
- Resources.none())) {
- // Get reserved or allocated container from application
- RMContainer reservedOrAllocatedRMContainer =
- application.getRMContainer(assignment.getAssignmentInformation()
- .getFirstAllocatedOrReservedContainerId());
+ try {
+ writeLock.lock();
+ if (request.anythingAllocatedOrReserved()) {
+ ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode>
+ allocation = request.getFirstAllocatedOrReservedContainer();
+ SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode>
+ schedulerContainer = allocation.getAllocatedOrReservedContainer();
+
+ // Do not modify queue when allocation from reserved container
+ if (allocation.getAllocateFromReservedContainer() == null) {
+ // Only invoke apply() of ParentQueue when new allocation /
+ // reservation happen.
+ applyToParentQueue = true;
// Book-keeping
// Note: Update headroom to account for current allocation too...
- allocateResource(clusterResource, application, assigned,
- node.getPartition(), reservedOrAllocatedRMContainer,
- assignment.isIncreasedAllocation());
-
- // Update reserved metrics
- Resource reservedRes =
- assignment.getAssignmentInformation().getReserved();
- if (reservedRes != null && !reservedRes.equals(Resources.none())) {
- incReservedResource(node.getPartition(), reservedRes);
- }
+ allocateResource(cluster,
+ schedulerContainer.getSchedulerApplicationAttempt(),
+ allocation.getAllocatedOrReservedResource(),
+ schedulerContainer.getNodePartition(),
+ schedulerContainer.getRmContainer(),
+ allocation.isIncreasedAllocation());
+ orderingPolicy.containerAllocated(
+ schedulerContainer.getSchedulerApplicationAttempt(),
+ schedulerContainer.getRmContainer());
+ }
- ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
- getParent().getQueueName(), getQueueName(),
- ActivityState.ACCEPTED, ActivityDiagnosticConstant.EMPTY);
-
- // Done
- return assignment;
- } else if (assignment.getSkippedType()
- == CSAssignment.SkippedType.OTHER) {
- ActivitiesLogger.APP.finishSkippedAppAllocationRecording(
- activitiesManager, application.getApplicationId(),
- ActivityState.SKIPPED, ActivityDiagnosticConstant.EMPTY);
- application.updateNodeInfoForAMDiagnostics(node);
- } else if (assignment.getSkippedType()
- == CSAssignment.SkippedType.QUEUE_LIMIT) {
- return assignment;
- } else{
- // If we don't allocate anything, and it is not skipped by application,
- // we will return to respect FIFO of applications
- ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
- getParent().getQueueName(), getQueueName(), ActivityState.SKIPPED,
- ActivityDiagnosticConstant.RESPECT_FIFO);
- ActivitiesLogger.APP.finishSkippedAppAllocationRecording(
- activitiesManager, application.getApplicationId(),
- ActivityState.SKIPPED, ActivityDiagnosticConstant.EMPTY);
- return CSAssignment.NULL_ASSIGNMENT;
+ // Update reserved resource
+ if (Resources.greaterThan(resourceCalculator, cluster,
+ request.getTotalReservedResource(), Resources.none())) {
+ incReservedResource(schedulerContainer.getNodePartition(),
+ request.getTotalReservedResource());
}
}
- ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
- getParent().getQueueName(), getQueueName(), ActivityState.SKIPPED,
- ActivityDiagnosticConstant.EMPTY);
-
- return CSAssignment.NULL_ASSIGNMENT;
} finally {
writeLock.unlock();
}
+
+ if (parent != null && applyToParentQueue) {
+ parent.apply(cluster, request);
+ }
}
+
protected Resource getHeadroom(User user, Resource queueCurrentLimit,
Resource clusterResource, FiCaSchedulerApp application) {
return getHeadroom(user, queueCurrentLimit, clusterResource, application,
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[49/50] [abbrv] hadoop git commit: YARN-5821. Drop left-over
preemption-related code and clean up method visibilities in the Schedulable
hierarchy (Contributed by Karthik Kambatla via Daniel Templeton)
Posted by ka...@apache.org.
YARN-5821. Drop left-over preemption-related code and clean up method visibilities in the Schedulable hierarchy
(Contributed by Karthik Kambatla via Daniel Templeton)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/e3b5c489
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/e3b5c489
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/e3b5c489
Branch: refs/heads/YARN-4752
Commit: e3b5c489bd96e51928f15604e2f99b21cf590997
Parents: 07b9bf3
Author: Daniel Templeton <te...@apache.org>
Authored: Thu Nov 3 14:50:09 2016 -0700
Committer: Karthik Kambatla <ka...@cloudera.com>
Committed: Thu Nov 10 14:48:15 2016 -0800
----------------------------------------------------------------------
.../scheduler/fair/FSAppAttempt.java | 77 ++++----------
.../scheduler/fair/FSLeafQueue.java | 102 +++----------------
.../scheduler/fair/FSParentQueue.java | 46 ++-------
.../resourcemanager/scheduler/fair/FSQueue.java | 20 ++--
.../scheduler/fair/Schedulable.java | 29 +++---
.../scheduler/fair/FakeSchedulable.java | 5 -
.../scheduler/fair/TestSchedulingPolicy.java | 5 -
7 files changed, 63 insertions(+), 221 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e3b5c489/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
index d9fdaba..8b4627e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
@@ -18,18 +18,17 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair;
-import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Comparator;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import static com.sun.xml.internal.xsom.impl.UName.comparator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience.Private;
@@ -81,7 +80,6 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
private FairScheduler scheduler;
private FSQueue fsQueue;
private Resource fairShare = Resources.createResource(0, 0);
- private RMContainerComparator comparator = new RMContainerComparator();
// Preemption related variables
private Resource fairshareStarvation = Resources.none();
@@ -121,7 +119,7 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
this.resourceWeights = new ResourceWeights();
}
- public ResourceWeights getResourceWeights() {
+ ResourceWeights getResourceWeights() {
return resourceWeights;
}
@@ -132,7 +130,7 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
return queue.getMetrics();
}
- public void containerCompleted(RMContainer rmContainer,
+ void containerCompleted(RMContainer rmContainer,
ContainerStatus containerStatus, RMContainerEventType event) {
try {
writeLock.lock();
@@ -491,7 +489,7 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
* @param schedulerKey Scheduler Key
* @param level NodeType
*/
- public void resetAllowedLocalityLevel(
+ void resetAllowedLocalityLevel(
SchedulerRequestKey schedulerKey, NodeType level) {
NodeType old;
try {
@@ -513,45 +511,45 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
}
// Preemption related methods
- public Resource getStarvation() {
+ Resource getStarvation() {
return Resources.add(fairshareStarvation, minshareStarvation);
}
- public void setMinshareStarvation(Resource starvation) {
+ void setMinshareStarvation(Resource starvation) {
this.minshareStarvation = starvation;
}
- public void resetMinshareStarvation() {
+ void resetMinshareStarvation() {
this.minshareStarvation = Resources.none();
}
- public void addPreemption(RMContainer container) {
+ void addPreemption(RMContainer container) {
containersToPreempt.add(container);
Resources.addTo(preemptedResources, container.getAllocatedResource());
}
- public Set<RMContainer> getPreemptionContainers() {
+ Set<RMContainer> getPreemptionContainers() {
return containersToPreempt;
}
- public Resource getPreemptedResources() {
+ private Resource getPreemptedResources() {
return preemptedResources;
}
- public void resetPreemptedResources() {
+ void resetPreemptedResources() {
preemptedResources = Resources.createResource(0);
for (RMContainer container : getPreemptionContainers()) {
Resources.addTo(preemptedResources, container.getAllocatedResource());
}
}
- public void clearPreemptedResources() {
+ void clearPreemptedResources() {
preemptedResources.setMemorySize(0);
preemptedResources.setVirtualCores(0);
}
- public boolean canContainerBePreempted(RMContainer container) {
+ boolean canContainerBePreempted(RMContainer container) {
// Sanity check that the app owns this container
if (!getLiveContainersMap().containsKey(container.getContainerId()) &&
!newlyAllocatedContainers.contains(container)) {
@@ -585,7 +583,7 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
* @param schedulerKey Scheduler Key
* @return Container
*/
- public Container createContainer(FSSchedulerNode node, Resource capability,
+ private Container createContainer(FSSchedulerNode node, Resource capability,
SchedulerRequestKey schedulerKey) {
NodeId nodeId = node.getRMNode().getNodeID();
@@ -593,12 +591,10 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
getApplicationAttemptId(), getNewContainerId());
// Create the container
- Container container = BuilderUtils.newContainer(containerId, nodeId,
+ return BuilderUtils.newContainer(containerId, nodeId,
node.getRMNode().getHttpAddress(), capability,
schedulerKey.getPriority(), null,
schedulerKey.getAllocationRequestId());
-
- return container;
}
/**
@@ -853,7 +849,8 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
}
Collection<SchedulerRequestKey> keysToTry = (reserved) ?
- Arrays.asList(node.getReservedContainer().getReservedSchedulerKey()) :
+ Collections.singletonList(
+ node.getReservedContainer().getReservedSchedulerKey()) :
getSchedulerKeys();
// For each priority, see if we can schedule a node local, rack local
@@ -1011,7 +1008,7 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
* Node that the application has an existing reservation on
* @return whether the reservation on the given node is valid.
*/
- public boolean assignReservedContainer(FSSchedulerNode node) {
+ boolean assignReservedContainer(FSSchedulerNode node) {
RMContainer rmContainer = node.getReservedContainer();
SchedulerRequestKey reservedSchedulerKey =
rmContainer.getReservedSchedulerKey();
@@ -1040,19 +1037,6 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
return true;
}
- static class RMContainerComparator implements Comparator<RMContainer>,
- Serializable {
- @Override
- public int compare(RMContainer c1, RMContainer c2) {
- int ret = c1.getContainer().getPriority().compareTo(
- c2.getContainer().getPriority());
- if (ret == 0) {
- return c2.getContainerId().compareTo(c1.getContainerId());
- }
- return ret;
- }
- }
-
/**
* Helper method that computes the extent of fairshare fairshareStarvation.
*/
@@ -1079,7 +1063,7 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
return this.fairshareStarvation;
}
- public ResourceRequest getNextResourceRequest() {
+ ResourceRequest getNextResourceRequest() {
return appSchedulingInfo.getNextResourceRequest();
}
@@ -1197,25 +1181,4 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
updateAMContainerDiagnostics(AMState.INACTIVATED,
diagnosticMessageBldr.toString());
}
-
- /**
- * Preempt a running container according to the priority
- */
- @Override
- public RMContainer preemptContainer() {
- if (LOG.isDebugEnabled()) {
- LOG.debug("App " + getName() + " is going to preempt a running " +
- "container");
- }
-
- RMContainer toBePreempted = null;
- for (RMContainer container : getLiveContainers()) {
- if (!getPreemptionContainers().contains(container) &&
- (toBePreempted == null ||
- comparator.compare(toBePreempted, container) > 0)) {
- toBePreempted = container;
- }
- }
- return toBePreempted;
- }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e3b5c489/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java
index 90a381e..3fcf627 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
@@ -72,7 +71,7 @@ public class FSLeafQueue extends FSQueue {
private Resource amResourceUsage;
private final ActiveUsersManager activeUsersManager;
- public static final List<FSQueue> EMPTY_LIST = Collections.emptyList();
+ private static final List<FSQueue> EMPTY_LIST = Collections.emptyList();
public FSLeafQueue(String name, FairScheduler scheduler,
FSParentQueue parent) {
@@ -84,7 +83,7 @@ public class FSLeafQueue extends FSQueue {
amResourceUsage = Resource.newInstance(0, 0);
}
- public void addApp(FSAppAttempt app, boolean runnable) {
+ void addApp(FSAppAttempt app, boolean runnable) {
writeLock.lock();
try {
if (runnable) {
@@ -111,7 +110,7 @@ public class FSLeafQueue extends FSQueue {
* Removes the given app from this queue.
* @return whether or not the app was runnable
*/
- public boolean removeApp(FSAppAttempt app) {
+ boolean removeApp(FSAppAttempt app) {
boolean runnable = false;
// Remove app from runnable/nonRunnable list while holding the write lock
@@ -142,7 +141,7 @@ public class FSLeafQueue extends FSQueue {
* Removes the given app if it is non-runnable and belongs to this queue
* @return true if the app is removed, false otherwise
*/
- public boolean removeNonRunnableApp(FSAppAttempt app) {
+ boolean removeNonRunnableApp(FSAppAttempt app) {
writeLock.lock();
try {
return nonRunnableApps.remove(app);
@@ -151,7 +150,7 @@ public class FSLeafQueue extends FSQueue {
}
}
- public boolean isRunnableApp(FSAppAttempt attempt) {
+ boolean isRunnableApp(FSAppAttempt attempt) {
readLock.lock();
try {
return runnableApps.contains(attempt);
@@ -160,7 +159,7 @@ public class FSLeafQueue extends FSQueue {
}
}
- public boolean isNonRunnableApp(FSAppAttempt attempt) {
+ boolean isNonRunnableApp(FSAppAttempt attempt) {
readLock.lock();
try {
return nonRunnableApps.contains(attempt);
@@ -169,30 +168,8 @@ public class FSLeafQueue extends FSQueue {
}
}
- public void resetPreemptedResources() {
- readLock.lock();
- try {
- for (FSAppAttempt attempt : runnableApps) {
- attempt.resetPreemptedResources();
- }
- } finally {
- readLock.unlock();
- }
- }
-
- public void clearPreemptedResources() {
- readLock.lock();
- try {
- for (FSAppAttempt attempt : runnableApps) {
- attempt.clearPreemptedResources();
- }
- } finally {
- readLock.unlock();
- }
- }
-
- public List<FSAppAttempt> getCopyOfNonRunnableAppSchedulables() {
- List<FSAppAttempt> appsToReturn = new ArrayList<FSAppAttempt>();
+ List<FSAppAttempt> getCopyOfNonRunnableAppSchedulables() {
+ List<FSAppAttempt> appsToReturn = new ArrayList<>();
readLock.lock();
try {
appsToReturn.addAll(nonRunnableApps);
@@ -320,7 +297,7 @@ public class FSLeafQueue extends FSQueue {
return usage;
}
- public Resource getAmResourceUsage() {
+ Resource getAmResourceUsage() {
return amResourceUsage;
}
@@ -407,42 +384,6 @@ public class FSLeafQueue extends FSQueue {
}
@Override
- public RMContainer preemptContainer() {
- RMContainer toBePreempted = null;
-
- // If this queue is not over its fair share, reject
- if (!preemptContainerPreCheck()) {
- return toBePreempted;
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Queue " + getName() + " is going to preempt a container " +
- "from its applications.");
- }
-
- // Choose the app that is most over fair share
- Comparator<Schedulable> comparator = policy.getComparator();
- FSAppAttempt candidateSched = null;
- readLock.lock();
- try {
- for (FSAppAttempt sched : runnableApps) {
- if (candidateSched == null ||
- comparator.compare(sched, candidateSched) > 0) {
- candidateSched = sched;
- }
- }
- } finally {
- readLock.unlock();
- }
-
- // Preempt from the selected app
- if (candidateSched != null) {
- toBePreempted = candidateSched.preemptContainer();
- }
- return toBePreempted;
- }
-
- @Override
public List<FSQueue> getChildQueues() {
return EMPTY_LIST;
}
@@ -451,7 +392,7 @@ public class FSLeafQueue extends FSQueue {
public List<QueueUserACLInfo> getQueueUserAclInfo(UserGroupInformation user) {
QueueUserACLInfo userAclInfo =
recordFactory.newRecordInstance(QueueUserACLInfo.class);
- List<QueueACL> operations = new ArrayList<QueueACL>();
+ List<QueueACL> operations = new ArrayList<>();
for (QueueACL operation : QueueACL.values()) {
if (hasAccess(operation, user)) {
operations.add(operation);
@@ -463,10 +404,6 @@ public class FSLeafQueue extends FSQueue {
return Collections.singletonList(userAclInfo);
}
- public long getLastTimeAtMinShare() {
- return lastTimeAtMinShare;
- }
-
private void setLastTimeAtMinShare(long lastTimeAtMinShare) {
this.lastTimeAtMinShare = lastTimeAtMinShare;
}
@@ -481,7 +418,7 @@ public class FSLeafQueue extends FSQueue {
}
}
- public int getNumNonRunnableApps() {
+ int getNumNonRunnableApps() {
readLock.lock();
try {
return nonRunnableApps.size();
@@ -533,10 +470,11 @@ public class FSLeafQueue extends FSQueue {
/**
* Check whether this queue can run this application master under the
* maxAMShare limit.
- * @param amResource
+ *
+ * @param amResource resources required to run the AM
* @return true if this queue can run
*/
- public boolean canRunAppAM(Resource amResource) {
+ boolean canRunAppAM(Resource amResource) {
if (Math.abs(maxAMShare - -1.0f) < 0.0001) {
return true;
}
@@ -561,7 +499,7 @@ public class FSLeafQueue extends FSQueue {
return Resources.fitsIn(ifRunAMResource, maxAMResource);
}
- public void addAMResourceUsage(Resource amResource) {
+ void addAMResourceUsage(Resource amResource) {
if (amResource != null) {
Resources.addTo(amResourceUsage, amResource);
}
@@ -583,16 +521,6 @@ public class FSLeafQueue extends FSQueue {
}
/**
- * Helper method to check if the queue should preempt containers
- *
- * @return true if check passes (can preempt) or false otherwise
- */
- private boolean preemptContainerPreCheck() {
- return parent.getPolicy().checkIfUsageOverFairShare(getResourceUsage(),
- getFairShare());
- }
-
- /**
* Helper method to compute the amount of minshare starvation.
*
* @return the extent of minshare starvation
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e3b5c489/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java
index 9eb5983..16570aa 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
@@ -61,7 +60,7 @@ public class FSParentQueue extends FSQueue {
super(name, scheduler, parent);
}
- public void addChildQueue(FSQueue child) {
+ void addChildQueue(FSQueue child) {
writeLock.lock();
try {
childQueues.add(child);
@@ -70,7 +69,7 @@ public class FSParentQueue extends FSQueue {
}
}
- public void removeChildQueue(FSQueue child) {
+ void removeChildQueue(FSQueue child) {
writeLock.lock();
try {
childQueues.remove(child);
@@ -93,7 +92,7 @@ public class FSParentQueue extends FSQueue {
}
}
- public void recomputeSteadyShares() {
+ void recomputeSteadyShares() {
readLock.lock();
try {
policy.computeSteadyShares(childQueues, getSteadyFairShare());
@@ -188,7 +187,7 @@ public class FSParentQueue extends FSQueue {
@Override
public List<QueueUserACLInfo> getQueueUserAclInfo(UserGroupInformation user) {
- List<QueueUserACLInfo> userAcls = new ArrayList<QueueUserACLInfo>();
+ List<QueueUserACLInfo> userAcls = new ArrayList<>();
// Add queue acls
userAcls.add(getUserAclInfo(user));
@@ -246,39 +245,6 @@ public class FSParentQueue extends FSQueue {
}
@Override
- public RMContainer preemptContainer() {
- RMContainer toBePreempted = null;
-
- // Find the childQueue which is most over fair share
- FSQueue candidateQueue = null;
- Comparator<Schedulable> comparator = policy.getComparator();
-
- readLock.lock();
- try {
- for (FSQueue queue : childQueues) {
- // Skip selection for non-preemptable queue
- if (!queue.isPreemptable()) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("skipping from queue=" + getName()
- + " because it's a non-preemptable queue");
- }
- } else if (candidateQueue == null ||
- comparator.compare(queue, candidateQueue) > 0) {
- candidateQueue = queue;
- }
- }
- } finally {
- readLock.unlock();
- }
-
- // Let the selected queue choose which of its container to preempt
- if (candidateQueue != null) {
- toBePreempted = candidateQueue.preemptContainer();
- }
- return toBePreempted;
- }
-
- @Override
public List<FSQueue> getChildQueues() {
readLock.lock();
try {
@@ -301,7 +267,7 @@ public class FSParentQueue extends FSQueue {
super.policy = policy;
}
- public void incrementRunnableApps() {
+ void incrementRunnableApps() {
writeLock.lock();
try {
runnableApps++;
@@ -310,7 +276,7 @@ public class FSParentQueue extends FSQueue {
}
}
- public void decrementRunnableApps() {
+ void decrementRunnableApps() {
writeLock.lock();
try {
runnableApps--;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e3b5c489/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSQueue.java
index e1e528e..572b5f9 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSQueue.java
@@ -253,7 +253,7 @@ public abstract class FSQueue implements Queue, Schedulable {
return steadyFairShare;
}
- public void setSteadyFairShare(Resource steadyFairShare) {
+ void setSteadyFairShare(Resource steadyFairShare) {
this.steadyFairShare = steadyFairShare;
metrics.setSteadyFairShare(steadyFairShare);
}
@@ -262,27 +262,27 @@ public abstract class FSQueue implements Queue, Schedulable {
return scheduler.getAllocationConfiguration().hasAccess(name, acl, user);
}
- public long getFairSharePreemptionTimeout() {
+ long getFairSharePreemptionTimeout() {
return fairSharePreemptionTimeout;
}
- public void setFairSharePreemptionTimeout(long fairSharePreemptionTimeout) {
+ void setFairSharePreemptionTimeout(long fairSharePreemptionTimeout) {
this.fairSharePreemptionTimeout = fairSharePreemptionTimeout;
}
- public long getMinSharePreemptionTimeout() {
+ long getMinSharePreemptionTimeout() {
return minSharePreemptionTimeout;
}
- public void setMinSharePreemptionTimeout(long minSharePreemptionTimeout) {
+ void setMinSharePreemptionTimeout(long minSharePreemptionTimeout) {
this.minSharePreemptionTimeout = minSharePreemptionTimeout;
}
- public float getFairSharePreemptionThreshold() {
+ float getFairSharePreemptionThreshold() {
return fairSharePreemptionThreshold;
}
- public void setFairSharePreemptionThreshold(float fairSharePreemptionThreshold) {
+ void setFairSharePreemptionThreshold(float fairSharePreemptionThreshold) {
this.fairSharePreemptionThreshold = fairSharePreemptionThreshold;
}
@@ -297,7 +297,7 @@ public abstract class FSQueue implements Queue, Schedulable {
* @param checkStarvation whether to check for fairshare or minshare
* starvation on update
*/
- public abstract void updateInternal(boolean checkStarvation);
+ abstract void updateInternal(boolean checkStarvation);
public void update(Resource fairShare, boolean checkStarvation) {
setFairShare(fairShare);
@@ -355,7 +355,7 @@ public abstract class FSQueue implements Queue, Schedulable {
*
* @return true if check passes (can assign) or false otherwise
*/
- protected boolean assignContainerPreCheck(FSSchedulerNode node) {
+ boolean assignContainerPreCheck(FSSchedulerNode node) {
if (!Resources.fitsIn(getResourceUsage(), maxShare)
|| node.getReservedContainer() != null) {
return false;
@@ -411,7 +411,7 @@ public abstract class FSQueue implements Queue, Schedulable {
return null;
}
- public boolean fitsInMaxShare(Resource additionalResource) {
+ boolean fitsInMaxShare(Resource additionalResource) {
Resource usagePlusAddition =
Resources.add(getResourceUsage(), additionalResource);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e3b5c489/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/Schedulable.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/Schedulable.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/Schedulable.java
index 289887f..cf78405 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/Schedulable.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/Schedulable.java
@@ -55,50 +55,45 @@ public interface Schedulable {
* Name of job/queue, used for debugging as well as for breaking ties in
* scheduling order deterministically.
*/
- public String getName();
+ String getName();
/**
* Maximum number of resources required by this Schedulable. This is defined as
* number of currently utilized resources + number of unlaunched resources (that
* are either not yet launched or need to be speculated).
*/
- public Resource getDemand();
+ Resource getDemand();
/** Get the aggregate amount of resources consumed by the schedulable. */
- public Resource getResourceUsage();
+ Resource getResourceUsage();
/** Minimum Resource share assigned to the schedulable. */
- public Resource getMinShare();
+ Resource getMinShare();
/** Maximum Resource share assigned to the schedulable. */
- public Resource getMaxShare();
+ Resource getMaxShare();
/** Job/queue weight in fair sharing. */
- public ResourceWeights getWeights();
+ ResourceWeights getWeights();
/** Start time for jobs in FIFO queues; meaningless for QueueSchedulables.*/
- public long getStartTime();
+ long getStartTime();
/** Job priority for jobs in FIFO queues; meaningless for QueueSchedulables. */
- public Priority getPriority();
+ Priority getPriority();
/** Refresh the Schedulable's demand and those of its children if any. */
- public void updateDemand();
+ void updateDemand();
/**
* Assign a container on this node if possible, and return the amount of
* resources assigned.
*/
- public Resource assignContainer(FSSchedulerNode node);
-
- /**
- * Preempt a container from this Schedulable if possible.
- */
- public RMContainer preemptContainer();
+ Resource assignContainer(FSSchedulerNode node);
/** Get the fair share assigned to this Schedulable. */
- public Resource getFairShare();
+ Resource getFairShare();
/** Assign a fair share to this Schedulable. */
- public void setFairShare(Resource fairShare);
+ void setFairShare(Resource fairShare);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e3b5c489/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FakeSchedulable.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FakeSchedulable.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FakeSchedulable.java
index 5a170cf..e802f42 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FakeSchedulable.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FakeSchedulable.java
@@ -86,11 +86,6 @@ public class FakeSchedulable implements Schedulable {
}
@Override
- public RMContainer preemptContainer() {
- return null;
- }
-
- @Override
public Resource getFairShare() {
return this.fairShare;
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e3b5c489/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestSchedulingPolicy.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestSchedulingPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestSchedulingPolicy.java
index dea2dd1..57c7301 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestSchedulingPolicy.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestSchedulingPolicy.java
@@ -330,11 +330,6 @@ public class TestSchedulingPolicy {
}
@Override
- public RMContainer preemptContainer() {
- throw new UnsupportedOperationException();
- }
-
- @Override
public Resource getFairShare() {
throw new UnsupportedOperationException();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[18/50] [abbrv] hadoop git commit: YARN-5377. Fix
TestQueuingContainerManager.testKillMultipleOpportunisticContainers.
(Konstantinos Karanasos via asuresh)
Posted by ka...@apache.org.
YARN-5377. Fix TestQueuingContainerManager.testKillMultipleOpportunisticContainers. (Konstantinos Karanasos via asuresh)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f38a6d03
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f38a6d03
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f38a6d03
Branch: refs/heads/YARN-4752
Commit: f38a6d03a11ca6de93a225563ddf55ec99d5063c
Parents: 3fff158
Author: Arun Suresh <as...@apache.org>
Authored: Mon Nov 7 22:10:03 2016 -0800
Committer: Arun Suresh <as...@apache.org>
Committed: Mon Nov 7 22:10:03 2016 -0800
----------------------------------------------------------------------
.../BaseContainerManagerTest.java | 38 +++++++++++++-------
.../queuing/TestQueuingContainerManager.java | 6 ++--
2 files changed, 29 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/f38a6d03/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java
index d359c3d..6dd1ac7 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java
@@ -284,15 +284,17 @@ public abstract class BaseContainerManagerTest {
.build());
}
- public static void waitForContainerState(ContainerManagementProtocol containerManager,
- ContainerId containerID, ContainerState finalState)
+ public static void waitForContainerState(
+ ContainerManagementProtocol containerManager, ContainerId containerID,
+ ContainerState finalState)
throws InterruptedException, YarnException, IOException {
waitForContainerState(containerManager, containerID, finalState, 20);
}
- public static void waitForContainerState(ContainerManagementProtocol containerManager,
- ContainerId containerID, ContainerState finalState, int timeOutMax)
- throws InterruptedException, YarnException, IOException {
+ public static void waitForContainerState(
+ ContainerManagementProtocol containerManager, ContainerId containerID,
+ ContainerState finalState, int timeOutMax)
+ throws InterruptedException, YarnException, IOException {
List<ContainerId> list = new ArrayList<ContainerId>();
list.add(containerID);
GetContainerStatusesRequest request =
@@ -314,8 +316,9 @@ public abstract class BaseContainerManagerTest {
finalState, containerStatus.getState());
}
- static void waitForApplicationState(ContainerManagerImpl containerManager,
- ApplicationId appID, ApplicationState finalState)
+ public static void waitForApplicationState(
+ ContainerManagerImpl containerManager, ApplicationId appID,
+ ApplicationState finalState)
throws InterruptedException {
// Wait for app-finish
Application app =
@@ -344,7 +347,16 @@ public abstract class BaseContainerManagerTest {
public static void waitForNMContainerState(ContainerManagerImpl
containerManager, ContainerId containerID,
org.apache.hadoop.yarn.server.nodemanager.containermanager
- .container.ContainerState finalState, int timeOutMax)
+ .container.ContainerState finalState, int timeOutMax)
+ throws InterruptedException, YarnException, IOException {
+ waitForNMContainerState(containerManager, containerID,
+ Arrays.asList(finalState), timeOutMax);
+ }
+
+ public static void waitForNMContainerState(ContainerManagerImpl
+ containerManager, ContainerId containerID,
+ List<org.apache.hadoop.yarn.server.nodemanager.containermanager
+ .container.ContainerState> finalStates, int timeOutMax)
throws InterruptedException, YarnException, IOException {
Container container = null;
org.apache.hadoop.yarn.server.nodemanager
@@ -358,15 +370,15 @@ public abstract class BaseContainerManagerTest {
currentState = container.getContainerState();
}
if (currentState != null) {
- LOG.info("Waiting for NM container to get into state " + finalState
- + ". Current state is " + currentState);
+ LOG.info("Waiting for NM container to get into one of the following " +
+ "states: " + finalStates + ". Current state is " + currentState);
}
timeoutSecs += 2;
- } while (!currentState.equals(finalState)
+ } while (!finalStates.contains(currentState)
&& timeoutSecs++ < timeOutMax);
LOG.info("Container state is " + currentState);
- Assert.assertEquals("ContainerState is not correct (timedout)",
- finalState, currentState);
+ Assert.assertTrue("ContainerState is not correct (timedout)",
+ finalStates.contains(currentState));
}
public static Token createContainerToken(ContainerId cId, long rmIdentifier,
http://git-wip-us.apache.org/repos/asf/hadoop/blob/f38a6d03/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/queuing/TestQueuingContainerManager.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/queuing/TestQueuingContainerManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/queuing/TestQueuingContainerManager.java
index caebef7..7f06afa 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/queuing/TestQueuingContainerManager.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/queuing/TestQueuingContainerManager.java
@@ -467,8 +467,10 @@ public class TestQueuingContainerManager extends BaseContainerManagerTest {
StartContainersRequest.newInstance(list);
containerManager.startContainers(allRequests);
- BaseContainerManagerTest.waitForNMContainerState(containerManager,
- createContainerId(0), ContainerState.DONE, 40);
+ BaseContainerManagerTest.waitForNMContainerState(
+ containerManager, createContainerId(0),
+ Arrays.asList(ContainerState.DONE,
+ ContainerState.CONTAINER_CLEANEDUP_AFTER_KILL), 40);
Thread.sleep(5000);
// Get container statuses. Container 0 should be killed, container 1
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[09/50] [abbrv] hadoop git commit: YARN-5716. Add global scheduler
interface definition and update CapacityScheduler to use it. Contributed by
Wangda Tan
Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestParentQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestParentQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestParentQueue.java
index 42a8872..d875969 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestParentQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestParentQueue.java
@@ -49,8 +49,12 @@ import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsMana
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeType;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.preemption.PreemptionManager;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.SchedulerContainer;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
import org.apache.hadoop.yarn.util.resource.Resources;
@@ -123,6 +127,27 @@ public class TestParentQueue {
return application;
}
+ private void applyAllocationToQueue(Resource clusterResource,
+ int allocatedMem,
+ CSQueue queue) {
+ // Call accept & apply for queue
+ ResourceCommitRequest request = mock(ResourceCommitRequest.class);
+ when(request.anythingAllocatedOrReserved()).thenReturn(true);
+ ContainerAllocationProposal allocation = mock(
+ ContainerAllocationProposal.class);
+ when(request.getTotalReleasedResource()).thenReturn(Resources.none());
+ when(request.getFirstAllocatedOrReservedContainer()).thenReturn(allocation);
+ SchedulerContainer scontainer = mock(SchedulerContainer.class);
+ when(allocation.getAllocatedOrReservedContainer()).thenReturn(scontainer);
+ when(allocation.getAllocatedOrReservedResource()).thenReturn(
+ Resources.createResource(allocatedMem));
+ when(scontainer.getNodePartition()).thenReturn("");
+
+ if (queue.accept(clusterResource, request)) {
+ queue.apply(clusterResource, request);
+ }
+ }
+
private void stubQueueAllocation(final CSQueue queue,
final Resource clusterResource, final FiCaSchedulerNode node,
final int allocation) {
@@ -157,7 +182,7 @@ public class TestParentQueue {
// Next call - nothing
if (allocation > 0) {
doReturn(new CSAssignment(Resources.none(), type)).when(queue)
- .assignContainers(eq(clusterResource), eq(node),
+ .assignContainers(eq(clusterResource), any(PlacementSet.class),
any(ResourceLimits.class), any(SchedulingMode.class));
// Mock the node's resource availability
@@ -168,7 +193,7 @@ public class TestParentQueue {
return new CSAssignment(allocatedResource, type);
}
- }).when(queue).assignContainers(eq(clusterResource), eq(node),
+ }).when(queue).assignContainers(eq(clusterResource), any(PlacementSet.class),
any(ResourceLimits.class), any(SchedulingMode.class));
}
@@ -205,8 +230,8 @@ public class TestParentQueue {
setupSingleLevelQueues(csConf);
Map<String, CSQueue> queues = new HashMap<String, CSQueue>();
- CSQueue root =
- CapacityScheduler.parseQueue(csContext, csConf, null,
+ CSQueue root =
+ CapacityScheduler.parseQueue(csContext, csConf, null,
CapacitySchedulerConfiguration.ROOT, queues, queues,
TestUtils.spyHook);
@@ -245,13 +270,18 @@ public class TestParentQueue {
// Now, A should get the scheduling opportunity since A=0G/6G, B=1G/14G
stubQueueAllocation(a, clusterResource, node_1, 2*GB);
stubQueueAllocation(b, clusterResource, node_1, 1*GB);
- root.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ root.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
InOrder allocationOrder = inOrder(a, b);
- allocationOrder.verify(a).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ allocationOrder.verify(a).assignContainers(eq(clusterResource),
+ any(PlacementSet.class), anyResourceLimits(),
+ any(SchedulingMode.class));
+ root.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
allocationOrder.verify(b).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
verifyQueueMetrics(a, 2*GB, clusterResource);
verifyQueueMetrics(b, 2*GB, clusterResource);
@@ -261,11 +291,13 @@ public class TestParentQueue {
stubQueueAllocation(b, clusterResource, node_0, 2*GB);
root.assignContainers(clusterResource, node_0,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ root.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
allocationOrder = inOrder(b, a);
allocationOrder.verify(b).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
allocationOrder.verify(a).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
verifyQueueMetrics(a, 3*GB, clusterResource);
verifyQueueMetrics(b, 4*GB, clusterResource);
@@ -277,9 +309,9 @@ public class TestParentQueue {
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
allocationOrder = inOrder(b, a);
allocationOrder.verify(b).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
allocationOrder.verify(a).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
verifyQueueMetrics(a, 3*GB, clusterResource);
verifyQueueMetrics(b, 8*GB, clusterResource);
@@ -287,13 +319,17 @@ public class TestParentQueue {
// since A has 3/6G while B has 8/14G
stubQueueAllocation(a, clusterResource, node_1, 1*GB);
stubQueueAllocation(b, clusterResource, node_1, 1*GB);
- root.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ root.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ root.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
allocationOrder = inOrder(a, b);
allocationOrder.verify(b).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
allocationOrder.verify(a).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
verifyQueueMetrics(a, 4*GB, clusterResource);
verifyQueueMetrics(b, 9*GB, clusterResource);
}
@@ -430,9 +466,9 @@ public class TestParentQueue {
setupMultiLevelQueues(csConf);
Map<String, CSQueue> queues = new HashMap<String, CSQueue>();
- CSQueue root =
- CapacityScheduler.parseQueue(csContext, csConf, null,
- CapacitySchedulerConfiguration.ROOT, queues, queues,
+ CSQueue root =
+ CapacityScheduler.parseQueue(csContext, csConf, null,
+ CapacitySchedulerConfiguration.ROOT, queues, queues,
TestUtils.spyHook);
// Setup some nodes
@@ -496,6 +532,8 @@ public class TestParentQueue {
stubQueueAllocation(c, clusterResource, node_1, 0*GB);
root.assignContainers(clusterResource, node_1,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ applyAllocationToQueue(clusterResource, 4*GB,
+ b);
verifyQueueMetrics(a, 0*GB, clusterResource);
verifyQueueMetrics(b, 4*GB, clusterResource);
verifyQueueMetrics(c, 1*GB, clusterResource);
@@ -506,15 +544,27 @@ public class TestParentQueue {
stubQueueAllocation(a1, clusterResource, node_0, 1*GB);
stubQueueAllocation(b3, clusterResource, node_0, 2*GB);
stubQueueAllocation(c, clusterResource, node_0, 2*GB);
+
root.assignContainers(clusterResource, node_0,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
InOrder allocationOrder = inOrder(a, c, b);
allocationOrder.verify(a).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
+ applyAllocationToQueue(clusterResource, 1*GB, a);
+
+ root.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
allocationOrder.verify(c).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
- allocationOrder.verify(b).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
+ applyAllocationToQueue(clusterResource, 2*GB, root);
+
+ root.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ allocationOrder.verify(b).assignContainers(eq(clusterResource),
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
+ applyAllocationToQueue(clusterResource, 2*GB, b);
verifyQueueMetrics(a, 1*GB, clusterResource);
verifyQueueMetrics(b, 6*GB, clusterResource);
verifyQueueMetrics(c, 3*GB, clusterResource);
@@ -533,17 +583,28 @@ public class TestParentQueue {
stubQueueAllocation(b3, clusterResource, node_2, 1*GB);
stubQueueAllocation(b1, clusterResource, node_2, 1*GB);
stubQueueAllocation(c, clusterResource, node_2, 1*GB);
- root.assignContainers(clusterResource, node_2,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ root.assignContainers(clusterResource, node_2,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
allocationOrder = inOrder(a, a2, a1, b, c);
allocationOrder.verify(a).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
allocationOrder.verify(a2).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
+ applyAllocationToQueue(clusterResource, 2*GB, a);
+
+ root.assignContainers(clusterResource, node_2,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
allocationOrder.verify(b).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
+ applyAllocationToQueue(clusterResource, 2*GB, b);
+
+ root.assignContainers(clusterResource, node_2,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
allocationOrder.verify(c).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
verifyQueueMetrics(a, 3*GB, clusterResource);
verifyQueueMetrics(b, 8*GB, clusterResource);
verifyQueueMetrics(c, 4*GB, clusterResource);
@@ -614,27 +675,25 @@ public class TestParentQueue {
public void testOffSwitchScheduling() throws Exception {
// Setup queue configs
setupSingleLevelQueues(csConf);
- csConf.setOffSwitchPerHeartbeatLimit(2);
-
Map<String, CSQueue> queues = new HashMap<String, CSQueue>();
- CSQueue root =
- CapacityScheduler.parseQueue(csContext, csConf, null,
- CapacitySchedulerConfiguration.ROOT, queues, queues,
+ CSQueue root =
+ CapacityScheduler.parseQueue(csContext, csConf, null,
+ CapacitySchedulerConfiguration.ROOT, queues, queues,
TestUtils.spyHook);
// Setup some nodes
final int memoryPerNode = 10;
final int coresPerNode = 16;
final int numNodes = 2;
-
- FiCaSchedulerNode node_0 =
+
+ FiCaSchedulerNode node_0 =
TestUtils.getMockNode("host_0", DEFAULT_RACK, 0, memoryPerNode*GB);
- FiCaSchedulerNode node_1 =
+ FiCaSchedulerNode node_1 =
TestUtils.getMockNode("host_1", DEFAULT_RACK, 0, memoryPerNode*GB);
-
- final Resource clusterResource =
- Resources.createResource(numNodes * (memoryPerNode*GB),
+
+ final Resource clusterResource =
+ Resources.createResource(numNodes * (memoryPerNode*GB),
numNodes * coresPerNode);
when(csContext.getNumClusterNodes()).thenReturn(numNodes);
@@ -644,50 +703,46 @@ public class TestParentQueue {
a.getQueueResourceUsage().incPending(Resources.createResource(1 * GB));
b.getQueueResourceUsage().incPending(Resources.createResource(1 * GB));
queues.get(CapacitySchedulerConfiguration.ROOT).getQueueResourceUsage()
- .incPending(Resources.createResource(1 * GB));
-
- // Simulate returning 2 containers on node_0 before offswitch limit
- stubQueueAllocation(a, clusterResource, node_0, 1*GB, NodeType.OFF_SWITCH);
- stubQueueAllocation(b, clusterResource, node_0, 1*GB, NodeType.OFF_SWITCH);
+ .incPending(Resources.createResource(1 * GB));
- root.assignContainers(clusterResource, node_0,
+ // Simulate B returning a container on node_0
+ stubQueueAllocation(a, clusterResource, node_0, 0*GB, NodeType.OFF_SWITCH);
+ stubQueueAllocation(b, clusterResource, node_0, 1*GB, NodeType.OFF_SWITCH);
+ root.assignContainers(clusterResource, node_0,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
- InOrder allocationOrder = inOrder(a, b);
- allocationOrder.verify(a, times(1)).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
- allocationOrder.verify(b, times(1)).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
- verifyQueueMetrics(a, 1*GB, clusterResource);
+ verifyQueueMetrics(a, 0*GB, clusterResource);
verifyQueueMetrics(b, 1*GB, clusterResource);
-
+
// Now, A should get the scheduling opportunity since A=0G/6G, B=1G/14G
// also, B gets a scheduling opportunity since A allocates RACK_LOCAL
stubQueueAllocation(a, clusterResource, node_1, 2*GB, NodeType.RACK_LOCAL);
stubQueueAllocation(b, clusterResource, node_1, 1*GB, NodeType.OFF_SWITCH);
- root.assignContainers(clusterResource, node_1,
+ root.assignContainers(clusterResource, node_1,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
- allocationOrder = inOrder(a, b);
- allocationOrder.verify(a, times(1)).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
- allocationOrder.verify(b, times(1)).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
- verifyQueueMetrics(a, 3*GB, clusterResource);
+ InOrder allocationOrder = inOrder(a);
+ allocationOrder.verify(a).assignContainers(eq(clusterResource),
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
+ root.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ allocationOrder = inOrder(b);
+ allocationOrder.verify(b).assignContainers(eq(clusterResource),
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
+ verifyQueueMetrics(a, 2*GB, clusterResource);
verifyQueueMetrics(b, 2*GB, clusterResource);
-
- // Now, B should get the scheduling opportunity
- // since A has 2/6G while B has 2/14G,
- // A also gets an opportunity because offswitchlimit not reached
+
+ // Now, B should get the scheduling opportunity
+ // since A has 2/6G while B has 2/14G,
+ // However, since B returns off-switch, A won't get an opportunity
stubQueueAllocation(a, clusterResource, node_0, 1*GB, NodeType.NODE_LOCAL);
stubQueueAllocation(b, clusterResource, node_0, 2*GB, NodeType.OFF_SWITCH);
-
- root.assignContainers(clusterResource, node_0,
+ root.assignContainers(clusterResource, node_0,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
allocationOrder = inOrder(b, a);
- allocationOrder.verify(b, times(1)).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
- allocationOrder.verify(a, times(1)).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
- verifyQueueMetrics(a, 4*GB, clusterResource);
+ allocationOrder.verify(b).assignContainers(eq(clusterResource),
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
+ allocationOrder.verify(a).assignContainers(eq(clusterResource),
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
+ verifyQueueMetrics(a, 2*GB, clusterResource);
verifyQueueMetrics(b, 4*GB, clusterResource);
}
@@ -743,11 +798,13 @@ public class TestParentQueue {
stubQueueAllocation(b3, clusterResource, node_1, 1*GB, NodeType.OFF_SWITCH);
root.assignContainers(clusterResource, node_1,
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ root.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
InOrder allocationOrder = inOrder(b2, b3);
allocationOrder.verify(b2).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
allocationOrder.verify(b3).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
verifyQueueMetrics(b2, 1*GB, clusterResource);
verifyQueueMetrics(b3, 2*GB, clusterResource);
@@ -760,9 +817,9 @@ public class TestParentQueue {
new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
allocationOrder = inOrder(b3, b2);
allocationOrder.verify(b3).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
allocationOrder.verify(b2).assignContainers(eq(clusterResource),
- any(FiCaSchedulerNode.class), anyResourceLimits(), any(SchedulingMode.class));
+ any(PlacementSet.class), anyResourceLimits(), any(SchedulingMode.class));
verifyQueueMetrics(b2, 1*GB, clusterResource);
verifyQueueMetrics(b3, 3*GB, clusterResource);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java
index 8fe85c9..f6caa50 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -30,6 +32,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import com.google.common.collect.ImmutableMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
@@ -59,6 +62,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicat
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerRequestKey;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.preemption.PreemptionManager;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager;
@@ -190,6 +194,15 @@ public class TestReservations {
}
static LeafQueue stubLeafQueue(LeafQueue queue) {
+ ParentQueue parent = (ParentQueue) queue.getParent();
+
+ if (parent != null) {
+ // Stub out parent queue's accept and apply.
+ doReturn(true).when(parent).accept(any(Resource.class),
+ any(ResourceCommitRequest.class));
+ doNothing().when(parent).apply(any(Resource.class),
+ any(ResourceCommitRequest.class));
+ }
return queue;
}
@@ -239,6 +252,12 @@ public class TestReservations {
FiCaSchedulerNode node_2 = TestUtils.getMockNode(host_2, DEFAULT_RACK, 0,
8 * GB);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1, node_2.getNodeID(), node_2);
+
when(csContext.getNode(node_0.getNodeID())).thenReturn(node_0);
when(csContext.getNode(node_1.getNodeID())).thenReturn(node_1);
when(csContext.getNode(node_2.getNodeID())).thenReturn(node_2);
@@ -268,8 +287,10 @@ public class TestReservations {
// Start testing...
// Only AM
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(2 * GB, a.getUsedResources().getMemorySize());
assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -280,8 +301,10 @@ public class TestReservations {
assertEquals(0 * GB, node_2.getAllocatedResource().getMemorySize());
// Only 1 map - simulating reduce
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(5 * GB, a.getUsedResources().getMemorySize());
assertEquals(5 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -292,8 +315,10 @@ public class TestReservations {
assertEquals(0 * GB, node_2.getAllocatedResource().getMemorySize());
// Only 1 map to other node - simulating reduce
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(8 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -308,8 +333,10 @@ public class TestReservations {
toSchedulerKey(priorityReduce)));
// try to assign reducer (5G on node 0 and should reserve)
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(13 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(5 * GB, a.getMetrics().getReservedMB());
@@ -325,8 +352,10 @@ public class TestReservations {
toSchedulerKey(priorityReduce)));
// assign reducer to node 2
- a.assignContainers(clusterResource, node_2,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_2,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(18 * GB, a.getUsedResources().getMemorySize());
assertEquals(13 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(5 * GB, a.getMetrics().getReservedMB());
@@ -343,8 +372,10 @@ public class TestReservations {
// node_1 heartbeat and unreserves from node_0 in order to allocate
// on node_1
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(18 * GB, a.getUsedResources().getMemorySize());
assertEquals(18 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -412,6 +443,12 @@ public class TestReservations {
when(csContext.getNode(node_1.getNodeID())).thenReturn(node_1);
when(csContext.getNode(node_2.getNodeID())).thenReturn(node_2);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1, node_2.getNodeID(), node_2);
+
cs.getNodeTracker().addNode(node_0);
cs.getNodeTracker().addNode(node_1);
cs.getNodeTracker().addNode(node_2);
@@ -434,8 +471,10 @@ public class TestReservations {
// Start testing...
// Only AM
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(2 * GB, a.getUsedResources().getMemorySize());
assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, app_1.getCurrentConsumption().getMemorySize());
@@ -446,8 +485,10 @@ public class TestReservations {
assertEquals(0 * GB, node_1.getAllocatedResource().getMemorySize());
assertEquals(0 * GB, node_2.getAllocatedResource().getMemorySize());
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(4 * GB, a.getUsedResources().getMemorySize());
assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(2 * GB, app_1.getCurrentConsumption().getMemorySize());
@@ -467,8 +508,10 @@ public class TestReservations {
priorityMap, recordFactory)));
// add a reservation for app_0
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(12 * GB, a.getUsedResources().getMemorySize());
assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(2 * GB, app_1.getCurrentConsumption().getMemorySize());
@@ -481,8 +524,10 @@ public class TestReservations {
// next assignment is beyond user limit for user_0 but it should assign to
// app_1 for user_1
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(14 * GB, a.getUsedResources().getMemorySize());
assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(4 * GB, app_1.getCurrentConsumption().getMemorySize());
@@ -544,6 +589,12 @@ public class TestReservations {
FiCaSchedulerNode node_2 = TestUtils.getMockNode(host_2, DEFAULT_RACK, 0,
8 * GB);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1, node_2.getNodeID(), node_2);
+
when(csContext.getNode(node_0.getNodeID())).thenReturn(node_0);
when(csContext.getNode(node_1.getNodeID())).thenReturn(node_1);
when(csContext.getNode(node_2.getNodeID())).thenReturn(node_2);
@@ -569,8 +620,10 @@ public class TestReservations {
// Start testing...
// Only AM
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(2 * GB, a.getUsedResources().getMemorySize());
assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -581,8 +634,10 @@ public class TestReservations {
assertEquals(0 * GB, node_2.getAllocatedResource().getMemorySize());
// Only 1 map - simulating reduce
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(5 * GB, a.getUsedResources().getMemorySize());
assertEquals(5 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -593,8 +648,10 @@ public class TestReservations {
assertEquals(0 * GB, node_2.getAllocatedResource().getMemorySize());
// Only 1 map to other node - simulating reduce
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(8 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -609,8 +666,10 @@ public class TestReservations {
toSchedulerKey(priorityReduce)));
// try to assign reducer (5G on node 0 and should reserve)
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(13 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(5 * GB, a.getMetrics().getReservedMB());
@@ -626,8 +685,10 @@ public class TestReservations {
toSchedulerKey(priorityReduce)));
// assign reducer to node 2
- a.assignContainers(clusterResource, node_2,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_2,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(18 * GB, a.getUsedResources().getMemorySize());
assertEquals(13 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(5 * GB, a.getMetrics().getReservedMB());
@@ -644,8 +705,10 @@ public class TestReservations {
// node_1 heartbeat and won't unreserve from node_0, potentially stuck
// if AM doesn't handle
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(18 * GB, a.getUsedResources().getMemorySize());
assertEquals(13 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(5 * GB, a.getMetrics().getReservedMB());
@@ -706,6 +769,12 @@ public class TestReservations {
FiCaSchedulerNode node_1 = TestUtils.getMockNode(host_1, DEFAULT_RACK, 0,
8 * GB);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1);
+
cs.getNodeTracker().addNode(node_0);
cs.getNodeTracker().addNode(node_1);
@@ -733,8 +802,10 @@ public class TestReservations {
// Start testing...
// Only AM
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(2 * GB, a.getUsedResources().getMemorySize());
assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -744,8 +815,10 @@ public class TestReservations {
assertEquals(0 * GB, node_1.getAllocatedResource().getMemorySize());
// Only 1 map - simulating reduce
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(5 * GB, a.getUsedResources().getMemorySize());
assertEquals(5 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -755,8 +828,10 @@ public class TestReservations {
assertEquals(0 * GB, node_1.getAllocatedResource().getMemorySize());
// Only 1 map to other node - simulating reduce
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(8 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -770,8 +845,10 @@ public class TestReservations {
toSchedulerKey(priorityReduce)));
// try to assign reducer (5G on node 0 and should reserve)
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(13 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(5 * GB, a.getMetrics().getReservedMB());
@@ -786,8 +863,10 @@ public class TestReservations {
toSchedulerKey(priorityReduce)));
// could allocate but told need to unreserve first
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(13 * GB, a.getUsedResources().getMemorySize());
assertEquals(13 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -983,6 +1062,12 @@ public class TestReservations {
when(csContext.getNode(node_1.getNodeID())).thenReturn(node_1);
when(csContext.getNode(node_2.getNodeID())).thenReturn(node_2);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1, node_2.getNodeID(), node_2);
+
final int numNodes = 2;
Resource clusterResource = Resources.createResource(numNodes * (8 * GB));
when(csContext.getNumClusterNodes()).thenReturn(numNodes);
@@ -1004,8 +1089,10 @@ public class TestReservations {
// Start testing...
// Only AM
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(2 * GB, a.getUsedResources().getMemorySize());
assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -1015,8 +1102,10 @@ public class TestReservations {
assertEquals(0 * GB, node_1.getAllocatedResource().getMemorySize());
// Only 1 map - simulating reduce
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(5 * GB, a.getUsedResources().getMemorySize());
assertEquals(5 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -1026,8 +1115,10 @@ public class TestReservations {
assertEquals(0 * GB, node_1.getAllocatedResource().getMemorySize());
// Only 1 map to other node - simulating reduce
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(8 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -1040,8 +1131,10 @@ public class TestReservations {
// now add in reservations and make sure it continues if config set
// allocate to queue so that the potential new capacity is greater then
// absoluteMaxCapacity
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(13 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(5 * GB, a.getMetrics().getReservedMB());
@@ -1153,6 +1246,12 @@ public class TestReservations {
FiCaSchedulerNode node_2 = TestUtils.getMockNode(host_2, DEFAULT_RACK, 0,
8 * GB);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1, node_2.getNodeID(), node_2);
+
when(csContext.getNode(node_0.getNodeID())).thenReturn(node_0);
when(csContext.getNode(node_1.getNodeID())).thenReturn(node_1);
when(csContext.getNode(node_2.getNodeID())).thenReturn(node_2);
@@ -1178,8 +1277,10 @@ public class TestReservations {
// Start testing...
// Only AM
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(2 * GB, a.getUsedResources().getMemorySize());
assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -1189,8 +1290,10 @@ public class TestReservations {
assertEquals(0 * GB, node_1.getAllocatedResource().getMemorySize());
// Only 1 map - simulating reduce
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(5 * GB, a.getUsedResources().getMemorySize());
assertEquals(5 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -1200,8 +1303,10 @@ public class TestReservations {
assertEquals(0 * GB, node_1.getAllocatedResource().getMemorySize());
// Only 1 map to other node - simulating reduce
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(8 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -1214,8 +1319,10 @@ public class TestReservations {
// now add in reservations and make sure it continues if config set
// allocate to queue so that the potential new capacity is greater then
// absoluteMaxCapacity
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(13 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(5 * GB, app_0.getCurrentReservation().getMemorySize());
@@ -1301,6 +1408,12 @@ public class TestReservations {
FiCaSchedulerNode node_2 = TestUtils.getMockNode(host_2, DEFAULT_RACK, 0,
8 * GB);
+ Map<ApplicationAttemptId, FiCaSchedulerApp> apps = ImmutableMap.of(
+ app_0.getApplicationAttemptId(), app_0, app_1.getApplicationAttemptId(),
+ app_1);
+ Map<NodeId, FiCaSchedulerNode> nodes = ImmutableMap.of(node_0.getNodeID(),
+ node_0, node_1.getNodeID(), node_1, node_2.getNodeID(), node_2);
+
when(csContext.getNode(node_0.getNodeID())).thenReturn(node_0);
when(csContext.getNode(node_1.getNodeID())).thenReturn(node_1);
when(csContext.getNode(node_2.getNodeID())).thenReturn(node_2);
@@ -1330,8 +1443,10 @@ public class TestReservations {
// Start testing...
// Only AM
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(2 * GB, a.getUsedResources().getMemorySize());
assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -1342,8 +1457,10 @@ public class TestReservations {
assertEquals(0 * GB, node_2.getAllocatedResource().getMemorySize());
// Only 1 map - simulating reduce
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(5 * GB, a.getUsedResources().getMemorySize());
assertEquals(5 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -1354,8 +1471,10 @@ public class TestReservations {
assertEquals(0 * GB, node_2.getAllocatedResource().getMemorySize());
// Only 1 map to other node - simulating reduce
- a.assignContainers(clusterResource, node_1,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_1,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(8 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -1370,8 +1489,10 @@ public class TestReservations {
// used (8G) + required (5G). It will not reserved since it has to unreserve
// some resource. Even with continous reservation looking, we don't allow
// unreserve resource to reserve container.
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(Resources.createResource(10 * GB)), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(Resources.createResource(10 * GB)),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(8 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -1386,8 +1507,10 @@ public class TestReservations {
// try to assign reducer (5G on node 0), but tell it's resource limits <
// used (8G) + required (5G). It will not reserved since it has to unreserve
// some resource. Unfortunately, there's nothing to unreserve.
- a.assignContainers(clusterResource, node_2,
- new ResourceLimits(Resources.createResource(10 * GB)), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_2,
+ new ResourceLimits(Resources.createResource(10 * GB)),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(8 * GB, a.getUsedResources().getMemorySize());
assertEquals(8 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -1400,8 +1523,10 @@ public class TestReservations {
assertEquals(0 * GB, node_2.getAllocatedResource().getMemorySize());
// let it assign 5G to node_2
- a.assignContainers(clusterResource, node_2,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_2,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(13 * GB, a.getUsedResources().getMemorySize());
assertEquals(13 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(0 * GB, a.getMetrics().getReservedMB());
@@ -1413,8 +1538,10 @@ public class TestReservations {
assertEquals(5 * GB, node_2.getAllocatedResource().getMemorySize());
// reserve 8G node_0
- a.assignContainers(clusterResource, node_0,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_0,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(21 * GB, a.getUsedResources().getMemorySize());
assertEquals(13 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(8 * GB, a.getMetrics().getReservedMB());
@@ -1428,8 +1555,10 @@ public class TestReservations {
// try to assign (8G on node 2). No room to allocate,
// continued to try due to having reservation above,
// but hits queue limits so can't reserve anymore.
- a.assignContainers(clusterResource, node_2,
- new ResourceLimits(clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
+ TestUtils.applyResourceCommitRequest(clusterResource,
+ a.assignContainers(clusterResource, node_2,
+ new ResourceLimits(clusterResource),
+ SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), nodes, apps);
assertEquals(21 * GB, a.getUsedResources().getMemorySize());
assertEquals(13 * GB, app_0.getCurrentConsumption().getMemorySize());
assertEquals(8 * GB, a.getMetrics().getReservedMB());
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestUtils.java
index a60b7ed..e34ee34 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestUtils.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestUtils.java
@@ -24,6 +24,8 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
+import java.io.IOException;
+import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -430,4 +432,28 @@ public class TestUtils {
req.setAllocationRequestId(allocationRequestId);
return SchedulerRequestKey.create(req);
}
+
+ public static void applyResourceCommitRequest(Resource clusterResource,
+ CSAssignment csAssignment,
+ final Map<NodeId, FiCaSchedulerNode> nodes,
+ final Map<ApplicationAttemptId, FiCaSchedulerApp> apps)
+ throws IOException {
+ CapacityScheduler cs = new CapacityScheduler() {
+ @Override
+ public FiCaSchedulerNode getNode(NodeId nodeId) {
+ return nodes.get(nodeId);
+ }
+
+ @Override
+ public FiCaSchedulerApp getApplicationAttempt(
+ ApplicationAttemptId applicationAttemptId) {
+ return apps.get(applicationAttemptId);
+ }
+ };
+
+ cs.setResourceCalculator(new DefaultResourceCalculator());
+
+ cs.submitResourceCommitRequest(clusterResource,
+ csAssignment);
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesSchedulerActivities.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesSchedulerActivities.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesSchedulerActivities.java
index a0bd951..1e61186 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesSchedulerActivities.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesSchedulerActivities.java
@@ -103,10 +103,6 @@ public class TestRMWebServicesSchedulerActivities
verifyStateOfAllocations(allocations.getJSONObject(i),
"finalAllocationState", "ALLOCATED");
verifyQueueOrder(allocations.getJSONObject(i), "root-a-b-b2-b3-b1");
- } else {
- verifyStateOfAllocations(allocations.getJSONObject(i),
- "finalAllocationState", "SKIPPED");
- verifyQueueOrder(allocations.getJSONObject(i), "root-a-b");
}
}
}
@@ -409,9 +405,9 @@ public class TestRMWebServicesSchedulerActivities
verifyStateOfAllocations(allocations, "finalAllocationState",
"ALLOCATED");
- verifyNumberOfNodes(allocations, 6);
+ verifyNumberOfNodes(allocations, 5);
- verifyQueueOrder(json.getJSONObject("allocations"), "root-a-b-b1");
+ verifyQueueOrder(json.getJSONObject("allocations"), "root-b-b1");
}
finally {
rm.stop();
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[08/50] [abbrv] hadoop git commit: HADOOP-13795. Skip
testGlobStatusThrowsExceptionForUnreadableDir in TestFSMainOperationsSwift.
Contributed by John Zhuge.
Posted by ka...@apache.org.
HADOOP-13795. Skip testGlobStatusThrowsExceptionForUnreadableDir in TestFSMainOperationsSwift. Contributed by John Zhuge.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/acd509dc
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/acd509dc
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/acd509dc
Branch: refs/heads/YARN-4752
Commit: acd509dc57d6b8b3791a8332fec9bdf53a8f9d36
Parents: f768955
Author: Xiao Chen <xi...@apache.org>
Authored: Mon Nov 7 09:21:01 2016 -0800
Committer: Xiao Chen <xi...@apache.org>
Committed: Mon Nov 7 09:21:01 2016 -0800
----------------------------------------------------------------------
.../org/apache/hadoop/fs/swift/TestFSMainOperationsSwift.java | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/acd509dc/hadoop-tools/hadoop-openstack/src/test/java/org/apache/hadoop/fs/swift/TestFSMainOperationsSwift.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-openstack/src/test/java/org/apache/hadoop/fs/swift/TestFSMainOperationsSwift.java b/hadoop-tools/hadoop-openstack/src/test/java/org/apache/hadoop/fs/swift/TestFSMainOperationsSwift.java
index 74299df..b595f1c 100644
--- a/hadoop-tools/hadoop-openstack/src/test/java/org/apache/hadoop/fs/swift/TestFSMainOperationsSwift.java
+++ b/hadoop-tools/hadoop-openstack/src/test/java/org/apache/hadoop/fs/swift/TestFSMainOperationsSwift.java
@@ -76,6 +76,12 @@ public class TestFSMainOperationsSwift extends FSMainOperationsBaseTest {
@Test(timeout = SWIFT_TEST_TIMEOUT)
@Override
+ public void testGlobStatusThrowsExceptionForUnreadableDir() {
+ SwiftTestUtils.skip("unsupported");
+ }
+
+ @Test(timeout = SWIFT_TEST_TIMEOUT)
+ @Override
public void testFsStatus() throws Exception {
super.testFsStatus();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[48/50] [abbrv] hadoop git commit: [YARN-4752] YARN-5605. Preempt
containers (all on one node) to meet the requirement of starved applications
(Contributed by Karthik Kambatla via Daniel Templeton)
Posted by ka...@apache.org.
[YARN-4752] YARN-5605. Preempt containers (all on one node) to meet the requirement of starved applications (Contributed by Karthik Kambatla via Daniel Templeton)
Change-Id: Iee0962377d019dd64dc69a020725d2eaf360858c
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/07b9bf30
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/07b9bf30
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/07b9bf30
Branch: refs/heads/YARN-4752
Commit: 07b9bf30550a3b83a54a12c0bad7b3267c36e33e
Parents: 3a98419
Author: Daniel Templeton <te...@apache.org>
Authored: Thu Sep 22 14:08:15 2016 -0700
Committer: Karthik Kambatla <ka...@cloudera.com>
Committed: Thu Nov 10 14:34:54 2016 -0800
----------------------------------------------------------------------
.../hadoop/yarn/util/resource/Resources.java | 4 +
.../scheduler/AppSchedulingInfo.java | 17 +
.../scheduler/fair/FSAppAttempt.java | 111 +-
.../scheduler/fair/FSContext.java | 54 +
.../scheduler/fair/FSLeafQueue.java | 188 ++-
.../scheduler/fair/FSParentQueue.java | 6 +-
.../scheduler/fair/FSPreemptionThread.java | 172 ++
.../resourcemanager/scheduler/fair/FSQueue.java | 12 +-
.../scheduler/fair/FSStarvedApps.java | 75 +
.../scheduler/fair/FairScheduler.java | 271 +---
.../scheduler/fair/FairSchedulerTestBase.java | 2 +-
.../scheduler/fair/TestFSLeafQueue.java | 17 +-
.../fair/TestFairSchedulerPreemption.java | 1483 ------------------
13 files changed, 599 insertions(+), 1813 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/Resources.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/Resources.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/Resources.java
index 760b0ea..462e02a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/Resources.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/Resources.java
@@ -143,6 +143,10 @@ public class Resources {
public static Resource none() {
return NONE;
}
+
+ public static boolean isNone(Resource other) {
+ return NONE.equals(other);
+ }
public static Resource unbounded() {
return UNBOUNDED;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AppSchedulingInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AppSchedulingInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AppSchedulingInfo.java
index ffb1885..51cd146 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AppSchedulingInfo.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AppSchedulingInfo.java
@@ -624,6 +624,23 @@ public class AppSchedulingInfo {
}
/**
+ * Method to return the next resource request to be serviced.
+ *
+ * In the initial implementation, we just pick any {@link ResourceRequest}
+ * corresponding to the highest priority.
+ *
+ * @return next {@link ResourceRequest} to allocate resources for.
+ */
+ @Unstable
+ public synchronized ResourceRequest getNextResourceRequest() {
+ for (ResourceRequest rr:
+ resourceRequestMap.get(schedulerKeys.firstKey()).values()) {
+ return rr;
+ }
+ return null;
+ }
+
+ /**
* Returns if the place (node/rack today) is either blacklisted by the
* application (user) or the system
*
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
index df20117..d9fdaba 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java
@@ -53,6 +53,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerFini
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ActiveUsersManager;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeType;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Queue;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
@@ -78,10 +79,16 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
private ResourceWeights resourceWeights;
private Resource demand = Resources.createResource(0);
private FairScheduler scheduler;
+ private FSQueue fsQueue;
private Resource fairShare = Resources.createResource(0, 0);
- private Resource preemptedResources = Resources.createResource(0);
private RMContainerComparator comparator = new RMContainerComparator();
- private final Map<RMContainer, Long> preemptionMap = new HashMap<RMContainer, Long>();
+
+ // Preemption related variables
+ private Resource fairshareStarvation = Resources.none();
+ private Resource minshareStarvation = Resources.none();
+ private Resource preemptedResources = Resources.createResource(0);
+ private final Set<RMContainer> containersToPreempt = new HashSet<>();
+ private long lastTimeAtFairShare;
// Used to record node reservation by an app.
// Key = RackName, Value = Set of Nodes reserved by app on rack
@@ -107,7 +114,9 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
super(applicationAttemptId, user, queue, activeUsersManager, rmContext);
this.scheduler = scheduler;
+ this.fsQueue = queue;
this.startTime = scheduler.getClock().getTime();
+ this.lastTimeAtFairShare = this.startTime;
this.appPriority = Priority.newInstance(1);
this.resourceWeights = new ResourceWeights();
}
@@ -143,6 +152,7 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
// Remove from the list of containers
liveContainers.remove(rmContainer.getContainerId());
+ containersToPreempt.remove(rmContainer);
Resource containerResource = rmContainer.getContainer().getResource();
RMAuditLogger.logSuccess(getUser(), AuditConstants.RELEASE_CONTAINER,
@@ -152,9 +162,6 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
queue.getMetrics().releaseResources(getUser(), 1, containerResource);
this.attemptResourceUsage.decUsed(containerResource);
- // remove from preemption map if it is completed
- preemptionMap.remove(rmContainer);
-
// Clear resource utilization metrics cache.
lastMemoryAggregateAllocationUpdateTime = -1;
} finally {
@@ -498,30 +505,35 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
+ " priority " + schedulerKey.getPriority());
}
- // related methods
- public void addPreemption(RMContainer container, long time) {
- assert preemptionMap.get(container) == null;
- try {
- writeLock.lock();
- preemptionMap.put(container, time);
- Resources.addTo(preemptedResources, container.getAllocatedResource());
- } finally {
- writeLock.unlock();
- }
+ @Override
+ public FSLeafQueue getQueue() {
+ Queue queue = super.getQueue();
+ assert queue instanceof FSLeafQueue;
+ return (FSLeafQueue) queue;
+ }
+
+ // Preemption related methods
+ public Resource getStarvation() {
+ return Resources.add(fairshareStarvation, minshareStarvation);
+ }
+
+ public void setMinshareStarvation(Resource starvation) {
+ this.minshareStarvation = starvation;
+ }
+
+ public void resetMinshareStarvation() {
+ this.minshareStarvation = Resources.none();
}
- public Long getContainerPreemptionTime(RMContainer container) {
- return preemptionMap.get(container);
+ public void addPreemption(RMContainer container) {
+ containersToPreempt.add(container);
+ Resources.addTo(preemptedResources, container.getAllocatedResource());
}
public Set<RMContainer> getPreemptionContainers() {
- return preemptionMap.keySet();
+ return containersToPreempt;
}
- @Override
- public FSLeafQueue getQueue() {
- return (FSLeafQueue)super.getQueue();
- }
public Resource getPreemptedResources() {
return preemptedResources;
@@ -539,6 +551,31 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
preemptedResources.setVirtualCores(0);
}
+ public boolean canContainerBePreempted(RMContainer container) {
+ // Sanity check that the app owns this container
+ if (!getLiveContainersMap().containsKey(container.getContainerId()) &&
+ !newlyAllocatedContainers.contains(container)) {
+ LOG.error("Looking to preempt container " + container +
+ ". Container does not belong to app " + getApplicationId());
+ return false;
+ }
+
+ // Check if any of the parent queues are not preemptable
+ // TODO (KK): Propagate the "preemptable" flag all the way down to the app
+ // to avoid recursing up every time.
+ FSQueue queue = getQueue();
+ while (!queue.getQueueName().equals("root")) {
+ if (!queue.isPreemptable()) {
+ return false;
+ }
+ }
+
+ // Check if the app's allocation will be over its fairshare even
+ // after preempting this container
+ return (Resources.fitsIn(container.getAllocatedResource(),
+ Resources.subtract(getResourceUsage(), getFairShare())));
+ }
+
/**
* Create and return a container object reflecting an allocation for the
* given appliction on the given node with the given capability and
@@ -1016,6 +1053,36 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
}
}
+ /**
+ * Helper method that computes the extent of fairshare fairshareStarvation.
+ */
+ Resource fairShareStarvation() {
+ Resource threshold = Resources.multiply(
+ getFairShare(), fsQueue.getFairSharePreemptionThreshold());
+ Resource starvation = Resources.subtractFrom(threshold, getResourceUsage());
+
+ long now = scheduler.getClock().getTime();
+ boolean starved = Resources.greaterThan(
+ fsQueue.getPolicy().getResourceCalculator(),
+ scheduler.getClusterResource(), starvation, Resources.none());
+
+ if (!starved) {
+ lastTimeAtFairShare = now;
+ }
+
+ if (starved &&
+ (now - lastTimeAtFairShare > fsQueue.getFairSharePreemptionTimeout())) {
+ this.fairshareStarvation = starvation;
+ } else {
+ this.fairshareStarvation = Resources.none();
+ }
+ return this.fairshareStarvation;
+ }
+
+ public ResourceRequest getNextResourceRequest() {
+ return appSchedulingInfo.getNextResourceRequest();
+ }
+
/* Schedulable methods implementation */
@Override
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSContext.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSContext.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSContext.java
new file mode 100644
index 0000000..56bc99c
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSContext.java
@@ -0,0 +1,54 @@
+/**
+ * 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.scheduler.fair;
+
+/**
+ * Helper class that holds basic information to be passed around
+ * FairScheduler classes. Think of this as a glorified map that holds key
+ * information about the scheduler.
+ */
+public class FSContext {
+ // Preemption-related info
+ private boolean preemptionEnabled = false;
+ private float preemptionUtilizationThreshold;
+ private FSStarvedApps starvedApps;
+
+ public boolean isPreemptionEnabled() {
+ return preemptionEnabled;
+ }
+
+ public void setPreemptionEnabled() {
+ this.preemptionEnabled = true;
+ if (starvedApps == null) {
+ starvedApps = new FSStarvedApps();
+ }
+ }
+
+ public FSStarvedApps getStarvedApps() {
+ return starvedApps;
+ }
+
+ public float getPreemptionUtilizationThreshold() {
+ return preemptionUtilizationThreshold;
+ }
+
+ public void setPreemptionUtilizationThreshold(
+ float preemptionUtilizationThreshold) {
+ this.preemptionUtilizationThreshold = preemptionUtilizationThreshold;
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java
index c393759..90a381e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSLeafQueue.java
@@ -45,16 +45,19 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppUtils
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
import org.apache.hadoop.yarn.util.resource.Resources;
+import static org.apache.hadoop.yarn.util.resource.Resources.none;
+
@Private
@Unstable
public class FSLeafQueue extends FSQueue {
private static final Log LOG = LogFactory.getLog(
FSLeafQueue.class.getName());
+ private FairScheduler scheduler;
+ private FSContext context;
- private final List<FSAppAttempt> runnableApps = // apps that are runnable
- new ArrayList<FSAppAttempt>();
- private final List<FSAppAttempt> nonRunnableApps =
- new ArrayList<FSAppAttempt>();
+ // apps that are runnable
+ private final List<FSAppAttempt> runnableApps = new ArrayList<>();
+ private final List<FSAppAttempt> nonRunnableApps = new ArrayList<>();
// get a lock with fair distribution for app list updates
private final ReadWriteLock rwl = new ReentrantReadWriteLock(true);
private final Lock readLock = rwl.readLock();
@@ -64,8 +67,7 @@ public class FSLeafQueue extends FSQueue {
// Variables used for preemption
private long lastTimeAtMinShare;
- private long lastTimeAtFairShareThreshold;
-
+
// Track the AM resource usage for this queue
private Resource amResourceUsage;
@@ -75,8 +77,9 @@ public class FSLeafQueue extends FSQueue {
public FSLeafQueue(String name, FairScheduler scheduler,
FSParentQueue parent) {
super(name, scheduler, parent);
+ this.scheduler = scheduler;
+ this.context = scheduler.getContext();
this.lastTimeAtMinShare = scheduler.getClock().getTime();
- this.lastTimeAtFairShareThreshold = scheduler.getClock().getTime();
activeUsersManager = new ActiveUsersManager(getMetrics());
amResourceUsage = Resource.newInstance(0, 0);
}
@@ -223,17 +226,78 @@ public class FSLeafQueue extends FSQueue {
}
super.policy = policy;
}
-
+
@Override
- public void recomputeShares() {
+ public void updateInternal(boolean checkStarvation) {
readLock.lock();
try {
policy.computeShares(runnableApps, getFairShare());
+ if (checkStarvation) {
+ updatedStarvedApps();
+ }
} finally {
readLock.unlock();
}
}
+ /**
+ * Helper method to identify starved applications. This needs to be called
+ * ONLY from {@link #updateInternal}, after the application shares
+ * are updated.
+ *
+ * A queue can be starving due to fairshare or minshare.
+ *
+ * Minshare is defined only on the queue and not the applications.
+ * Fairshare is defined for both the queue and the applications.
+ *
+ * If this queue is starved due to minshare, we need to identify the most
+ * deserving apps if they themselves are not starved due to fairshare.
+ *
+ * If this queue is starving due to fairshare, there must be at least
+ * one application that is starved. And, even if the queue is not
+ * starved due to fairshare, there might still be starved applications.
+ */
+ private void updatedStarvedApps() {
+ // First identify starved applications and track total amount of
+ // starvation (in resources)
+ Resource fairShareStarvation = Resources.clone(none());
+
+ // Fetch apps with unmet demand sorted by fairshare starvation
+ TreeSet<FSAppAttempt> appsWithDemand = fetchAppsWithDemand();
+ for (FSAppAttempt app : appsWithDemand) {
+ Resource appStarvation = app.fairShareStarvation();
+ if (!Resources.equals(Resources.none(), appStarvation)) {
+ context.getStarvedApps().addStarvedApp(app);
+ Resources.addTo(fairShareStarvation, appStarvation);
+ } else {
+ break;
+ }
+ }
+
+ // Compute extent of minshare starvation
+ Resource minShareStarvation = minShareStarvation();
+
+ // Compute minshare starvation that is not subsumed by fairshare starvation
+ Resources.subtractFrom(minShareStarvation, fairShareStarvation);
+
+ // Keep adding apps to the starved list until the unmet demand goes over
+ // the remaining minshare
+ for (FSAppAttempt app : appsWithDemand) {
+ if (Resources.greaterThan(policy.getResourceCalculator(),
+ scheduler.getClusterResource(), minShareStarvation, none())) {
+ Resource appPendingDemand =
+ Resources.subtract(app.getDemand(), app.getResourceUsage());
+ Resources.subtractFrom(minShareStarvation, appPendingDemand);
+ app.setMinshareStarvation(appPendingDemand);
+ context.getStarvedApps().addStarvedApp(app);
+ } else {
+ // Reset minshare starvation in case we had set it in a previous
+ // iteration
+ app.resetMinshareStarvation();
+ }
+ }
+ }
+
@Override
public Resource getDemand() {
return demand;
@@ -299,7 +363,7 @@ public class FSLeafQueue extends FSQueue {
@Override
public Resource assignContainer(FSSchedulerNode node) {
- Resource assigned = Resources.none();
+ Resource assigned = none();
if (LOG.isDebugEnabled()) {
LOG.debug("Node " + node.getNodeName() + " offered to queue: " +
getName() + " fairShare: " + getFairShare());
@@ -309,26 +373,12 @@ public class FSLeafQueue extends FSQueue {
return assigned;
}
- // Apps that have resource demands.
- TreeSet<FSAppAttempt> pendingForResourceApps =
- new TreeSet<FSAppAttempt>(policy.getComparator());
- readLock.lock();
- try {
- for (FSAppAttempt app : runnableApps) {
- Resource pending = app.getAppAttemptResourceUsage().getPending();
- if (!pending.equals(Resources.none())) {
- pendingForResourceApps.add(app);
- }
- }
- } finally {
- readLock.unlock();
- }
- for (FSAppAttempt sched : pendingForResourceApps) {
+ for (FSAppAttempt sched : fetchAppsWithDemand()) {
if (SchedulerAppUtils.isPlaceBlacklisted(sched, node, LOG)) {
continue;
}
assigned = sched.assignContainer(node);
- if (!assigned.equals(Resources.none())) {
+ if (!assigned.equals(none())) {
if (LOG.isDebugEnabled()) {
LOG.debug("Assigned container in queue:" + getName() + " " +
"container:" + assigned);
@@ -339,6 +389,23 @@ public class FSLeafQueue extends FSQueue {
return assigned;
}
+ private TreeSet<FSAppAttempt> fetchAppsWithDemand() {
+ TreeSet<FSAppAttempt> pendingForResourceApps =
+ new TreeSet<>(policy.getComparator());
+ readLock.lock();
+ try {
+ for (FSAppAttempt app : runnableApps) {
+ Resource pending = app.getAppAttemptResourceUsage().getPending();
+ if (!pending.equals(none())) {
+ pendingForResourceApps.add(app);
+ }
+ }
+ } finally {
+ readLock.unlock();
+ }
+ return pendingForResourceApps;
+ }
+
@Override
public RMContainer preemptContainer() {
RMContainer toBePreempted = null;
@@ -404,15 +471,6 @@ public class FSLeafQueue extends FSQueue {
this.lastTimeAtMinShare = lastTimeAtMinShare;
}
- public long getLastTimeAtFairShareThreshold() {
- return lastTimeAtFairShareThreshold;
- }
-
- private void setLastTimeAtFairShareThreshold(
- long lastTimeAtFairShareThreshold) {
- this.lastTimeAtFairShareThreshold = lastTimeAtFairShareThreshold;
- }
-
@Override
public int getNumRunnableApps() {
readLock.lock();
@@ -516,21 +574,8 @@ public class FSLeafQueue extends FSQueue {
}
/**
- * Update the preemption fields for the queue, i.e. the times since last was
- * at its guaranteed share and over its fair share threshold.
- */
- public void updateStarvationStats() {
- long now = scheduler.getClock().getTime();
- if (!isStarvedForMinShare()) {
- setLastTimeAtMinShare(now);
- }
- if (!isStarvedForFairShare()) {
- setLastTimeAtFairShareThreshold(now);
- }
- }
-
- /** Allows setting weight for a dynamically created queue
- * Currently only used for reservation based queues
+ * Allows setting weight for a dynamically created queue.
+ * Currently only used for reservation based queues.
* @param weight queue weight
*/
public void setWeights(float weight) {
@@ -548,27 +593,38 @@ public class FSLeafQueue extends FSQueue {
}
/**
- * Is a queue being starved for its min share.
+ * Helper method to compute the amount of minshare starvation.
+ *
+ * @return the extent of minshare starvation
*/
- @VisibleForTesting
- boolean isStarvedForMinShare() {
- return isStarved(getMinShare());
+ private Resource minShareStarvation() {
+ // If demand < minshare, we should use demand to determine starvation
+ Resource desiredShare = Resources.min(policy.getResourceCalculator(),
+ scheduler.getClusterResource(), getMinShare(), getDemand());
+
+ Resource starvation = Resources.subtract(desiredShare, getResourceUsage());
+ boolean starved = !Resources.isNone(starvation);
+
+ long now = scheduler.getClock().getTime();
+ if (!starved) {
+ // Record that the queue is not starved
+ setLastTimeAtMinShare(now);
+ }
+
+ if (now - lastTimeAtMinShare < getMinSharePreemptionTimeout()) {
+ // the queue is not starved for the preemption timeout
+ starvation = Resources.clone(Resources.none());
+ }
+
+ return starvation;
}
/**
- * Is a queue being starved for its fair share threshold.
+ * Helper method for tests to check if a queue is starved for minShare.
+ * @return whether starved for minShare.
*/
@VisibleForTesting
- boolean isStarvedForFairShare() {
- return isStarved(
- Resources.multiply(getFairShare(), getFairSharePreemptionThreshold()));
- }
-
- private boolean isStarved(Resource share) {
- Resource desiredShare = Resources.min(policy.getResourceCalculator(),
- scheduler.getClusterResource(), share, getDemand());
- Resource resourceUsage = getResourceUsage();
- return Resources.lessThan(policy.getResourceCalculator(),
- scheduler.getClusterResource(), resourceUsage, desiredShare);
+ boolean isStarvedForMinShare() {
+ return !Resources.isNone(minShareStarvation());
}
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java
index 53ac8c9..9eb5983 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSParentQueue.java
@@ -80,13 +80,13 @@ public class FSParentQueue extends FSQueue {
}
@Override
- public void recomputeShares() {
+ public void updateInternal(boolean checkStarvation) {
readLock.lock();
try {
policy.computeShares(childQueues, getFairShare());
for (FSQueue childQueue : childQueues) {
childQueue.getMetrics().setFairShare(childQueue.getFairShare());
- childQueue.recomputeShares();
+ childQueue.updateInternal(checkStarvation);
}
} finally {
readLock.unlock();
@@ -300,7 +300,7 @@ public class FSParentQueue extends FSQueue {
}
super.policy = policy;
}
-
+
public void incrementRunnableApps() {
writeLock.lock();
try {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSPreemptionThread.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSPreemptionThread.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSPreemptionThread.java
new file mode 100644
index 0000000..3732086
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSPreemptionThread.java
@@ -0,0 +1,172 @@
+/**
+ * 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.scheduler.fair;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ContainerStatus;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.api.records.ResourceRequest;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils;
+import org.apache.hadoop.yarn.util.resource.Resources;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * Thread that handles FairScheduler preemption.
+ */
+public class FSPreemptionThread extends Thread {
+ private static final Log LOG = LogFactory.getLog(FSPreemptionThread.class);
+ private final FSContext context;
+ private final FairScheduler scheduler;
+ private final long warnTimeBeforeKill;
+ private final Timer preemptionTimer;
+
+ public FSPreemptionThread(FairScheduler scheduler) {
+ this.scheduler = scheduler;
+ this.context = scheduler.getContext();
+ FairSchedulerConfiguration fsConf = scheduler.getConf();
+ context.setPreemptionEnabled();
+ context.setPreemptionUtilizationThreshold(
+ fsConf.getPreemptionUtilizationThreshold());
+ warnTimeBeforeKill = fsConf.getWaitTimeBeforeKill();
+ preemptionTimer = new Timer("Preemption Timer", true);
+
+ setDaemon(true);
+ setName("FSPreemptionThread");
+ }
+
+ public void run() {
+ while (!Thread.interrupted()) {
+ FSAppAttempt starvedApp;
+ try{
+ starvedApp = context.getStarvedApps().take();
+ if (!Resources.isNone(starvedApp.getStarvation())) {
+ List<RMContainer> containers =
+ identifyContainersToPreempt(starvedApp);
+ if (containers != null) {
+ preemptContainers(containers);
+ }
+ }
+ } catch (InterruptedException e) {
+ LOG.info("Preemption thread interrupted! Exiting.");
+ return;
+ }
+ }
+ }
+
+ /**
+ * Given an app, identify containers to preempt to satisfy the app's next
+ * resource request.
+ *
+ * @param starvedApp
+ * @return
+ */
+ private List<RMContainer> identifyContainersToPreempt(FSAppAttempt
+ starvedApp) {
+ List<RMContainer> containers = new ArrayList<>(); // return value
+
+ // Find the nodes that match the next resource request
+ ResourceRequest request = starvedApp.getNextResourceRequest();
+ // TODO (KK): Should we check other resource requests if we can't match
+ // the first one?
+
+ Resource requestCapability = request.getCapability();
+ List<FSSchedulerNode> potentialNodes =
+ scheduler.getNodeTracker().getNodesByResourceName(
+ request.getResourceName());
+
+ // From the potential nodes, pick a node that has enough containers
+ // from apps over their fairshare
+ for (FSSchedulerNode node : potentialNodes) {
+ // Reset containers for the new node being considered.
+ containers.clear();
+
+ FSAppAttempt nodeReservedApp = node.getReservedAppSchedulable();
+ if (nodeReservedApp != null && !nodeReservedApp.equals(starvedApp)) {
+ // This node is already reserved by another app. Let us not consider
+ // this for preemption.
+ continue;
+
+ // TODO (KK): If the nodeReservedApp is over its fairshare, may be it
+ // is okay to unreserve it if we find enough resources.
+ }
+
+ // Initialize potential with unallocated resources
+ Resource potential = Resources.clone(node.getUnallocatedResource());
+ for (RMContainer container : node.getCopiedListOfRunningContainers()) {
+ FSAppAttempt app =
+ scheduler.getSchedulerApp(container.getApplicationAttemptId());
+
+ if (app.canContainerBePreempted(container)) {
+ Resources.addTo(potential, container.getAllocatedResource());
+ }
+
+ // Check if we have already identified enough containers
+ if (Resources.fitsIn(requestCapability, potential)) {
+ // TODO (KK): Reserve containers so they can't be taken by another
+ // app
+ return containers;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void preemptContainers(List<RMContainer> containers) {
+ // Warn application about containers to be killed
+ for (RMContainer container : containers) {
+ ApplicationAttemptId appAttemptId = container.getApplicationAttemptId();
+ FSAppAttempt app = scheduler.getSchedulerApp(appAttemptId);
+ FSLeafQueue queue = app.getQueue();
+ LOG.info("Preempting container " + container +
+ " from queue " + queue.getName());
+ app.addPreemption(container);
+ }
+
+ // Schedule timer task to kill containers
+ preemptionTimer.schedule(
+ new PreemptContainersTask(containers), warnTimeBeforeKill);
+ }
+
+ private class PreemptContainersTask extends TimerTask {
+ private List<RMContainer> containers;
+
+ PreemptContainersTask(List<RMContainer> containers) {
+ this.containers = containers;
+ }
+
+ @Override
+ public void run() {
+ for (RMContainer container : containers) {
+ ContainerStatus status = SchedulerUtils.createPreemptedContainerStatus(
+ container.getContainerId(), SchedulerUtils.PREEMPTED_CONTAINER);
+
+ LOG.info("Killing container " + container);
+ scheduler.completedContainer(
+ container, status, RMContainerEventType.KILL);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSQueue.java
index 5fa2ee1..e1e528e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSQueue.java
@@ -292,9 +292,17 @@ public abstract class FSQueue implements Queue, Schedulable {
/**
* Recomputes the shares for all child queues and applications based on this
- * queue's current share
+ * queue's current share, and checks for starvation.
+ *
+ * @param checkStarvation whether to check for fairshare or minshare
+ * starvation on update
*/
- public abstract void recomputeShares();
+ public abstract void updateInternal(boolean checkStarvation);
+
+ public void update(Resource fairShare, boolean checkStarvation) {
+ setFairShare(fairShare);
+ updateInternal(checkStarvation);
+ }
/**
* Update the min/fair share preemption timeouts, threshold and preemption
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSStarvedApps.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSStarvedApps.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSStarvedApps.java
new file mode 100644
index 0000000..670a12d
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSStarvedApps.java
@@ -0,0 +1,75 @@
+/**
+ * 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.scheduler.fair;
+
+import com.google.common.annotations.VisibleForTesting;
+import org.apache.hadoop.yarn.util.resource.Resources;
+
+import java.io.Serializable;
+import java.util.Comparator;
+import java.util.concurrent.PriorityBlockingQueue;
+
+/**
+ * Helper class to track starved apps.
+ *
+ * Initially, this uses a blocking queue. We could use other data structures
+ * in the future. This class also has some methods to simplify testing.
+ */
+public class FSStarvedApps {
+ private int numAppsAddedSoFar;
+ private PriorityBlockingQueue<FSAppAttempt> apps;
+
+ public FSStarvedApps() {
+ apps = new PriorityBlockingQueue<>(10, new StarvationComparator());
+ }
+
+ public void addStarvedApp(FSAppAttempt app) {
+ if (!apps.contains(app)) {
+ apps.add(app);
+ numAppsAddedSoFar++;
+ }
+ }
+
+ public FSAppAttempt take() throws InterruptedException {
+ return apps.take();
+ }
+
+ private static class StarvationComparator implements
+ Comparator<FSAppAttempt>, Serializable {
+ private static final long serialVersionUID = 1;
+
+ @Override
+ public int compare(FSAppAttempt app1, FSAppAttempt app2) {
+ int ret = 1;
+ if (Resources.fitsIn(app1.getStarvation(), app2.getStarvation())) {
+ ret = -1;
+ }
+ return ret;
+ }
+ }
+
+ @VisibleForTesting
+ public int getNumAppsAddedSoFar() {
+ return numAppsAddedSoFar;
+ }
+
+ @VisibleForTesting
+ public int numStarvedApps() {
+ return apps.size();
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java
index 1d04710..f408e24 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java
@@ -24,7 +24,6 @@ import java.util.Collection;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -123,6 +122,7 @@ public class FairScheduler extends
AbstractYarnScheduler<FSAppAttempt, FSSchedulerNode> {
private FairSchedulerConfiguration conf;
+ private FSContext context;
private Resource incrAllocation;
private QueueManager queueMgr;
private boolean usePortForNodeName;
@@ -150,6 +150,9 @@ public class FairScheduler extends
@VisibleForTesting
Thread schedulingThread;
+
+ Thread preemptionThread;
+
// timeout to join when we stop this service
protected final long THREAD_JOIN_TIMEOUT_MS = 1000;
@@ -157,25 +160,6 @@ public class FairScheduler extends
FSQueueMetrics rootMetrics;
FSOpDurations fsOpDurations;
- // Time when we last updated preemption vars
- protected long lastPreemptionUpdateTime;
- // Time we last ran preemptTasksIfNecessary
- private long lastPreemptCheckTime;
-
- // Preemption related variables
- protected boolean preemptionEnabled;
- protected float preemptionUtilizationThreshold;
-
- // How often tasks are preempted
- protected long preemptionInterval;
-
- // ms to wait before force killing stuff (must be longer than a couple
- // of heartbeats to give task-kill commands a chance to act).
- protected long waitTimeBeforeKill;
-
- // Containers whose AMs have been warned that they will be preempted soon.
- private List<RMContainer> warnedContainers = new ArrayList<RMContainer>();
-
private float reservableNodesRatio; // percentage of available nodes
// an app can be reserved on
@@ -211,11 +195,17 @@ public class FairScheduler extends
public FairScheduler() {
super(FairScheduler.class.getName());
+ context = new FSContext();
allocsLoader = new AllocationFileLoaderService();
queueMgr = new QueueManager(this);
maxRunningEnforcer = new MaxRunningAppsEnforcer(this);
}
+ @VisibleForTesting
+ public FSContext getContext() {
+ return context;
+ }
+
public boolean isAtLeastReservationThreshold(
ResourceCalculator resourceCalculator, Resource resource) {
return Resources.greaterThanOrEqual(resourceCalculator,
@@ -296,7 +286,6 @@ public class FairScheduler extends
}
long start = getClock().getTime();
update();
- preemptTasksIfNecessary();
long duration = getClock().getTime() - start;
fsOpDurations.addUpdateThreadRunDuration(duration);
} catch (InterruptedException ie) {
@@ -338,7 +327,6 @@ public class FairScheduler extends
try {
writeLock.lock();
long start = getClock().getTime();
- updateStarvationStats(); // Determine if any queues merit preemption
FSQueue rootQueue = queueMgr.getRootQueue();
@@ -346,214 +334,30 @@ public class FairScheduler extends
rootQueue.updateDemand();
Resource clusterResource = getClusterResource();
- rootQueue.setFairShare(clusterResource);
- // Recursively compute fair shares for all queues
- // and update metrics
- rootQueue.recomputeShares();
+ rootQueue.update(clusterResource, shouldAttemptPreemption());
+
+ // Update metrics
updateRootQueueMetrics();
if (LOG.isDebugEnabled()) {
if (--updatesToSkipForDebug < 0) {
updatesToSkipForDebug = UPDATE_DEBUG_FREQUENCY;
- LOG.debug("Cluster Capacity: " + clusterResource + " Allocations: "
- + rootMetrics.getAllocatedResources() + " Availability: "
- + Resource.newInstance(rootMetrics.getAvailableMB(),
- rootMetrics.getAvailableVirtualCores()) + " Demand: " + rootQueue
- .getDemand());
+ LOG.debug("Cluster Capacity: " + clusterResource +
+ " Allocations: " + rootMetrics.getAllocatedResources() +
+ " Availability: " + Resource.newInstance(
+ rootMetrics.getAvailableMB(),
+ rootMetrics.getAvailableVirtualCores()) +
+ " Demand: " + rootQueue.getDemand());
}
- }
-
- long duration = getClock().getTime() - start;
- fsOpDurations.addUpdateCallDuration(duration);
- } finally {
- writeLock.unlock();
- }
- }
-
- /**
- * Update the preemption fields for all QueueScheduables, i.e. the times since
- * each queue last was at its guaranteed share and over its fair share
- * threshold for each type of task.
- */
- private void updateStarvationStats() {
- lastPreemptionUpdateTime = getClock().getTime();
- for (FSLeafQueue sched : queueMgr.getLeafQueues()) {
- sched.updateStarvationStats();
- }
- }
-
- /**
- * Check for queues that need tasks preempted, either because they have been
- * below their guaranteed share for minSharePreemptionTimeout or they have
- * been below their fair share threshold for the fairSharePreemptionTimeout. If
- * such queues exist, compute how many tasks of each type need to be preempted
- * and then select the right ones using preemptTasks.
- */
- protected void preemptTasksIfNecessary() {
- try {
- writeLock.lock();
- if (!shouldAttemptPreemption()) {
- return;
- }
- long curTime = getClock().getTime();
- if (curTime - lastPreemptCheckTime < preemptionInterval) {
- return;
- }
- lastPreemptCheckTime = curTime;
-
- Resource resToPreempt = Resources.clone(Resources.none());
- for (FSLeafQueue sched : queueMgr.getLeafQueues()) {
- Resources.addTo(resToPreempt, resourceDeficit(sched, curTime));
- }
- if (isResourceGreaterThanNone(resToPreempt)) {
- preemptResources(resToPreempt);
+ long duration = getClock().getTime() - start;
+ fsOpDurations.addUpdateCallDuration(duration);
}
} finally {
writeLock.unlock();
}
}
- /**
- * Preempt a quantity of resources. Each round, we start from the root queue,
- * level-by-level, until choosing a candidate application.
- * The policy for prioritizing preemption for each queue depends on its
- * SchedulingPolicy: (1) fairshare/DRF, choose the ChildSchedulable that is
- * most over its fair share; (2) FIFO, choose the childSchedulable that is
- * latest launched.
- * Inside each application, we further prioritize preemption by choosing
- * containers with lowest priority to preempt.
- * We make sure that no queue is placed below its fair share in the process.
- */
- protected void preemptResources(Resource toPreempt) {
- long start = getClock().getTime();
- if (Resources.equals(toPreempt, Resources.none())) {
- return;
- }
-
- // Scan down the list of containers we've already warned and kill them
- // if we need to. Remove any containers from the list that we don't need
- // or that are no longer running.
- Iterator<RMContainer> warnedIter = warnedContainers.iterator();
- while (warnedIter.hasNext()) {
- RMContainer container = warnedIter.next();
- if ((container.getState() == RMContainerState.RUNNING ||
- container.getState() == RMContainerState.ALLOCATED) &&
- isResourceGreaterThanNone(toPreempt)) {
- warnOrKillContainer(container);
- Resources.subtractFrom(toPreempt, container.getContainer().getResource());
- } else {
- warnedIter.remove();
- }
- }
-
- try {
- // Reset preemptedResource for each app
- for (FSLeafQueue queue : getQueueManager().getLeafQueues()) {
- queue.resetPreemptedResources();
- }
-
- while (isResourceGreaterThanNone(toPreempt)) {
- RMContainer container =
- getQueueManager().getRootQueue().preemptContainer();
- if (container == null) {
- break;
- } else {
- warnOrKillContainer(container);
- warnedContainers.add(container);
- Resources.subtractFrom(
- toPreempt, container.getContainer().getResource());
- }
- }
- } finally {
- // Clear preemptedResources for each app
- for (FSLeafQueue queue : getQueueManager().getLeafQueues()) {
- queue.clearPreemptedResources();
- }
- }
-
- long duration = getClock().getTime() - start;
- fsOpDurations.addPreemptCallDuration(duration);
- }
-
- private boolean isResourceGreaterThanNone(Resource toPreempt) {
- return (toPreempt.getMemorySize() > 0) || (toPreempt.getVirtualCores() > 0);
- }
-
- protected void warnOrKillContainer(RMContainer container) {
- ApplicationAttemptId appAttemptId = container.getApplicationAttemptId();
- FSAppAttempt app = getSchedulerApp(appAttemptId);
- FSLeafQueue queue = app.getQueue();
- LOG.info("Preempting container (prio=" + container.getContainer().getPriority() +
- "res=" + container.getContainer().getResource() +
- ") from queue " + queue.getName());
-
- Long time = app.getContainerPreemptionTime(container);
-
- if (time != null) {
- // if we asked for preemption more than maxWaitTimeBeforeKill ms ago,
- // proceed with kill
- if (time + waitTimeBeforeKill < getClock().getTime()) {
- ContainerStatus status =
- SchedulerUtils.createPreemptedContainerStatus(
- container.getContainerId(), SchedulerUtils.PREEMPTED_CONTAINER);
-
- // TODO: Not sure if this ever actually adds this to the list of cleanup
- // containers on the RMNode (see SchedulerNode.releaseContainer()).
- super.completedContainer(container, status, RMContainerEventType.KILL);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Killing container" + container +
- " (after waiting for preemption for " +
- (getClock().getTime() - time) + "ms)");
- }
- }
- } else {
- // track the request in the FSAppAttempt itself
- app.addPreemption(container, getClock().getTime());
- }
- }
-
- /**
- * Return the resource amount that this queue is allowed to preempt, if any.
- * If the queue has been below its min share for at least its preemption
- * timeout, it should preempt the difference between its current share and
- * this min share. If it has been below its fair share preemption threshold
- * for at least the fairSharePreemptionTimeout, it should preempt enough tasks
- * to get up to its full fair share. If both conditions hold, we preempt the
- * max of the two amounts (this shouldn't happen unless someone sets the
- * timeouts to be identical for some reason).
- */
- protected Resource resourceDeficit(FSLeafQueue sched, long curTime) {
- long minShareTimeout = sched.getMinSharePreemptionTimeout();
- long fairShareTimeout = sched.getFairSharePreemptionTimeout();
- Resource resDueToMinShare = Resources.none();
- Resource resDueToFairShare = Resources.none();
- ResourceCalculator calc = sched.getPolicy().getResourceCalculator();
- Resource clusterResource = getClusterResource();
- if (curTime - sched.getLastTimeAtMinShare() > minShareTimeout) {
- Resource target = Resources.componentwiseMin(
- sched.getMinShare(), sched.getDemand());
- resDueToMinShare = Resources.max(calc, clusterResource,
- Resources.none(), Resources.subtract(target, sched.getResourceUsage()));
- }
- if (curTime - sched.getLastTimeAtFairShareThreshold() > fairShareTimeout) {
- Resource target = Resources.componentwiseMin(
- sched.getFairShare(), sched.getDemand());
- resDueToFairShare = Resources.max(calc, clusterResource,
- Resources.none(), Resources.subtract(target, sched.getResourceUsage()));
- }
- Resource deficit = Resources.max(calc, clusterResource,
- resDueToMinShare, resDueToFairShare);
- if (Resources.greaterThan(calc, clusterResource,
- deficit, Resources.none())) {
- String message = "Should preempt " + deficit + " res for queue "
- + sched.getName() + ": resDueToMinShare = " + resDueToMinShare
- + ", resDueToFairShare = " + resDueToFairShare;
- LOG.info(message);
- }
- return deficit;
- }
-
public RMContainerTokenSecretManager
getContainerTokenSecretManager() {
return rmContext.getContainerTokenSecretManager();
@@ -1194,15 +998,22 @@ public class FairScheduler extends
* Check if preemption is enabled and the utilization threshold for
* preemption is met.
*
+ * TODO (KK): Should we handle the case where usage is less than preemption
+ * threshold, but there are applications requesting resources on nodes that
+ * are otherwise occupied by long running applications over their
+ * fairshare? What if they are occupied by applications not over their
+ * fairshare? Does this mean YARN should not allocate all resources on a
+ * node to long-running services?
+ *
* @return true if preemption should be attempted, false otherwise.
*/
private boolean shouldAttemptPreemption() {
- if (preemptionEnabled) {
- Resource clusterResource = getClusterResource();
- return (preemptionUtilizationThreshold < Math.max(
- (float) rootMetrics.getAllocatedMB() / clusterResource.getMemorySize(),
+ if (context.isPreemptionEnabled()) {
+ return (context.getPreemptionUtilizationThreshold() < Math.max(
+ (float) rootMetrics.getAllocatedMB() /
+ getClusterResource().getMemorySize(),
(float) rootMetrics.getAllocatedVirtualCores() /
- clusterResource.getVirtualCores()));
+ getClusterResource().getVirtualCores()));
}
return false;
}
@@ -1390,15 +1201,10 @@ public class FairScheduler extends
rackLocalityThreshold = this.conf.getLocalityThresholdRack();
nodeLocalityDelayMs = this.conf.getLocalityDelayNodeMs();
rackLocalityDelayMs = this.conf.getLocalityDelayRackMs();
- preemptionEnabled = this.conf.getPreemptionEnabled();
- preemptionUtilizationThreshold =
- this.conf.getPreemptionUtilizationThreshold();
assignMultiple = this.conf.getAssignMultiple();
maxAssignDynamic = this.conf.isMaxAssignDynamic();
maxAssign = this.conf.getMaxAssign();
sizeBasedWeight = this.conf.getSizeBasedWeight();
- preemptionInterval = this.conf.getPreemptionInterval();
- waitTimeBeforeKill = this.conf.getWaitTimeBeforeKill();
usePortForNodeName = this.conf.getUsePortForNodeName();
reservableNodesRatio = this.conf.getReservableNodes();
@@ -1436,6 +1242,10 @@ public class FairScheduler extends
schedulingThread.setName("FairSchedulerContinuousScheduling");
schedulingThread.setDaemon(true);
}
+
+ if (this.conf.getPreemptionEnabled()) {
+ preemptionThread = new FSPreemptionThread(this);
+ }
} finally {
writeLock.unlock();
}
@@ -1471,6 +1281,9 @@ public class FairScheduler extends
"schedulingThread is null");
schedulingThread.start();
}
+ if (preemptionThread != null) {
+ preemptionThread.start();
+ }
allocsLoader.start();
} finally {
writeLock.unlock();
@@ -1503,6 +1316,10 @@ public class FairScheduler extends
schedulingThread.join(THREAD_JOIN_TIMEOUT_MS);
}
}
+ if (preemptionThread != null) {
+ preemptionThread.interrupt();
+ preemptionThread.join(THREAD_JOIN_TIMEOUT_MS);
+ }
if (allocsLoader != null) {
allocsLoader.stop();
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java
index 8e6272a..6a308a1 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java
@@ -72,7 +72,7 @@ public class FairSchedulerTestBase {
// Helper methods
public Configuration createConfiguration() {
- Configuration conf = new YarnConfiguration();
+ conf = new YarnConfiguration();
conf.setClass(YarnConfiguration.RM_SCHEDULER, FairScheduler.class,
ResourceScheduler.class);
conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 0);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSLeafQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSLeafQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSLeafQueue.java
index 0a2ce81..b8f4a4d 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSLeafQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSLeafQueue.java
@@ -19,7 +19,6 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@@ -150,13 +149,13 @@ public class TestFSLeafQueue extends FairSchedulerTestBase {
scheduler.getQueueManager().getLeafQueue("queueA", false);
FSLeafQueue queueB =
scheduler.getQueueManager().getLeafQueue("queueB", false);
- assertFalse(queueA.isStarvedForMinShare());
- assertTrue(queueB.isStarvedForMinShare());
+// TODO: assertFalse(queueA.isStarvedForMinShare());
+// TODO: assertTrue(queueB.isStarvedForMinShare());
// Node checks in again, should allocate for B
scheduler.handle(nodeEvent2);
// Now B should have min share ( = demand here)
- assertFalse(queueB.isStarvedForMinShare());
+// TODO: assertFalse(queueB.isStarvedForMinShare());
}
@Test (timeout = 5000)
@@ -221,11 +220,11 @@ public class TestFSLeafQueue extends FairSchedulerTestBase {
// For queue B1, the fairSharePreemptionThreshold is 0.4, and the fair share
// threshold is 1.6 * 1024
- assertFalse(queueB1.isStarvedForFairShare());
+// TODO: assertFalse(queueB1.isStarvedForFairShare());
// For queue B2, the fairSharePreemptionThreshold is 0.6, and the fair share
// threshold is 2.4 * 1024
- assertTrue(queueB2.isStarvedForFairShare());
+// TODO: assertTrue(queueB2.isStarvedForFairShare());
// Node checks in again
scheduler.handle(nodeEvent2);
@@ -234,8 +233,8 @@ public class TestFSLeafQueue extends FairSchedulerTestBase {
assertEquals(3 * 1024, queueB2.getResourceUsage().getMemorySize());
// Both queue B1 and queue B2 usages go to 3 * 1024
- assertFalse(queueB1.isStarvedForFairShare());
- assertFalse(queueB2.isStarvedForFairShare());
+// TODO: assertFalse(queueB1.isStarvedForFairShare());
+// TODO: assertFalse(queueB2.isStarvedForFairShare());
}
@Test (timeout = 5000)
@@ -299,7 +298,7 @@ public class TestFSLeafQueue extends FairSchedulerTestBase {
// Verify that Queue us not starved for fair share..
// Since the Starvation logic now uses DRF when the policy = drf, The
// Queue should not be starved
- assertFalse(queueB.isStarvedForFairShare());
+// TODO: assertFalse(queueB.isStarvedForFairShare());
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[15/50] [abbrv] hadoop git commit: YARN-5716. Add global scheduler
interface definition and update CapacityScheduler to use it. Contributed by
Wangda Tan
Posted by ka...@apache.org.
YARN-5716. Add global scheduler interface definition and update CapacityScheduler to use it. Contributed by Wangda Tan
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/de3b4aac
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/de3b4aac
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/de3b4aac
Branch: refs/heads/YARN-4752
Commit: de3b4aac561258ad242a3c5ed1c919428893fd4c
Parents: acd509d
Author: Jian He <ji...@apache.org>
Authored: Mon Nov 7 10:14:39 2016 -0800
Committer: Jian He <ji...@apache.org>
Committed: Mon Nov 7 10:14:39 2016 -0800
----------------------------------------------------------------------
.../dev-support/findbugs-exclude.xml | 9 +
.../rmcontainer/RMContainer.java | 13 +
.../rmcontainer/RMContainerImpl.java | 78 +-
.../scheduler/AppSchedulingInfo.java | 168 +++-
.../scheduler/SchedulerApplicationAttempt.java | 73 +-
.../scheduler/activities/ActivitiesLogger.java | 17 +-
.../scheduler/activities/ActivitiesManager.java | 7 +-
.../scheduler/capacity/AbstractCSQueue.java | 71 ++
.../scheduler/capacity/CSAssignment.java | 33 +
.../scheduler/capacity/CSQueue.java | 19 +-
.../scheduler/capacity/CapacityScheduler.java | 773 ++++++++++++++-----
.../CapacitySchedulerConfiguration.java | 4 +
.../scheduler/capacity/LeafQueue.java | 451 ++++++-----
.../scheduler/capacity/ParentQueue.java | 428 +++++-----
.../allocator/AbstractContainerAllocator.java | 39 +-
.../capacity/allocator/ContainerAllocation.java | 12 +-
.../capacity/allocator/ContainerAllocator.java | 15 +-
.../allocator/IncreaseContainerAllocator.java | 89 +--
.../allocator/RegularContainerAllocator.java | 215 +++---
.../scheduler/common/AssignmentInformation.java | 44 +-
.../common/ContainerAllocationProposal.java | 111 +++
.../common/ResourceAllocationCommitter.java | 29 +
.../scheduler/common/ResourceCommitRequest.java | 164 ++++
.../scheduler/common/SchedulerContainer.java | 80 ++
.../scheduler/common/fica/FiCaSchedulerApp.java | 624 ++++++++++++---
.../scheduler/fifo/FifoAppAttempt.java | 110 +++
.../scheduler/fifo/FifoScheduler.java | 55 +-
.../scheduler/placement/PlacementSet.java | 65 ++
.../scheduler/placement/PlacementSetUtils.java | 36 +
.../placement/ResourceRequestUpdateResult.java | 43 ++
.../placement/SchedulingPlacementSet.java | 90 +++
.../scheduler/placement/SimplePlacementSet.java | 70 ++
.../AbstractComparatorOrderingPolicy.java | 4 +-
.../scheduler/policy/FairOrderingPolicy.java | 3 +-
.../scheduler/policy/FifoOrderingPolicy.java | 4 +-
.../FifoOrderingPolicyForPendingApps.java | 3 +-
.../yarn/server/resourcemanager/MockRM.java | 47 +-
.../resourcemanager/TestClientRMService.java | 2 +-
.../scheduler/TestSchedulerHealth.java | 6 +-
.../capacity/TestCapacityScheduler.java | 56 +-
.../TestCapacitySchedulerAsyncScheduling.java | 143 ++++
.../scheduler/capacity/TestChildQueueOrder.java | 21 +-
.../capacity/TestContainerAllocation.java | 45 +-
.../capacity/TestContainerResizing.java | 10 +-
.../scheduler/capacity/TestLeafQueue.java | 647 +++++++++++-----
.../scheduler/capacity/TestParentQueue.java | 209 +++--
.../scheduler/capacity/TestReservations.java | 277 +++++--
.../scheduler/capacity/TestUtils.java | 26 +
.../TestRMWebServicesSchedulerActivities.java | 8 +-
49 files changed, 4212 insertions(+), 1334 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml b/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml
index 01b1da7..ab36a4e 100644
--- a/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml
+++ b/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml
@@ -574,4 +574,13 @@
\u2002\u2002\u2002\u2002</Or>
<Bug pattern="VO_VOLATILE_INCREMENT" />
</Match>
+
+
+ <!-- Ignore false alert for UL_UNRELEASED_LOCK_EXCEPTION_PATH -->
+ <Match>
+ <Class name="org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler$ResourceCommitterService"/>
+ <Method name="run" />
+ <Bug pattern="UL_UNRELEASED_LOCK_EXCEPTION_PATH" />
+ </Match>
+
</FindBugsFilter>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainer.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainer.java
index e5d1208..a244ad8 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainer.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainer.java
@@ -25,6 +25,7 @@ import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.api.records.ContainerState;
+import org.apache.hadoop.yarn.api.records.ContainerStatus;
import org.apache.hadoop.yarn.api.records.ExecutionType;
import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.Priority;
@@ -46,6 +47,8 @@ public interface RMContainer extends EventHandler<RMContainerEvent> {
ContainerId getContainerId();
+ void setContainerId(ContainerId containerId);
+
ApplicationAttemptId getApplicationAttemptId();
RMContainerState getState();
@@ -105,4 +108,14 @@ public interface RMContainer extends EventHandler<RMContainerEvent> {
* @return If the container was allocated remotely.
*/
boolean isRemotelyAllocated();
+
+ /*
+ * Return reserved resource for reserved containers, return allocated resource
+ * for other container
+ */
+ Resource getAllocatedOrReservedResource();
+
+ boolean completed();
+
+ NodeId getNodeId();
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java
index 706821e..4294ef0 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java
@@ -161,7 +161,6 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
RMContainerEvent> stateMachine;
private final ReadLock readLock;
private final WriteLock writeLock;
- private final ContainerId containerId;
private final ApplicationAttemptId appAttemptId;
private final NodeId nodeId;
private final Container container;
@@ -224,7 +223,6 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
RMContext rmContext, long creationTime, String nodeLabelExpression,
boolean isExternallyAllocated) {
this.stateMachine = stateMachineFactory.make(this);
- this.containerId = container.getId();
this.nodeId = nodeId;
this.container = container;
this.allocatedSchedulerKey = SchedulerRequestKey.extractFrom(container);
@@ -255,7 +253,7 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
// containers. If false, and if this container is marked as the AM, metrics
// will still be published for this container, but that calculation happens
// later.
- if (saveNonAMContainerMetaInfo) {
+ if (saveNonAMContainerMetaInfo && null != container.getId()) {
rmContext.getSystemMetricsPublisher().containerCreated(
this, this.creationTime);
}
@@ -263,7 +261,7 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
@Override
public ContainerId getContainerId() {
- return this.containerId;
+ return this.container.getId();
}
@Override
@@ -356,8 +354,8 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
public String getDiagnosticsInfo() {
try {
readLock.lock();
- if (getFinishedStatus() != null) {
- return getFinishedStatus().getDiagnostics();
+ if (finishedStatus != null) {
+ return finishedStatus.getDiagnostics();
} else {
return null;
}
@@ -374,7 +372,7 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
logURL.append(WebAppUtils.getHttpSchemePrefix(rmContext
.getYarnConfiguration()));
logURL.append(WebAppUtils.getRunningLogURL(
- container.getNodeHttpAddress(), containerId.toString(),
+ container.getNodeHttpAddress(), getContainerId().toString(),
user));
return logURL.toString();
} finally {
@@ -386,8 +384,8 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
public int getContainerExitStatus() {
try {
readLock.lock();
- if (getFinishedStatus() != null) {
- return getFinishedStatus().getExitStatus();
+ if (finishedStatus != null) {
+ return finishedStatus.getExitStatus();
} else {
return 0;
}
@@ -400,8 +398,8 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
public ContainerState getContainerState() {
try {
readLock.lock();
- if (getFinishedStatus() != null) {
- return getFinishedStatus().getState();
+ if (finishedStatus != null) {
+ return finishedStatus.getState();
} else {
return ContainerState.RUNNING;
}
@@ -431,7 +429,7 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
@Override
public String toString() {
- return containerId.toString();
+ return getContainerId().toString();
}
@Override
@@ -476,7 +474,7 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
} catch (InvalidStateTransitionException e) {
LOG.error("Can't handle this event at current state", e);
LOG.error("Invalid event " + event.getType() +
- " on container " + this.containerId);
+ " on container " + this.getContainerId());
}
if (oldState != getState()) {
LOG.info(event.getContainerId() + " Container Transitioned from "
@@ -489,10 +487,15 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
}
}
- public ContainerStatus getFinishedStatus() {
- return finishedStatus;
+ public boolean completed() {
+ return finishedStatus != null;
}
-
+
+ @Override
+ public NodeId getNodeId() {
+ return nodeId;
+ }
+
private static class BaseTransition implements
SingleArcTransition<RMContainerImpl, RMContainerEvent> {
@@ -517,7 +520,7 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
report.getContainerExitStatus());
new FinishedTransition().transition(container,
- new RMContainerFinishedEvent(container.containerId, status,
+ new RMContainerFinishedEvent(container.getContainerId(), status,
RMContainerEventType.FINISHED));
return RMContainerState.COMPLETED;
} else if (report.getContainerState().equals(ContainerState.RUNNING)) {
@@ -654,11 +657,11 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
} else {
// Something wrong happened, kill the container
LOG.warn("Something wrong happened, container size reported by NM"
- + " is not expected, ContainerID=" + container.containerId
+ + " is not expected, ContainerID=" + container.getContainerId()
+ " rm-size-resource:" + rmContainerResource + " nm-size-reosurce:"
+ nmContainerResource);
container.eventHandler.handle(new RMNodeCleanContainerEvent(
- container.nodeId, container.containerId));
+ container.nodeId, container.getContainerId()));
}
}
@@ -761,7 +764,7 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
// Inform node
container.eventHandler.handle(new RMNodeCleanContainerEvent(
- container.nodeId, container.containerId));
+ container.nodeId, container.getContainerId()));
// Inform appAttempt
super.transition(container, event);
@@ -831,8 +834,8 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
@Override
public int compareTo(RMContainer o) {
- if (containerId != null && o.getContainerId() != null) {
- return containerId.compareTo(o.getContainerId());
+ if (getContainerId() != null && o.getContainerId() != null) {
+ return getContainerId().compareTo(o.getContainerId());
}
return -1;
}
@@ -865,4 +868,35 @@ public class RMContainerImpl implements RMContainer, Comparable<RMContainer> {
public boolean isRemotelyAllocated() {
return isExternallyAllocated;
}
+
+ @Override
+ public Resource getAllocatedOrReservedResource() {
+ try {
+ readLock.lock();
+ if (getState().equals(RMContainerState.RESERVED)) {
+ return getReservedResource();
+ } else {
+ return getAllocatedResource();
+ }
+ } finally {
+ readLock.unlock();
+ }
+ }
+
+ @Override
+ public void setContainerId(ContainerId containerId) {
+ // In some cases, for example, global scheduling. It is possible that
+ // container created without container-id assigned, so we will publish
+ // container creation event to timeline service when id assigned.
+ container.setId(containerId);
+
+ // If saveNonAMContainerMetaInfo is true, store system metrics for all
+ // containers. If false, and if this container is marked as the AM, metrics
+ // will still be published for this container, but that calculation happens
+ // later.
+ if (saveNonAMContainerMetaInfo && null != container.getId()) {
+ rmContext.getSystemMetricsPublisher().containerCreated(
+ this, this.creationTime);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AppSchedulingInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AppSchedulingInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AppSchedulingInfo.java
index 59a6650..ffb1885 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AppSchedulingInfo.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AppSchedulingInfo.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -32,6 +33,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.apache.commons.collections.IteratorUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience.Private;
@@ -49,6 +51,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerState;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.ResourceRequestUpdateResult;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SchedulingPlacementSet;
import org.apache.hadoop.yarn.util.resource.Resources;
/**
@@ -691,6 +696,25 @@ public class AppSchedulingInfo {
}
}
+ public List<ResourceRequest> allocate(NodeType type,
+ SchedulerNode node, SchedulerRequestKey schedulerKey,
+ Container containerAllocated) {
+ try {
+ writeLock.lock();
+ ResourceRequest request;
+ if (type == NodeType.NODE_LOCAL) {
+ request = resourceRequestMap.get(schedulerKey).get(node.getNodeName());
+ } else if (type == NodeType.RACK_LOCAL) {
+ request = resourceRequestMap.get(schedulerKey).get(node.getRackName());
+ } else{
+ request = resourceRequestMap.get(schedulerKey).get(ResourceRequest.ANY);
+ }
+ return allocate(type, node, schedulerKey, request, containerAllocated);
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
/**
* Resources have been allocated to this application by the resource
* scheduler. Track them.
@@ -701,40 +725,26 @@ public class AppSchedulingInfo {
* @param containerAllocated Container Allocated
* @return List of ResourceRequests
*/
- public List<ResourceRequest> allocate(NodeType type, SchedulerNode node,
- SchedulerRequestKey schedulerKey, ResourceRequest request,
- Container containerAllocated) {
- List<ResourceRequest> resourceRequests = new ArrayList<>();
+ public List<ResourceRequest> allocate(NodeType type,
+ SchedulerNode node, SchedulerRequestKey schedulerKey,
+ ResourceRequest request, Container containerAllocated) {
try {
- this.writeLock.lock();
+ writeLock.lock();
+ List<ResourceRequest> resourceRequests = new ArrayList<>();
if (type == NodeType.NODE_LOCAL) {
allocateNodeLocal(node, schedulerKey, request, resourceRequests);
} else if (type == NodeType.RACK_LOCAL) {
allocateRackLocal(node, schedulerKey, request, resourceRequests);
- } else {
+ } else{
allocateOffSwitch(request, resourceRequests, schedulerKey);
}
- QueueMetrics metrics = queue.getMetrics();
- if (pending) {
- // once an allocation is done we assume the application is
- // running from scheduler's POV.
- pending = false;
- metrics.runAppAttempt(applicationId, user);
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("allocate: applicationId=" + applicationId
- + " container=" + containerAllocated.getId()
- + " host=" + containerAllocated.getNodeId().toString()
- + " user=" + user
- + " resource=" + request.getCapability()
- + " type=" + type);
+ if (null != containerAllocated) {
+ updateMetricsForAllocatedContainer(request, type, containerAllocated);
}
- metrics.allocateResources(user, 1, request.getCapability(), true);
- metrics.incrNodeTypeAggregations(user, type);
return resourceRequests;
} finally {
- this.writeLock.unlock();
+ writeLock.unlock();
}
}
@@ -942,4 +952,116 @@ public class AppSchedulingInfo {
request.getRelaxLocality(), request.getNodeLabelExpression());
return newRequest;
}
+
+ /*
+ * In async environment, pending resource request could be updated during
+ * scheduling, this method checks pending request before allocating
+ */
+ public boolean checkAllocation(NodeType type, SchedulerNode node,
+ SchedulerRequestKey schedulerKey) {
+ try {
+ readLock.lock();
+ ResourceRequest r = resourceRequestMap.get(schedulerKey).get(
+ ResourceRequest.ANY);
+ if (r == null || r.getNumContainers() <= 0) {
+ return false;
+ }
+ if (type == NodeType.RACK_LOCAL || type == NodeType.NODE_LOCAL) {
+ r = resourceRequestMap.get(schedulerKey).get(node.getRackName());
+ if (r == null || r.getNumContainers() <= 0) {
+ return false;
+ }
+ if (type == NodeType.NODE_LOCAL) {
+ r = resourceRequestMap.get(schedulerKey).get(node.getNodeName());
+ if (r == null || r.getNumContainers() <= 0) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ } finally {
+ readLock.unlock();
+ }
+ }
+
+ public void updateMetricsForAllocatedContainer(
+ ResourceRequest request, NodeType type, Container containerAllocated) {
+ try {
+ writeLock.lock();
+ QueueMetrics metrics = queue.getMetrics();
+ if (pending) {
+ // once an allocation is done we assume the application is
+ // running from scheduler's POV.
+ pending = false;
+ metrics.runAppAttempt(applicationId, user);
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("allocate: applicationId=" + applicationId + " container="
+ + containerAllocated.getId() + " host=" + containerAllocated
+ .getNodeId().toString() + " user=" + user + " resource=" + request
+ .getCapability() + " type=" + type);
+ }
+ metrics.allocateResources(user, 1, request.getCapability(), true);
+ metrics.incrNodeTypeAggregations(user, type);
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ // Get placement-set by specified schedulerKey
+ // Now simply return all node of the input clusterPlacementSet
+ // TODO, need update this when we support global scheduling
+ public <N extends SchedulerNode> SchedulingPlacementSet<N> getSchedulingPlacementSet(
+ SchedulerRequestKey schedulerkey) {
+ return new SchedulingPlacementSet<N>() {
+ @Override
+ @SuppressWarnings("unchecked")
+ public Iterator<N> getPreferredNodeIterator(
+ PlacementSet<N> clusterPlacementSet) {
+ return IteratorUtils.singletonIterator(
+ clusterPlacementSet.getAllNodes().values().iterator().next());
+ }
+
+ @Override
+ public ResourceRequestUpdateResult updateResourceRequests(
+ List<ResourceRequest> requests,
+ boolean recoverPreemptedRequestForAContainer) {
+ return null;
+ }
+
+ @Override
+ public Map<String, ResourceRequest> getResourceRequests() {
+ return null;
+ }
+
+ @Override
+ public ResourceRequest getResourceRequest(String resourceName,
+ SchedulerRequestKey requestKey) {
+ return null;
+ }
+
+ @Override
+ public List<ResourceRequest> allocate(NodeType type, SchedulerNode node,
+ ResourceRequest request) {
+ return null;
+ }
+
+ @Override
+ public Map<NodeId, N> getAllNodes() {
+ return null;
+ }
+
+ @Override
+ public long getVersion() {
+ return 0;
+ }
+
+ @Override
+ public String getPartition() {
+ return null;
+ }
+ };
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
index d148132..bb1d461 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java
@@ -28,10 +28,12 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import com.google.common.collect.ConcurrentHashMultiset;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang.time.FastDateFormat;
import org.apache.commons.logging.Log;
@@ -49,12 +51,14 @@ import org.apache.hadoop.yarn.api.records.ExecutionType;
import org.apache.hadoop.yarn.api.records.LogAggregationContext;
import org.apache.hadoop.yarn.api.records.NMToken;
import org.apache.hadoop.yarn.api.records.NodeId;
+import org.apache.hadoop.yarn.api.records.NodeLabel;
import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
import org.apache.hadoop.yarn.server.api.ContainerType;
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.AggregateAppResourceUsage;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
@@ -69,6 +73,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerStat
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerUpdatesAcquiredEvent;
import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeCleanContainerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.SchedulingMode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SchedulingPlacementSet;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.policy.SchedulableEntity;
import org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerContext;
@@ -178,6 +185,11 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
protected ReentrantReadWriteLock.ReadLock readLock;
protected ReentrantReadWriteLock.WriteLock writeLock;
+ // Not confirmed allocation resource, will be used to avoid too many proposal
+ // rejected because of duplicated allocation
+ private AtomicLong unconfirmedAllocatedMem = new AtomicLong();
+ private AtomicInteger unconfirmedAllocatedVcores = new AtomicInteger();
+
public SchedulerApplicationAttempt(ApplicationAttemptId applicationAttemptId,
String user, Queue queue, ActiveUsersManager activeUsersManager,
RMContext rmContext) {
@@ -529,6 +541,8 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
if (rmContainer == null) {
rmContainer = new RMContainerImpl(container, getApplicationAttemptId(),
node.getNodeID(), appSchedulingInfo.getUser(), rmContext);
+ }
+ if (rmContainer.getState() == RMContainerState.NEW) {
attemptResourceUsage.incReserved(node.getPartition(),
container.getResource());
((RMContainerImpl) rmContainer).setQueueName(this.getQueueName());
@@ -839,16 +853,10 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
}
// used for continuous scheduling
- public void resetSchedulingOpportunities(
- SchedulerRequestKey schedulerKey, long currentTimeMs) {
- try {
- writeLock.lock();
- lastScheduledContainer.put(schedulerKey, currentTimeMs);
- schedulingOpportunities.setCount(schedulerKey, 0);
- } finally {
- writeLock.unlock();
- }
-
+ public void resetSchedulingOpportunities(SchedulerRequestKey schedulerKey,
+ long currentTimeMs) {
+ lastScheduledContainer.put(schedulerKey, currentTimeMs);
+ schedulingOpportunities.setCount(schedulerKey, 0);
}
@VisibleForTesting
@@ -998,6 +1006,11 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
public void incNumAllocatedContainers(NodeType containerType,
NodeType requestType) {
+ if (containerType == null || requestType == null) {
+ // Sanity check
+ return;
+ }
+
RMAppAttempt attempt =
rmContext.getRMApps().get(attemptId.getApplicationId())
.getCurrentAppAttempt();
@@ -1039,9 +1052,27 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
public boolean hasPendingResourceRequest(ResourceCalculator rc,
String nodePartition, Resource cluster,
SchedulingMode schedulingMode) {
- return SchedulerUtils.hasPendingResourceRequest(rc,
- this.attemptResourceUsage, nodePartition, cluster,
- schedulingMode);
+ // We need to consider unconfirmed allocations
+ if (schedulingMode == SchedulingMode.IGNORE_PARTITION_EXCLUSIVITY) {
+ nodePartition = RMNodeLabelsManager.NO_LABEL;
+ }
+
+ Resource pending = attemptResourceUsage.getPending(nodePartition);
+
+ // TODO, need consider node partition here
+ // To avoid too many allocation-proposals rejected for non-default
+ // partition allocation
+ if (StringUtils.equals(nodePartition, RMNodeLabelsManager.NO_LABEL)) {
+ pending = Resources.subtract(pending, Resources
+ .createResource(unconfirmedAllocatedMem.get(),
+ unconfirmedAllocatedVcores.get()));
+ }
+
+ if (Resources.greaterThan(rc, cluster, pending, Resources.none())) {
+ return true;
+ }
+
+ return false;
}
@VisibleForTesting
@@ -1206,6 +1237,22 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
this.isAttemptRecovering = isRecovering;
}
+ public <N extends SchedulerNode> SchedulingPlacementSet<N> getSchedulingPlacementSet(
+ SchedulerRequestKey schedulerRequestKey) {
+ return appSchedulingInfo.getSchedulingPlacementSet(schedulerRequestKey);
+ }
+
+
+ public void incUnconfirmedRes(Resource res) {
+ unconfirmedAllocatedMem.addAndGet(res.getMemorySize());
+ unconfirmedAllocatedVcores.addAndGet(res.getVirtualCores());
+ }
+
+ public void decUnconfirmedRes(Resource res) {
+ unconfirmedAllocatedMem.addAndGet(-res.getMemorySize());
+ unconfirmedAllocatedVcores.addAndGet(-res.getVirtualCores());
+ }
+
/**
* Different state for Application Master, user can see this state from web UI
*/
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/activities/ActivitiesLogger.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/activities/ActivitiesLogger.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/activities/ActivitiesLogger.java
index 8fa1bb5..3f8ed55 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/activities/ActivitiesLogger.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/activities/ActivitiesLogger.java
@@ -25,12 +25,14 @@ import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.Priority;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
/**
* Utility for logging scheduler activities
*/
+// FIXME: make sure PlacementSet works with this class
public class ActivitiesLogger {
private static final Log LOG = LogFactory.getLog(ActivitiesLogger.class);
@@ -112,7 +114,7 @@ public class ActivitiesLogger {
*/
public static void recordAppActivityWithAllocation(
ActivitiesManager activitiesManager, SchedulerNode node,
- SchedulerApplicationAttempt application, Container updatedContainer,
+ SchedulerApplicationAttempt application, RMContainer updatedContainer,
ActivityState activityState) {
if (activitiesManager == null) {
return;
@@ -122,9 +124,9 @@ public class ActivitiesLogger {
// Add application-container activity into specific node allocation.
activitiesManager.addSchedulingActivityForNode(node.getNodeID(),
application.getApplicationId().toString(),
- updatedContainer.getId().toString(),
- updatedContainer.getPriority().toString(), activityState,
- ActivityDiagnosticConstant.EMPTY, type);
+ updatedContainer.getContainer().toString(),
+ updatedContainer.getContainer().getPriority().toString(),
+ activityState, ActivityDiagnosticConstant.EMPTY, type);
type = "app";
// Add queue-application activity into specific node allocation.
activitiesManager.addSchedulingActivityForNode(node.getNodeID(),
@@ -138,9 +140,10 @@ public class ActivitiesLogger {
application.getApplicationId())) {
String type = "container";
activitiesManager.addSchedulingActivityForApp(
- application.getApplicationId(), updatedContainer.getId().toString(),
- updatedContainer.getPriority().toString(), activityState,
- ActivityDiagnosticConstant.EMPTY, type);
+ application.getApplicationId(),
+ updatedContainer.getContainerId(),
+ updatedContainer.getContainer().getPriority().toString(),
+ activityState, ActivityDiagnosticConstant.EMPTY, type);
}
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/activities/ActivitiesManager.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/activities/ActivitiesManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/activities/ActivitiesManager.java
index 4fa5feb..af73ae3 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/activities/ActivitiesManager.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/activities/ActivitiesManager.java
@@ -200,12 +200,13 @@ public class ActivitiesManager extends AbstractService {
// Add queue, application or container activity into specific application
// allocation.
void addSchedulingActivityForApp(ApplicationId applicationId,
- String containerId, String priority, ActivityState state,
+ ContainerId containerId, String priority, ActivityState state,
String diagnostic, String type) {
if (shouldRecordThisApp(applicationId)) {
AppAllocation appAllocation = appsAllocation.get(applicationId);
- appAllocation.addAppAllocationActivity(containerId, priority, state,
- diagnostic, type);
+ appAllocation.addAppAllocationActivity(containerId == null ?
+ "Container-Id-Not-Assigned" :
+ containerId.toString(), priority, state, diagnostic, type);
}
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java
index 096f5ea..7e18b29 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,6 +55,12 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceUsage;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.SchedulerContainer;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimplePlacementSet;
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
import org.apache.hadoop.yarn.util.resource.Resources;
@@ -738,4 +745,68 @@ public abstract class AbstractCSQueue implements CSQueue {
return csContext.getPreemptionManager().getKillableContainers(queueName,
partition);
}
+
+ @VisibleForTesting
+ @Override
+ public CSAssignment assignContainers(Resource clusterResource,
+ FiCaSchedulerNode node, ResourceLimits resourceLimits,
+ SchedulingMode schedulingMode) {
+ return assignContainers(clusterResource, new SimplePlacementSet<>(node),
+ resourceLimits, schedulingMode);
+ }
+
+ @Override
+ public boolean accept(Resource cluster,
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request) {
+ // Do we need to check parent queue before making this decision?
+ boolean checkParentQueue = false;
+
+ ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> allocation =
+ request.getFirstAllocatedOrReservedContainer();
+ SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> schedulerContainer =
+ allocation.getAllocatedOrReservedContainer();
+
+ // Do not check when allocating new container from a reserved container
+ if (allocation.getAllocateFromReservedContainer() == null) {
+ Resource required = allocation.getAllocatedOrReservedResource();
+ Resource netAllocated = Resources.subtract(required,
+ request.getTotalReleasedResource());
+
+ try {
+ readLock.lock();
+
+ String partition = schedulerContainer.getNodePartition();
+ Resource maxResourceLimit;
+ if (allocation.getSchedulingMode()
+ == SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY) {
+ maxResourceLimit = getQueueMaxResource(partition, cluster);
+ } else{
+ maxResourceLimit = labelManager.getResourceByLabel(
+ schedulerContainer.getNodePartition(), cluster);
+ }
+ if (!Resources.fitsIn(resourceCalculator, cluster,
+ Resources.add(queueUsage.getUsed(partition), netAllocated),
+ maxResourceLimit)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Used resource=" + queueUsage.getUsed(partition)
+ + " exceeded maxResourceLimit of the queue ="
+ + maxResourceLimit);
+ }
+ return false;
+ }
+ } finally {
+ readLock.unlock();
+ }
+
+ // Only check parent queue when something new allocated or reserved.
+ checkParentQueue = true;
+ }
+
+
+ if (parent != null && checkParentQueue) {
+ return parent.accept(cluster, request);
+ }
+
+ return true;
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSAssignment.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSAssignment.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSAssignment.java
index 7bea9af..2cae9a9 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSAssignment.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSAssignment.java
@@ -38,7 +38,11 @@ public class CSAssignment {
new CSAssignment(SkippedType.OTHER);
private Resource resource;
+ // Container allocation locality type
private NodeType type;
+
+ // Pending request locality type
+ private NodeType requestLocalityType;
private RMContainer excessReservation;
private FiCaSchedulerApp application;
private SkippedType skipped;
@@ -57,6 +61,10 @@ public class CSAssignment {
private boolean increaseAllocation;
private List<RMContainer> containersToKill;
+ // Set when fulfilledReservation = true
+ private RMContainer fulfilledReservedContainer;
+ private SchedulingMode schedulingMode;
+
public CSAssignment(Resource resource, NodeType type) {
this(resource, type, null, null, SkippedType.NONE, false);
}
@@ -173,4 +181,29 @@ public class CSAssignment {
public List<RMContainer> getContainersToKill() {
return containersToKill;
}
+
+ public RMContainer getFulfilledReservedContainer() {
+ return fulfilledReservedContainer;
+ }
+
+ public void setFulfilledReservedContainer(
+ RMContainer fulfilledReservedContainer) {
+ this.fulfilledReservedContainer = fulfilledReservedContainer;
+ }
+
+ public SchedulingMode getSchedulingMode() {
+ return schedulingMode;
+ }
+
+ public void setSchedulingMode(SchedulingMode schedulingMode) {
+ this.schedulingMode = schedulingMode;
+ }
+
+ public NodeType getRequestLocalityType() {
+ return requestLocalityType;
+ }
+
+ public void setRequestLocalityType(NodeType requestLocalityType) {
+ this.requestLocalityType = requestLocalityType;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSQueue.java
index daf7790..e5cbd04 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSQueue.java
@@ -23,6 +23,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
+import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.security.AccessControlException;
@@ -42,8 +43,11 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceUsage;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedContainerChangeRequest;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimplePlacementSet;
/**
* <code>CSQueue</code> represents a node in the tree of
@@ -195,14 +199,14 @@ extends org.apache.hadoop.yarn.server.resourcemanager.scheduler.Queue {
/**
* Assign containers to applications in the queue or it's children (if any).
* @param clusterResource the resource of the cluster.
- * @param node node on which resources are available
+ * @param ps {@link PlacementSet} of nodes which resources are available
* @param resourceLimits how much overall resource of this queue can use.
* @param schedulingMode Type of exclusive check when assign container on a
* NodeManager, see {@link SchedulingMode}.
* @return the assignment
*/
public CSAssignment assignContainers(Resource clusterResource,
- FiCaSchedulerNode node, ResourceLimits resourceLimits,
+ PlacementSet<FiCaSchedulerNode> ps, ResourceLimits resourceLimits,
SchedulingMode schedulingMode);
/**
@@ -340,4 +344,15 @@ extends org.apache.hadoop.yarn.server.resourcemanager.scheduler.Queue {
* @return valid node labels
*/
public Set<String> getNodeLabelsForQueue();
+
+ @VisibleForTesting
+ CSAssignment assignContainers(Resource clusterResource,
+ FiCaSchedulerNode node, ResourceLimits resourceLimits,
+ SchedulingMode schedulingMode);
+
+ boolean accept(Resource cluster,
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request);
+
+ void apply(Resource cluster,
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[46/50] [abbrv] hadoop git commit: YARN-5834.
TestNodeStatusUpdater.testNMRMConnectionConf compares nodemanager wait time
to the incorrect value. (Chang Li via kasha)
Posted by ka...@apache.org.
YARN-5834. TestNodeStatusUpdater.testNMRMConnectionConf compares nodemanager wait time to the incorrect value. (Chang Li via kasha)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3a984195
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3a984195
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3a984195
Branch: refs/heads/YARN-4752
Commit: 3a98419532687e4362ffc26abbc1264232820db7
Parents: 89354f0
Author: Karthik Kambatla <ka...@cloudera.com>
Authored: Thu Nov 10 14:08:51 2016 -0800
Committer: Karthik Kambatla <ka...@cloudera.com>
Committed: Thu Nov 10 14:08:51 2016 -0800
----------------------------------------------------------------------
.../hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3a984195/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java
index 977cb76..59a4563 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java
@@ -1524,13 +1524,13 @@ public class TestNodeStatusUpdater {
long t = System.currentTimeMillis();
long duration = t - waitStartTime;
boolean waitTimeValid = (duration >= nmRmConnectionWaitMs) &&
- (duration < (connectionWaitMs + delta));
+ (duration < (nmRmConnectionWaitMs + delta));
if(!waitTimeValid) {
// throw exception if NM doesn't retry long enough
throw new Exception("NM should have tried re-connecting to RM during " +
- "period of at least " + connectionWaitMs + " ms, but " +
- "stopped retrying within " + (connectionWaitMs + delta) +
+ "period of at least " + nmRmConnectionWaitMs + " ms, but " +
+ "stopped retrying within " + (nmRmConnectionWaitMs + delta) +
" ms: " + e, e);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[44/50] [abbrv] hadoop git commit: HDFS-9337. Validate required
params for WebHDFS requests (Contributed by Jagadesh Kiran N)
Posted by ka...@apache.org.
HDFS-9337. Validate required params for WebHDFS requests (Contributed by Jagadesh Kiran N)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ca68f9cb
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ca68f9cb
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ca68f9cb
Branch: refs/heads/YARN-4752
Commit: ca68f9cb5bc78e996c0daf8024cf0e7a4faef12a
Parents: 86ac1ad
Author: Vinayakumar B <vi...@apache.org>
Authored: Thu Nov 10 16:51:33 2016 +0530
Committer: Vinayakumar B <vi...@apache.org>
Committed: Thu Nov 10 16:51:33 2016 +0530
----------------------------------------------------------------------
.../web/resources/NamenodeWebHdfsMethods.java | 31 +++++++++++++++++---
.../hadoop-hdfs/src/site/markdown/WebHDFS.md | 3 +-
.../hdfs/server/namenode/FSXAttrBaseTest.java | 3 +-
.../org/apache/hadoop/hdfs/web/TestWebHDFS.java | 21 ++++++++++++-
4 files changed, 51 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca68f9cb/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
index 15195e0..5d9b12a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
@@ -424,6 +424,18 @@ public class NamenodeWebHdfsMethods {
excludeDatanodes, createFlagParam, noredirect);
}
+ /** Validate all required params. */
+ @SuppressWarnings("rawtypes")
+ private void validateOpParams(HttpOpParam<?> op, Param... params) {
+ for (Param param : params) {
+ if (param.getValue() == null || param.getValueString() == null || param
+ .getValueString().isEmpty()) {
+ throw new IllegalArgumentException("Required param " + param.getName()
+ + " for op: " + op.getValueString() + " is null or empty");
+ }
+ }
+ }
+
/** Handle HTTP PUT request. */
@PUT
@Path("{" + UriFsPathParam.NAME + ":.*}")
@@ -576,6 +588,7 @@ public class NamenodeWebHdfsMethods {
}
case CREATESYMLINK:
{
+ validateOpParams(op, destination);
np.createSymlink(destination.getValue(), fullpath,
PermissionParam.getDefaultSymLinkFsPermission(),
createParent.getValue());
@@ -583,6 +596,7 @@ public class NamenodeWebHdfsMethods {
}
case RENAME:
{
+ validateOpParams(op, destination);
final EnumSet<Options.Rename> s = renameOptions.getValue();
if (s.isEmpty()) {
final boolean b = np.rename(fullpath, destination.getValue());
@@ -621,6 +635,7 @@ public class NamenodeWebHdfsMethods {
}
case RENEWDELEGATIONTOKEN:
{
+ validateOpParams(op, delegationTokenArgument);
final Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>();
token.decodeFromUrlString(delegationTokenArgument.getValue());
final long expiryTime = np.renewDelegationToken(token);
@@ -629,16 +644,19 @@ public class NamenodeWebHdfsMethods {
}
case CANCELDELEGATIONTOKEN:
{
+ validateOpParams(op, delegationTokenArgument);
final Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>();
token.decodeFromUrlString(delegationTokenArgument.getValue());
np.cancelDelegationToken(token);
return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
}
case MODIFYACLENTRIES: {
+ validateOpParams(op, aclPermission);
np.modifyAclEntries(fullpath, aclPermission.getAclPermission(true));
return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
}
case REMOVEACLENTRIES: {
+ validateOpParams(op, aclPermission);
np.removeAclEntries(fullpath, aclPermission.getAclPermission(false));
return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
}
@@ -651,10 +669,12 @@ public class NamenodeWebHdfsMethods {
return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
}
case SETACL: {
+ validateOpParams(op, aclPermission);
np.setAcl(fullpath, aclPermission.getAclPermission(true));
return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
}
case SETXATTR: {
+ validateOpParams(op, xattrName, xattrSetFlag);
np.setXAttr(
fullpath,
XAttrHelper.buildXAttr(xattrName.getXAttrName(),
@@ -662,6 +682,7 @@ public class NamenodeWebHdfsMethods {
return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
}
case REMOVEXATTR: {
+ validateOpParams(op, xattrName);
np.removeXAttr(fullpath, XAttrHelper.buildXAttr(xattrName.getXAttrName()));
return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
}
@@ -676,6 +697,7 @@ public class NamenodeWebHdfsMethods {
return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
}
case RENAMESNAPSHOT: {
+ validateOpParams(op, oldSnapshotName, snapshotName);
np.renameSnapshot(fullpath, oldSnapshotName.getValue(),
snapshotName.getValue());
return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
@@ -794,15 +816,13 @@ public class NamenodeWebHdfsMethods {
}
case CONCAT:
{
+ validateOpParams(op, concatSrcs);
np.concat(fullpath, concatSrcs.getAbsolutePaths());
return Response.ok().build();
}
case TRUNCATE:
{
- if (newLength.getValue() == null) {
- throw new IllegalArgumentException(
- "newLength parameter is Missing");
- }
+ validateOpParams(op, newLength);
// We treat each rest request as a separate client.
final boolean b = np.truncate(fullpath, newLength.getValue(),
"DFSClient_" + DFSUtil.getSecureRandom().nextLong());
@@ -1033,6 +1053,7 @@ public class NamenodeWebHdfsMethods {
return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
}
case GETXATTRS: {
+ validateOpParams(op, xattrEncoding);
List<String> names = null;
if (xattrNames != null) {
names = Lists.newArrayListWithCapacity(xattrNames.size());
@@ -1054,6 +1075,7 @@ public class NamenodeWebHdfsMethods {
return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
}
case CHECKACCESS: {
+ validateOpParams(op, fsAction);
np.checkAccess(fullpath, FsAction.getFsAction(fsAction.getValue()));
return Response.ok().build();
}
@@ -1222,6 +1244,7 @@ public class NamenodeWebHdfsMethods {
return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
}
case DELETESNAPSHOT: {
+ validateOpParams(op, snapshotName);
np.deleteSnapshot(fullpath, snapshotName.getValue());
return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca68f9cb/hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/WebHDFS.md
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/WebHDFS.md b/hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/WebHDFS.md
index 1d7d704..eda1350 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/WebHDFS.md
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/WebHDFS.md
@@ -1203,7 +1203,8 @@ Delegation Token Operations
* Submit a HTTP GET request.
- curl -i "http://<HOST>:<PORT>/webhdfs/v1/?op=GETDELEGATIONTOKEN&renewer=<USER>&service=<SERVICE>&kind=<KIND>"
+ curl -i "http://<HOST>:<PORT>/webhdfs/v1/?op=GETDELEGATIONTOKEN
+ [&renewer=<USER>][&service=<SERVICE>][&kind=<KIND>]"
The client receives a response with a [`Token` JSON object](#Token_JSON_Schema):
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca68f9cb/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSXAttrBaseTest.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSXAttrBaseTest.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSXAttrBaseTest.java
index c526484..8aa5dc9 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSXAttrBaseTest.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSXAttrBaseTest.java
@@ -287,7 +287,8 @@ public class FSXAttrBaseTest {
} catch (NullPointerException e) {
GenericTestUtils.assertExceptionContains("XAttr name cannot be null", e);
} catch (RemoteException e) {
- GenericTestUtils.assertExceptionContains("XAttr name cannot be null", e);
+ GenericTestUtils.assertExceptionContains("Required param xattr.name for "
+ + "op: SETXATTR is null or empty", e);
}
// Set xattr with empty name: "user."
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca68f9cb/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFS.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFS.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFS.java
index 23d543d..5386a45 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFS.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFS.java
@@ -75,6 +75,7 @@ import org.apache.hadoop.hdfs.web.resources.Param;
import org.apache.hadoop.io.retry.RetryPolicy;
import org.apache.hadoop.io.retry.RetryPolicy.RetryAction;
import org.apache.hadoop.io.retry.RetryPolicy.RetryAction.RetryDecision;
+import org.apache.hadoop.ipc.RemoteException;
import org.apache.hadoop.ipc.RetriableException;
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.token.SecretManager.InvalidToken;
@@ -527,6 +528,15 @@ public class TestWebHDFS {
final Path s1path = SnapshotTestHelper.getSnapshotRoot(foo, "s1");
Assert.assertTrue(webHdfs.exists(s1path));
+ // delete operation snapshot name as null
+ try {
+ webHdfs.deleteSnapshot(foo, null);
+ fail("Expected IllegalArgumentException");
+ } catch (RemoteException e) {
+ Assert.assertEquals("Required param snapshotname for "
+ + "op: DELETESNAPSHOT is null or empty", e.getLocalizedMessage());
+ }
+
// delete the two snapshots
webHdfs.deleteSnapshot(foo, "s1");
assertFalse(webHdfs.exists(s1path));
@@ -585,6 +595,15 @@ public class TestWebHDFS {
final Path s1path = SnapshotTestHelper.getSnapshotRoot(foo, "s1");
Assert.assertTrue(webHdfs.exists(s1path));
+ // rename s1 to s2 with oldsnapshotName as null
+ try {
+ webHdfs.renameSnapshot(foo, null, "s2");
+ fail("Expected IllegalArgumentException");
+ } catch (RemoteException e) {
+ Assert.assertEquals("Required param oldsnapshotname for "
+ + "op: RENAMESNAPSHOT is null or empty", e.getLocalizedMessage());
+ }
+
// rename s1 to s2
webHdfs.renameSnapshot(foo, "s1", "s2");
assertFalse(webHdfs.exists(s1path));
@@ -643,7 +662,7 @@ public class TestWebHDFS {
try {
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build();
final FileSystem webHdfs = WebHdfsTestUtil.getWebHdfsFileSystem(conf,
- WebHdfsConstants.WEBHDFS_SCHEME);
+ WebHdfsConstants.WEBHDFS_SCHEME);
Assert.assertNull(webHdfs.getDelegationToken(null));
} finally {
if (cluster != null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[05/50] [abbrv] hadoop git commit: MAPREDUCE-6790. Update jackson
from 1.9.13 to 2.x in hadoop-mapreduce.
Posted by ka...@apache.org.
MAPREDUCE-6790. Update jackson from 1.9.13 to 2.x in hadoop-mapreduce.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ca33bdd5
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ca33bdd5
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ca33bdd5
Branch: refs/heads/YARN-4752
Commit: ca33bdd5c6afd45110edb6961d1c492bcb009472
Parents: 049e7d2
Author: Akira Ajisaka <aa...@apache.org>
Authored: Mon Nov 7 11:19:21 2016 +0900
Committer: Akira Ajisaka <aa...@apache.org>
Committed: Mon Nov 7 11:19:21 2016 +0900
----------------------------------------------------------------------
.../hadoop-mapreduce-client-app/pom.xml | 4 ++++
.../jobhistory/JobHistoryEventHandler.java | 4 ++--
.../jobhistory/TestJobHistoryEventHandler.java | 5 +++--
.../hadoop-mapreduce-client-core/pom.xml | 4 ++++
.../org/apache/hadoop/mapred/QueueManager.java | 8 ++++----
.../org/apache/hadoop/mapreduce/JobSubmitter.java | 17 ++++++-----------
.../mapreduce/util/JobHistoryEventUtils.java | 9 +++++----
.../apache/hadoop/mapreduce/v2/TestRMNMInfo.java | 4 ++--
8 files changed, 30 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca33bdd5/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml
index ef0ed6e..8634903 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml
@@ -85,6 +85,10 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca33bdd5/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java
index e61bbaa..0403356 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java
@@ -76,9 +76,9 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.event.EventHandler;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.google.common.annotations.VisibleForTesting;
import com.sun.jersey.api.client.ClientHandlerException;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca33bdd5/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestJobHistoryEventHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestJobHistoryEventHandler.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestJobHistoryEventHandler.java
index bfe764d..54a2fad 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestJobHistoryEventHandler.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestJobHistoryEventHandler.java
@@ -73,8 +73,6 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
import org.apache.hadoop.yarn.server.MiniYARNCluster;
import org.apache.hadoop.yarn.server.timeline.TimelineStore;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.ObjectMapper;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -82,6 +80,9 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
public class TestJobHistoryEventHandler {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca33bdd5/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/pom.xml b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/pom.xml
index 00bb11b..3c16c3d 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/pom.xml
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/pom.xml
@@ -53,6 +53,10 @@
<artifactId>jsonassert</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca33bdd5/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/QueueManager.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/QueueManager.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/QueueManager.java
index 794c55d..d4ea87b 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/QueueManager.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/QueueManager.java
@@ -18,6 +18,9 @@
package org.apache.hadoop.mapred;
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.core.JsonGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -28,9 +31,6 @@ import org.apache.hadoop.mapreduce.QueueState;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authorize.AccessControlList;
import org.apache.hadoop.util.StringUtils;
-import org.codehaus.jackson.JsonFactory;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.JsonGenerator;
import java.io.BufferedInputStream;
import java.io.InputStream;
@@ -532,7 +532,7 @@ public class QueueManager {
}
JsonFactory dumpFactory = new JsonFactory();
- JsonGenerator dumpGenerator = dumpFactory.createJsonGenerator(out);
+ JsonGenerator dumpGenerator = dumpFactory.createGenerator(out);
QueueConfigurationParser parser;
boolean aclsEnabled = false;
if (conf != null) {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca33bdd5/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobSubmitter.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobSubmitter.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobSubmitter.java
index d1cc72c..a842649 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobSubmitter.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobSubmitter.java
@@ -32,6 +32,10 @@ import java.util.Map;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -60,10 +64,6 @@ import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
import org.apache.hadoop.util.ReflectionUtils;
import org.apache.hadoop.yarn.api.records.ReservationId;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
import com.google.common.base.Charsets;
@@ -407,7 +407,6 @@ class JobSubmitter {
LOG.info("loading user's secret keys from " + tokensFileName);
String localFileName = new Path(tokensFileName).toUri().getPath();
- boolean json_error = false;
try {
// read JSON
Map<String, String> nm = READER.readValue(new File(localFileName));
@@ -416,13 +415,9 @@ class JobSubmitter {
credentials.addSecretKey(new Text(ent.getKey()), ent.getValue()
.getBytes(Charsets.UTF_8));
}
- } catch (JsonMappingException e) {
- json_error = true;
- } catch (JsonParseException e) {
- json_error = true;
- }
- if(json_error)
+ } catch (JsonMappingException | JsonParseException e) {
LOG.warn("couldn't parse Token Cache JSON file with user secret keys");
+ }
}
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca33bdd5/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/util/JobHistoryEventUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/util/JobHistoryEventUtils.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/util/JobHistoryEventUtils.java
index 89abf0e..b5c8b11 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/util/JobHistoryEventUtils.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/util/JobHistoryEventUtils.java
@@ -20,14 +20,15 @@ package org.apache.hadoop.mapreduce.util;
import java.util.HashSet;
import java.util.Set;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.CounterGroup;
import org.apache.hadoop.mapreduce.Counters;
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.node.ArrayNode;
-import org.codehaus.jackson.node.ObjectNode;
/**
* Class containing utility methods to be used by JobHistoryEventHandler.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca33bdd5/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestRMNMInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestRMNMInfo.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestRMNMInfo.java
index afd6d47..0e55529 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestRMNMInfo.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestRMNMInfo.java
@@ -24,6 +24,8 @@ import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
@@ -36,8 +38,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
import org.apache.hadoop.yarn.server.resourcemanager.RMNMInfo;
import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.ObjectMapper;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[33/50] [abbrv] hadoop git commit: HDFS-11056. Concurrent append and
read operations lead to checksum error. Contributed by Wei-Chiu Chuang.
Posted by ka...@apache.org.
HDFS-11056. Concurrent append and read operations lead to checksum error. Contributed by Wei-Chiu Chuang.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c619e9b4
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c619e9b4
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c619e9b4
Branch: refs/heads/YARN-4752
Commit: c619e9b43fd00ba0e59a98ae09685ff719bb722b
Parents: 367c3d4
Author: Wei-Chiu Chuang <we...@apache.org>
Authored: Wed Nov 9 09:15:51 2016 -0800
Committer: Wei-Chiu Chuang <we...@apache.org>
Committed: Wed Nov 9 09:16:50 2016 -0800
----------------------------------------------------------------------
.../datanode/fsdataset/impl/FsVolumeImpl.java | 41 +++++++++++
.../org/apache/hadoop/hdfs/TestFileAppend.java | 71 ++++++++++++++++++++
.../fsdataset/impl/FsDatasetImplTestUtils.java | 14 ++++
3 files changed, 126 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/c619e9b4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
index 1627865..5880b3e 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
@@ -23,6 +23,7 @@ import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.OutputStreamWriter;
+import java.io.RandomAccessFile;
import java.net.URI;
import java.nio.channels.ClosedChannelException;
import java.nio.file.Files;
@@ -47,6 +48,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.DF;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.StorageType;
+import org.apache.hadoop.hdfs.server.datanode.BlockMetadataHeader;
import org.apache.hadoop.util.AutoCloseableLock;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.DFSUtilClient;
@@ -59,6 +61,7 @@ import org.apache.hadoop.hdfs.server.datanode.LocalReplica;
import org.apache.hadoop.hdfs.server.datanode.ReplicaInfo;
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.ReplicaState;
import org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory;
+import org.apache.hadoop.util.DataChecksum;
import org.apache.hadoop.util.DiskChecker.DiskOutOfSpaceException;
import org.apache.hadoop.hdfs.server.datanode.ReplicaBuilder;
import org.apache.hadoop.hdfs.server.datanode.LocalReplicaInPipeline;
@@ -1102,6 +1105,28 @@ public class FsVolumeImpl implements FsVolumeSpi {
}
+ private byte[] loadLastPartialChunkChecksum(
+ File blockFile, File metaFile) throws IOException {
+ DataChecksum dcs = BlockMetadataHeader.readHeader(metaFile).getChecksum();
+ final int checksumSize = dcs.getChecksumSize();
+ final long onDiskLen = blockFile.length();
+ final int bytesPerChecksum = dcs.getBytesPerChecksum();
+
+ if (onDiskLen % bytesPerChecksum == 0) {
+ // the last chunk is a complete one. No need to preserve its checksum
+ // because it will not be modified.
+ return null;
+ }
+
+ int offsetInChecksum = BlockMetadataHeader.getHeaderSize() +
+ (int)(onDiskLen / bytesPerChecksum * checksumSize);
+ byte[] lastChecksum = new byte[checksumSize];
+ RandomAccessFile raf = new RandomAccessFile(metaFile, "r");
+ raf.seek(offsetInChecksum);
+ raf.read(lastChecksum, 0, checksumSize);
+ return lastChecksum;
+ }
+
public ReplicaInPipeline append(String bpid, ReplicaInfo replicaInfo,
long newGS, long estimateBlockLen) throws IOException {
@@ -1126,6 +1151,13 @@ public class FsVolumeImpl implements FsVolumeSpi {
.setBytesToReserve(bytesReserved)
.buildLocalReplicaInPipeline();
+ // load last checksum and datalen
+ LocalReplica localReplica = (LocalReplica)replicaInfo;
+ byte[] lastChunkChecksum = loadLastPartialChunkChecksum(
+ localReplica.getBlockFile(), localReplica.getMetaFile());
+ newReplicaInfo.setLastChecksumAndDataLen(
+ replicaInfo.getNumBytes(), lastChunkChecksum);
+
// rename meta file to rbw directory
// rename block file to rbw directory
newReplicaInfo.moveReplicaFrom(replicaInfo, newBlkFile);
@@ -1170,6 +1202,12 @@ public class FsVolumeImpl implements FsVolumeSpi {
.setBytesToReserve(0)
.buildLocalReplicaInPipeline();
rbw.setBytesAcked(visible);
+
+ // load last checksum and datalen
+ final File destMeta = FsDatasetUtil.getMetaFile(dest,
+ b.getGenerationStamp());
+ byte[] lastChunkChecksum = loadLastPartialChunkChecksum(dest, destMeta);
+ rbw.setLastChecksumAndDataLen(numBytes, lastChunkChecksum);
return rbw;
}
@@ -1206,6 +1244,9 @@ public class FsVolumeImpl implements FsVolumeSpi {
.setDirectoryToUse(blockFile.getParentFile())
.setBytesToReserve(newlength)
.buildLocalReplicaInPipeline();
+ // In theory, this rbw replica needs to reload last chunk checksum,
+ // but it is immediately converted to finalized state within the same lock,
+ // so no need to update it.
return newReplicaInfo;
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/c619e9b4/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileAppend.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileAppend.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileAppend.java
index 3e8561f..20cec6a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileAppend.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileAppend.java
@@ -24,10 +24,12 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.util.EnumSet;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeoutException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.BlockLocation;
@@ -44,10 +46,16 @@ import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
+import org.apache.hadoop.hdfs.server.datanode.DataNodeTestUtils;
+import org.apache.hadoop.hdfs.server.datanode.ReplicaBeingWritten;
+import org.apache.hadoop.hdfs.server.datanode.ReplicaHandler;
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi;
+import org.apache.hadoop.hdfs.server.datanode.fsdataset.ReplicaOutputStreams;
import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil;
+import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetUtil;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.ipc.RemoteException;
+import org.apache.hadoop.util.DataChecksum;
import org.apache.hadoop.util.Time;
import org.junit.Assert;
import org.junit.Test;
@@ -61,6 +69,8 @@ public class TestFileAppend{
private static byte[] fileContents = null;
+ static final DataChecksum DEFAULT_CHECKSUM =
+ DataChecksum.newDataChecksum(DataChecksum.Type.CRC32C, 512);
//
// writes to file but does not close it
//
@@ -655,4 +665,65 @@ public class TestFileAppend{
cluster.shutdown();
}
}
+
+ @Test(timeout = 10000)
+ public void testConcurrentAppendRead()
+ throws IOException, TimeoutException, InterruptedException {
+ // Create a finalized replica and append to it
+ // Read block data and checksum. Verify checksum.
+ Configuration conf = new HdfsConfiguration();
+ conf.setInt(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, 1024);
+ conf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, 1);
+ conf.setInt("dfs.min.replication", 1);
+
+ MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
+ try {
+ cluster.waitActive();
+ DataNode dn = cluster.getDataNodes().get(0);
+ FsDatasetSpi<?> dataSet = DataNodeTestUtils.getFSDataset(dn);
+
+ // create a file with 1 byte of data.
+ long initialFileLength = 1;
+ DistributedFileSystem fs = cluster.getFileSystem();
+ Path fileName = new Path("/appendCorruptBlock");
+ DFSTestUtil.createFile(fs, fileName, initialFileLength, (short) 1, 0);
+ DFSTestUtil.waitReplication(fs, fileName, (short) 1);
+ Assert.assertTrue("File not created", fs.exists(fileName));
+
+ // Call FsDatasetImpl#append to append the block file,
+ // which converts it to a rbw replica.
+ ExtendedBlock block = DFSTestUtil.getFirstBlock(fs, fileName);
+ long newGS = block.getGenerationStamp()+1;
+ ReplicaHandler
+ replicaHandler = dataSet.append(block, newGS, initialFileLength);
+
+ // write data to block file
+ ReplicaBeingWritten rbw =
+ (ReplicaBeingWritten)replicaHandler.getReplica();
+ ReplicaOutputStreams
+ outputStreams = rbw.createStreams(false, DEFAULT_CHECKSUM);
+ OutputStream dataOutput = outputStreams.getDataOut();
+
+ byte[] appendBytes = new byte[1];
+ dataOutput.write(appendBytes, 0, 1);
+ dataOutput.flush();
+ dataOutput.close();
+
+ // update checksum file
+ final int smallBufferSize = DFSUtilClient.getSmallBufferSize(conf);
+ FsDatasetUtil.computeChecksum(
+ rbw.getMetaFile(), rbw.getMetaFile(), rbw.getBlockFile(),
+ smallBufferSize, conf);
+
+ // read the block
+ // the DataNode BlockSender should read from the rbw replica's in-memory
+ // checksum, rather than on-disk checksum. Otherwise it will see a
+ // checksum mismatch error.
+ final byte[] readBlock = DFSTestUtil.readFileBuffer(fs, fileName);
+ assertEquals("should have read only one byte!", 1, readBlock.length);
+ } finally {
+ cluster.shutdown();
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/c619e9b4/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImplTestUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImplTestUtils.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImplTestUtils.java
index 07ddb59..05b41fb 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImplTestUtils.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImplTestUtils.java
@@ -28,6 +28,7 @@ import org.apache.hadoop.fs.DF;
import org.apache.hadoop.hdfs.protocol.Block;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.ReplicaState;
+import org.apache.hadoop.hdfs.server.datanode.BlockMetadataHeader;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
import org.apache.hadoop.hdfs.server.datanode.DataStorage;
import org.apache.hadoop.hdfs.server.datanode.DatanodeUtil;
@@ -43,10 +44,13 @@ import org.apache.hadoop.hdfs.server.datanode.ReplicaUnderRecovery;
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi.FsVolumeReferences;
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi;
import org.apache.hadoop.test.GenericTestUtils;
+import org.apache.hadoop.util.DataChecksum;
import org.apache.log4j.Level;
+import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
@@ -67,6 +71,8 @@ public class FsDatasetImplTestUtils implements FsDatasetTestUtils {
LogFactory.getLog(FsDatasetImplTestUtils.class);
private final FsDatasetImpl dataset;
+ private static final DataChecksum DEFAULT_CHECKSUM =
+ DataChecksum.newDataChecksum(DataChecksum.Type.CRC32C, 512);
/**
* By default we assume 2 data directories (volumes) per DataNode.
*/
@@ -245,9 +251,17 @@ public class FsDatasetImplTestUtils implements FsDatasetTestUtils {
dataset.volumeMap.add(block.getBlockPoolId(), info);
info.getBlockFile().createNewFile();
info.getMetaFile().createNewFile();
+ saveMetaFileHeader(info.getMetaFile());
return info;
}
+ private void saveMetaFileHeader(File metaFile) throws IOException {
+ DataOutputStream metaOut = new DataOutputStream(
+ new FileOutputStream(metaFile));
+ BlockMetadataHeader.writeHeader(metaOut, DEFAULT_CHECKSUM);
+ metaOut.close();
+ }
+
@Override
public Replica createReplicaInPipeline(ExtendedBlock block)
throws IOException {
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[23/50] [abbrv] hadoop git commit: HADOOP-13802. Make generic options
help more consistent, and aligned. Contributed by Grant Sohn
Posted by ka...@apache.org.
HADOOP-13802. Make generic options help more consistent, and aligned. Contributed by Grant Sohn
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/2a65eb12
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2a65eb12
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2a65eb12
Branch: refs/heads/YARN-4752
Commit: 2a65eb121e23243fcb642d28b3f74241536485d8
Parents: 29e3b34
Author: Mingliang Liu <li...@apache.org>
Authored: Tue Nov 8 14:41:58 2016 -0800
Committer: Mingliang Liu <li...@apache.org>
Committed: Tue Nov 8 15:40:22 2016 -0800
----------------------------------------------------------------------
.../hadoop/util/GenericOptionsParser.java | 37 ++++++++++++--------
1 file changed, 22 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2a65eb12/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericOptionsParser.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericOptionsParser.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericOptionsParser.java
index 170812b..d98de56 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericOptionsParser.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericOptionsParser.java
@@ -567,21 +567,28 @@ public class GenericOptionsParser {
* @param out stream to print the usage message to.
*/
public static void printGenericCommandUsage(PrintStream out) {
-
- out.println("Generic options supported are");
- out.println("-conf <configuration file> specify an application configuration file");
- out.println("-D <property=value> use value for given property");
- out.println("-fs <local|namenode:port> specify a namenode");
- out.println("-jt <local|resourcemanager:port> specify a ResourceManager");
- out.println("-files <comma separated list of files> " +
- "specify comma separated files to be copied to the map reduce cluster");
- out.println("-libjars <comma separated list of jars> " +
- "specify comma separated jar files to include in the classpath.");
- out.println("-archives <comma separated list of archives> " +
- "specify comma separated archives to be unarchived" +
- " on the compute machines.\n");
- out.println("The general command line syntax is");
- out.println("command [genericOptions] [commandOptions]\n");
+ out.println("Generic options supported are:");
+ out.println("-conf <configuration file> "
+ + "specify an application configuration file");
+ out.println("-D <property=value> "
+ + "define a value for a given property");
+ out.println("-fs <local|namenode:port> "
+ + "specify a namenode");
+ out.println("-jt <local|resourcemanager:port> "
+ + "specify a ResourceManager");
+ out.println("-files <file1,...> "
+ + "specify a comma-separated list of files to be copied to the map "
+ + "reduce cluster");
+ out.println("-libjars <jar1,...> "
+ + "specify a comma-separated list of jar files to be included in the "
+ + "classpath");
+ out.println("-archives <archive1,...> "
+ + "specify a comma-separated list of archives to be unarchived on the "
+ + "compute machines");
+ out.println();
+ out.println("The general command line syntax is:");
+ out.println("command [genericOptions] [commandOptions]");
+ out.println();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[47/50] [abbrv] hadoop git commit: [YARN-4752] YARN-5605. Preempt
containers (all on one node) to meet the requirement of starved applications
(Contributed by Karthik Kambatla via Daniel Templeton)
Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b9bf30/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerPreemption.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerPreemption.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerPreemption.java
deleted file mode 100644
index 2cbe507..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerPreemption.java
+++ /dev/null
@@ -1,1483 +0,0 @@
-/**
- * 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.scheduler.fair;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
-import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
-import org.apache.hadoop.yarn.api.records.Container;
-import org.apache.hadoop.yarn.api.records.ContainerId;
-import org.apache.hadoop.yarn.api.records.Resource;
-import org.apache.hadoop.yarn.api.records.ResourceRequest;
-import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.apache.hadoop.yarn.event.AsyncDispatcher;
-import org.apache.hadoop.yarn.server.resourcemanager.MockNodes;
-import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
-import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
-import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
-
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerRequestKey;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity
- .TestUtils;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.ContainerPreemptEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSchedulerEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEventType;
-import org.apache.hadoop.yarn.util.ControlledClock;
-import org.apache.hadoop.yarn.util.resource.Resources;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestFairSchedulerPreemption extends FairSchedulerTestBase {
- private final static String ALLOC_FILE = new File(TEST_DIR,
- TestFairSchedulerPreemption.class.getName() + ".xml").getAbsolutePath();
-
- private ControlledClock clock;
-
- private static class StubbedFairScheduler extends FairScheduler {
- public long lastPreemptMemory = -1;
-
- @Override
- protected void preemptResources(Resource toPreempt) {
- lastPreemptMemory = toPreempt.getMemorySize();
- }
-
- public void resetLastPreemptResources() {
- lastPreemptMemory = -1;
- }
- }
-
- public Configuration createConfiguration() {
- Configuration conf = super.createConfiguration();
- conf.setClass(YarnConfiguration.RM_SCHEDULER, StubbedFairScheduler.class,
- ResourceScheduler.class);
- conf.setBoolean(FairSchedulerConfiguration.PREEMPTION, true);
- conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
- return conf;
- }
-
- @Before
- public void setup() throws IOException {
- conf = createConfiguration();
- clock = new ControlledClock();
- }
-
- @After
- public void teardown() {
- if (resourceManager != null) {
- resourceManager.stop();
- resourceManager = null;
- }
- conf = null;
- }
-
- private void startResourceManagerWithStubbedFairScheduler(float utilizationThreshold) {
- conf.setFloat(FairSchedulerConfiguration.PREEMPTION_THRESHOLD,
- utilizationThreshold);
- resourceManager = new MockRM(conf);
- resourceManager.start();
-
- assertTrue(
- resourceManager.getResourceScheduler() instanceof StubbedFairScheduler);
- scheduler = (FairScheduler)resourceManager.getResourceScheduler();
-
- scheduler.setClock(clock);
- scheduler.updateInterval = 60 * 1000;
- }
-
- // YARN-4648: The starting code for ResourceManager mock is originated from
- // TestFairScheduler. It should be keep as it was to guarantee no changing
- // behaviour of ResourceManager preemption.
- private void startResourceManagerWithRealFairScheduler() {
- scheduler = new FairScheduler();
- conf = new YarnConfiguration();
- conf.setClass(YarnConfiguration.RM_SCHEDULER, FairScheduler.class,
- ResourceScheduler.class);
- conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 0);
- conf.setInt(FairSchedulerConfiguration.RM_SCHEDULER_INCREMENT_ALLOCATION_MB,
- 1024);
- conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB, 10240);
- conf.setBoolean(FairSchedulerConfiguration.ASSIGN_MULTIPLE, false);
- conf.setFloat(FairSchedulerConfiguration.PREEMPTION_THRESHOLD, 0f);
- conf.setFloat(
- FairSchedulerConfiguration
- .RM_SCHEDULER_RESERVATION_THRESHOLD_INCREMENT_MULTIPLE,
- TEST_RESERVATION_THRESHOLD);
-
- resourceManager = new MockRM(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());
- }
-
- private void stopResourceManager() {
- if (scheduler != null) {
- scheduler.stop();
- scheduler = null;
- }
- if (resourceManager != null) {
- resourceManager.stop();
- resourceManager = null;
- }
- QueueMetrics.clearQueueMetrics();
- DefaultMetricsSystem.shutdown();
- }
-
- private void registerNodeAndSubmitApp(
- int memory, int vcores, int appContainers, int appMemory) {
- RMNode node1 = MockNodes.newNodeInfo(
- 1, Resources.createResource(memory, vcores), 1, "node1");
- NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
- scheduler.handle(nodeEvent1);
-
- assertEquals("Incorrect amount of resources in the cluster",
- memory, scheduler.rootMetrics.getAvailableMB());
- assertEquals("Incorrect amount of resources in the cluster",
- vcores, scheduler.rootMetrics.getAvailableVirtualCores());
-
- createSchedulingRequest(appMemory, "queueA", "user1", appContainers);
- scheduler.update();
- // Sufficient node check-ins to fully schedule containers
- for (int i = 0; i < 3; i++) {
- NodeUpdateSchedulerEvent nodeUpdate1 = new NodeUpdateSchedulerEvent(node1);
- scheduler.handle(nodeUpdate1);
- }
- assertEquals("app1's request is not met",
- memory - appContainers * appMemory,
- scheduler.rootMetrics.getAvailableMB());
- }
-
- @Test
- public void testPreemptionWithFreeResources() throws Exception {
- PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
- out.println("<?xml version=\"1.0\"?>");
- out.println("<allocations>");
- out.println("<queue name=\"default\">");
- out.println("<maxResources>0mb,0vcores</maxResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueA\">");
- out.println("<weight>1</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueB\">");
- out.println("<weight>1</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("</queue>");
- out.print("<defaultMinSharePreemptionTimeout>5</defaultMinSharePreemptionTimeout>");
- out.print("<fairSharePreemptionTimeout>10</fairSharePreemptionTimeout>");
- out.println("</allocations>");
- out.close();
-
- startResourceManagerWithStubbedFairScheduler(0f);
- // Create node with 4GB memory and 4 vcores
- registerNodeAndSubmitApp(4 * 1024, 4, 2, 1024);
-
- // Verify submitting another request triggers preemption
- createSchedulingRequest(1024, "queueB", "user1", 1, 1);
- scheduler.update();
- clock.tickSec(6);
-
- ((StubbedFairScheduler) scheduler).resetLastPreemptResources();
- scheduler.preemptTasksIfNecessary();
- assertEquals("preemptResources() should have been called", 1024,
- ((StubbedFairScheduler) scheduler).lastPreemptMemory);
-
- resourceManager.stop();
-
- startResourceManagerWithStubbedFairScheduler(0.8f);
- // Create node with 4GB memory and 4 vcores
- registerNodeAndSubmitApp(4 * 1024, 4, 3, 1024);
-
- // Verify submitting another request doesn't trigger preemption
- createSchedulingRequest(1024, "queueB", "user1", 1, 1);
- scheduler.update();
- clock.tickSec(6);
-
- ((StubbedFairScheduler) scheduler).resetLastPreemptResources();
- scheduler.preemptTasksIfNecessary();
- assertEquals("preemptResources() should not have been called", -1,
- ((StubbedFairScheduler) scheduler).lastPreemptMemory);
-
- resourceManager.stop();
-
- startResourceManagerWithStubbedFairScheduler(0.7f);
- // Create node with 4GB memory and 4 vcores
- registerNodeAndSubmitApp(4 * 1024, 4, 3, 1024);
-
- // Verify submitting another request triggers preemption
- createSchedulingRequest(1024, "queueB", "user1", 1, 1);
- scheduler.update();
- clock.tickSec(6);
-
- ((StubbedFairScheduler) scheduler).resetLastPreemptResources();
- scheduler.preemptTasksIfNecessary();
- assertEquals("preemptResources() should have been called", 1024,
- ((StubbedFairScheduler) scheduler).lastPreemptMemory);
- }
-
- @Test (timeout = 5000)
- /**
- * Make sure containers are chosen to be preempted in the correct order.
- */
- public void testChoiceOfPreemptedContainers() throws Exception {
- startResourceManagerWithRealFairScheduler();
- conf.setLong(FairSchedulerConfiguration.PREEMPTION_INTERVAL, 5000);
- conf.setLong(FairSchedulerConfiguration.WAIT_TIME_BEFORE_KILL, 10000);
- conf.set(FairSchedulerConfiguration.ALLOCATION_FILE + ".allocation.file", ALLOC_FILE);
- conf.set(FairSchedulerConfiguration.USER_AS_DEFAULT_QUEUE, "false");
-
- ControlledClock clock = new ControlledClock();
- scheduler.setClock(clock);
-
- PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
- out.println("<?xml version=\"1.0\"?>");
- out.println("<allocations>");
- out.println("<queue name=\"queueA\">");
- out.println("<weight>.25</weight>");
- out.println("</queue>");
- out.println("<queue name=\"queueB\">");
- out.println("<weight>.25</weight>");
- out.println("</queue>");
- out.println("<queue name=\"queueC\">");
- out.println("<weight>.25</weight>");
- out.println("</queue>");
- out.println("<queue name=\"default\">");
- out.println("<weight>.25</weight>");
- out.println("</queue>");
- out.println("</allocations>");
- out.close();
-
- scheduler.init(conf);
- scheduler.start();
- scheduler.reinitialize(conf, resourceManager.getRMContext());
-
- // Create two nodes
- RMNode node1 =
- MockNodes.newNodeInfo(1, Resources.createResource(4 * 1024, 4), 1,
- "127.0.0.1");
- NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
- scheduler.handle(nodeEvent1);
-
- RMNode node2 =
- MockNodes.newNodeInfo(1, Resources.createResource(4 * 1024, 4), 2,
- "127.0.0.2");
- NodeAddedSchedulerEvent nodeEvent2 = new NodeAddedSchedulerEvent(node2);
- scheduler.handle(nodeEvent2);
-
- // Queue A and B each request two applications
- ApplicationAttemptId app1 =
- createSchedulingRequest(1 * 1024, 1, "queueA", "user1", 1, 1);
- createSchedulingRequestExistingApplication(1 * 1024, 1, 2, app1);
- ApplicationAttemptId app2 =
- createSchedulingRequest(1 * 1024, 1, "queueA", "user1", 1, 3);
- createSchedulingRequestExistingApplication(1 * 1024, 1, 4, app2);
-
- ApplicationAttemptId app3 =
- createSchedulingRequest(1 * 1024, 1, "queueB", "user1", 1, 1);
- createSchedulingRequestExistingApplication(1 * 1024, 1, 2, app3);
- ApplicationAttemptId app4 =
- createSchedulingRequest(1 * 1024, 1, "queueB", "user1", 1, 3);
- createSchedulingRequestExistingApplication(1 * 1024, 1, 4, app4);
-
- scheduler.update();
-
- scheduler.getQueueManager().getLeafQueue("queueA", true)
- .setPolicy(SchedulingPolicy.parse("fifo"));
- scheduler.getQueueManager().getLeafQueue("queueB", true)
- .setPolicy(SchedulingPolicy.parse("fair"));
-
- // Sufficient node check-ins to fully schedule containers
- NodeUpdateSchedulerEvent nodeUpdate1 = new NodeUpdateSchedulerEvent(node1);
- NodeUpdateSchedulerEvent nodeUpdate2 = new NodeUpdateSchedulerEvent(node2);
- for (int i = 0; i < 4; i++) {
- scheduler.handle(nodeUpdate1);
- scheduler.handle(nodeUpdate2);
- }
-
- assertEquals(2, scheduler.getSchedulerApp(app1).getLiveContainers().size());
- assertEquals(2, scheduler.getSchedulerApp(app2).getLiveContainers().size());
- assertEquals(2, scheduler.getSchedulerApp(app3).getLiveContainers().size());
- assertEquals(2, scheduler.getSchedulerApp(app4).getLiveContainers().size());
-
- // Now new requests arrive from queueC and default
- createSchedulingRequest(1 * 1024, 1, "queueC", "user1", 1, 1);
- createSchedulingRequest(1 * 1024, 1, "queueC", "user1", 1, 1);
- createSchedulingRequest(1 * 1024, 1, "default", "user1", 1, 1);
- createSchedulingRequest(1 * 1024, 1, "default", "user1", 1, 1);
- scheduler.update();
-
- // We should be able to claw back one container from queueA and queueB each.
- scheduler.preemptResources(Resources.createResource(2 * 1024));
- assertEquals(2, scheduler.getSchedulerApp(app1).getLiveContainers().size());
- assertEquals(2, scheduler.getSchedulerApp(app3).getLiveContainers().size());
-
- // First verify we are adding containers to preemption list for the app.
- // For queueA (fifo), app2 is selected.
- // For queueB (fair), app4 is selected.
- assertTrue("App2 should have container to be preempted",
- !Collections.disjoint(
- scheduler.getSchedulerApp(app2).getLiveContainers(),
- scheduler.getSchedulerApp(app2).getPreemptionContainers()));
- assertTrue("App4 should have container to be preempted",
- !Collections.disjoint(
- scheduler.getSchedulerApp(app2).getLiveContainers(),
- scheduler.getSchedulerApp(app2).getPreemptionContainers()));
-
- // Pretend 15 seconds have passed
- clock.tickSec(15);
-
- // Trigger a kill by insisting we want containers back
- scheduler.preemptResources(Resources.createResource(2 * 1024));
-
- // At this point the containers should have been killed (since we are not simulating AM)
- assertEquals(1, scheduler.getSchedulerApp(app2).getLiveContainers().size());
- assertEquals(1, scheduler.getSchedulerApp(app4).getLiveContainers().size());
- // Inside each app, containers are sorted according to their priorities.
- // Containers with priority 4 are preempted for app2 and app4.
- Set<RMContainer> set = new HashSet<RMContainer>();
- for (RMContainer container :
- scheduler.getSchedulerApp(app2).getLiveContainers()) {
- if (container.getAllocatedSchedulerKey().getPriority().getPriority() ==
- 4) {
- set.add(container);
- }
- }
- for (RMContainer container :
- scheduler.getSchedulerApp(app4).getLiveContainers()) {
- if (container.getAllocatedSchedulerKey().getPriority().getPriority() ==
- 4) {
- set.add(container);
- }
- }
- assertTrue("Containers with priority=4 in app2 and app4 should be " +
- "preempted.", set.isEmpty());
-
- // Trigger a kill by insisting we want containers back
- scheduler.preemptResources(Resources.createResource(2 * 1024));
-
- // Pretend 15 seconds have passed
- clock.tickSec(15);
-
- // We should be able to claw back another container from A and B each.
- // For queueA (fifo), continue preempting from app2.
- // For queueB (fair), even app4 has a lowest priority container with p=4, it
- // still preempts from app3 as app3 is most over fair share.
- scheduler.preemptResources(Resources.createResource(2 * 1024));
-
- assertEquals(2, scheduler.getSchedulerApp(app1).getLiveContainers().size());
- assertEquals(0, scheduler.getSchedulerApp(app2).getLiveContainers().size());
- assertEquals(1, scheduler.getSchedulerApp(app3).getLiveContainers().size());
- assertEquals(1, scheduler.getSchedulerApp(app4).getLiveContainers().size());
-
- // Now A and B are below fair share, so preemption shouldn't do anything
- scheduler.preemptResources(Resources.createResource(2 * 1024));
- assertTrue("App1 should have no container to be preempted",
- scheduler.getSchedulerApp(app1).getPreemptionContainers().isEmpty());
- assertTrue("App2 should have no container to be preempted",
- scheduler.getSchedulerApp(app2).getPreemptionContainers().isEmpty());
- assertTrue("App3 should have no container to be preempted",
- scheduler.getSchedulerApp(app3).getPreemptionContainers().isEmpty());
- assertTrue("App4 should have no container to be preempted",
- scheduler.getSchedulerApp(app4).getPreemptionContainers().isEmpty());
- stopResourceManager();
- }
-
- @Test
- public void testPreemptionIsNotDelayedToNextRound() throws Exception {
- startResourceManagerWithRealFairScheduler();
-
- conf.setLong(FairSchedulerConfiguration.PREEMPTION_INTERVAL, 5000);
- conf.setLong(FairSchedulerConfiguration.WAIT_TIME_BEFORE_KILL, 10000);
- conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
- conf.set(FairSchedulerConfiguration.USER_AS_DEFAULT_QUEUE, "false");
-
- ControlledClock clock = new ControlledClock();
- scheduler.setClock(clock);
-
- PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
- out.println("<?xml version=\"1.0\"?>");
- out.println("<allocations>");
- out.println("<queue name=\"queueA\">");
- out.println("<weight>8</weight>");
- out.println("<queue name=\"queueA1\" />");
- out.println("<queue name=\"queueA2\" />");
- out.println("</queue>");
- out.println("<queue name=\"queueB\">");
- out.println("<weight>2</weight>");
- out.println("</queue>");
- out.println("<defaultFairSharePreemptionTimeout>10</defaultFairSharePreemptionTimeout>");
- out.println("<defaultFairSharePreemptionThreshold>.5</defaultFairSharePreemptionThreshold>");
- out.println("</allocations>");
- out.close();
-
- scheduler.init(conf);
- scheduler.start();
- scheduler.reinitialize(conf, resourceManager.getRMContext());
-
- // Add a node of 8G
- RMNode node1 = MockNodes.newNodeInfo(1,
- Resources.createResource(8 * 1024, 8), 1, "127.0.0.1");
- NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
- scheduler.handle(nodeEvent1);
-
- // Run apps in queueA.A1 and queueB
- ApplicationAttemptId app1 = createSchedulingRequest(1 * 1024, 1,
- "queueA.queueA1", "user1", 7, 1);
- // createSchedulingRequestExistingApplication(1 * 1024, 1, 2, app1);
- ApplicationAttemptId app2 = createSchedulingRequest(1 * 1024, 1, "queueB",
- "user2", 1, 1);
-
- scheduler.update();
-
- NodeUpdateSchedulerEvent nodeUpdate1 = new NodeUpdateSchedulerEvent(node1);
- for (int i = 0; i < 8; i++) {
- scheduler.handle(nodeUpdate1);
- }
-
- // verify if the apps got the containers they requested
- assertEquals(7, scheduler.getSchedulerApp(app1).getLiveContainers().size());
- assertEquals(1, scheduler.getSchedulerApp(app2).getLiveContainers().size());
-
- // Now submit an app in queueA.queueA2
- ApplicationAttemptId app3 = createSchedulingRequest(1 * 1024, 1,
- "queueA.queueA2", "user3", 7, 1);
- scheduler.update();
-
- // Let 11 sec pass
- clock.tickSec(11);
-
- scheduler.update();
- Resource toPreempt = scheduler.resourceDeficit(scheduler.getQueueManager()
- .getLeafQueue("queueA.queueA2", false), clock.getTime());
- assertEquals(3277, toPreempt.getMemorySize());
-
- // verify if the 3 containers required by queueA2 are preempted in the same
- // round
- scheduler.preemptResources(toPreempt);
- assertEquals(3, scheduler.getSchedulerApp(app1).getPreemptionContainers()
- .size());
- stopResourceManager();
- }
-
- @Test (timeout = 5000)
- /**
- * Tests the timing of decision to preempt tasks.
- */
- public void testPreemptionDecision() throws Exception {
- startResourceManagerWithRealFairScheduler();
-
- conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
- ControlledClock clock = new ControlledClock();
- scheduler.setClock(clock);
-
- PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
- out.println("<?xml version=\"1.0\"?>");
- out.println("<allocations>");
- out.println("<queue name=\"default\">");
- out.println("<maxResources>0mb,0vcores</maxResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueA\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueB\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueC\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueD\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("</queue>");
- out.println("<defaultMinSharePreemptionTimeout>5</defaultMinSharePreemptionTimeout>");
- out.println("<defaultFairSharePreemptionTimeout>10</defaultFairSharePreemptionTimeout>");
- out.println("<defaultFairSharePreemptionThreshold>.5</defaultFairSharePreemptionThreshold>");
- out.println("</allocations>");
- out.close();
-
- scheduler.init(conf);
- scheduler.start();
- scheduler.reinitialize(conf, resourceManager.getRMContext());
-
- // Create four nodes
- RMNode node1 =
- MockNodes.newNodeInfo(1, Resources.createResource(2 * 1024, 2), 1,
- "127.0.0.1");
- NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
- scheduler.handle(nodeEvent1);
-
- RMNode node2 =
- MockNodes.newNodeInfo(1, Resources.createResource(2 * 1024, 2), 2,
- "127.0.0.2");
- NodeAddedSchedulerEvent nodeEvent2 = new NodeAddedSchedulerEvent(node2);
- scheduler.handle(nodeEvent2);
-
- RMNode node3 =
- MockNodes.newNodeInfo(1, Resources.createResource(2 * 1024, 2), 3,
- "127.0.0.3");
- NodeAddedSchedulerEvent nodeEvent3 = new NodeAddedSchedulerEvent(node3);
- scheduler.handle(nodeEvent3);
-
- // Queue A and B each request three containers
- ApplicationAttemptId app1 =
- createSchedulingRequest(1 * 1024, "queueA", "user1", 1, 1);
- ApplicationAttemptId app2 =
- createSchedulingRequest(1 * 1024, "queueA", "user1", 1, 2);
- ApplicationAttemptId app3 =
- createSchedulingRequest(1 * 1024, "queueA", "user1", 1, 3);
-
- ApplicationAttemptId app4 =
- createSchedulingRequest(1 * 1024, "queueB", "user1", 1, 1);
- ApplicationAttemptId app5 =
- createSchedulingRequest(1 * 1024, "queueB", "user1", 1, 2);
- ApplicationAttemptId app6 =
- createSchedulingRequest(1 * 1024, "queueB", "user1", 1, 3);
-
- scheduler.update();
-
- // Sufficient node check-ins to fully schedule containers
- for (int i = 0; i < 2; i++) {
- NodeUpdateSchedulerEvent nodeUpdate1 = new NodeUpdateSchedulerEvent(node1);
- scheduler.handle(nodeUpdate1);
-
- NodeUpdateSchedulerEvent nodeUpdate2 = new NodeUpdateSchedulerEvent(node2);
- scheduler.handle(nodeUpdate2);
-
- NodeUpdateSchedulerEvent nodeUpdate3 = new NodeUpdateSchedulerEvent(node3);
- scheduler.handle(nodeUpdate3);
- }
-
- // Now new requests arrive from queues C and D
- ApplicationAttemptId app7 =
- createSchedulingRequest(1 * 1024, "queueC", "user1", 1, 1);
- ApplicationAttemptId app8 =
- createSchedulingRequest(1 * 1024, "queueC", "user1", 1, 2);
- ApplicationAttemptId app9 =
- createSchedulingRequest(1 * 1024, "queueC", "user1", 1, 3);
-
- ApplicationAttemptId app10 =
- createSchedulingRequest(1 * 1024, "queueD", "user1", 1, 1);
- ApplicationAttemptId app11 =
- createSchedulingRequest(1 * 1024, "queueD", "user1", 1, 2);
- ApplicationAttemptId app12 =
- createSchedulingRequest(1 * 1024, "queueD", "user1", 1, 3);
-
- scheduler.update();
-
- FSLeafQueue schedC =
- scheduler.getQueueManager().getLeafQueue("queueC", true);
- FSLeafQueue schedD =
- scheduler.getQueueManager().getLeafQueue("queueD", true);
-
- assertTrue(Resources.equals(
- Resources.none(), scheduler.resourceDeficit(schedC, clock.getTime())));
- assertTrue(Resources.equals(
- Resources.none(), scheduler.resourceDeficit(schedD, clock.getTime())));
- // After minSharePreemptionTime has passed, they should want to preempt min
- // share.
- clock.tickSec(6);
- assertEquals(
- 1024, scheduler.resourceDeficit(schedC, clock.getTime()).getMemorySize());
- assertEquals(
- 1024, scheduler.resourceDeficit(schedD, clock.getTime()).getMemorySize());
-
- // After fairSharePreemptionTime has passed, they should want to preempt
- // fair share.
- scheduler.update();
- clock.tickSec(6);
- assertEquals(
- 1536 , scheduler.resourceDeficit(schedC, clock.getTime()).getMemorySize());
- assertEquals(
- 1536, scheduler.resourceDeficit(schedD, clock.getTime()).getMemorySize());
- stopResourceManager();
- }
-
- @Test
-/**
- * Tests the timing of decision to preempt tasks.
- */
- public void testPreemptionDecisionWithDRF() throws Exception {
- startResourceManagerWithRealFairScheduler();
-
- conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
- ControlledClock clock = new ControlledClock();
- scheduler.setClock(clock);
-
- PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
- out.println("<?xml version=\"1.0\"?>");
- out.println("<allocations>");
- out.println("<queue name=\"default\">");
- out.println("<maxResources>0mb,0vcores</maxResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueA\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,1vcores</minResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueB\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,2vcores</minResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueC\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,3vcores</minResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueD\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,2vcores</minResources>");
- out.println("</queue>");
- out.println("<defaultMinSharePreemptionTimeout>5</defaultMinSharePreemptionTimeout>");
- out.println("<defaultFairSharePreemptionTimeout>10</defaultFairSharePreemptionTimeout>");
- out.println("<defaultFairSharePreemptionThreshold>.5</defaultFairSharePreemptionThreshold>");
- out.println("<defaultQueueSchedulingPolicy>drf</defaultQueueSchedulingPolicy>");
- out.println("</allocations>");
- out.close();
-
- scheduler.init(conf);
- scheduler.start();
- scheduler.reinitialize(conf, resourceManager.getRMContext());
-
- // Create four nodes
- RMNode node1 =
- MockNodes.newNodeInfo(1, Resources.createResource(2 * 1024, 4), 1,
- "127.0.0.1");
- NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
- scheduler.handle(nodeEvent1);
-
- RMNode node2 =
- MockNodes.newNodeInfo(1, Resources.createResource(2 * 1024, 4), 2,
- "127.0.0.2");
- NodeAddedSchedulerEvent nodeEvent2 = new NodeAddedSchedulerEvent(node2);
- scheduler.handle(nodeEvent2);
-
- RMNode node3 =
- MockNodes.newNodeInfo(1, Resources.createResource(2 * 1024, 4), 3,
- "127.0.0.3");
- NodeAddedSchedulerEvent nodeEvent3 = new NodeAddedSchedulerEvent(node3);
- scheduler.handle(nodeEvent3);
-
- // Queue A and B each request three containers
- ApplicationAttemptId app1 =
- createSchedulingRequest(1 * 1024, "queueA", "user1", 1, 1);
- ApplicationAttemptId app2 =
- createSchedulingRequest(1 * 1024, "queueA", "user1", 1, 2);
- ApplicationAttemptId app3 =
- createSchedulingRequest(1 * 1024, "queueA", "user1", 1, 3);
-
- ApplicationAttemptId app4 =
- createSchedulingRequest(1 * 1024, "queueB", "user1", 1, 1);
- ApplicationAttemptId app5 =
- createSchedulingRequest(1 * 1024, "queueB", "user1", 1, 2);
- ApplicationAttemptId app6 =
- createSchedulingRequest(1 * 1024, "queueB", "user1", 1, 3);
-
- scheduler.update();
-
- // Sufficient node check-ins to fully schedule containers
- for (int i = 0; i < 2; i++) {
- NodeUpdateSchedulerEvent nodeUpdate1 = new NodeUpdateSchedulerEvent(node1);
- scheduler.handle(nodeUpdate1);
-
- NodeUpdateSchedulerEvent nodeUpdate2 = new NodeUpdateSchedulerEvent(node2);
- scheduler.handle(nodeUpdate2);
-
- NodeUpdateSchedulerEvent nodeUpdate3 = new NodeUpdateSchedulerEvent(node3);
- scheduler.handle(nodeUpdate3);
- }
-
- // Now new requests arrive from queues C and D
- ApplicationAttemptId app7 =
- createSchedulingRequest(1 * 1024, "queueC", "user1", 1, 1);
- ApplicationAttemptId app8 =
- createSchedulingRequest(1 * 1024, "queueC", "user1", 1, 2);
- ApplicationAttemptId app9 =
- createSchedulingRequest(1 * 1024, "queueC", "user1", 1, 3);
-
- ApplicationAttemptId app10 =
- createSchedulingRequest(1 * 1024, "queueD", "user1", 2, 1);
- ApplicationAttemptId app11 =
- createSchedulingRequest(1 * 1024, "queueD", "user1", 2, 2);
- ApplicationAttemptId app12 =
- createSchedulingRequest(1 * 1024, "queueD", "user1", 2, 3);
-
- scheduler.update();
-
- FSLeafQueue schedC =
- scheduler.getQueueManager().getLeafQueue("queueC", true);
- FSLeafQueue schedD =
- scheduler.getQueueManager().getLeafQueue("queueD", true);
-
- assertTrue(Resources.equals(
- Resources.none(), scheduler.resourceDeficit(schedC, clock.getTime())));
- assertTrue(Resources.equals(
- Resources.none(), scheduler.resourceDeficit(schedD, clock.getTime())));
-
- // Test :
- // 1) whether componentWise min works as expected.
- // 2) DRF calculator is used
-
- // After minSharePreemptionTime has passed, they should want to preempt min
- // share.
- clock.tickSec(6);
- Resource res = scheduler.resourceDeficit(schedC, clock.getTime());
- assertEquals(1024, res.getMemorySize());
- // Demand = 3
- assertEquals(3, res.getVirtualCores());
-
- res = scheduler.resourceDeficit(schedD, clock.getTime());
- assertEquals(1024, res.getMemorySize());
- // Demand = 6, but min share = 2
- assertEquals(2, res.getVirtualCores());
-
- // After fairSharePreemptionTime has passed, they should want to preempt
- // fair share.
- scheduler.update();
- clock.tickSec(6);
- res = scheduler.resourceDeficit(schedC, clock.getTime());
- assertEquals(1536, res.getMemorySize());
- assertEquals(3, res.getVirtualCores());
-
- res = scheduler.resourceDeficit(schedD, clock.getTime());
- assertEquals(1536, res.getMemorySize());
- // Demand = 6, but fair share = 3
- assertEquals(3, res.getVirtualCores());
- stopResourceManager();
- }
-
- @Test
- /**
- * Tests the various timing of decision to preempt tasks.
- */
- public void testPreemptionDecisionWithVariousTimeout() throws Exception {
- startResourceManagerWithRealFairScheduler();
- conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
- ControlledClock clock = new ControlledClock();
- scheduler.setClock(clock);
-
- PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
- out.println("<?xml version=\"1.0\"?>");
- out.println("<allocations>");
- out.println("<queue name=\"default\">");
- out.println("<maxResources>0mb,0vcores</maxResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueA\">");
- out.println("<weight>1</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueB\">");
- out.println("<weight>2</weight>");
- out.println("<minSharePreemptionTimeout>10</minSharePreemptionTimeout>");
- out.println("<fairSharePreemptionTimeout>25</fairSharePreemptionTimeout>");
- out.println("<queue name=\"queueB1\">");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("<minSharePreemptionTimeout>5</minSharePreemptionTimeout>");
- out.println("</queue>");
- out.println("<queue name=\"queueB2\">");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("<fairSharePreemptionTimeout>20</fairSharePreemptionTimeout>");
- out.println("</queue>");
- out.println("</queue>");
- out.println("<queue name=\"queueC\">");
- out.println("<weight>1</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("</queue>");
- out.print("<defaultMinSharePreemptionTimeout>15</defaultMinSharePreemptionTimeout>");
- out.print("<defaultFairSharePreemptionTimeout>30</defaultFairSharePreemptionTimeout>");
- out.println("</allocations>");
- out.close();
-
- scheduler.init(conf);
- scheduler.start();
- scheduler.reinitialize(conf, resourceManager.getRMContext());
-
- // Check the min/fair share preemption timeout for each queue
- QueueManager queueMgr = scheduler.getQueueManager();
- assertEquals(30000, queueMgr.getQueue("root")
- .getFairSharePreemptionTimeout());
- assertEquals(30000, queueMgr.getQueue("default")
- .getFairSharePreemptionTimeout());
- assertEquals(30000, queueMgr.getQueue("queueA")
- .getFairSharePreemptionTimeout());
- assertEquals(25000, queueMgr.getQueue("queueB")
- .getFairSharePreemptionTimeout());
- assertEquals(25000, queueMgr.getQueue("queueB.queueB1")
- .getFairSharePreemptionTimeout());
- assertEquals(20000, queueMgr.getQueue("queueB.queueB2")
- .getFairSharePreemptionTimeout());
- assertEquals(30000, queueMgr.getQueue("queueC")
- .getFairSharePreemptionTimeout());
- assertEquals(15000, queueMgr.getQueue("root")
- .getMinSharePreemptionTimeout());
- assertEquals(15000, queueMgr.getQueue("default")
- .getMinSharePreemptionTimeout());
- assertEquals(15000, queueMgr.getQueue("queueA")
- .getMinSharePreemptionTimeout());
- assertEquals(10000, queueMgr.getQueue("queueB")
- .getMinSharePreemptionTimeout());
- assertEquals(5000, queueMgr.getQueue("queueB.queueB1")
- .getMinSharePreemptionTimeout());
- assertEquals(10000, queueMgr.getQueue("queueB.queueB2")
- .getMinSharePreemptionTimeout());
- assertEquals(15000, queueMgr.getQueue("queueC")
- .getMinSharePreemptionTimeout());
-
- // Create one big node
- RMNode node1 =
- MockNodes.newNodeInfo(1, Resources.createResource(6 * 1024, 6), 1,
- "127.0.0.1");
- NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
- scheduler.handle(nodeEvent1);
-
- // Queue A takes all resources
- for (int i = 0; i < 6; i ++) {
- createSchedulingRequest(1 * 1024, "queueA", "user1", 1, 1);
- }
-
- scheduler.update();
-
- // Sufficient node check-ins to fully schedule containers
- NodeUpdateSchedulerEvent nodeUpdate1 = new NodeUpdateSchedulerEvent(node1);
- for (int i = 0; i < 6; i++) {
- scheduler.handle(nodeUpdate1);
- }
-
- // Now new requests arrive from queues B1, B2 and C
- createSchedulingRequest(1 * 1024, "queueB.queueB1", "user1", 1, 1);
- createSchedulingRequest(1 * 1024, "queueB.queueB1", "user1", 1, 2);
- createSchedulingRequest(1 * 1024, "queueB.queueB1", "user1", 1, 3);
- createSchedulingRequest(1 * 1024, "queueB.queueB2", "user1", 1, 1);
- createSchedulingRequest(1 * 1024, "queueB.queueB2", "user1", 1, 2);
- createSchedulingRequest(1 * 1024, "queueB.queueB2", "user1", 1, 3);
- createSchedulingRequest(1 * 1024, "queueC", "user1", 1, 1);
- createSchedulingRequest(1 * 1024, "queueC", "user1", 1, 2);
- createSchedulingRequest(1 * 1024, "queueC", "user1", 1, 3);
-
- scheduler.update();
-
- FSLeafQueue queueB1 = queueMgr.getLeafQueue("queueB.queueB1", true);
- FSLeafQueue queueB2 = queueMgr.getLeafQueue("queueB.queueB2", true);
- FSLeafQueue queueC = queueMgr.getLeafQueue("queueC", true);
-
- assertTrue(Resources.equals(
- Resources.none(), scheduler.resourceDeficit(queueB1, clock.getTime())));
- assertTrue(Resources.equals(
- Resources.none(), scheduler.resourceDeficit(queueB2, clock.getTime())));
- assertTrue(Resources.equals(
- Resources.none(), scheduler.resourceDeficit(queueC, clock.getTime())));
-
- // After 5 seconds, queueB1 wants to preempt min share
- scheduler.update();
- clock.tickSec(6);
- assertEquals(
- 1024, scheduler.resourceDeficit(queueB1, clock.getTime()).getMemorySize());
- assertEquals(
- 0, scheduler.resourceDeficit(queueB2, clock.getTime()).getMemorySize());
- assertEquals(
- 0, scheduler.resourceDeficit(queueC, clock.getTime()).getMemorySize());
-
- // After 10 seconds, queueB2 wants to preempt min share
- scheduler.update();
- clock.tickSec(5);
- assertEquals(
- 1024, scheduler.resourceDeficit(queueB1, clock.getTime()).getMemorySize());
- assertEquals(
- 1024, scheduler.resourceDeficit(queueB2, clock.getTime()).getMemorySize());
- assertEquals(
- 0, scheduler.resourceDeficit(queueC, clock.getTime()).getMemorySize());
-
- // After 15 seconds, queueC wants to preempt min share
- scheduler.update();
- clock.tickSec(5);
- assertEquals(
- 1024, scheduler.resourceDeficit(queueB1, clock.getTime()).getMemorySize());
- assertEquals(
- 1024, scheduler.resourceDeficit(queueB2, clock.getTime()).getMemorySize());
- assertEquals(
- 1024, scheduler.resourceDeficit(queueC, clock.getTime()).getMemorySize());
-
- // After 20 seconds, queueB2 should want to preempt fair share
- scheduler.update();
- clock.tickSec(5);
- assertEquals(
- 1024, scheduler.resourceDeficit(queueB1, clock.getTime()).getMemorySize());
- assertEquals(
- 1536, scheduler.resourceDeficit(queueB2, clock.getTime()).getMemorySize());
- assertEquals(
- 1024, scheduler.resourceDeficit(queueC, clock.getTime()).getMemorySize());
-
- // After 25 seconds, queueB1 should want to preempt fair share
- scheduler.update();
- clock.tickSec(5);
- assertEquals(
- 1536, scheduler.resourceDeficit(queueB1, clock.getTime()).getMemorySize());
- assertEquals(
- 1536, scheduler.resourceDeficit(queueB2, clock.getTime()).getMemorySize());
- assertEquals(
- 1024, scheduler.resourceDeficit(queueC, clock.getTime()).getMemorySize());
-
- // After 30 seconds, queueC should want to preempt fair share
- scheduler.update();
- clock.tickSec(5);
- assertEquals(
- 1536, scheduler.resourceDeficit(queueB1, clock.getTime()).getMemorySize());
- assertEquals(
- 1536, scheduler.resourceDeficit(queueB2, clock.getTime()).getMemorySize());
- assertEquals(
- 1536, scheduler.resourceDeficit(queueC, clock.getTime()).getMemorySize());
- stopResourceManager();
- }
-
- @Test
- /**
- * Tests the decision to preempt tasks respect to non-preemptable queues
- * 1, Queues as follow:
- * queueA(non-preemptable)
- * queueB(preemptable)
- * parentQueue(non-preemptable)
- * --queueC(preemptable)
- * queueD(preemptable)
- * 2, Submit request to queueA, queueB, queueC, and all of them are over MinShare
- * 3, Now all resource are occupied
- * 4, Submit request to queueD, and need to preempt resource from other queues
- * 5, Only preemptable queue(queueB) would be preempted.
- */
- public void testPreemptionDecisionWithNonPreemptableQueue() throws Exception {
- startResourceManagerWithRealFairScheduler();
- conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
- ControlledClock clock = new ControlledClock();
- scheduler.setClock(clock);
-
- PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
- out.println("<?xml version=\"1.0\"?>");
- out.println("<allocations>");
- out.println("<queue name=\"default\">");
- out.println("<maxResources>0mb,0vcores</maxResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueA\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("<allowPreemptionFrom>false</allowPreemptionFrom>");
- out.println("</queue>");
- out.println("<queue name=\"queueB\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("</queue>");
- out.println("<queue name=\"parentQueue\">");
- out.println("<allowPreemptionFrom>false</allowPreemptionFrom>");
- out.println("<queue name=\"queueC\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("</queue>");
- out.println("</queue>");
- out.println("<queue name=\"queueD\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>2048mb,0vcores</minResources>");
- out.println("</queue>");
- out.println("<defaultMinSharePreemptionTimeout>5</defaultMinSharePreemptionTimeout>");
- out.println("<defaultFairSharePreemptionTimeout>10</defaultFairSharePreemptionTimeout>");
- out.println("<defaultFairSharePreemptionThreshold>.5</defaultFairSharePreemptionThreshold>");
- out.println("</allocations>");
- out.close();
-
- scheduler.init(conf);
- scheduler.start();
- scheduler.reinitialize(conf, resourceManager.getRMContext());
-
- // Create four nodes(3G each)
- RMNode node1 =
- MockNodes.newNodeInfo(1, Resources.createResource(3 * 1024, 3), 1,
- "127.0.0.1");
- NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
- scheduler.handle(nodeEvent1);
-
- RMNode node2 =
- MockNodes.newNodeInfo(1, Resources.createResource(3 * 1024, 3), 2,
- "127.0.0.2");
- NodeAddedSchedulerEvent nodeEvent2 = new NodeAddedSchedulerEvent(node2);
- scheduler.handle(nodeEvent2);
-
- RMNode node3 =
- MockNodes.newNodeInfo(1, Resources.createResource(3 * 1024, 3), 3,
- "127.0.0.3");
- NodeAddedSchedulerEvent nodeEvent3 = new NodeAddedSchedulerEvent(node3);
- scheduler.handle(nodeEvent3);
-
- RMNode node4 =
- MockNodes.newNodeInfo(1, Resources.createResource(3 * 1024, 3), 4,
- "127.0.0.4");
- NodeAddedSchedulerEvent nodeEvent4 = new NodeAddedSchedulerEvent(node4);
- scheduler.handle(nodeEvent4);
-
- // Submit apps to queueA, queueB, queueC,
- // now all resource of the cluster is occupied
- ApplicationAttemptId app1 =
- createSchedulingRequest(1 * 1024, "queueA", "user1", 4, 1);
- ApplicationAttemptId app2 =
- createSchedulingRequest(1 * 1024, "queueB", "user1", 4, 2);
- ApplicationAttemptId app3 =
- createSchedulingRequest(1 * 1024, "parentQueue.queueC", "user1", 4, 3);
-
- scheduler.update();
-
- // Sufficient node check-ins to fully schedule containers
- for (int i = 0; i < 3; i++) {
- NodeUpdateSchedulerEvent nodeUpdate1 = new NodeUpdateSchedulerEvent(node1);
- scheduler.handle(nodeUpdate1);
-
- NodeUpdateSchedulerEvent nodeUpdate2 = new NodeUpdateSchedulerEvent(node2);
- scheduler.handle(nodeUpdate2);
-
- NodeUpdateSchedulerEvent nodeUpdate3 = new NodeUpdateSchedulerEvent(node3);
- scheduler.handle(nodeUpdate3);
-
- NodeUpdateSchedulerEvent nodeUpdate4 = new NodeUpdateSchedulerEvent(node4);
- scheduler.handle(nodeUpdate4);
- }
-
- assertEquals(4, scheduler.getSchedulerApp(app1).getLiveContainers().size());
- assertEquals(4, scheduler.getSchedulerApp(app2).getLiveContainers().size());
- assertEquals(4, scheduler.getSchedulerApp(app3).getLiveContainers().size());
-
- // Now new requests arrive from queues D
- ApplicationAttemptId app4 =
- createSchedulingRequest(1 * 1024, "queueD", "user1", 4, 1);
- scheduler.update();
- FSLeafQueue schedD =
- scheduler.getQueueManager().getLeafQueue("queueD", true);
-
- // After minSharePreemptionTime has passed, 2G resource should preempted from
- // queueB to queueD
- clock.tickSec(6);
- assertEquals(2048,
- scheduler.resourceDeficit(schedD, clock.getTime()).getMemorySize());
-
- scheduler.preemptResources(Resources.createResource(2 * 1024));
- // now only app2 is selected to be preempted
- assertTrue("App2 should have container to be preempted",
- !Collections.disjoint(
- scheduler.getSchedulerApp(app2).getLiveContainers(),
- scheduler.getSchedulerApp(app2).getPreemptionContainers()));
- assertTrue("App1 should not have container to be preempted",
- Collections.disjoint(
- scheduler.getSchedulerApp(app1).getLiveContainers(),
- scheduler.getSchedulerApp(app1).getPreemptionContainers()));
- assertTrue("App3 should not have container to be preempted",
- Collections.disjoint(
- scheduler.getSchedulerApp(app3).getLiveContainers(),
- scheduler.getSchedulerApp(app3).getPreemptionContainers()));
- // Pretend 20 seconds have passed
- clock.tickSec(20);
- scheduler.preemptResources(Resources.createResource(2 * 1024));
- for (int i = 0; i < 3; i++) {
- NodeUpdateSchedulerEvent nodeUpdate1 = new NodeUpdateSchedulerEvent(node1);
- scheduler.handle(nodeUpdate1);
-
- NodeUpdateSchedulerEvent nodeUpdate2 = new NodeUpdateSchedulerEvent(node2);
- scheduler.handle(nodeUpdate2);
-
- NodeUpdateSchedulerEvent nodeUpdate3 = new NodeUpdateSchedulerEvent(node3);
- scheduler.handle(nodeUpdate3);
-
- NodeUpdateSchedulerEvent nodeUpdate4 = new NodeUpdateSchedulerEvent(node4);
- scheduler.handle(nodeUpdate4);
- }
- // after preemption
- assertEquals(4, scheduler.getSchedulerApp(app1).getLiveContainers().size());
- assertEquals(2, scheduler.getSchedulerApp(app2).getLiveContainers().size());
- assertEquals(4, scheduler.getSchedulerApp(app3).getLiveContainers().size());
- assertEquals(2, scheduler.getSchedulerApp(app4).getLiveContainers().size());
- stopResourceManager();
- }
-
- @Test
- /**
- * Tests the decision to preempt tasks when allowPreemptionFrom is set false on
- * all queues.
- * Then none of them would be preempted actually.
- * 1, Queues as follow:
- * queueA(non-preemptable)
- * queueB(non-preemptable)
- * parentQueue(non-preemptable)
- * --queueC(preemptable)
- * parentQueue(preemptable)
- * --queueD(non-preemptable)
- * 2, Submit request to queueB, queueC, queueD, and all of them are over MinShare
- * 3, Now all resource are occupied
- * 4, Submit request to queueA, and need to preempt resource from other queues
- * 5, None of queues would be preempted.
- */
- public void testPreemptionDecisionWhenPreemptionDisabledOnAllQueues()
- throws Exception {
- startResourceManagerWithRealFairScheduler();
- conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
- ControlledClock clock = new ControlledClock();
- scheduler.setClock(clock);
-
- PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
- out.println("<?xml version=\"1.0\"?>");
- out.println("<allocations>");
- out.println("<queue name=\"default\">");
- out.println("<maxResources>0mb,0vcores</maxResources>");
- out.println("</queue>");
- out.println("<queue name=\"queueA\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>2048mb,0vcores</minResources>");
- out.println("<allowPreemptionFrom>false</allowPreemptionFrom>");
- out.println("</queue>");
- out.println("<queue name=\"queueB\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("<allowPreemptionFrom>false</allowPreemptionFrom>");
- out.println("</queue>");
- out.println("<queue name=\"parentQueue1\">");
- out.println("<allowPreemptionFrom>false</allowPreemptionFrom>");
- out.println("<queue name=\"queueC\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("</queue>");
- out.println("</queue>");
- out.println("<queue name=\"parentQueue2\">");
- out.println("<queue name=\"queueD\">");
- out.println("<weight>.25</weight>");
- out.println("<minResources>1024mb,0vcores</minResources>");
- out.println("<allowPreemptionFrom>false</allowPreemptionFrom>");
- out.println("</queue>");
- out.println("</queue>");
- out.println("<defaultMinSharePreemptionTimeout>5</defaultMinSharePreemptionTimeout>");
- out.println("<defaultFairSharePreemptionTimeout>10</defaultFairSharePreemptionTimeout>");
- out.println("<defaultFairSharePreemptionThreshold>.5</defaultFairSharePreemptionThreshold>");
- out.println("</allocations>");
- out.close();
-
- scheduler.init(conf);
- scheduler.start();
- scheduler.reinitialize(conf, resourceManager.getRMContext());
-
- // Create four nodes(3G each)
- RMNode node1 =
- MockNodes.newNodeInfo(1, Resources.createResource(3 * 1024, 3), 1,
- "127.0.0.1");
- NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
- scheduler.handle(nodeEvent1);
-
- RMNode node2 =
- MockNodes.newNodeInfo(1, Resources.createResource(3 * 1024, 3), 2,
- "127.0.0.2");
- NodeAddedSchedulerEvent nodeEvent2 = new NodeAddedSchedulerEvent(node2);
- scheduler.handle(nodeEvent2);
-
- RMNode node3 =
- MockNodes.newNodeInfo(1, Resources.createResource(3 * 1024, 3), 3,
- "127.0.0.3");
- NodeAddedSchedulerEvent nodeEvent3 = new NodeAddedSchedulerEvent(node3);
- scheduler.handle(nodeEvent3);
-
- RMNode node4 =
- MockNodes.newNodeInfo(1, Resources.createResource(3 * 1024, 3), 4,
- "127.0.0.4");
- NodeAddedSchedulerEvent nodeEvent4 = new NodeAddedSchedulerEvent(node4);
- scheduler.handle(nodeEvent4);
-
- // Submit apps to queueB, queueC, queueD
- // now all resource of the cluster is occupied
-
- ApplicationAttemptId app1 =
- createSchedulingRequest(1 * 1024, "queueB", "user1", 4, 1);
- ApplicationAttemptId app2 =
- createSchedulingRequest(1 * 1024, "parentQueue1.queueC", "user1", 4, 2);
- ApplicationAttemptId app3 =
- createSchedulingRequest(1 * 1024, "parentQueue2.queueD", "user1", 4, 3);
- scheduler.update();
-
- // Sufficient node check-ins to fully schedule containers
- for (int i = 0; i < 3; i++) {
- NodeUpdateSchedulerEvent nodeUpdate1 = new NodeUpdateSchedulerEvent(node1);
- scheduler.handle(nodeUpdate1);
-
- NodeUpdateSchedulerEvent nodeUpdate2 = new NodeUpdateSchedulerEvent(node2);
- scheduler.handle(nodeUpdate2);
-
- NodeUpdateSchedulerEvent nodeUpdate3 = new NodeUpdateSchedulerEvent(node3);
- scheduler.handle(nodeUpdate3);
-
- NodeUpdateSchedulerEvent nodeUpdate4 = new NodeUpdateSchedulerEvent(node4);
- scheduler.handle(nodeUpdate4);
- }
-
- assertEquals(4, scheduler.getSchedulerApp(app1).getLiveContainers().size());
- assertEquals(4, scheduler.getSchedulerApp(app2).getLiveContainers().size());
- assertEquals(4, scheduler.getSchedulerApp(app3).getLiveContainers().size());
-
- // Now new requests arrive from queues A
- ApplicationAttemptId app4 =
- createSchedulingRequest(1 * 1024, "queueA", "user1", 4, 1);
- scheduler.update();
- FSLeafQueue schedA =
- scheduler.getQueueManager().getLeafQueue("queueA", true);
-
- // After minSharePreemptionTime has passed, resource deficit is 2G
- clock.tickSec(6);
- assertEquals(2048,
- scheduler.resourceDeficit(schedA, clock.getTime()).getMemorySize());
-
- scheduler.preemptResources(Resources.createResource(2 * 1024));
- // now none app is selected to be preempted
- assertTrue("App1 should have container to be preempted",
- Collections.disjoint(
- scheduler.getSchedulerApp(app1).getLiveContainers(),
- scheduler.getSchedulerApp(app1).getPreemptionContainers()));
- assertTrue("App2 should not have container to be preempted",
- Collections.disjoint(
- scheduler.getSchedulerApp(app2).getLiveContainers(),
- scheduler.getSchedulerApp(app2).getPreemptionContainers()));
- assertTrue("App3 should not have container to be preempted",
- Collections.disjoint(
- scheduler.getSchedulerApp(app3).getLiveContainers(),
- scheduler.getSchedulerApp(app3).getPreemptionContainers()));
- // Pretend 20 seconds have passed
- clock.tickSec(20);
- scheduler.preemptResources(Resources.createResource(2 * 1024));
- for (int i = 0; i < 3; i++) {
- NodeUpdateSchedulerEvent nodeUpdate1 = new NodeUpdateSchedulerEvent(node1);
- scheduler.handle(nodeUpdate1);
-
- NodeUpdateSchedulerEvent nodeUpdate2 = new NodeUpdateSchedulerEvent(node2);
- scheduler.handle(nodeUpdate2);
-
- NodeUpdateSchedulerEvent nodeUpdate3 = new NodeUpdateSchedulerEvent(node3);
- scheduler.handle(nodeUpdate3);
-
- NodeUpdateSchedulerEvent nodeUpdate4 = new NodeUpdateSchedulerEvent(node4);
- scheduler.handle(nodeUpdate4);
- }
- // after preemption
- assertEquals(4, scheduler.getSchedulerApp(app1).getLiveContainers().size());
- assertEquals(4, scheduler.getSchedulerApp(app2).getLiveContainers().size());
- assertEquals(4, scheduler.getSchedulerApp(app3).getLiveContainers().size());
- assertEquals(0, scheduler.getSchedulerApp(app4).getLiveContainers().size());
- stopResourceManager();
- }
-
- @Test
- public void testBackwardsCompatiblePreemptionConfiguration() throws Exception {
- startResourceManagerWithRealFairScheduler();
- conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
-
- PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
- out.println("<?xml version=\"1.0\"?>");
- out.println("<allocations>");
- out.println("<queue name=\"default\">");
- out.println("</queue>");
- out.println("<queue name=\"queueA\">");
- out.println("</queue>");
- out.println("<queue name=\"queueB\">");
- out.println("<queue name=\"queueB1\">");
- out.println("<minSharePreemptionTimeout>5</minSharePreemptionTimeout>");
- out.println("</queue>");
- out.println("<queue name=\"queueB2\">");
- out.println("</queue>");
- out.println("</queue>");
- out.println("<queue name=\"queueC\">");
- out.println("</queue>");
- out.print("<defaultMinSharePreemptionTimeout>15</defaultMinSharePreemptionTimeout>");
- out.print("<defaultFairSharePreemptionTimeout>30</defaultFairSharePreemptionTimeout>");
- out.print("<fairSharePreemptionTimeout>40</fairSharePreemptionTimeout>");
- out.println("</allocations>");
- out.close();
-
- scheduler.init(conf);
- scheduler.start();
- scheduler.reinitialize(conf, resourceManager.getRMContext());
-
- // Check the min/fair share preemption timeout for each queue
- QueueManager queueMgr = scheduler.getQueueManager();
- assertEquals(30000, queueMgr.getQueue("root")
- .getFairSharePreemptionTimeout());
- assertEquals(30000, queueMgr.getQueue("default")
- .getFairSharePreemptionTimeout());
- assertEquals(30000, queueMgr.getQueue("queueA")
- .getFairSharePreemptionTimeout());
- assertEquals(30000, queueMgr.getQueue("queueB")
- .getFairSharePreemptionTimeout());
- assertEquals(30000, queueMgr.getQueue("queueB.queueB1")
- .getFairSharePreemptionTimeout());
- assertEquals(30000, queueMgr.getQueue("queueB.queueB2")
- .getFairSharePreemptionTimeout());
- assertEquals(30000, queueMgr.getQueue("queueC")
- .getFairSharePreemptionTimeout());
- assertEquals(15000, queueMgr.getQueue("root")
- .getMinSharePreemptionTimeout());
- assertEquals(15000, queueMgr.getQueue("default")
- .getMinSharePreemptionTimeout());
- assertEquals(15000, queueMgr.getQueue("queueA")
- .getMinSharePreemptionTimeout());
- assertEquals(15000, queueMgr.getQueue("queueB")
- .getMinSharePreemptionTimeout());
- assertEquals(5000, queueMgr.getQueue("queueB.queueB1")
- .getMinSharePreemptionTimeout());
- assertEquals(15000, queueMgr.getQueue("queueB.queueB2")
- .getMinSharePreemptionTimeout());
- assertEquals(15000, queueMgr.getQueue("queueC")
- .getMinSharePreemptionTimeout());
-
- // If both exist, we take the default one
- out = new PrintWriter(new FileWriter(ALLOC_FILE));
- out.println("<?xml version=\"1.0\"?>");
- out.println("<allocations>");
- out.println("<queue name=\"default\">");
- out.println("</queue>");
- out.println("<queue name=\"queueA\">");
- out.println("</queue>");
- out.println("<queue name=\"queueB\">");
- out.println("<queue name=\"queueB1\">");
- out.println("<minSharePreemptionTimeout>5</minSharePreemptionTimeout>");
- out.println("</queue>");
- out.println("<queue name=\"queueB2\">");
- out.println("</queue>");
- out.println("</queue>");
- out.println("<queue name=\"queueC\">");
- out.println("</queue>");
- out.print("<defaultMinSharePreemptionTimeout>15</defaultMinSharePreemptionTimeout>");
- out.print("<defaultFairSharePreemptionTimeout>25</defaultFairSharePreemptionTimeout>");
- out.print("<fairSharePreemptionTimeout>30</fairSharePreemptionTimeout>");
- out.println("</allocations>");
- out.close();
-
- scheduler.reinitialize(conf, resourceManager.getRMContext());
-
- assertEquals(25000, queueMgr.getQueue("root")
- .getFairSharePreemptionTimeout());
- stopResourceManager();
- }
-
- @Test(timeout = 5000)
- public void testRecoverRequestAfterPreemption() throws Exception {
- startResourceManagerWithRealFairScheduler();
- conf.setLong(FairSchedulerConfiguration.WAIT_TIME_BEFORE_KILL, 10);
-
- ControlledClock clock = new ControlledClock();
- scheduler.setClock(clock);
- scheduler.init(conf);
- scheduler.start();
- scheduler.reinitialize(conf, resourceManager.getRMContext());
-
- SchedulerRequestKey schedulerKey = TestUtils.toSchedulerKey(20);
- String host = "127.0.0.1";
- int GB = 1024;
-
- // Create Node and raised Node Added event
- RMNode node = MockNodes.newNodeInfo(1,
- Resources.createResource(16 * 1024, 4), 0, host);
- NodeAddedSchedulerEvent nodeEvent = new NodeAddedSchedulerEvent(node);
- scheduler.handle(nodeEvent);
-
- // Create 3 container requests and place it in ask
- List<ResourceRequest> ask = new ArrayList<ResourceRequest>();
- ResourceRequest nodeLocalRequest = createResourceRequest(GB, 1, host,
- schedulerKey.getPriority().getPriority(), 1, true);
- ResourceRequest rackLocalRequest = createResourceRequest(GB, 1,
- node.getRackName(), schedulerKey.getPriority().getPriority(), 1,
- true);
- ResourceRequest offRackRequest = createResourceRequest(GB, 1,
- ResourceRequest.ANY, schedulerKey.getPriority().getPriority(), 1, true);
- ask.add(nodeLocalRequest);
- ask.add(rackLocalRequest);
- ask.add(offRackRequest);
-
- // Create Request and update
- ApplicationAttemptId appAttemptId = createSchedulingRequest("queueA",
- "user1", ask);
- scheduler.update();
-
- // Sufficient node check-ins to fully schedule containers
- NodeUpdateSchedulerEvent nodeUpdate = new NodeUpdateSchedulerEvent(node);
- scheduler.handle(nodeUpdate);
-
- assertEquals(1, scheduler.getSchedulerApp(appAttemptId).getLiveContainers()
- .size());
- SchedulerApplicationAttempt app = scheduler.getSchedulerApp(appAttemptId);
-
- // ResourceRequest will be empty once NodeUpdate is completed
- Assert.assertNull(app.getResourceRequest(schedulerKey, host));
-
- ContainerId containerId1 = ContainerId.newContainerId(appAttemptId, 1);
- RMContainer rmContainer = app.getRMContainer(containerId1);
-
- // Create a preempt event and register for preemption
- scheduler.warnOrKillContainer(rmContainer);
-
- // Wait for few clock ticks
- clock.tickSec(5);
-
- // preempt now
- scheduler.warnOrKillContainer(rmContainer);
-
- // Trigger container rescheduled event
- scheduler.handle(new ContainerPreemptEvent(appAttemptId, rmContainer,
- SchedulerEventType.MARK_CONTAINER_FOR_KILLABLE));
-
- List<ResourceRequest> requests = rmContainer.getResourceRequests();
- // Once recovered, resource request will be present again in app
- Assert.assertEquals(3, requests.size());
- for (ResourceRequest request : requests) {
- Assert.assertEquals(1,
- app.getResourceRequest(schedulerKey, request.getResourceName())
- .getNumContainers());
- }
-
- // Send node heartbeat
- scheduler.update();
- scheduler.handle(nodeUpdate);
-
- List<Container> containers = scheduler.allocate(appAttemptId,
- Collections.<ResourceRequest> emptyList(),
- Collections.<ContainerId> emptyList(), null, null, null, null).getContainers();
-
- // Now with updated ResourceRequest, a container is allocated for AM.
- Assert.assertTrue(containers.size() == 1);
- stopResourceManager();
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[27/50] [abbrv] hadoop git commit: HDFS-9482. Replace DatanodeInfo
constructors with a builder pattern. Contributed by Brahma Reddy Battula.
Posted by ka...@apache.org.
HDFS-9482. Replace DatanodeInfo constructors with a builder pattern. Contributed by Brahma Reddy Battula.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ed0bebab
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ed0bebab
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ed0bebab
Branch: refs/heads/YARN-4752
Commit: ed0bebabaaf27cd730f7f8eb002d92c9c7db327d
Parents: 62d8c17
Author: Brahma Reddy Battula <br...@apache.org>
Authored: Tue Nov 8 18:17:07 2016 -0800
Committer: Arpit Agarwal <ar...@apache.org>
Committed: Tue Nov 8 18:17:07 2016 -0800
----------------------------------------------------------------------
.../hadoop/hdfs/DFSStripedOutputStream.java | 4 +-
.../hadoop/hdfs/protocol/DatanodeInfo.java | 217 +++++++++++++++----
.../hadoop/hdfs/protocolPB/PBHelperClient.java | 22 +-
.../apache/hadoop/hdfs/web/JsonUtilClient.java | 42 ++--
.../NamenodeProtocolServerSideTranslatorPB.java | 6 +-
.../hadoop/hdfs/server/datanode/DataNode.java | 4 +-
.../server/datanode/ReportBadBlockAction.java | 4 +-
.../erasurecode/StripedBlockWriter.java | 4 +-
.../hdfs/server/namenode/FSNamesystem.java | 7 +-
.../org/apache/hadoop/hdfs/DFSTestUtil.java | 37 ++--
.../hadoop/hdfs/TestDFSClientSocketSize.java | 6 +-
.../apache/hadoop/hdfs/TestFileCorruption.java | 7 +-
.../client/impl/TestBlockReaderFactory.java | 6 +-
.../hadoop/hdfs/protocolPB/TestPBHelper.java | 4 +-
.../hdfs/server/datanode/TestBlockRecovery.java | 6 +-
.../impl/TestInterDatanodeProtocol.java | 4 +-
.../shortcircuit/TestShortCircuitCache.java | 11 +-
17 files changed, 277 insertions(+), 114 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java
index d5d0dfb..52fc5eb 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java
@@ -50,6 +50,7 @@ import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
import org.apache.hadoop.hdfs.protocol.DatanodeID;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
@@ -766,7 +767,8 @@ public class DFSStripedOutputStream extends DFSOutputStream {
newNodes[i] = nodes[0];
newStorageIDs[i] = storageIDs[0];
} else {
- newNodes[i] = new DatanodeInfo(DatanodeID.EMPTY_DATANODE_ID);
+ newNodes[i] = new DatanodeInfoBuilder()
+ .setNodeID(DatanodeID.EMPTY_DATANODE_ID).build();
newStorageIDs[i] = "";
}
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java
index e9ee8b9..8f9f3d5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java
@@ -86,7 +86,7 @@ public class DatanodeInfo extends DatanodeID implements Node {
protected AdminStates adminState;
private long maintenanceExpireTimeInMS;
- public DatanodeInfo(DatanodeInfo from) {
+ protected DatanodeInfo(DatanodeInfo from) {
super(from);
this.capacity = from.getCapacity();
this.dfsUsed = from.getDfsUsed();
@@ -103,7 +103,7 @@ public class DatanodeInfo extends DatanodeID implements Node {
this.upgradeDomain = from.getUpgradeDomain();
}
- public DatanodeInfo(DatanodeID nodeID) {
+ protected DatanodeInfo(DatanodeID nodeID) {
super(nodeID);
this.capacity = 0L;
this.dfsUsed = 0L;
@@ -118,57 +118,13 @@ public class DatanodeInfo extends DatanodeID implements Node {
this.adminState = null;
}
- public DatanodeInfo(DatanodeID nodeID, String location) {
+ protected DatanodeInfo(DatanodeID nodeID, String location) {
this(nodeID);
this.location = location;
}
- public DatanodeInfo(DatanodeID nodeID, String location,
- final long capacity, final long dfsUsed, final long remaining,
- final long blockPoolUsed, final long cacheCapacity, final long cacheUsed,
- final long lastUpdate, final long lastUpdateMonotonic,
- final int xceiverCount, final AdminStates adminState,
- final String upgradeDomain) {
- this(nodeID.getIpAddr(), nodeID.getHostName(), nodeID.getDatanodeUuid(),
- nodeID.getXferPort(), nodeID.getInfoPort(), nodeID.getInfoSecurePort(),
- nodeID.getIpcPort(), capacity, dfsUsed, remaining, blockPoolUsed,
- cacheCapacity, cacheUsed, lastUpdate, lastUpdateMonotonic,
- xceiverCount, location, adminState, upgradeDomain);
- }
-
- /** Constructor */
- public DatanodeInfo(final String ipAddr, final String hostName,
- final String datanodeUuid, final int xferPort, final int infoPort,
- final int infoSecurePort, final int ipcPort,
- final long capacity, final long dfsUsed, final long remaining,
- final long blockPoolUsed, final long cacheCapacity, final long cacheUsed,
- final long lastUpdate, final long lastUpdateMonotonic,
- final int xceiverCount, final String networkLocation,
- final AdminStates adminState) {
- this(ipAddr, hostName, datanodeUuid, xferPort, infoPort, infoSecurePort,
- ipcPort, capacity, dfsUsed, remaining, blockPoolUsed, cacheCapacity,
- cacheUsed, lastUpdate, lastUpdateMonotonic, xceiverCount,
- networkLocation, adminState, null);
- }
-
- /** Constructor */
- public DatanodeInfo(final String ipAddr, final String hostName,
- final String datanodeUuid, final int xferPort, final int infoPort,
- final int infoSecurePort, final int ipcPort,
- final long capacity, final long dfsUsed, final long remaining,
- final long blockPoolUsed, final long cacheCapacity, final long cacheUsed,
- final long lastUpdate, final long lastUpdateMonotonic,
- final int xceiverCount, final String networkLocation,
- final AdminStates adminState,
- final String upgradeDomain) {
- this(ipAddr, hostName, datanodeUuid, xferPort, infoPort, infoSecurePort,
- ipcPort, capacity, dfsUsed, 0L, remaining, blockPoolUsed,
- cacheCapacity, cacheUsed, lastUpdate, lastUpdateMonotonic,
- xceiverCount, networkLocation, adminState, upgradeDomain);
- }
-
/** Constructor. */
- public DatanodeInfo(final String ipAddr, final String hostName,
+ private DatanodeInfo(final String ipAddr, final String hostName,
final String datanodeUuid, final int xferPort, final int infoPort,
final int infoSecurePort, final int ipcPort, final long capacity,
final long dfsUsed, final long nonDfsUsed, final long remaining,
@@ -662,4 +618,169 @@ public class DatanodeInfo extends DatanodeID implements Node {
public void setSoftwareVersion(String softwareVersion) {
this.softwareVersion = softwareVersion;
}
+
+ /**
+ * Building the DataNodeInfo.
+ */
+ public static class DatanodeInfoBuilder {
+ private String location = NetworkTopology.DEFAULT_RACK;
+ private long capacity;
+ private long dfsUsed;
+ private long remaining;
+ private long blockPoolUsed;
+ private long cacheCapacity;
+ private long cacheUsed;
+ private long lastUpdate;
+ private long lastUpdateMonotonic;
+ private int xceiverCount;
+ private DatanodeInfo.AdminStates adminState;
+ private String upgradeDomain;
+ private String ipAddr;
+ private String hostName;
+ private String datanodeUuid;
+ private int xferPort;
+ private int infoPort;
+ private int infoSecurePort;
+ private int ipcPort;
+ private long nonDfsUsed = 0L;
+
+ public DatanodeInfoBuilder setFrom(DatanodeInfo from) {
+ this.capacity = from.getCapacity();
+ this.dfsUsed = from.getDfsUsed();
+ this.nonDfsUsed = from.getNonDfsUsed();
+ this.remaining = from.getRemaining();
+ this.blockPoolUsed = from.getBlockPoolUsed();
+ this.cacheCapacity = from.getCacheCapacity();
+ this.cacheUsed = from.getCacheUsed();
+ this.lastUpdate = from.getLastUpdate();
+ this.lastUpdateMonotonic = from.getLastUpdateMonotonic();
+ this.xceiverCount = from.getXceiverCount();
+ this.location = from.getNetworkLocation();
+ this.adminState = from.getAdminState();
+ this.upgradeDomain = from.getUpgradeDomain();
+ setNodeID(from);
+ return this;
+ }
+
+ public DatanodeInfoBuilder setNodeID(DatanodeID nodeID) {
+ this.ipAddr = nodeID.getIpAddr();
+ this.hostName = nodeID.getHostName();
+ this.datanodeUuid = nodeID.getDatanodeUuid();
+ this.xferPort = nodeID.getXferPort();
+ this.infoPort = nodeID.getInfoPort();
+ this.infoSecurePort = nodeID.getInfoSecurePort();
+ this.ipcPort = nodeID.getIpcPort();
+ return this;
+ }
+
+ public DatanodeInfoBuilder setCapacity(long capacity) {
+ this.capacity = capacity;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setDfsUsed(long dfsUsed) {
+ this.dfsUsed = dfsUsed;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setRemaining(long remaining) {
+ this.remaining = remaining;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setBlockPoolUsed(long blockPoolUsed) {
+ this.blockPoolUsed = blockPoolUsed;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setCacheCapacity(long cacheCapacity) {
+ this.cacheCapacity = cacheCapacity;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setCacheUsed(long cacheUsed) {
+ this.cacheUsed = cacheUsed;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setLastUpdate(long lastUpdate) {
+ this.lastUpdate = lastUpdate;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setLastUpdateMonotonic(
+ long lastUpdateMonotonic) {
+ this.lastUpdateMonotonic = lastUpdateMonotonic;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setXceiverCount(int xceiverCount) {
+ this.xceiverCount = xceiverCount;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setAdminState(
+ DatanodeInfo.AdminStates adminState) {
+ this.adminState = adminState;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setUpgradeDomain(String upgradeDomain) {
+ this.upgradeDomain = upgradeDomain;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setHostName(String hostName) {
+ this.hostName = hostName;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setDatanodeUuid(String datanodeUuid) {
+ this.datanodeUuid = datanodeUuid;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setXferPort(int xferPort) {
+ this.xferPort = xferPort;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setInfoPort(int infoPort) {
+ this.infoPort = infoPort;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setInfoSecurePort(int infoSecurePort) {
+ this.infoSecurePort = infoSecurePort;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setIpcPort(int ipcPort) {
+ this.ipcPort = ipcPort;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setNetworkLocation(String networkLocation) {
+ this.location = networkLocation;
+ return this;
+ }
+
+ public DatanodeInfoBuilder setNonDfsUsed(long nonDfsUsed) {
+ this.nonDfsUsed = nonDfsUsed;
+ return this;
+ }
+
+ public DatanodeInfo build() {
+ return new DatanodeInfo(ipAddr, hostName, datanodeUuid, xferPort,
+ infoPort, infoSecurePort, ipcPort, capacity, dfsUsed, nonDfsUsed,
+ remaining, blockPoolUsed, cacheCapacity, cacheUsed, lastUpdate,
+ lastUpdateMonotonic, xceiverCount, location, adminState,
+ upgradeDomain);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelperClient.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelperClient.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelperClient.java
index 246b5a5..2ba7bad 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelperClient.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelperClient.java
@@ -70,6 +70,7 @@ import org.apache.hadoop.hdfs.protocol.ClientProtocol;
import org.apache.hadoop.hdfs.protocol.CorruptFileBlocks;
import org.apache.hadoop.hdfs.protocol.DatanodeID;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo.AdminStates;
import org.apache.hadoop.hdfs.protocol.DatanodeLocalInfo;
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
@@ -585,13 +586,18 @@ public class PBHelperClient {
if (di == null) {
return null;
}
- DatanodeInfo dinfo = new DatanodeInfo(convert(di.getId()),
- di.hasLocation() ? di.getLocation() : null, di.getCapacity(),
- di.getDfsUsed(), di.getRemaining(), di.getBlockPoolUsed(),
- di.getCacheCapacity(), di.getCacheUsed(), di.getLastUpdate(),
- di.getLastUpdateMonotonic(), di.getXceiverCount(),
- convert(di.getAdminState()),
- di.hasUpgradeDomain() ? di.getUpgradeDomain() : null);
+ DatanodeInfoBuilder dinfo =
+ new DatanodeInfoBuilder().setNodeID(convert(di.getId()))
+ .setNetworkLocation(di.hasLocation() ? di.getLocation() : null)
+ .setCapacity(di.getCapacity()).setDfsUsed(di.getDfsUsed())
+ .setRemaining(di.getRemaining())
+ .setBlockPoolUsed(di.getBlockPoolUsed())
+ .setCacheCapacity(di.getCacheCapacity())
+ .setCacheUsed(di.getCacheUsed()).setLastUpdate(di.getLastUpdate())
+ .setLastUpdateMonotonic(di.getLastUpdateMonotonic())
+ .setXceiverCount(di.getXceiverCount())
+ .setAdminState(convert(di.getAdminState())).setUpgradeDomain(
+ di.hasUpgradeDomain() ? di.getUpgradeDomain() : null);
if (di.hasNonDfsUsed()) {
dinfo.setNonDfsUsed(di.getNonDfsUsed());
} else {
@@ -599,7 +605,7 @@ public class PBHelperClient {
long nonDFSUsed = di.getCapacity() - di.getDfsUsed() - di.getRemaining();
dinfo.setNonDfsUsed(nonDFSUsed < 0 ? 0 : nonDFSUsed);
}
- return dinfo;
+ return dinfo.build();
}
public static StorageType[] convertStorageTypes(
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
index 97cb042..a75f4f1 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
@@ -36,6 +36,7 @@ import org.apache.hadoop.fs.permission.AclStatus;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.hdfs.DFSUtilClient;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.protocol.FsPermissionExtension;
@@ -271,27 +272,26 @@ class JsonUtilClient {
}
// TODO: Fix storageID
- return new DatanodeInfo(
- ipAddr,
- (String)m.get("hostName"),
- (String)m.get("storageID"),
- xferPort,
- ((Number) m.get("infoPort")).intValue(),
- getInt(m, "infoSecurePort", 0),
- ((Number) m.get("ipcPort")).intValue(),
-
- getLong(m, "capacity", 0l),
- getLong(m, "dfsUsed", 0l),
- getLong(m, "remaining", 0l),
- getLong(m, "blockPoolUsed", 0l),
- getLong(m, "cacheCapacity", 0l),
- getLong(m, "cacheUsed", 0l),
- getLong(m, "lastUpdate", 0l),
- getLong(m, "lastUpdateMonotonic", 0l),
- getInt(m, "xceiverCount", 0),
- getString(m, "networkLocation", ""),
- DatanodeInfo.AdminStates.valueOf(getString(m, "adminState", "NORMAL")),
- getString(m, "upgradeDomain", ""));
+ return new DatanodeInfoBuilder().setIpAddr(ipAddr)
+ .setHostName((String) m.get("hostName"))
+ .setDatanodeUuid((String) m.get("storageID")).setXferPort(xferPort)
+ .setInfoPort(((Number) m.get("infoPort")).intValue())
+ .setInfoSecurePort(getInt(m, "infoSecurePort", 0))
+ .setIpcPort(((Number) m.get("ipcPort")).intValue())
+ .setCapacity(getLong(m, "capacity", 0L))
+ .setDfsUsed(getLong(m, "dfsUsed", 0L))
+ .setRemaining(getLong(m, "remaining", 0L))
+ .setBlockPoolUsed(getLong(m, "blockPoolUsed", 0L))
+ .setCacheCapacity(getLong(m, "cacheCapacity", 0L))
+ .setCacheUsed(getLong(m, "cacheUsed", 0L))
+ .setLastUpdate(getLong(m, "lastUpdate", 0L))
+ .setLastUpdateMonotonic(getLong(m, "lastUpdateMonotonic", 0L))
+ .setXceiverCount(getInt(m, "xceiverCount", 0))
+ .setNetworkLocation(getString(m, "networkLocation", "")).setAdminState(
+ DatanodeInfo.AdminStates
+ .valueOf(getString(m, "adminState", "NORMAL")))
+ .setUpgradeDomain(getString(m, "upgradeDomain", ""))
+ .build();
}
/** Convert an Object[] to a DatanodeInfo[]. */
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolServerSideTranslatorPB.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolServerSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolServerSideTranslatorPB.java
index db7a8d2..c7b3e74 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolServerSideTranslatorPB.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolServerSideTranslatorPB.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hdfs.protocolPB;
import java.io.IOException;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.VersionRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.VersionResponseProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.EndCheckpointRequestProto;
@@ -78,8 +79,9 @@ public class NamenodeProtocolServerSideTranslatorPB implements
@Override
public GetBlocksResponseProto getBlocks(RpcController unused,
GetBlocksRequestProto request) throws ServiceException {
- DatanodeInfo dnInfo = new DatanodeInfo(PBHelperClient.convert(request
- .getDatanode()));
+ DatanodeInfo dnInfo = new DatanodeInfoBuilder()
+ .setNodeID(PBHelperClient.convert(request.getDatanode()))
+ .build();
BlocksWithLocations blocks;
try {
blocks = impl.getBlocks(dnInfo, request.getSize());
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java
index de9e48e..78a2044 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java
@@ -123,6 +123,7 @@ import org.apache.hadoop.hdfs.protocol.BlockLocalPathInfo;
import org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol;
import org.apache.hadoop.hdfs.protocol.DatanodeID;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.DatanodeLocalInfo;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
@@ -2384,7 +2385,8 @@ public class DataNode extends ReconfigurableBase
in = new DataInputStream(unbufIn);
blockSender = new BlockSender(b, 0, b.getNumBytes(),
false, false, true, DataNode.this, null, cachingStrategy);
- DatanodeInfo srcNode = new DatanodeInfo(bpReg);
+ DatanodeInfo srcNode = new DatanodeInfoBuilder().setNodeID(bpReg)
+ .build();
new Sender(out).writeBlock(b, targetStorageTypes[0], accessToken,
clientname, targets, targetStorageTypes, srcNode,
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReportBadBlockAction.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReportBadBlockAction.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReportBadBlockAction.java
index be46707..2946358 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReportBadBlockAction.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReportBadBlockAction.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import org.apache.hadoop.fs.StorageType;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
import org.apache.hadoop.hdfs.protocolPB.DatanodeProtocolClientSideTranslatorPB;
@@ -52,7 +53,8 @@ public class ReportBadBlockAction implements BPServiceActorAction {
if (bpRegistration == null) {
return;
}
- DatanodeInfo[] dnArr = { new DatanodeInfo(bpRegistration) };
+ DatanodeInfo[] dnArr = {new DatanodeInfoBuilder()
+ .setNodeID(bpRegistration).build()};
String[] uuids = { storageUuid };
StorageType[] types = { storageType };
LocatedBlock[] locatedBlock = { new LocatedBlock(block,
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedBlockWriter.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedBlockWriter.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedBlockWriter.java
index 11551e7..592be45 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedBlockWriter.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedBlockWriter.java
@@ -23,6 +23,7 @@ import org.apache.hadoop.fs.StorageType;
import org.apache.hadoop.hdfs.DFSPacket;
import org.apache.hadoop.hdfs.DFSUtilClient;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.protocol.datatransfer.BlockConstructionStage;
import org.apache.hadoop.hdfs.protocol.datatransfer.IOStreamPair;
@@ -132,7 +133,8 @@ class StripedBlockWriter {
DFSUtilClient.getSmallBufferSize(conf)));
in = new DataInputStream(unbufIn);
- DatanodeInfo source = new DatanodeInfo(datanode.getDatanodeId());
+ DatanodeInfo source = new DatanodeInfoBuilder()
+ .setNodeID(datanode.getDatanodeId()).build();
new Sender(out).writeBlock(block, storageType,
blockToken, "", new DatanodeInfo[]{target},
new StorageType[]{storageType}, source,
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
index d6ae0fa..7e3fabe 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
@@ -181,6 +181,7 @@ import org.apache.hadoop.hdfs.protocol.CachePoolInfo;
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
import org.apache.hadoop.hdfs.protocol.DatanodeID;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
import org.apache.hadoop.hdfs.protocol.EncryptionZone;
@@ -4040,7 +4041,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
DatanodeInfo[] arr = new DatanodeInfo[results.size()];
for (int i=0; i<arr.length; i++) {
- arr[i] = new DatanodeInfo(results.get(i));
+ arr[i] = new DatanodeInfoBuilder().setFrom(results.get(i))
+ .build();
}
return arr;
} finally {
@@ -4061,7 +4063,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
DatanodeStorageReport[] reports = new DatanodeStorageReport[datanodes.size()];
for (int i = 0; i < reports.length; i++) {
final DatanodeDescriptor d = datanodes.get(i);
- reports[i] = new DatanodeStorageReport(new DatanodeInfo(d),
+ reports[i] = new DatanodeStorageReport(
+ new DatanodeInfoBuilder().setFrom(d).build(),
d.getStorageReports());
}
return reports;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java
index 7f26b03..945d2c8 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java
@@ -110,6 +110,7 @@ import org.apache.hadoop.hdfs.protocol.CachePoolInfo;
import org.apache.hadoop.hdfs.protocol.DatanodeID;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo.AdminStates;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
import org.apache.hadoop.hdfs.protocol.LayoutVersion;
@@ -1066,34 +1067,42 @@ public class DFSTestUtil {
}
public static DatanodeInfo getLocalDatanodeInfo() {
- return new DatanodeInfo(getLocalDatanodeID());
+ return new DatanodeInfoBuilder().setNodeID(getLocalDatanodeID())
+ .build();
}
public static DatanodeInfo getDatanodeInfo(String ipAddr) {
- return new DatanodeInfo(getDatanodeID(ipAddr));
+ return new DatanodeInfoBuilder().setNodeID(getDatanodeID(ipAddr))
+ .build();
}
public static DatanodeInfo getLocalDatanodeInfo(int port) {
- return new DatanodeInfo(getLocalDatanodeID(port));
+ return new DatanodeInfoBuilder().setNodeID(getLocalDatanodeID(port))
+ .build();
}
public static DatanodeInfo getDatanodeInfo(String ipAddr,
String host, int port) {
- return new DatanodeInfo(new DatanodeID(ipAddr, host,
- UUID.randomUUID().toString(), port,
- DFSConfigKeys.DFS_DATANODE_HTTP_DEFAULT_PORT,
- DFSConfigKeys.DFS_DATANODE_HTTPS_DEFAULT_PORT,
- DFSConfigKeys.DFS_DATANODE_IPC_DEFAULT_PORT));
+ return new DatanodeInfoBuilder().setNodeID(
+ new DatanodeID(ipAddr, host, UUID.randomUUID().toString(), port,
+ DFSConfigKeys.DFS_DATANODE_HTTP_DEFAULT_PORT,
+ DFSConfigKeys.DFS_DATANODE_HTTPS_DEFAULT_PORT,
+ DFSConfigKeys.DFS_DATANODE_IPC_DEFAULT_PORT)).build();
}
public static DatanodeInfo getLocalDatanodeInfo(String ipAddr,
String hostname, AdminStates adminState) {
- return new DatanodeInfo(ipAddr, hostname, "",
- DFSConfigKeys.DFS_DATANODE_DEFAULT_PORT,
- DFSConfigKeys.DFS_DATANODE_HTTP_DEFAULT_PORT,
- DFSConfigKeys.DFS_DATANODE_HTTPS_DEFAULT_PORT,
- DFSConfigKeys.DFS_DATANODE_IPC_DEFAULT_PORT,
- 1l, 2l, 3l, 4l, 0l, 0l, 0l, 5, 6, "local", adminState);
+ return new DatanodeInfoBuilder().setIpAddr(ipAddr).setHostName(hostname)
+ .setDatanodeUuid("")
+ .setXferPort(DFSConfigKeys.DFS_DATANODE_DEFAULT_PORT)
+ .setInfoPort(DFSConfigKeys.DFS_DATANODE_HTTP_DEFAULT_PORT)
+ .setInfoSecurePort(DFSConfigKeys.DFS_DATANODE_HTTPS_DEFAULT_PORT)
+ .setIpcPort(DFSConfigKeys.DFS_DATANODE_IPC_DEFAULT_PORT).setCapacity(1L)
+ .setDfsUsed(2L).setRemaining(3L).setBlockPoolUsed(4L)
+ .setCacheCapacity(0L).setCacheUsed(0L).setLastUpdate(0L)
+ .setLastUpdateMonotonic(5).setXceiverCount(6)
+ .setNetworkLocation("local").setAdminState(adminState)
+ .build();
}
public static DatanodeDescriptor getDatanodeDescriptor(String ipAddr,
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientSocketSize.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientSocketSize.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientSocketSize.java
index a2a7afc..fa12f34 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientSocketSize.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientSocketSize.java
@@ -18,7 +18,7 @@
package org.apache.hadoop.hdfs;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.log4j.Level;
@@ -91,7 +91,9 @@ public class TestDFSClientSocketSize {
cluster.waitActive();
LOG.info("MiniDFSCluster started.");
try (Socket socket = DataStreamer.createSocketForPipeline(
- new DatanodeInfo(cluster.dataNodes.get(0).datanode.getDatanodeId()),
+ new DatanodeInfoBuilder()
+ .setNodeID(cluster.dataNodes.get(0).datanode.getDatanodeId())
+ .build(),
1, cluster.getFileSystem().getClient())) {
return socket.getSendBufferSize();
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileCorruption.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileCorruption.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileCorruption.java
index 5477700..1f62414 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileCorruption.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileCorruption.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hdfs;
import com.google.common.base.Supplier;
import org.apache.hadoop.fs.StorageType;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -43,7 +44,6 @@ import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.protocol.BlockListAsLongs;
import org.apache.hadoop.hdfs.protocol.BlockListAsLongs.BlockReportReplica;
-import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
@@ -161,8 +161,9 @@ public class TestFileCorruption {
FSNamesystem ns = cluster.getNamesystem();
ns.writeLock();
try {
- cluster.getNamesystem().getBlockManager().findAndMarkBlockAsCorrupt(
- blk, new DatanodeInfo(dnR), "TEST", "STORAGE_ID");
+ cluster.getNamesystem().getBlockManager().findAndMarkBlockAsCorrupt(blk,
+ new DatanodeInfoBuilder().setNodeID(dnR).build(), "TEST",
+ "STORAGE_ID");
} finally {
ns.writeUnlock();
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/client/impl/TestBlockReaderFactory.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/client/impl/TestBlockReaderFactory.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/client/impl/TestBlockReaderFactory.java
index ca498c7..2d04549 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/client/impl/TestBlockReaderFactory.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/client/impl/TestBlockReaderFactory.java
@@ -48,6 +48,7 @@ import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
import org.apache.hadoop.hdfs.shortcircuit.DfsClientShmManager.PerDatanodeVisitorInfo;
import org.apache.hadoop.hdfs.shortcircuit.DfsClientShmManager.Visitor;
@@ -333,8 +334,9 @@ public class TestBlockReaderFactory {
Assert.assertTrue(Arrays.equals(contents, expected));
final ShortCircuitCache cache =
fs.getClient().getClientContext().getShortCircuitCache();
- final DatanodeInfo datanode =
- new DatanodeInfo(cluster.getDataNodes().get(0).getDatanodeId());
+ final DatanodeInfo datanode = new DatanodeInfoBuilder()
+ .setNodeID(cluster.getDataNodes().get(0).getDatanodeId())
+ .build();
cache.getDfsClientShmManager().visit(new Visitor() {
@Override
public void visit(HashMap<DatanodeInfo, PerDatanodeVisitorInfo> info)
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocolPB/TestPBHelper.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocolPB/TestPBHelper.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocolPB/TestPBHelper.java
index 4072071..5cb2571 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocolPB/TestPBHelper.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocolPB/TestPBHelper.java
@@ -39,6 +39,7 @@ import org.apache.hadoop.hdfs.StripedFileTestUtil;
import org.apache.hadoop.hdfs.protocol.Block;
import org.apache.hadoop.hdfs.protocol.DatanodeID;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo.AdminStates;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
@@ -735,7 +736,8 @@ public class TestPBHelper {
@Test
public void testDataNodeInfoPBHelper() {
DatanodeID id = DFSTestUtil.getLocalDatanodeID();
- DatanodeInfo dnInfos0 = new DatanodeInfo(id);
+ DatanodeInfo dnInfos0 = new DatanodeInfoBuilder().setNodeID(id)
+ .build();
dnInfos0.setCapacity(3500L);
dnInfos0.setDfsUsed(1000L);
dnInfos0.setNonDfsUsed(2000L);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java
index c09303f..f011b9d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockRecovery.java
@@ -69,6 +69,7 @@ import org.apache.hadoop.hdfs.StripedFileTestUtil;
import org.apache.hadoop.util.AutoCloseableLock;
import org.apache.hadoop.hdfs.protocol.DatanodeID;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
@@ -510,8 +511,9 @@ public class TestBlockRecovery {
private Collection<RecoveringBlock> initRecoveringBlocks() throws IOException {
Collection<RecoveringBlock> blocks = new ArrayList<RecoveringBlock>(1);
DatanodeInfo mockOtherDN = DFSTestUtil.getLocalDatanodeInfo();
- DatanodeInfo[] locs = new DatanodeInfo[] {
- new DatanodeInfo(dn.getDNRegistrationForBP(block.getBlockPoolId())),
+ DatanodeInfo[] locs = new DatanodeInfo[] {new DatanodeInfoBuilder()
+ .setNodeID(dn.getDNRegistrationForBP(
+ block.getBlockPoolId())).build(),
mockOtherDN };
RecoveringBlock rBlock = new RecoveringBlock(block, locs, RECOVERY_ID);
blocks.add(rBlock);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestInterDatanodeProtocol.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestInterDatanodeProtocol.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestInterDatanodeProtocol.java
index 4f6db24..86e9f90 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestInterDatanodeProtocol.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestInterDatanodeProtocol.java
@@ -38,6 +38,7 @@ import org.apache.hadoop.hdfs.protocol.Block;
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
import org.apache.hadoop.hdfs.protocol.DatanodeID;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
@@ -400,7 +401,8 @@ public class TestInterDatanodeProtocol {
final InetSocketAddress addr = NetUtils.getConnectAddress(server);
DatanodeID fakeDnId = DFSTestUtil.getLocalDatanodeID(addr.getPort());
- DatanodeInfo dInfo = new DatanodeInfo(fakeDnId);
+ DatanodeInfo dInfo = new DatanodeInfoBuilder().setNodeID(fakeDnId)
+ .build();
InterDatanodeProtocol proxy = null;
try {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ed0bebab/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitCache.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitCache.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitCache.java
index 8e217c2..06c6cf6 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitCache.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitCache.java
@@ -51,6 +51,7 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
import org.apache.hadoop.hdfs.net.DomainPeer;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.server.datanode.BlockMetadataHeader;
import org.apache.hadoop.hdfs.server.datanode.DataNodeFaultInjector;
@@ -430,8 +431,9 @@ public class TestShortCircuitCache {
DomainPeer peer = getDomainPeerToDn(conf);
MutableBoolean usedPeer = new MutableBoolean(false);
ExtendedBlockId blockId = new ExtendedBlockId(123, "xyz");
- final DatanodeInfo datanode =
- new DatanodeInfo(cluster.getDataNodes().get(0).getDatanodeId());
+ final DatanodeInfo datanode = new DatanodeInfoBuilder()
+ .setNodeID(cluster.getDataNodes().get(0).getDatanodeId())
+ .build();
// Allocating the first shm slot requires using up a peer.
Slot slot = cache.allocShmSlot(datanode, peer, usedPeer,
blockId, "testAllocShm_client");
@@ -571,8 +573,9 @@ public class TestShortCircuitCache {
Assert.assertTrue(Arrays.equals(contents, expected));
// Loading this file brought the ShortCircuitReplica into our local
// replica cache.
- final DatanodeInfo datanode =
- new DatanodeInfo(cluster.getDataNodes().get(0).getDatanodeId());
+ final DatanodeInfo datanode = new DatanodeInfoBuilder()
+ .setNodeID(cluster.getDataNodes().get(0).getDatanodeId())
+ .build();
cache.getDfsClientShmManager().visit(new Visitor() {
@Override
public void visit(HashMap<DatanodeInfo, PerDatanodeVisitorInfo> info)
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[25/50] [abbrv] hadoop git commit: HADOOP-13789. Hadoop Common
includes generated test protos in both jar and test-jar. Contributed by Sean
Busbey.
Posted by ka...@apache.org.
HADOOP-13789. Hadoop Common includes generated test protos in both jar and test-jar. Contributed by Sean Busbey.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/e1c6ef2e
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/e1c6ef2e
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/e1c6ef2e
Branch: refs/heads/YARN-4752
Commit: e1c6ef2efa9d87fdfc7474ca63998a13a3929874
Parents: 77c13c3
Author: Andrew Wang <wa...@apache.org>
Authored: Tue Nov 8 16:33:55 2016 -0800
Committer: Andrew Wang <wa...@apache.org>
Committed: Tue Nov 8 16:33:55 2016 -0800
----------------------------------------------------------------------
hadoop-common-project/hadoop-common/pom.xml | 6 +-
hadoop-hdfs-project/hadoop-hdfs-client/pom.xml | 2 -
hadoop-hdfs-project/hadoop-hdfs/pom.xml | 2 -
.../hadoop-mapreduce-client-common/pom.xml | 2 -
.../hadoop-mapreduce-client-shuffle/pom.xml | 2 -
.../hadoop/maven/plugin/protoc/ProtocMojo.java | 228 +--------------
.../maven/plugin/protoc/ProtocRunner.java | 283 +++++++++++++++++++
.../maven/plugin/protoc/ProtocTestMojo.java | 61 ++++
.../maven/plugin/protoc/package-info.java | 98 +++++++
.../hadoop-yarn/hadoop-yarn-api/pom.xml | 2 -
.../hadoop-yarn/hadoop-yarn-client/pom.xml | 2 -
.../hadoop-yarn/hadoop-yarn-common/pom.xml | 2 -
.../pom.xml | 2 -
.../hadoop-yarn-server-common/pom.xml | 2 -
.../hadoop-yarn-server-nodemanager/pom.xml | 2 -
.../hadoop-yarn-server-resourcemanager/pom.xml | 8 +-
.../hadoop-yarn-server-tests/pom.xml | 6 +-
17 files changed, 454 insertions(+), 256 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-common-project/hadoop-common/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/pom.xml b/hadoop-common-project/hadoop-common/pom.xml
index 645d495..37f0b70 100644
--- a/hadoop-common-project/hadoop-common/pom.xml
+++ b/hadoop-common-project/hadoop-common/pom.xml
@@ -369,7 +369,6 @@
</execution>
<execution>
<id>compile-protoc</id>
- <phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
@@ -397,14 +396,12 @@
<include>GenericRefreshProtocol.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
<execution>
<id>compile-test-protoc</id>
- <phase>generate-test-sources</phase>
<goals>
- <goal>protoc</goal>
+ <goal>test-protoc</goal>
</goals>
<configuration>
<protocVersion>${protobuf.version}</protocVersion>
@@ -419,7 +416,6 @@
<include>test_rpc_service.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-test-sources/java</output>
</configuration>
</execution>
<execution>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml b/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml
index 193f423..8ce5f3f 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml
@@ -138,7 +138,6 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<executions>
<execution>
<id>compile-protoc</id>
- <phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
@@ -164,7 +163,6 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<include>ReconfigurationProtocol.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-hdfs-project/hadoop-hdfs/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/pom.xml b/hadoop-hdfs-project/hadoop-hdfs/pom.xml
index b3ad50a..5427db8 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/pom.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs/pom.xml
@@ -325,7 +325,6 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<executions>
<execution>
<id>compile-protoc</id>
- <phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
@@ -352,7 +351,6 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<include>fsimage.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
<execution>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/pom.xml b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/pom.xml
index fb3ceb6..f78e83b 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/pom.xml
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/pom.xml
@@ -61,7 +61,6 @@
<executions>
<execution>
<id>compile-protoc</id>
- <phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
@@ -82,7 +81,6 @@
<include>MRClientProtocol.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-shuffle/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-shuffle/pom.xml b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-shuffle/pom.xml
index 856d074..41a5220 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-shuffle/pom.xml
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-shuffle/pom.xml
@@ -59,7 +59,6 @@
<executions>
<execution>
<id>compile-protoc</id>
- <phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
@@ -76,7 +75,6 @@
<include>ShuffleHandlerRecovery.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java
----------------------------------------------------------------------
diff --git a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java
index df479fd..2d0fc62 100644
--- a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java
+++ b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java
@@ -13,8 +13,6 @@
*/
package org.apache.hadoop.maven.plugin.protoc;
-import org.apache.hadoop.maven.plugin.util.Exec;
-import org.apache.hadoop.maven.plugin.util.FileSetUtils;
import org.apache.maven.model.FileSet;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -22,22 +20,13 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.zip.CRC32;
+/**
+ * Mojo to generate java classes from .proto files using protoc.
+ * See package info for examples of use in a maven pom.
+ */
@Mojo(name="protoc", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
public class ProtocMojo extends AbstractMojo {
@@ -63,213 +52,10 @@ public class ProtocMojo extends AbstractMojo {
"${project.build.directory}/hadoop-maven-plugins-protoc-checksums.json")
private String checksumPath;
- /**
- * Compares include and source file checksums against previously computed
- * checksums stored in a json file in the build directory.
- */
- public class ChecksumComparator {
-
- private final Map<String, Long> storedChecksums;
- private final Map<String, Long> computedChecksums;
-
- private final File checksumFile;
-
- ChecksumComparator(String checksumPath) throws IOException {
- checksumFile = new File(checksumPath);
- // Read in the checksums
- if (checksumFile.exists()) {
- ObjectMapper mapper = new ObjectMapper();
- storedChecksums = mapper
- .readValue(checksumFile, new TypeReference<Map<String, Long>>() {
- });
- } else {
- storedChecksums = new HashMap<>(0);
- }
- computedChecksums = new HashMap<>();
- }
-
- public boolean hasChanged(File file) throws IOException {
- if (!file.exists()) {
- throw new FileNotFoundException(
- "Specified protoc include or source does not exist: " + file);
- }
- if (file.isDirectory()) {
- return hasDirectoryChanged(file);
- } else if (file.isFile()) {
- return hasFileChanged(file);
- } else {
- throw new IOException("Not a file or directory: " + file);
- }
- }
-
- private boolean hasDirectoryChanged(File directory) throws IOException {
- File[] listing = directory.listFiles();
- boolean changed = false;
- if (listing == null) {
- // not changed.
- return false;
- }
- // Do not exit early, since we need to compute and save checksums
- // for each file within the directory.
- for (File f : listing) {
- if (f.isDirectory()) {
- if (hasDirectoryChanged(f)) {
- changed = true;
- }
- } else if (f.isFile()) {
- if (hasFileChanged(f)) {
- changed = true;
- }
- } else {
- getLog().debug("Skipping entry that is not a file or directory: "
- + f);
- }
- }
- return changed;
- }
-
- private boolean hasFileChanged(File file) throws IOException {
- long computedCsum = computeChecksum(file);
-
- // Return if the generated csum matches the stored csum
- Long storedCsum = storedChecksums.get(file.getCanonicalPath());
- if (storedCsum == null || storedCsum.longValue() != computedCsum) {
- // It has changed.
- return true;
- }
- return false;
- }
-
- private long computeChecksum(File file) throws IOException {
- // If we've already computed the csum, reuse the computed value
- final String canonicalPath = file.getCanonicalPath();
- if (computedChecksums.containsKey(canonicalPath)) {
- return computedChecksums.get(canonicalPath);
- }
- // Compute the csum for the file
- CRC32 crc = new CRC32();
- byte[] buffer = new byte[1024*64];
- try (BufferedInputStream in =
- new BufferedInputStream(new FileInputStream(file))) {
- while (true) {
- int read = in.read(buffer);
- if (read <= 0) {
- break;
- }
- crc.update(buffer, 0, read);
- }
- }
- // Save it in the generated map and return
- final long computedCsum = crc.getValue();
- computedChecksums.put(canonicalPath, computedCsum);
- return crc.getValue();
- }
-
- public void writeChecksums() throws IOException {
- ObjectMapper mapper = new ObjectMapper();
- try (BufferedOutputStream out = new BufferedOutputStream(
- new FileOutputStream(checksumFile))) {
- mapper.writeValue(out, computedChecksums);
- getLog().info("Wrote protoc checksums to file " + checksumFile);
- }
- }
- }
-
public void execute() throws MojoExecutionException {
- try {
- List<String> command = new ArrayList<String>();
- command.add(protocCommand);
- command.add("--version");
- Exec exec = new Exec(this);
- List<String> out = new ArrayList<String>();
- if (exec.run(command, out) == 127) {
- getLog().error("protoc, not found at: " + protocCommand);
- throw new MojoExecutionException("protoc failure");
- } else {
- if (out.isEmpty()) {
- getLog().error("stdout: " + out);
- throw new MojoExecutionException(
- "'protoc --version' did not return a version");
- } else {
- if (!out.get(0).endsWith(protocVersion)) {
- throw new MojoExecutionException(
- "protoc version is '" + out.get(0) + "', expected version is '"
- + protocVersion + "'");
- }
- }
- }
- if (!output.mkdirs()) {
- if (!output.exists()) {
- throw new MojoExecutionException(
- "Could not create directory: " + output);
- }
- }
-
- // Whether the import or source protoc files have changed.
- ChecksumComparator comparator = new ChecksumComparator(checksumPath);
- boolean importsChanged = false;
-
- command = new ArrayList<String>();
- command.add(protocCommand);
- command.add("--java_out=" + output.getCanonicalPath());
- if (imports != null) {
- for (File i : imports) {
- if (comparator.hasChanged(i)) {
- importsChanged = true;
- }
- command.add("-I" + i.getCanonicalPath());
- }
- }
- // Filter to generate classes for just the changed source files.
- List<File> changedSources = new ArrayList<>();
- boolean sourcesChanged = false;
- for (File f : FileSetUtils.convertFileSetToFiles(source)) {
- // Need to recompile if the source has changed, or if any import has
- // changed.
- if (comparator.hasChanged(f) || importsChanged) {
- sourcesChanged = true;
- changedSources.add(f);
- command.add(f.getCanonicalPath());
- }
- }
-
- if (!sourcesChanged && !importsChanged) {
- getLog().info("No changes detected in protoc files, skipping "
- + "generation.");
- } else {
- if (getLog().isDebugEnabled()) {
- StringBuilder b = new StringBuilder();
- b.append("Generating classes for the following protoc files: [");
- String prefix = "";
- for (File f : changedSources) {
- b.append(prefix);
- b.append(f.toString());
- prefix = ", ";
- }
- b.append("]");
- getLog().debug(b.toString());
- }
-
- exec = new Exec(this);
- out = new ArrayList<String>();
- List<String> err = new ArrayList<>();
- if (exec.run(command, out, err) != 0) {
- getLog().error("protoc compiler error");
- for (String s : out) {
- getLog().error(s);
- }
- for (String s : err) {
- getLog().error(s);
- }
- throw new MojoExecutionException("protoc failure");
- }
- // Write the new checksum file on success.
- comparator.writeChecksums();
- }
- } catch (Throwable ex) {
- throw new MojoExecutionException(ex.toString(), ex);
- }
- project.addCompileSourceRoot(output.getAbsolutePath());
+ final ProtocRunner protoc = new ProtocRunner(project, imports, output,
+ source, protocCommand, protocVersion, checksumPath, this, false);
+ protoc.execute();
}
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocRunner.java
----------------------------------------------------------------------
diff --git a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocRunner.java b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocRunner.java
new file mode 100644
index 0000000..ef15884
--- /dev/null
+++ b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocRunner.java
@@ -0,0 +1,283 @@
+/*
+ * Licensed 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.maven.plugin.protoc;
+
+import org.apache.hadoop.maven.plugin.util.Exec;
+import org.apache.hadoop.maven.plugin.util.FileSetUtils;
+import org.apache.maven.model.FileSet;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.CRC32;
+
+/**
+ * Common execution for both the main and test protoc mojos.
+ */
+public class ProtocRunner {
+
+ private final MavenProject project;
+ private final File[] imports;
+ private final File output;
+ private final FileSet source;
+ private final String protocCommand;
+ private final String protocVersion;
+ private final String checksumPath;
+ private final boolean test;
+ private final AbstractMojo mojo;
+
+ @SuppressWarnings("checkstyle:parameternumber")
+ public ProtocRunner(final MavenProject project, final File[] imports,
+ final File output, final FileSet source, final String protocCommand,
+ final String protocVersion, final String checksumPath,
+ final AbstractMojo mojo, final boolean test) {
+ this.project = project;
+ this.imports = Arrays.copyOf(imports, imports.length);
+ this.output = output;
+ this.source = source;
+ this.protocCommand = protocCommand;
+ this.protocVersion = protocVersion;
+ this.checksumPath = checksumPath;
+ this.mojo = mojo;
+ this.test = test;
+ }
+
+ /**
+ * Compares include and source file checksums against previously computed
+ * checksums stored in a json file in the build directory.
+ */
+ public class ChecksumComparator {
+
+ private final Map<String, Long> storedChecksums;
+ private final Map<String, Long> computedChecksums;
+
+ private final File checksumFile;
+
+ ChecksumComparator(String checksumPath) throws IOException {
+ checksumFile = new File(checksumPath);
+ // Read in the checksums
+ if (checksumFile.exists()) {
+ ObjectMapper mapper = new ObjectMapper();
+ storedChecksums = mapper
+ .readValue(checksumFile, new TypeReference<Map<String, Long>>() {
+ });
+ } else {
+ storedChecksums = new HashMap<>(0);
+ }
+ computedChecksums = new HashMap<>();
+ }
+
+ public boolean hasChanged(File file) throws IOException {
+ if (!file.exists()) {
+ throw new FileNotFoundException(
+ "Specified protoc include or source does not exist: " + file);
+ }
+ if (file.isDirectory()) {
+ return hasDirectoryChanged(file);
+ } else if (file.isFile()) {
+ return hasFileChanged(file);
+ } else {
+ throw new IOException("Not a file or directory: " + file);
+ }
+ }
+
+ private boolean hasDirectoryChanged(File directory) throws IOException {
+ File[] listing = directory.listFiles();
+ boolean changed = false;
+ if (listing == null) {
+ // not changed.
+ return false;
+ }
+ // Do not exit early, since we need to compute and save checksums
+ // for each file within the directory.
+ for (File f : listing) {
+ if (f.isDirectory()) {
+ if (hasDirectoryChanged(f)) {
+ changed = true;
+ }
+ } else if (f.isFile()) {
+ if (hasFileChanged(f)) {
+ changed = true;
+ }
+ } else {
+ mojo.getLog().debug("Skipping entry that is not a file or directory: "
+ + f);
+ }
+ }
+ return changed;
+ }
+
+ private boolean hasFileChanged(File file) throws IOException {
+ long computedCsum = computeChecksum(file);
+
+ // Return if the generated csum matches the stored csum
+ Long storedCsum = storedChecksums.get(file.getCanonicalPath());
+ if (storedCsum == null || storedCsum.longValue() != computedCsum) {
+ // It has changed.
+ return true;
+ }
+ return false;
+ }
+
+ private long computeChecksum(File file) throws IOException {
+ // If we've already computed the csum, reuse the computed value
+ final String canonicalPath = file.getCanonicalPath();
+ if (computedChecksums.containsKey(canonicalPath)) {
+ return computedChecksums.get(canonicalPath);
+ }
+ // Compute the csum for the file
+ CRC32 crc = new CRC32();
+ byte[] buffer = new byte[1024*64];
+ try (BufferedInputStream in =
+ new BufferedInputStream(new FileInputStream(file))) {
+ while (true) {
+ int read = in.read(buffer);
+ if (read <= 0) {
+ break;
+ }
+ crc.update(buffer, 0, read);
+ }
+ }
+ // Save it in the generated map and return
+ final long computedCsum = crc.getValue();
+ computedChecksums.put(canonicalPath, computedCsum);
+ return crc.getValue();
+ }
+
+ public void writeChecksums() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ try (BufferedOutputStream out = new BufferedOutputStream(
+ new FileOutputStream(checksumFile))) {
+ mapper.writeValue(out, computedChecksums);
+ mojo.getLog().info("Wrote protoc checksums to file " + checksumFile);
+ }
+ }
+ }
+
+ public void execute() throws MojoExecutionException {
+ try {
+ List<String> command = new ArrayList<String>();
+ command.add(protocCommand);
+ command.add("--version");
+ Exec exec = new Exec(mojo);
+ List<String> out = new ArrayList<String>();
+ if (exec.run(command, out) == 127) {
+ mojo.getLog().error("protoc, not found at: " + protocCommand);
+ throw new MojoExecutionException("protoc failure");
+ } else {
+ if (out.isEmpty()) {
+ mojo.getLog().error("stdout: " + out);
+ throw new MojoExecutionException(
+ "'protoc --version' did not return a version");
+ } else {
+ if (!out.get(0).endsWith(protocVersion)) {
+ throw new MojoExecutionException(
+ "protoc version is '" + out.get(0) + "', expected version is '"
+ + protocVersion + "'");
+ }
+ }
+ }
+ if (!output.mkdirs()) {
+ if (!output.exists()) {
+ throw new MojoExecutionException(
+ "Could not create directory: " + output);
+ }
+ }
+
+ // Whether the import or source protoc files have changed.
+ ChecksumComparator comparator = new ChecksumComparator(checksumPath);
+ boolean importsChanged = false;
+
+ command = new ArrayList<String>();
+ command.add(protocCommand);
+ command.add("--java_out=" + output.getCanonicalPath());
+ if (imports != null) {
+ for (File i : imports) {
+ if (comparator.hasChanged(i)) {
+ importsChanged = true;
+ }
+ command.add("-I" + i.getCanonicalPath());
+ }
+ }
+ // Filter to generate classes for just the changed source files.
+ List<File> changedSources = new ArrayList<>();
+ boolean sourcesChanged = false;
+ for (File f : FileSetUtils.convertFileSetToFiles(source)) {
+ // Need to recompile if the source has changed, or if any import has
+ // changed.
+ if (comparator.hasChanged(f) || importsChanged) {
+ sourcesChanged = true;
+ changedSources.add(f);
+ command.add(f.getCanonicalPath());
+ }
+ }
+
+ if (!sourcesChanged && !importsChanged) {
+ mojo.getLog().info("No changes detected in protoc files, skipping "
+ + "generation.");
+ } else {
+ if (mojo.getLog().isDebugEnabled()) {
+ StringBuilder b = new StringBuilder();
+ b.append("Generating classes for the following protoc files: [");
+ String prefix = "";
+ for (File f : changedSources) {
+ b.append(prefix);
+ b.append(f.toString());
+ prefix = ", ";
+ }
+ b.append("]");
+ mojo.getLog().debug(b.toString());
+ }
+
+ exec = new Exec(mojo);
+ out = new ArrayList<String>();
+ List<String> err = new ArrayList<>();
+ if (exec.run(command, out, err) != 0) {
+ mojo.getLog().error("protoc compiler error");
+ for (String s : out) {
+ mojo.getLog().error(s);
+ }
+ for (String s : err) {
+ mojo.getLog().error(s);
+ }
+ throw new MojoExecutionException("protoc failure");
+ }
+ // Write the new checksum file on success.
+ comparator.writeChecksums();
+ }
+ } catch (Throwable ex) {
+ throw new MojoExecutionException(ex.toString(), ex);
+ }
+ if(test) {
+ project.addTestCompileSourceRoot(output.getAbsolutePath());
+ } else {
+ project.addCompileSourceRoot(output.getAbsolutePath());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocTestMojo.java
----------------------------------------------------------------------
diff --git a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocTestMojo.java b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocTestMojo.java
new file mode 100644
index 0000000..c50f6ca
--- /dev/null
+++ b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocTestMojo.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed 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.maven.plugin.protoc;
+
+import org.apache.maven.model.FileSet;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+
+/**
+ * Mojo to generate java test classes from .proto files using protoc.
+ * See package info for examples of use in a maven pom.
+ */
+@Mojo(name="test-protoc", defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES)
+public class ProtocTestMojo extends AbstractMojo {
+
+ @Parameter(defaultValue="${project}", readonly=true)
+ private MavenProject project;
+
+ @Parameter
+ private File[] imports;
+
+ @Parameter(defaultValue=
+ "${project.build.directory}/generated-test-sources/java")
+ private File output;
+
+ @Parameter(required=true)
+ private FileSet source;
+
+ @Parameter(defaultValue="protoc")
+ private String protocCommand;
+
+ @Parameter(required=true)
+ private String protocVersion;
+
+ @Parameter(defaultValue =
+ "${project.build.directory}/hadoop-maven-plugins-protoc-checksums.json")
+ private String checksumPath;
+
+ public void execute() throws MojoExecutionException {
+ final ProtocRunner protoc = new ProtocRunner(project, imports, output,
+ source, protocCommand, protocVersion, checksumPath, this, true);
+ protoc.execute();
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/package-info.java
----------------------------------------------------------------------
diff --git a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/package-info.java b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/package-info.java
new file mode 100644
index 0000000..c4c30ce
--- /dev/null
+++ b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/package-info.java
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+/**
+ * <p>Plugins to generate Java files based on protocol buffers with the protoc
+ * command.
+ *
+ * <p>For generated files intended for primary build artifacts use like:
+ * <pre>
+ * <plugins>
+ * ... SNIP ...
+ * <plugin>
+ * <groupId>org.apache.hadoop</groupId>
+ * <artifactId>hadoop-maven-plugins</artifactId>
+ * <executions>
+ * ... SNIP ...
+ * <execution>
+ * <id>compile-protoc</id>
+ * <goals>
+ * <goal>protoc</goal>
+ * </goals>
+ * <configuration>
+ * <protocVersion>${protobuf.version}</protocVersion>
+ * <protocCommand>${protoc.path}</protocCommand>
+ * <imports>
+ * <param>${basedir}/src/main/proto</param>
+ * </imports>
+ * <source>
+ * <directory>${basedir}/src/main/proto</directory>
+ * <includes>
+ * <include>HAServiceProtocol.proto</include>
+ * ... SNIP ...
+ * <include>RefreshCallQueueProtocol.proto</include>
+ * <include>GenericRefreshProtocol.proto</include>
+ * </includes>
+ * </source>
+ * </configuration>
+ * </execution>
+ * ... SNIP ...
+ * </executions>
+ * ... SNIP ...
+ * </plugin>
+ * </plugins>
+ * </pre>
+ *
+ * For generated files intended only for test, use like:
+ * <pre>
+ * <plugins>
+ * ... SNIP ...
+ * <plugin>
+ * <groupId>org.apache.hadoop</groupId>
+ * <artifactId>hadoop-maven-plugins</artifactId>
+ * <executions>
+ * ... SNIP ...
+ * <execution>
+ * <id>compile-test-protoc</id>
+ * <goals>
+ * <goal>test-protoc</goal>
+ * </goals>
+ * <configuration>
+ * <protocVersion>${protobuf.version}</protocVersion>
+ * <protocCommand>${protoc.path}</protocCommand>
+ * <imports>
+ * <param>${basedir}/src/test/proto</param>
+ * </imports>
+ * <source>
+ * <directory>${basedir}/src/test/proto</directory>
+ * <includes>
+ * <include>test.proto</include>
+ * <include>test_rpc_service.proto</include>
+ * </includes>
+ * </source>
+ * </configuration>
+ * </execution>
+ * ... SNIP ...
+ * </executions>
+ * ... SNIP ...
+ * </plugin>
+ * </plugins>
+ * </pre>
+ *
+ */
+package org.apache.hadoop.maven.plugin.protoc;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
index 52e276b..71014e4 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
@@ -100,7 +100,6 @@
<executions>
<execution>
<id>compile-protoc</id>
- <phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
@@ -128,7 +127,6 @@
<include>server/SCM_Admin_protocol.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml
index 668c50d..a53ec57 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml
@@ -154,7 +154,6 @@
<executions>
<execution>
<id>compile-protoc</id>
- <phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
@@ -172,7 +171,6 @@
<include>test_amrm_token.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml
index b2d3f32..f55c488 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml
@@ -262,7 +262,6 @@
</execution>
<execution>
<id>compile-protoc</id>
- <phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
@@ -280,7 +279,6 @@
<include>yarn_security_token.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
<execution>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml
index 1474c19..15f6511 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml
@@ -195,7 +195,6 @@
<executions>
<execution>
<id>compile-protoc</id>
- <phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
@@ -215,7 +214,6 @@
<include>yarn_server_timelineserver_recovery.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/pom.xml
index b9e10ee..ee892d1 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/pom.xml
@@ -129,7 +129,6 @@
<executions>
<execution>
<id>compile-protoc</id>
- <phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
@@ -153,7 +152,6 @@
<include>collectornodemanager_protocol.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml
index 6fbe39e..acc1d50 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml
@@ -291,7 +291,6 @@
<executions>
<execution>
<id>compile-protoc</id>
- <phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
@@ -311,7 +310,6 @@
<include>LocalizationProtocol.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml
index 8e83a15..0fcd535 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml
@@ -287,7 +287,6 @@
<executions>
<execution>
<id>compile-protoc</id>
- <phase>generate-sources</phase>
<goals>
<goal>protoc</goal>
</goals>
@@ -307,14 +306,12 @@
<include>yarn_server_resourcemanager_recovery.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
<execution>
<id>compile-test-protoc</id>
- <phase>generate-sources</phase>
<goals>
- <goal>protoc</goal>
+ <goal>test-protoc</goal>
</goals>
<configuration>
<protocVersion>${protobuf.version}</protocVersion>
@@ -327,10 +324,9 @@
<source>
<directory>${basedir}/src/test/proto</directory>
<includes>
- <include>test_client_tokens.proto</include>
+ <include>test_client_tokens.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e1c6ef2e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/pom.xml
index 58bed0b..359c706 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/pom.xml
@@ -135,10 +135,9 @@
<artifactId>hadoop-maven-plugins</artifactId>
<executions>
<execution>
- <id>compile-protoc</id>
- <phase>generate-sources</phase>
+ <id>compile-test-protoc</id>
<goals>
- <goal>protoc</goal>
+ <goal>test-protoc</goal>
</goals>
<configuration>
<protocVersion>${protobuf.version}</protocVersion>
@@ -154,7 +153,6 @@
<include>test_token.proto</include>
</includes>
</source>
- <output>${project.build.directory}/generated-sources/java</output>
</configuration>
</execution>
</executions>
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[40/50] [abbrv] hadoop git commit: HDFS-11120. TestEncryptionZones
should waitActive. Contributed by John Zhuge.
Posted by ka...@apache.org.
HDFS-11120. TestEncryptionZones should waitActive. Contributed by John Zhuge.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/71adf44c
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/71adf44c
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/71adf44c
Branch: refs/heads/YARN-4752
Commit: 71adf44c3fc5655700cdc904e61366d438c938eb
Parents: de3a5f8
Author: Xiao Chen <xi...@apache.org>
Authored: Wed Nov 9 17:15:19 2016 -0800
Committer: Xiao Chen <xi...@apache.org>
Committed: Wed Nov 9 17:16:07 2016 -0800
----------------------------------------------------------------------
.../apache/hadoop/hdfs/TestEncryptionZones.java | 61 +++++++++++---------
1 file changed, 34 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/71adf44c/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
index 3a0586e..8605b9e 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
@@ -94,7 +94,9 @@ import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.Timeout;
import org.mockito.Mockito;
import static org.junit.Assert.assertNotNull;
@@ -146,6 +148,9 @@ public class TestEncryptionZones {
new Path(testRootDir.toString(), "test.jks").toUri();
}
+ @Rule
+ public Timeout globalTimeout = new Timeout(120 * 1000);
+
@Before
public void setup() throws Exception {
conf = new HdfsConfiguration();
@@ -160,6 +165,7 @@ public class TestEncryptionZones {
conf.setInt(DFSConfigKeys.DFS_NAMENODE_LIST_ENCRYPTION_ZONES_NUM_RESPONSES,
2);
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
+ cluster.waitActive();
Logger.getLogger(EncryptionZoneManager.class).setLevel(Level.TRACE);
fs = cluster.getFileSystem();
fsWrapper = new FileSystemTestWrapper(fs);
@@ -231,7 +237,7 @@ public class TestEncryptionZones {
* with sticky bits.
* @throws Exception
*/
- @Test(timeout = 60000)
+ @Test
public void testTrashStickyBit() throws Exception {
// create an EZ /zones/zone1, make it world writable.
final Path zoneParent = new Path("/zones");
@@ -294,7 +300,7 @@ public class TestEncryptionZones {
* with sticky bits.
* @throws Exception
*/
- @Test(timeout = 60000)
+ @Test
public void testProvisionTrash() throws Exception {
// create an EZ /zones/zone1
final Path zoneParent = new Path("/zones");
@@ -326,7 +332,8 @@ public class TestEncryptionZones {
assertTrue(trashFileStatus.getPermission().getStickyBit());
}
- @Test(timeout = 60000)
+ // CHECKSTYLE:OFF:MethodLengthCheck
+ @Test
public void testBasicOperations() throws Exception {
int numZones = 0;
@@ -485,8 +492,9 @@ public class TestEncryptionZones {
assertNumZones(numZones);
assertZonePresent(null, nonpersistZone.toString());
}
+ // CHECKSTYLE:ON:MethodLengthCheck
- @Test(timeout = 60000)
+ @Test
public void testBasicOperationsRootDir() throws Exception {
int numZones = 0;
final Path rootDir = new Path("/");
@@ -510,7 +518,7 @@ public class TestEncryptionZones {
/**
* Test listing encryption zones as a non super user.
*/
- @Test(timeout = 60000)
+ @Test
public void testListEncryptionZonesAsNonSuperUser() throws Exception {
final UserGroupInformation user = UserGroupInformation.
@@ -544,7 +552,7 @@ public class TestEncryptionZones {
/**
* Test getEncryptionZoneForPath as a non super user.
*/
- @Test(timeout = 60000)
+ @Test
public void testGetEZAsNonSuperUser() throws Exception {
final UserGroupInformation user = UserGroupInformation.
@@ -688,12 +696,12 @@ public class TestEncryptionZones {
}
}
- @Test(timeout = 60000)
+ @Test
public void testRenameFileSystem() throws Exception {
doRenameEncryptionZone(fsWrapper);
}
- @Test(timeout = 60000)
+ @Test
public void testRenameFileContext() throws Exception {
doRenameEncryptionZone(fcWrapper);
}
@@ -703,7 +711,7 @@ public class TestEncryptionZones {
return blocks.getFileEncryptionInfo();
}
- @Test(timeout = 120000)
+ @Test
public void testReadWrite() throws Exception {
final HdfsAdmin dfsAdmin =
new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);
@@ -759,7 +767,7 @@ public class TestEncryptionZones {
verifyFilesEqual(fs, encFile1, encFile2, len);
}
- @Test(timeout = 120000)
+ @Test
public void testReadWriteUsingWebHdfs() throws Exception {
final HdfsAdmin dfsAdmin =
new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);
@@ -808,7 +816,7 @@ public class TestEncryptionZones {
out.close();
}
- @Test(timeout = 60000)
+ @Test
public void testVersionAndSuiteNegotiation() throws Exception {
final HdfsAdmin dfsAdmin =
new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);
@@ -935,14 +943,13 @@ public class TestEncryptionZones {
}
}
- @Test(timeout = 120000)
+ @Test
public void testCreateEZWithNoProvider() throws Exception {
// Unset the key provider and make sure EZ ops don't work
final Configuration clusterConf = cluster.getConfiguration(0);
clusterConf
.unset(CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH);
cluster.restartNameNode(true);
- cluster.waitActive();
final Path zone1 = new Path("/zone1");
fsWrapper.mkdir(zone1, FsPermission.getDirDefault(), true);
try {
@@ -960,7 +967,7 @@ public class TestEncryptionZones {
assertNumZones(0);
}
- @Test(timeout = 120000)
+ @Test
public void testIsEncryptedMethod() throws Exception {
doTestIsEncryptedMethod(new Path("/"));
doTestIsEncryptedMethod(new Path("/.reserved/raw"));
@@ -1137,7 +1144,7 @@ public class TestEncryptionZones {
* Tests the retry logic in startFile. We release the lock while generating
* an EDEK, so tricky things can happen in the intervening time.
*/
- @Test(timeout = 120000)
+ @Test
public void testStartFileRetry() throws Exception {
final Path zone1 = new Path("/zone1");
final Path file = new Path(zone1, "file1");
@@ -1232,7 +1239,7 @@ public class TestEncryptionZones {
/**
* Tests obtaining delegation token from stored key
*/
- @Test(timeout = 120000)
+ @Test
public void testDelegationToken() throws Exception {
UserGroupInformation.createRemoteUser("JobTracker");
DistributedFileSystem dfs = cluster.getFileSystem();
@@ -1263,7 +1270,7 @@ public class TestEncryptionZones {
/**
* Test running fsck on a system with encryption zones.
*/
- @Test(timeout = 60000)
+ @Test
public void testFsckOnEncryptionZones() throws Exception {
final int len = 8196;
final Path zoneParent = new Path("/zones");
@@ -1294,7 +1301,7 @@ public class TestEncryptionZones {
* Test correctness of successive snapshot creation and deletion
* on a system with encryption zones.
*/
- @Test(timeout = 60000)
+ @Test
public void testSnapshotsOnEncryptionZones() throws Exception {
final String TEST_KEY2 = "testkey2";
DFSTestUtil.createKey(TEST_KEY2, cluster, conf);
@@ -1376,7 +1383,7 @@ public class TestEncryptionZones {
* they function properly when the target is in the same
* or different ez.
*/
- @Test(timeout = 60000)
+ @Test
public void testEncryptionZonesWithSymlinks() throws Exception {
// Verify we can create an encryption zone over both link and target
final int len = 8192;
@@ -1411,7 +1418,7 @@ public class TestEncryptionZones {
fs.delete(target, true);
}
- @Test(timeout = 60000)
+ @Test
public void testConcatFailsInEncryptionZones() throws Exception {
final int len = 8192;
final Path ez = new Path("/ez");
@@ -1436,7 +1443,7 @@ public class TestEncryptionZones {
/**
* Test running the OfflineImageViewer on a system with encryption zones.
*/
- @Test(timeout = 60000)
+ @Test
public void testOfflineImageViewerOnEncryptionZones() throws Exception {
final int len = 8196;
final Path zoneParent = new Path("/zones");
@@ -1467,7 +1474,7 @@ public class TestEncryptionZones {
/**
* Test creating encryption zone on the root path
*/
- @Test(timeout = 60000)
+ @Test
public void testEncryptionZonesOnRootPath() throws Exception {
final int len = 8196;
final Path rootDir = new Path("/");
@@ -1486,7 +1493,7 @@ public class TestEncryptionZones {
DFSTestUtil.verifyFilesNotEqual(fs, zoneFile, rawFile, len);
}
- @Test(timeout = 60000)
+ @Test
public void testEncryptionZonesOnRelativePath() throws Exception {
final int len = 8196;
final Path baseDir = new Path("/somewhere/base");
@@ -1504,7 +1511,7 @@ public class TestEncryptionZones {
.getEncryptionZoneForPath(zoneDir).getPath().toString());
}
- @Test(timeout = 60000)
+ @Test
public void testGetEncryptionZoneOnANonExistentPaths() throws Exception {
final Path ezPath = new Path("/ez");
fs.mkdirs(ezPath);
@@ -1519,7 +1526,7 @@ public class TestEncryptionZones {
assertNull("Expected null for non-existent path not in EZ", ez);
}
- @Test(timeout = 120000)
+ @Test
public void testEncryptionZoneWithTrash() throws Exception {
// Create the encryption zone1
final HdfsAdmin dfsAdmin =
@@ -1582,7 +1589,7 @@ public class TestEncryptionZones {
verifyShellDeleteWithTrash(shell, topEZ);
}
- @Test(timeout = 120000)
+ @Test
public void testRootDirEZTrash() throws Exception {
final HdfsAdmin dfsAdmin =
new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);
@@ -1619,7 +1626,7 @@ public class TestEncryptionZones {
}
- @Test(timeout = 120000)
+ @Test
public void testGetTrashRoots() throws Exception {
final HdfsAdmin dfsAdmin =
new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[04/50] [abbrv] hadoop git commit: HDFS-10970. Update jackson from
1.9.13 to 2.x in hadoop-hdfs.
Posted by ka...@apache.org.
HDFS-10970. Update jackson from 1.9.13 to 2.x in hadoop-hdfs.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/049e7d27
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/049e7d27
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/049e7d27
Branch: refs/heads/YARN-4752
Commit: 049e7d27bea13d4254baccf49401daae820b71df
Parents: 59bc84a
Author: Akira Ajisaka <aa...@apache.org>
Authored: Mon Nov 7 11:16:31 2016 +0900
Committer: Akira Ajisaka <aa...@apache.org>
Committed: Mon Nov 7 11:16:31 2016 +0900
----------------------------------------------------------------------
hadoop-hdfs-project/hadoop-hdfs-client/pom.xml | 4 ++++
.../hdfs/server/datanode/DiskBalancerWorkItem.java | 4 ++--
.../hdfs/server/datanode/DiskBalancerWorkStatus.java | 13 ++++++-------
.../hadoop/hdfs/util/CombinedHostsFileReader.java | 8 ++++----
.../hadoop/hdfs/util/CombinedHostsFileWriter.java | 2 +-
.../org/apache/hadoop/hdfs/web/JsonUtilClient.java | 4 ++--
.../org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java | 4 ++--
.../ConfRefreshTokenBasedAccessTokenProvider.java | 4 ++--
.../oauth2/CredentialBasedAccessTokenProvider.java | 4 ++--
.../org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java | 2 +-
.../TestClientCredentialTimeBasedTokenRefresher.java | 2 +-
.../TestRefreshTokenTimeBasedTokenRefresher.java | 2 +-
hadoop-hdfs-project/hadoop-hdfs-nfs/pom.xml | 10 ----------
hadoop-hdfs-project/hadoop-hdfs/pom.xml | 14 ++++----------
.../server/datanode/fsdataset/impl/FsVolumeImpl.java | 8 ++++----
.../hdfs/server/diskbalancer/command/Command.java | 4 ++--
.../diskbalancer/connectors/JsonNodeConnector.java | 4 ++--
.../diskbalancer/datamodel/DiskBalancerCluster.java | 8 ++++----
.../diskbalancer/datamodel/DiskBalancerVolume.java | 8 ++++----
.../diskbalancer/datamodel/DiskBalancerVolumeSet.java | 6 +++---
.../hdfs/server/diskbalancer/planner/NodePlan.java | 6 +++---
.../hdfs/server/namenode/StartupProgressServlet.java | 6 +++---
.../java/org/apache/hadoop/hdfs/web/JsonUtil.java | 2 +-
.../hdfs/server/datanode/TestDataNodeMXBean.java | 4 ++--
.../hdfs/server/diskbalancer/TestDiskBalancerRPC.java | 2 +-
.../hdfs/server/namenode/TestNameNodeMXBean.java | 2 +-
.../java/org/apache/hadoop/hdfs/web/TestJsonUtil.java | 4 ++--
27 files changed, 64 insertions(+), 77 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml b/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml
index 1e38019..193f423 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml
@@ -111,6 +111,10 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancerWorkItem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancerWorkItem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancerWorkItem.java
index 909bbd5..0cdd107 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancerWorkItem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancerWorkItem.java
@@ -20,11 +20,11 @@
package org.apache.hadoop.hdfs.server.datanode;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
import com.google.common.base.Preconditions;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancerWorkStatus.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancerWorkStatus.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancerWorkStatus.java
index 94bf6a6..452ab27 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancerWorkStatus.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancerWorkStatus.java
@@ -20,19 +20,19 @@
package org.apache.hadoop.hdfs.server.datanode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
+import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.base.Preconditions;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
-import org.codehaus.jackson.map.SerializationConfig;
-
-import static org.codehaus.jackson.map.type.TypeFactory.defaultInstance;
import java.io.IOException;
import java.util.List;
import java.util.LinkedList;
+import static com.fasterxml.jackson.databind.type.TypeFactory.defaultInstance;
+
/**
* Helper class that reports how much work has has been done by the node.
*/
@@ -41,8 +41,7 @@ import java.util.LinkedList;
public class DiskBalancerWorkStatus {
private static final ObjectMapper MAPPER = new ObjectMapper();
private static final ObjectMapper MAPPER_WITH_INDENT_OUTPUT =
- new ObjectMapper().enable(
- SerializationConfig.Feature.INDENT_OUTPUT);
+ new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
private static final ObjectReader READER_WORKSTATUS =
new ObjectMapper().reader(DiskBalancerWorkStatus.class);
private static final ObjectReader READER_WORKENTRY = new ObjectMapper()
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/CombinedHostsFileReader.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/CombinedHostsFileReader.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/CombinedHostsFileReader.java
index 9b23ad0..668d56e 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/CombinedHostsFileReader.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/CombinedHostsFileReader.java
@@ -18,6 +18,9 @@
package org.apache.hadoop.hdfs.util;
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.IOException;
@@ -28,9 +31,6 @@ import java.util.HashSet;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
-import org.codehaus.jackson.JsonFactory;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
import org.apache.hadoop.hdfs.protocol.DatanodeAdminProperties;
/**
@@ -66,7 +66,7 @@ public final class CombinedHostsFileReader {
try (Reader input =
new InputStreamReader(new FileInputStream(hostsFile), "UTF-8")) {
Iterator<DatanodeAdminProperties> iterator =
- READER.readValues(JSON_FACTORY.createJsonParser(input));
+ READER.readValues(JSON_FACTORY.createParser(input));
while (iterator.hasNext()) {
DatanodeAdminProperties properties = iterator.next();
allDNs.add(properties);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/CombinedHostsFileWriter.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/CombinedHostsFileWriter.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/CombinedHostsFileWriter.java
index 7a50d63..d771191 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/CombinedHostsFileWriter.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/CombinedHostsFileWriter.java
@@ -25,9 +25,9 @@ import java.io.Writer;
import java.util.Set;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
-import org.codehaus.jackson.map.ObjectMapper;
import org.apache.hadoop.hdfs.protocol.DatanodeAdminProperties;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
index 4d1d4e8..97cb042 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
@@ -17,6 +17,8 @@
*/
package org.apache.hadoop.hdfs.web;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -48,8 +50,6 @@ import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
import org.apache.hadoop.util.DataChecksum;
import org.apache.hadoop.util.StringUtils;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
index 92d8a13..23804b7 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
@@ -49,6 +49,8 @@ import java.util.StringTokenizer;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.BoundedInputStream;
import org.apache.hadoop.conf.Configuration;
@@ -103,8 +105,6 @@ import org.apache.hadoop.security.token.TokenSelector;
import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSelector;
import org.apache.hadoop.util.Progressable;
import org.apache.hadoop.util.StringUtils;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/oauth2/ConfRefreshTokenBasedAccessTokenProvider.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/oauth2/ConfRefreshTokenBasedAccessTokenProvider.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/oauth2/ConfRefreshTokenBasedAccessTokenProvider.java
index 2d62d10..f90ca19 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/oauth2/ConfRefreshTokenBasedAccessTokenProvider.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/oauth2/ConfRefreshTokenBasedAccessTokenProvider.java
@@ -18,6 +18,8 @@
*/
package org.apache.hadoop.hdfs.web.oauth2;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
@@ -28,8 +30,6 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.web.URLConnectionFactory;
import org.apache.hadoop.util.Timer;
import org.apache.http.HttpStatus;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
import java.io.IOException;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/oauth2/CredentialBasedAccessTokenProvider.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/oauth2/CredentialBasedAccessTokenProvider.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/oauth2/CredentialBasedAccessTokenProvider.java
index 0d9006e..8c0ddd4 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/oauth2/CredentialBasedAccessTokenProvider.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/oauth2/CredentialBasedAccessTokenProvider.java
@@ -18,6 +18,8 @@
*/
package org.apache.hadoop.hdfs.web.oauth2;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
@@ -28,8 +30,6 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.web.URLConnectionFactory;
import org.apache.hadoop.util.Timer;
import org.apache.http.HttpStatus;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
import java.io.IOException;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java
index 032fff0..bd12204 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java
@@ -18,6 +18,7 @@
*/
package org.apache.hadoop.hdfs.web;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
@@ -27,7 +28,6 @@ import org.apache.hadoop.hdfs.web.oauth2.ConfCredentialBasedAccessTokenProvider;
import org.apache.hadoop.hdfs.web.oauth2.CredentialBasedAccessTokenProvider;
import org.apache.hadoop.hdfs.web.oauth2.OAuth2ConnectionConfigurator;
import org.apache.http.HttpStatus;
-import org.codehaus.jackson.map.ObjectMapper;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestClientCredentialTimeBasedTokenRefresher.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestClientCredentialTimeBasedTokenRefresher.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestClientCredentialTimeBasedTokenRefresher.java
index d796753..935cd9e 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestClientCredentialTimeBasedTokenRefresher.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestClientCredentialTimeBasedTokenRefresher.java
@@ -18,11 +18,11 @@
*/
package org.apache.hadoop.hdfs.web.oauth2;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.net.ServerSocketUtil;
import org.apache.hadoop.util.Timer;
import org.apache.http.HttpStatus;
-import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import org.mockserver.client.server.MockServerClient;
import org.mockserver.integration.ClientAndServer;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestRefreshTokenTimeBasedTokenRefresher.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestRefreshTokenTimeBasedTokenRefresher.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestRefreshTokenTimeBasedTokenRefresher.java
index 889ad0e..d9996bc 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestRefreshTokenTimeBasedTokenRefresher.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestRefreshTokenTimeBasedTokenRefresher.java
@@ -18,10 +18,10 @@
*/
package org.apache.hadoop.hdfs.web.oauth2;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.Timer;
import org.apache.http.HttpStatus;
-import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import org.mockserver.client.server.MockServerClient;
import org.mockserver.integration.ClientAndServer;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs-nfs/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-nfs/pom.xml b/hadoop-hdfs-project/hadoop-hdfs-nfs/pom.xml
index 5746814..90236c9 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-nfs/pom.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs-nfs/pom.xml
@@ -165,16 +165,6 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-core-asl</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
<groupId>xmlenc</groupId>
<artifactId>xmlenc</artifactId>
<scope>compile</scope>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/pom.xml b/hadoop-hdfs-project/hadoop-hdfs/pom.xml
index 36db4d8..b3ad50a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/pom.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs/pom.xml
@@ -165,16 +165,6 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-core-asl</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
<groupId>xmlenc</groupId>
<artifactId>xmlenc</artifactId>
<scope>compile</scope>
@@ -227,6 +217,10 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>bcprov-jdk16</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
index 76af724..1627865 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
@@ -77,13 +77,13 @@ import org.apache.hadoop.util.DiskChecker.DiskErrorException;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.util.Timer;
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
-import org.codehaus.jackson.map.ObjectWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
+import com.fasterxml.jackson.databind.ObjectWriter;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/command/Command.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/command/Command.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/command/Command.java
index b4f95bb..cee37e5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/command/Command.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/command/Command.java
@@ -18,6 +18,8 @@
package org.apache.hadoop.hdfs.server.diskbalancer.command;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
@@ -47,8 +49,6 @@ import org.apache.hadoop.hdfs.server.diskbalancer.datamodel.DiskBalancerVolumeSe
import org.apache.hadoop.hdfs.tools.DiskBalancerCLI;
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.security.UserGroupInformation;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/connectors/JsonNodeConnector.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/connectors/JsonNodeConnector.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/connectors/JsonNodeConnector.java
index b47beff..323938a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/connectors/JsonNodeConnector.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/connectors/JsonNodeConnector.java
@@ -17,6 +17,8 @@
package org.apache.hadoop.hdfs.server.diskbalancer.connectors;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
import com.google.common.base.Preconditions;
import org.slf4j.Logger;
@@ -24,8 +26,6 @@ import org.slf4j.LoggerFactory;
import org.apache.hadoop.hdfs.server.diskbalancer.datamodel.DiskBalancerCluster;
import org.apache.hadoop.hdfs.server.diskbalancer.datamodel
.DiskBalancerDataNode;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
import java.io.File;
import java.net.URL;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java
index 8d7fb2d..1b17829 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java
@@ -17,6 +17,10 @@
package org.apache.hadoop.hdfs.server.diskbalancer.datamodel;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
import com.google.common.base.Preconditions;
import org.apache.commons.io.FileUtils;
@@ -27,10 +31,6 @@ import org.apache.hadoop.hdfs.server.diskbalancer.planner.NodePlan;
import org.apache.hadoop.hdfs.server.diskbalancer.planner.Planner;
import org.apache.hadoop.hdfs.server.diskbalancer.planner.PlannerFactory;
import org.apache.hadoop.hdfs.web.JsonUtil;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
import java.io.File;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerVolume.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerVolume.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerVolume.java
index 8b627b0..ccaa7d9 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerVolume.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerVolume.java
@@ -17,13 +17,13 @@
package org.apache.hadoop.hdfs.server.diskbalancer.datamodel;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
import com.google.common.base.Preconditions;
import org.apache.hadoop.hdfs.web.JsonUtil;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerVolumeSet.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerVolumeSet.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerVolumeSet.java
index 97d8e28..5a4eb6d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerVolumeSet.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerVolumeSet.java
@@ -18,12 +18,12 @@
package org.apache.hadoop.hdfs.server.diskbalancer.datamodel;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import java.io.Serializable;
import java.util.ArrayList;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/planner/NodePlan.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/planner/NodePlan.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/planner/NodePlan.java
index 995f4ab..153536a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/planner/NodePlan.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/planner/NodePlan.java
@@ -17,10 +17,10 @@
package org.apache.hadoop.hdfs.server.diskbalancer.planner;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Preconditions;
-import org.codehaus.jackson.annotate.JsonTypeInfo;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.JavaType;
import java.io.IOException;
import java.util.LinkedList;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/StartupProgressServlet.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/StartupProgressServlet.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/StartupProgressServlet.java
index f18fd92..9fb0c62 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/StartupProgressServlet.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/StartupProgressServlet.java
@@ -21,14 +21,14 @@ import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
import org.apache.hadoop.hdfs.server.namenode.startupprogress.Phase;
import org.apache.hadoop.hdfs.server.namenode.startupprogress.StartupProgress;
import org.apache.hadoop.hdfs.server.namenode.startupprogress.StartupProgressView;
import org.apache.hadoop.hdfs.server.namenode.startupprogress.Step;
import org.apache.hadoop.hdfs.server.namenode.startupprogress.StepType;
import org.apache.hadoop.io.IOUtils;
-import org.codehaus.jackson.JsonFactory;
-import org.codehaus.jackson.JsonGenerator;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -61,7 +61,7 @@ public class StartupProgressServlet extends DfsServlet {
StartupProgress prog = NameNodeHttpServer.getStartupProgressFromContext(
getServletContext());
StartupProgressView view = prog.createView();
- JsonGenerator json = new JsonFactory().createJsonGenerator(resp.getWriter());
+ JsonGenerator json = new JsonFactory().createGenerator(resp.getWriter());
try {
json.writeStartObject();
json.writeNumberField(ELAPSED_TIME, view.getElapsedTime());
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java
index 0542f3a..a0dadbd 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/JsonUtil.java
@@ -27,8 +27,8 @@ import org.apache.hadoop.ipc.RemoteException;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
import org.apache.hadoop.util.StringUtils;
-import org.codehaus.jackson.map.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java
index 6933c3e..3474290 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java
@@ -26,6 +26,8 @@ import java.util.Map;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Supplier;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,8 +38,6 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.DFSTestUtil;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.test.GenericTestUtils;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
import org.junit.Assert;
import org.junit.Test;
import org.eclipse.jetty.util.ajax.JSON;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/TestDiskBalancerRPC.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/TestDiskBalancerRPC.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/TestDiskBalancerRPC.java
index 12ce160..368fd89 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/TestDiskBalancerRPC.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/TestDiskBalancerRPC.java
@@ -17,6 +17,7 @@
package org.apache.hadoop.hdfs.server.diskbalancer;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -36,7 +37,6 @@ import org.apache.hadoop.hdfs.server.diskbalancer.datamodel.DiskBalancerCluster;
import org.apache.hadoop.hdfs.server.diskbalancer.datamodel.DiskBalancerDataNode;
import org.apache.hadoop.hdfs.server.diskbalancer.planner.GreedyPlanner;
import org.apache.hadoop.hdfs.server.diskbalancer.planner.NodePlan;
-import org.codehaus.jackson.map.ObjectMapper;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java
index 659a1d2..6221137 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java
@@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hdfs.server.namenode;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Supplier;
import com.google.common.util.concurrent.Uninterruptibles;
import org.apache.commons.io.FileUtils;
@@ -50,7 +51,6 @@ import org.apache.hadoop.io.nativeio.NativeIO.POSIX.NoMlockCacheManipulator;
import org.apache.hadoop.net.ServerSocketUtil;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.VersionInfo;
-import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert;
import org.junit.Test;
import org.eclipse.jetty.util.ajax.JSON;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/049e7d27/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java
index 8947c5b..94cec85 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestJsonUtil.java
@@ -42,11 +42,11 @@ import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
import org.apache.hadoop.util.Time;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ObjectReader;
import org.junit.Assert;
import org.junit.Test;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
import com.google.common.collect.Lists;
public class TestJsonUtil {
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[24/50] [abbrv] hadoop git commit: HADOOP-13782. Make MutableRates
metrics thread-local write, aggregate-on-read. Contributed by Erik Krogen.
Posted by ka...@apache.org.
HADOOP-13782. Make MutableRates metrics thread-local write, aggregate-on-read. Contributed by Erik Krogen.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/77c13c38
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/77c13c38
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/77c13c38
Branch: refs/heads/YARN-4752
Commit: 77c13c385774c51766fe505397fa916754ac08d4
Parents: 2a65eb1
Author: Zhe Zhang <zh...@apache.org>
Authored: Tue Nov 8 16:07:36 2016 -0800
Committer: Zhe Zhang <zh...@apache.org>
Committed: Tue Nov 8 16:07:36 2016 -0800
----------------------------------------------------------------------
.../hadoop/ipc/metrics/RpcDetailedMetrics.java | 4 +-
.../metrics2/lib/MutableMetricsFactory.java | 5 +
.../hadoop/metrics2/lib/MutableRates.java | 6 +
.../lib/MutableRatesWithAggregation.java | 148 +++++++++++++++++++
.../hadoop/metrics2/lib/TestMutableMetrics.java | 148 ++++++++++++++++++-
5 files changed, 306 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/77c13c38/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/metrics/RpcDetailedMetrics.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/metrics/RpcDetailedMetrics.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/metrics/RpcDetailedMetrics.java
index 7414364..ad36742 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/metrics/RpcDetailedMetrics.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/metrics/RpcDetailedMetrics.java
@@ -24,7 +24,7 @@ import org.apache.hadoop.metrics2.annotation.Metric;
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
-import org.apache.hadoop.metrics2.lib.MutableRates;
+import org.apache.hadoop.metrics2.lib.MutableRatesWithAggregation;
/**
* This class is for maintaining RPC method related statistics
@@ -34,7 +34,7 @@ import org.apache.hadoop.metrics2.lib.MutableRates;
@Metrics(about="Per method RPC metrics", context="rpcdetailed")
public class RpcDetailedMetrics {
- @Metric MutableRates rates;
+ @Metric MutableRatesWithAggregation rates;
static final Log LOG = LogFactory.getLog(RpcDetailedMetrics.class);
final MetricsRegistry registry;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/77c13c38/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java
index ae2cb4f..b926c4b 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java
@@ -67,6 +67,11 @@ public class MutableMetricsFactory {
if (cls == MutableRates.class) {
return new MutableRates(registry);
}
+ if (cls == MutableRatesWithAggregation.class) {
+ MutableRatesWithAggregation rates = new MutableRatesWithAggregation();
+ registry.add(info.name(), rates);
+ return rates;
+ }
if (cls == MutableStat.class) {
return registry.newStat(info.name(), info.description(),
annotation.sampleName(), annotation.valueName(),
http://git-wip-us.apache.org/repos/asf/hadoop/blob/77c13c38/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRates.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRates.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRates.java
index 121c292..1074e87 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRates.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRates.java
@@ -33,6 +33,12 @@ import org.apache.hadoop.metrics2.MetricsRecordBuilder;
/**
* Helper class to manage a group of mutable rate metrics
+ *
+ * This class synchronizes all accesses to the metrics it
+ * contains, so it should not be used in situations where
+ * there is high contention on the metrics.
+ * {@link MutableRatesWithAggregation} is preferable in that
+ * situation.
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
http://git-wip-us.apache.org/repos/asf/hadoop/blob/77c13c38/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRatesWithAggregation.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRatesWithAggregation.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRatesWithAggregation.java
new file mode 100644
index 0000000..64eae03
--- /dev/null
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRatesWithAggregation.java
@@ -0,0 +1,148 @@
+/**
+ * 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.metrics2.lib;
+
+import com.google.common.collect.Sets;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedDeque;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.metrics2.MetricsRecordBuilder;
+import org.apache.hadoop.metrics2.util.SampleStat;
+
+
+/**
+ * Helper class to manage a group of mutable rate metrics.
+ *
+ * Each thread will maintain a local rate count, and upon snapshot,
+ * these values will be aggregated into a global rate. This class
+ * should only be used for long running threads, as any metrics
+ * produced between the last snapshot and the death of a thread
+ * will be lost. This allows for significantly higher concurrency
+ * than {@link MutableRates}. See HADOOP-24420.
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Evolving
+public class MutableRatesWithAggregation extends MutableMetric {
+ static final Log LOG = LogFactory.getLog(MutableRatesWithAggregation.class);
+ private final Map<String, MutableRate> globalMetrics = new HashMap<>();
+ private final Set<Class<?>> protocolCache = Sets.newHashSet();
+
+ private final ConcurrentLinkedDeque<WeakReference<ConcurrentMap<String, ThreadSafeSampleStat>>>
+ weakReferenceQueue = new ConcurrentLinkedDeque<>();
+ private final ThreadLocal<ConcurrentMap<String, ThreadSafeSampleStat>>
+ threadLocalMetricsMap = new ThreadLocal<>();
+
+ /**
+ * Initialize the registry with all the methods in a protocol
+ * so they all show up in the first snapshot.
+ * Convenient for JMX implementations.
+ * @param protocol the protocol class
+ */
+ public void init(Class<?> protocol) {
+ if (protocolCache.contains(protocol)) {
+ return;
+ }
+ protocolCache.add(protocol);
+ for (Method method : protocol.getDeclaredMethods()) {
+ String name = method.getName();
+ LOG.debug(name);
+ addMetricIfNotExists(name);
+ }
+ }
+
+ /**
+ * Add a rate sample for a rate metric.
+ * @param name of the rate metric
+ * @param elapsed time
+ */
+ public void add(String name, long elapsed) {
+ ConcurrentMap<String, ThreadSafeSampleStat> localStats =
+ threadLocalMetricsMap.get();
+ if (localStats == null) {
+ localStats = new ConcurrentHashMap<>();
+ threadLocalMetricsMap.set(localStats);
+ weakReferenceQueue.add(new WeakReference<>(localStats));
+ }
+ ThreadSafeSampleStat stat = localStats.get(name);
+ if (stat == null) {
+ stat = new ThreadSafeSampleStat();
+ localStats.put(name, stat);
+ }
+ stat.add(elapsed);
+ }
+
+ @Override
+ public synchronized void snapshot(MetricsRecordBuilder rb, boolean all) {
+ Iterator<WeakReference<ConcurrentMap<String, ThreadSafeSampleStat>>> iter =
+ weakReferenceQueue.iterator();
+ while (iter.hasNext()) {
+ ConcurrentMap<String, ThreadSafeSampleStat> map = iter.next().get();
+ if (map == null) {
+ // Thread has died; clean up its state
+ iter.remove();
+ } else {
+ // Aggregate the thread's local samples into the global metrics
+ for (Map.Entry<String, ThreadSafeSampleStat> entry : map.entrySet()) {
+ String name = entry.getKey();
+ MutableRate globalMetric = addMetricIfNotExists(name);
+ entry.getValue().snapshotInto(globalMetric);
+ }
+ }
+ }
+ for (MutableRate globalMetric : globalMetrics.values()) {
+ globalMetric.snapshot(rb, all);
+ }
+ }
+
+ private synchronized MutableRate addMetricIfNotExists(String name) {
+ MutableRate metric = globalMetrics.get(name);
+ if (metric == null) {
+ metric = new MutableRate(name, name, false);
+ globalMetrics.put(name, metric);
+ }
+ return metric;
+ }
+
+ private static class ThreadSafeSampleStat {
+
+ private SampleStat stat = new SampleStat();
+
+ synchronized void add(double x) {
+ stat.add(x);
+ }
+
+ synchronized void snapshotInto(MutableRate metric) {
+ if (stat.numSamples() > 0) {
+ metric.add(stat.numSamples(), Math.round(stat.total()));
+ stat.reset();
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/77c13c38/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java
index 9161df5..1faa361 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestMutableMetrics.java
@@ -19,9 +19,7 @@
package org.apache.hadoop.metrics2.lib;
import static org.apache.hadoop.metrics2.lib.Interns.info;
-import static org.apache.hadoop.test.MetricsAsserts.assertCounter;
-import static org.apache.hadoop.test.MetricsAsserts.assertGauge;
-import static org.apache.hadoop.test.MetricsAsserts.mockMetricsRecordBuilder;
+import static org.apache.hadoop.test.MetricsAsserts.*;
import static org.mockito.AdditionalMatchers.eq;
import static org.mockito.AdditionalMatchers.geq;
import static org.mockito.AdditionalMatchers.leq;
@@ -29,10 +27,15 @@ import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.junit.Assert.*;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Random;
+import java.util.concurrent.CountDownLatch;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
import org.apache.hadoop.metrics2.util.Quantile;
import org.junit.Test;
@@ -42,6 +45,7 @@ import org.junit.Test;
*/
public class TestMutableMetrics {
+ private static final Log LOG = LogFactory.getLog(TestMutableMetrics.class);
private final double EPSILON = 1e-42;
/**
@@ -129,6 +133,144 @@ public class TestMutableMetrics {
assertGauge("BarAvgTime", 0.0, rb);
}
+ @Test public void testMutableRatesWithAggregationInit() {
+ MetricsRecordBuilder rb = mockMetricsRecordBuilder();
+ MutableRatesWithAggregation rates = new MutableRatesWithAggregation();
+
+ rates.init(TestProtocol.class);
+ rates.snapshot(rb, false);
+
+ assertCounter("FooNumOps", 0L, rb);
+ assertGauge("FooAvgTime", 0.0, rb);
+ assertCounter("BarNumOps", 0L, rb);
+ assertGauge("BarAvgTime", 0.0, rb);
+ }
+
+ @Test public void testMutableRatesWithAggregationSingleThread() {
+ MutableRatesWithAggregation rates = new MutableRatesWithAggregation();
+
+ rates.add("foo", 1);
+ rates.add("bar", 5);
+
+ MetricsRecordBuilder rb = mockMetricsRecordBuilder();
+ rates.snapshot(rb, false);
+ assertCounter("FooNumOps", 1L, rb);
+ assertGauge("FooAvgTime", 1.0, rb);
+ assertCounter("BarNumOps", 1L, rb);
+ assertGauge("BarAvgTime", 5.0, rb);
+
+ rates.add("foo", 1);
+ rates.add("foo", 3);
+ rates.add("bar", 6);
+
+ rb = mockMetricsRecordBuilder();
+ rates.snapshot(rb, false);
+ assertCounter("FooNumOps", 3L, rb);
+ assertGauge("FooAvgTime", 2.0, rb);
+ assertCounter("BarNumOps", 2L, rb);
+ assertGauge("BarAvgTime", 6.0, rb);
+ }
+
+ @Test public void testMutableRatesWithAggregationManyThreads()
+ throws InterruptedException {
+ final MutableRatesWithAggregation rates = new MutableRatesWithAggregation();
+
+ final int n = 10;
+ long[] opCount = new long[n];
+ double[] opTotalTime = new double[n];
+
+ for (int i = 0; i < n; i++) {
+ opCount[i] = 0;
+ opTotalTime[i] = 0;
+ // Initialize so that the getLongCounter() method doesn't complain
+ rates.add("metric" + i, 0);
+ }
+
+ Thread[] threads = new Thread[n];
+ final CountDownLatch firstAddsFinished = new CountDownLatch(threads.length);
+ final CountDownLatch firstSnapshotsFinished = new CountDownLatch(1);
+ final CountDownLatch secondAddsFinished =
+ new CountDownLatch(threads.length);
+ final CountDownLatch secondSnapshotsFinished = new CountDownLatch(1);
+ long seed = new Random().nextLong();
+ LOG.info("Random seed = " + seed);
+ final Random sleepRandom = new Random(seed);
+ for (int tIdx = 0; tIdx < threads.length; tIdx++) {
+ final int threadIdx = tIdx;
+ threads[threadIdx] = new Thread() {
+ @Override
+ public void run() {
+ try {
+ for (int i = 0; i < 1000; i++) {
+ rates.add("metric" + (i % n), (i / n) % 2 == 0 ? 1 : 2);
+ // Sleep so additions can be interleaved with snapshots
+ Thread.sleep(sleepRandom.nextInt(5));
+ }
+ firstAddsFinished.countDown();
+
+ // Make sure all threads stay alive long enough for the first
+ // snapshot to complete; else their metrics may be lost to GC
+ firstSnapshotsFinished.await();
+
+ // Let half the threads continue with more metrics and let half die
+ if (threadIdx % 2 == 0) {
+ for (int i = 0; i < 1000; i++) {
+ rates.add("metric" + (i % n), (i / n) % 2 == 0 ? 1 : 2);
+ }
+ secondAddsFinished.countDown();
+ secondSnapshotsFinished.await();
+ } else {
+ secondAddsFinished.countDown();
+ }
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ }
+ };
+ }
+ for (Thread t : threads) {
+ t.start();
+ }
+ // Snapshot concurrently with additions but aggregate the totals into
+ // opCount / opTotalTime
+ for (int i = 0; i < 100; i++) {
+ snapshotMutableRatesWithAggregation(rates, opCount, opTotalTime);
+ Thread.sleep(sleepRandom.nextInt(20));
+ }
+ firstAddsFinished.await();
+ // Final snapshot to grab any remaining metrics and then verify that
+ // the totals are as expected
+ snapshotMutableRatesWithAggregation(rates, opCount, opTotalTime);
+ for (int i = 0; i < n; i++) {
+ assertEquals("metric" + i + " count", 1001, opCount[i]);
+ assertEquals("metric" + i + " total", 1500, opTotalTime[i], 1.0);
+ }
+ firstSnapshotsFinished.countDown();
+
+ // After half of the threads die, ensure that the remaining ones still
+ // add metrics correctly and that snapshot occurs correctly
+ secondAddsFinished.await();
+ snapshotMutableRatesWithAggregation(rates, opCount, opTotalTime);
+ for (int i = 0; i < n; i++) {
+ assertEquals("metric" + i + " count", 1501, opCount[i]);
+ assertEquals("metric" + i + " total", 2250, opTotalTime[i], 1.0);
+ }
+ secondSnapshotsFinished.countDown();
+ }
+
+ private static void snapshotMutableRatesWithAggregation(
+ MutableRatesWithAggregation rates, long[] opCount, double[] opTotalTime) {
+ MetricsRecordBuilder rb = mockMetricsRecordBuilder();
+ rates.snapshot(rb, true);
+ for (int i = 0; i < opCount.length; i++) {
+ long prevOpCount = opCount[i];
+ long newOpCount = getLongCounter("Metric" + i + "NumOps", rb);
+ opCount[i] = newOpCount;
+ double avgTime = getDoubleGauge("Metric" + i + "AvgTime", rb);
+ opTotalTime[i] += avgTime * (newOpCount - prevOpCount);
+ }
+ }
+
/**
* Tests that when using {@link MutableStat#add(long, long)}, even with a high
* sample count, the mean does not lose accuracy.
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[42/50] [abbrv] hadoop git commit: YARN-5843. Incorrect documentation
for timeline service entityType/events REST end points (Bibin A Chundatt via
Varun Saxena)
Posted by ka...@apache.org.
YARN-5843. Incorrect documentation for timeline service entityType/events REST end points (Bibin A Chundatt via Varun Saxena)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c8bc7a84
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c8bc7a84
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c8bc7a84
Branch: refs/heads/YARN-4752
Commit: c8bc7a84758f360849b96c2e19c8c41b7e9dbb65
Parents: c202a10
Author: Varun Saxena <va...@apache.org>
Authored: Thu Nov 10 12:10:03 2016 +0530
Committer: Varun Saxena <va...@apache.org>
Committed: Thu Nov 10 12:10:03 2016 +0530
----------------------------------------------------------------------
.../src/site/markdown/TimelineServer.md | 21 +++++++++-----------
1 file changed, 9 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/c8bc7a84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/TimelineServer.md
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/TimelineServer.md b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/TimelineServer.md
index f09909b..ae9faae 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/TimelineServer.md
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/TimelineServer.md
@@ -632,7 +632,7 @@ Use the following URI to obtain all the entity objects of a given
### HTTP Operations Supported:
- GET http://localhost:8188/ws/v1/timeline/DS_APP_ATTEMPT
+ GET
### Query Parameters Supported:
@@ -687,7 +687,7 @@ will be returned as a collection of container objects. See also
HTTP Request:
- GET http://<timeline server http address:port>/ws/v1/timeline/{entity-type}
+ GET http://localhost:8188/ws/v1/timeline/DS_APP_ATTEMPT
Response Header:
@@ -795,7 +795,7 @@ String.
HTTP Request:
- GET http://<timeline server http address:port>/ws/v1/timeline/{entity-type}/{entity-id}
+ GET http://localhost:8188/ws/v1/timeline/DS_APP_ATTEMPT/appattempt_1430424020775_0003_000001
Response Header:
@@ -805,8 +805,6 @@ Response Header:
Response Body:
- http://localhost:8188/ws/v1/timeline/DS_APP_ATTEMPT/appattempt_1430424020775_0003_000001
-
{
"events":[
{
@@ -847,15 +845,17 @@ Use the following URI to obtain the event objects of the given `entityType`.
### Query Parameters Supported:
-1. `entityIds` - The entity IDs to retrieve events for.
+1. `entityId` - The entity IDs to retrieve events for. If null, no events will be returned.
+ Multiple entityIds can be given as comma separated values.
1. `limit` - A limit on the number of events to return for each entity. If null,
defaults to 100 events per entity.
1. `windowStart` - If not null, retrieves only events later than the given time
(exclusive)
1. `windowEnd` - If not null, retrieves only events earlier than the given time
(inclusive)
-1. `eventTypes` - Restricts the events returned to the given types. If null,
- events of all types will be returned.
+1. `eventType` - Restricts the events returned to the given types. If null,
+ events of all types will be returned. Multiple eventTypes can be given as
+ comma separated values.
### Elements of the `events` (Timeline Entity List) Object
@@ -882,7 +882,7 @@ Below is the elements of a single event object. Note that `value` of
HTTP Request:
- GET http://<timeline server http address:port>/ws/v1/timeline/entity%20type%200/events
+ GET http://localhost:8188/ws/v1/timeline/DS_APP_ATTEMPT/events?entityId=appattempt_1430424020775_0003_000001
Response Header:
@@ -893,9 +893,6 @@ Response Header:
Response Body:
- GET http://localhost:8188/ws/v1/timeline/DS_APP_ATTEMPT/events?entityId=appattempt_1430424020775_0003_000001
-
-
{
"events": [
{
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[20/50] [abbrv] hadoop git commit: HADOOP-13707. If kerberos is
enabled while HTTP SPNEGO is not configured,
some links cannot be accessed. Contributed by Yuanbo Liu.
Posted by ka...@apache.org.
HADOOP-13707. If kerberos is enabled while HTTP SPNEGO is not configured, some links cannot be accessed. Contributed by Yuanbo Liu.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/dbb133cc
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/dbb133cc
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/dbb133cc
Branch: refs/heads/YARN-4752
Commit: dbb133ccfc00e20622a5dbf7a6e1126fb63d7487
Parents: 026b39a
Author: Brahma Reddy Battula <br...@apache.org>
Authored: Tue Nov 8 20:52:36 2016 +0530
Committer: Brahma Reddy Battula <br...@apache.org>
Committed: Tue Nov 8 20:55:10 2016 +0530
----------------------------------------------------------------------
.../org/apache/hadoop/conf/ConfServlet.java | 8 ++++-
.../hadoop/http/AdminAuthorizedServlet.java | 11 +++++--
.../org/apache/hadoop/http/HttpServer2.java | 32 ++++++++++++++++++--
.../org/apache/hadoop/jmx/JMXJsonServlet.java | 8 ++++-
.../java/org/apache/hadoop/log/LogLevel.java | 11 +++++--
.../org/apache/hadoop/http/TestHttpServer.java | 17 ++++++++++-
6 files changed, 75 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/dbb133cc/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/ConfServlet.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/ConfServlet.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/ConfServlet.java
index cdc9581..cfd7b97 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/ConfServlet.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/ConfServlet.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.conf;
import java.io.IOException;
import java.io.Writer;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -58,7 +59,12 @@ public class ConfServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
+ // If user is a static user and auth Type is null, that means
+ // there is a non-security environment and no need authorization,
+ // otherwise, do the authorization.
+ final ServletContext servletContext = getServletContext();
+ if (!HttpServer2.isStaticUserAndNoneAuthType(servletContext, request) &&
+ !HttpServer2.isInstrumentationAccessAllowed(servletContext,
request, response)) {
return;
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/dbb133cc/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/AdminAuthorizedServlet.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/AdminAuthorizedServlet.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/AdminAuthorizedServlet.java
index a4b05a1..456e89f 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/AdminAuthorizedServlet.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/AdminAuthorizedServlet.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.http;
import java.io.IOException;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -35,9 +36,13 @@ public class AdminAuthorizedServlet extends DefaultServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- // Do the authorization
- if (HttpServer2.hasAdministratorAccess(getServletContext(), request,
+ throws ServletException, IOException {
+ // If user is a static user and auth Type is null, that means
+ // there is a non-security environment and no need authorization,
+ // otherwise, do the authorization.
+ final ServletContext servletContext = getServletContext();
+ if (HttpServer2.isStaticUserAndNoneAuthType(servletContext, request) ||
+ HttpServer2.hasAdministratorAccess(servletContext, request,
response)) {
// Authorization is done. Just call super.
super.doGet(request, response);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/dbb133cc/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java
index 49ec90a..b930f75 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java
@@ -98,6 +98,9 @@ import com.google.common.collect.Lists;
import com.sun.jersey.spi.container.servlet.ServletContainer;
import org.eclipse.jetty.util.ssl.SslContextFactory;
+import static org.apache.hadoop.fs.CommonConfigurationKeys.DEFAULT_HADOOP_HTTP_STATIC_USER;
+import static org.apache.hadoop.fs.CommonConfigurationKeys.HADOOP_HTTP_STATIC_USER;
+
/**
* Create a Jetty embedded server to answer http requests. The primary goal is
* to serve up status information for the server. There are three contexts:
@@ -1112,6 +1115,24 @@ public final class HttpServer2 implements FilterContainer {
}
/**
+ * check whether user is static and unauthenticated, if the
+ * answer is TRUE, that means http sever is in non-security
+ * environment.
+ * @param servletContext the servlet context.
+ * @param request the servlet request.
+ * @return TRUE/FALSE based on the logic described above.
+ */
+ public static boolean isStaticUserAndNoneAuthType(
+ ServletContext servletContext, HttpServletRequest request) {
+ Configuration conf =
+ (Configuration) servletContext.getAttribute(CONF_CONTEXT_ATTRIBUTE);
+ final String authType = request.getAuthType();
+ final String staticUser = conf.get(HADOOP_HTTP_STATIC_USER,
+ DEFAULT_HADOOP_HTTP_STATIC_USER);
+ return authType == null && staticUser.equals(request.getRemoteUser());
+ }
+
+ /**
* Checks the user has privileges to access to instrumentation servlets.
* <p/>
* If <code>hadoop.security.instrumentation.requires.admin</code> is set to FALSE
@@ -1208,9 +1229,14 @@ public final class HttpServer2 implements FilterContainer {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
- request, response)) {
+ throws ServletException, IOException {
+ // If user is a static user and auth Type is null, that means
+ // there is a non-security environment and no need authorization,
+ // otherwise, do the authorization.
+ final ServletContext servletContext = getServletContext();
+ if (!HttpServer2.isStaticUserAndNoneAuthType(servletContext, request) &&
+ !HttpServer2.isInstrumentationAccessAllowed(servletContext,
+ request, response)) {
return;
}
response.setContentType("text/plain; charset=UTF-8");
http://git-wip-us.apache.org/repos/asf/hadoop/blob/dbb133cc/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/JMXJsonServlet.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/JMXJsonServlet.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/JMXJsonServlet.java
index b6ec7bc..05434d6 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/JMXJsonServlet.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/JMXJsonServlet.java
@@ -38,6 +38,7 @@ import javax.management.RuntimeMBeanException;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeType;
import javax.management.openmbean.TabularData;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -168,7 +169,12 @@ public class JMXJsonServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
- if (!isInstrumentationAccessAllowed(request, response)) {
+ // If user is a static user and auth Type is null, that means
+ // there is a non-security environment and no need authorization,
+ // otherwise, do the authorization.
+ final ServletContext servletContext = getServletContext();
+ if (!HttpServer2.isStaticUserAndNoneAuthType(servletContext, request) &&
+ !isInstrumentationAccessAllowed(request, response)) {
return;
}
JsonGenerator jg = null;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/dbb133cc/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java
index 79eae12..8802f83 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java
@@ -27,6 +27,7 @@ import java.util.regex.Pattern;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -323,9 +324,13 @@ public class LogLevel {
public void doGet(HttpServletRequest request, HttpServletResponse response
) throws ServletException, IOException {
- // Do the authorization
- if (!HttpServer2.hasAdministratorAccess(getServletContext(), request,
- response)) {
+ // If user is a static user and auth Type is null, that means
+ // there is a non-security environment and no need authorization,
+ // otherwise, do the authorization.
+ final ServletContext servletContext = getServletContext();
+ if (!HttpServer2.isStaticUserAndNoneAuthType(servletContext, request) &&
+ !HttpServer2.hasAdministratorAccess(servletContext,
+ request, response)) {
return;
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/dbb133cc/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java
index a36e8ca..bac3fbb 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java
@@ -67,6 +67,9 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
+import static org.apache.hadoop.fs.CommonConfigurationKeys.DEFAULT_HADOOP_HTTP_STATIC_USER;
+import static org.apache.hadoop.fs.CommonConfigurationKeys.HADOOP_HTTP_STATIC_USER;
+
public class TestHttpServer extends HttpServerFunctionalTest {
static final Log LOG = LogFactory.getLog(TestHttpServer.class);
private static HttpServer2 server;
@@ -459,7 +462,7 @@ public class TestHttpServer extends HttpServerFunctionalTest {
String serverURL = "http://"
+ NetUtils.getHostPortString(myServer.getConnectorAddress(0)) + "/";
for (String servlet : new String[] { "conf", "logs", "stacks",
- "logLevel" }) {
+ "logLevel", "jmx" }) {
for (String user : new String[] { "userA", "userB", "userC", "userD" }) {
assertEquals(HttpURLConnection.HTTP_OK, getHttpStatusCode(serverURL
+ servlet, user));
@@ -467,6 +470,18 @@ public class TestHttpServer extends HttpServerFunctionalTest {
assertEquals(HttpURLConnection.HTTP_FORBIDDEN, getHttpStatusCode(
serverURL + servlet, "userE"));
}
+
+ // hadoop.security.authorization is set as true while
+ // hadoop.http.authentication.type's value is `simple`(default value)
+ // in this case, static user has administrator access
+ final String staticUser = conf.get(HADOOP_HTTP_STATIC_USER,
+ DEFAULT_HADOOP_HTTP_STATIC_USER);
+ for (String servlet : new String[] {"conf", "logs", "stacks",
+ "logLevel", "jmx"}) {
+ assertEquals(HttpURLConnection.HTTP_OK, getHttpStatusCode(
+ serverURL + servlet, staticUser));
+ }
+
myServer.stop();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[13/50] [abbrv] hadoop git commit: YARN-5716. Add global scheduler
interface definition and update CapacityScheduler to use it. Contributed by
Wangda Tan
Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.java
index a69af6e..fd0c68b 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.java
@@ -47,8 +47,13 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.Activi
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivitiesLogger;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivityState;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.AllocationState;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.SchedulerContainer;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSetUtils;
import org.apache.hadoop.yarn.util.resource.Resources;
import java.io.IOException;
@@ -71,12 +76,10 @@ public class ParentQueue extends AbstractCSQueue {
protected final Set<CSQueue> childQueues;
private final boolean rootQueue;
- final Comparator<CSQueue> nonPartitionedQueueComparator;
- final PartitionedQueueComparator partitionQueueComparator;
- volatile int numApplications;
+ private final Comparator<CSQueue> nonPartitionedQueueComparator;
+ private final PartitionedQueueComparator partitionQueueComparator;
+ private volatile int numApplications;
private final CapacitySchedulerContext scheduler;
- private boolean needToResortQueuesAtNextAllocation = false;
- private int offswitchPerHeartbeatLimit;
private final RecordFactory recordFactory =
RecordFactoryProvider.getRecordFactory(null);
@@ -86,7 +89,7 @@ public class ParentQueue extends AbstractCSQueue {
super(cs, queueName, parent, old);
this.scheduler = cs;
this.nonPartitionedQueueComparator = cs.getNonPartitionedQueueComparator();
- this.partitionQueueComparator = cs.getPartitionedQueueComparator();
+ this.partitionQueueComparator = new PartitionedQueueComparator();
this.rootQueue = (parent == null);
@@ -126,16 +129,12 @@ public class ParentQueue extends AbstractCSQueue {
}
}
- offswitchPerHeartbeatLimit =
- csContext.getConfiguration().getOffSwitchPerHeartbeatLimit();
-
LOG.info(queueName + ", capacity=" + this.queueCapacities.getCapacity()
+ ", absoluteCapacity=" + this.queueCapacities.getAbsoluteCapacity()
+ ", maxCapacity=" + this.queueCapacities.getMaximumCapacity()
+ ", absoluteMaxCapacity=" + this.queueCapacities
.getAbsoluteMaximumCapacity() + ", state=" + state + ", acls="
+ aclsString + ", labels=" + labelStrBuilder.toString() + "\n"
- + ", offswitchPerHeartbeatLimit = " + getOffSwitchPerHeartbeatLimit()
+ ", reservationsContinueLooking=" + reservationsContinueLooking);
} finally {
writeLock.unlock();
@@ -215,11 +214,6 @@ public class ParentQueue extends AbstractCSQueue {
}
- @Private
- public int getOffSwitchPerHeartbeatLimit() {
- return offswitchPerHeartbeatLimit;
- }
-
private QueueUserACLInfo getUserAclInfo(
UserGroupInformation user) {
try {
@@ -435,156 +429,145 @@ public class ParentQueue extends AbstractCSQueue {
@Override
public CSAssignment assignContainers(Resource clusterResource,
- FiCaSchedulerNode node, ResourceLimits resourceLimits,
- SchedulingMode schedulingMode) {
- int offswitchCount = 0;
- try {
- writeLock.lock();
- // if our queue cannot access this node, just return
- if (schedulingMode == SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY
- && !accessibleToPartition(node.getPartition())) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Skip this queue=" + getQueuePath()
- + ", because it is not able to access partition=" + node
+ PlacementSet<FiCaSchedulerNode> ps, ResourceLimits resourceLimits,
+ SchedulingMode schedulingMode) {
+ FiCaSchedulerNode node = PlacementSetUtils.getSingleNode(ps);
+
+ // if our queue cannot access this node, just return
+ if (schedulingMode == SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY
+ && !accessibleToPartition(ps.getPartition())) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Skip this queue=" + getQueuePath()
+ + ", because it is not able to access partition=" + ps
+ .getPartition());
+ }
+
+ ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
+ getParentName(), getQueueName(), ActivityState.REJECTED,
+ ActivityDiagnosticConstant.NOT_ABLE_TO_ACCESS_PARTITION + node
.getPartition());
- }
+ if (rootQueue) {
+ ActivitiesLogger.NODE.finishSkippedNodeAllocation(activitiesManager,
+ node);
+ }
- ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
- getParentName(), getQueueName(), ActivityState.REJECTED,
- ActivityDiagnosticConstant.NOT_ABLE_TO_ACCESS_PARTITION + node
- .getPartition());
- if (rootQueue) {
- ActivitiesLogger.NODE.finishSkippedNodeAllocation(activitiesManager,
- node);
- }
+ return CSAssignment.NULL_ASSIGNMENT;
+ }
- return CSAssignment.NULL_ASSIGNMENT;
+ // Check if this queue need more resource, simply skip allocation if this
+ // queue doesn't need more resources.
+ if (!super.hasPendingResourceRequest(ps.getPartition(), clusterResource,
+ schedulingMode)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Skip this queue=" + getQueuePath()
+ + ", because it doesn't need more resource, schedulingMode="
+ + schedulingMode.name() + " node-partition=" + ps
+ .getPartition());
}
- // Check if this queue need more resource, simply skip allocation if this
- // queue doesn't need more resources.
- if (!super.hasPendingResourceRequest(node.getPartition(), clusterResource,
- schedulingMode)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Skip this queue=" + getQueuePath()
- + ", because it doesn't need more resource, schedulingMode="
- + schedulingMode.name() + " node-partition=" + node
- .getPartition());
- }
+ ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
+ getParentName(), getQueueName(), ActivityState.SKIPPED,
+ ActivityDiagnosticConstant.QUEUE_DO_NOT_NEED_MORE_RESOURCE);
+ if (rootQueue) {
+ ActivitiesLogger.NODE.finishSkippedNodeAllocation(activitiesManager,
+ node);
+ }
+
+ return CSAssignment.NULL_ASSIGNMENT;
+ }
+
+ CSAssignment assignment = new CSAssignment(Resources.createResource(0, 0),
+ NodeType.NODE_LOCAL);
+
+ while (canAssign(clusterResource, node)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Trying to assign containers to child-queue of "
+ + getQueueName());
+ }
+
+ // Are we over maximum-capacity for this queue?
+ // This will also consider parent's limits and also continuous reservation
+ // looking
+ if (!super.canAssignToThisQueue(clusterResource, ps.getPartition(),
+ resourceLimits, Resources
+ .createResource(getMetrics().getReservedMB(),
+ getMetrics().getReservedVirtualCores()), schedulingMode)) {
ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
getParentName(), getQueueName(), ActivityState.SKIPPED,
- ActivityDiagnosticConstant.QUEUE_DO_NOT_NEED_MORE_RESOURCE);
+ ActivityDiagnosticConstant.QUEUE_MAX_CAPACITY_LIMIT);
if (rootQueue) {
ActivitiesLogger.NODE.finishSkippedNodeAllocation(activitiesManager,
node);
}
- return CSAssignment.NULL_ASSIGNMENT;
+ break;
}
- CSAssignment assignment = new CSAssignment(Resources.createResource(0, 0),
- NodeType.NODE_LOCAL);
+ // Schedule
+ CSAssignment assignedToChild = assignContainersToChildQueues(
+ clusterResource, ps, resourceLimits, schedulingMode);
+ assignment.setType(assignedToChild.getType());
+ assignment.setRequestLocalityType(
+ assignedToChild.getRequestLocalityType());
+ assignment.setExcessReservation(assignedToChild.getExcessReservation());
+ assignment.setContainersToKill(assignedToChild.getContainersToKill());
- while (canAssign(clusterResource, node)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Trying to assign containers to child-queue of "
- + getQueueName());
- }
+ // Done if no child-queue assigned anything
+ if (Resources.greaterThan(resourceCalculator, clusterResource,
+ assignedToChild.getResource(), Resources.none())) {
- // Are we over maximum-capacity for this queue?
- // This will also consider parent's limits and also continuous reservation
- // looking
- if (!super.canAssignToThisQueue(clusterResource, node.getPartition(),
- resourceLimits, Resources
- .createResource(getMetrics().getReservedMB(),
- getMetrics().getReservedVirtualCores()), schedulingMode)) {
-
- ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
- getParentName(), getQueueName(), ActivityState.SKIPPED,
- ActivityDiagnosticConstant.QUEUE_MAX_CAPACITY_LIMIT);
+ ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
+ getParentName(), getQueueName(), ActivityState.ACCEPTED,
+ ActivityDiagnosticConstant.EMPTY);
+
+ boolean isReserved =
+ assignedToChild.getAssignmentInformation().getReservationDetails()
+ != null && !assignedToChild.getAssignmentInformation()
+ .getReservationDetails().isEmpty();
+ if (node != null && !isReserved) {
if (rootQueue) {
- ActivitiesLogger.NODE.finishSkippedNodeAllocation(activitiesManager,
- node);
- }
-
- break;
- }
-
- // Schedule
- CSAssignment assignedToChild = assignContainersToChildQueues(
- clusterResource, node, resourceLimits, schedulingMode);
- assignment.setType(assignedToChild.getType());
-
- // Done if no child-queue assigned anything
- if (Resources.greaterThan(resourceCalculator, clusterResource,
- assignedToChild.getResource(), Resources.none())) {
-
- ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
- getParentName(), getQueueName(), ActivityState.ACCEPTED,
- ActivityDiagnosticConstant.EMPTY);
-
- if (node.getReservedContainer() == null) {
- if (rootQueue) {
- ActivitiesLogger.NODE.finishAllocatedNodeAllocation(
- activitiesManager, node,
- assignedToChild.getAssignmentInformation()
- .getFirstAllocatedOrReservedContainerId(),
- AllocationState.ALLOCATED);
- }
- } else{
- if (rootQueue) {
- ActivitiesLogger.NODE.finishAllocatedNodeAllocation(
- activitiesManager, node,
- assignedToChild.getAssignmentInformation()
- .getFirstAllocatedOrReservedContainerId(),
- AllocationState.RESERVED);
- }
+ ActivitiesLogger.NODE.finishAllocatedNodeAllocation(
+ activitiesManager, node,
+ assignedToChild.getAssignmentInformation()
+ .getFirstAllocatedOrReservedContainerId(),
+ AllocationState.ALLOCATED);
}
-
- // Track resource utilization for the parent-queue
- allocateResource(clusterResource, assignedToChild.getResource(),
- node.getPartition(), assignedToChild.isIncreasedAllocation());
-
- // Track resource utilization in this pass of the scheduler
- Resources.addTo(assignment.getResource(),
- assignedToChild.getResource());
- Resources.addTo(assignment.getAssignmentInformation().getAllocated(),
- assignedToChild.getAssignmentInformation().getAllocated());
- Resources.addTo(assignment.getAssignmentInformation().getReserved(),
- assignedToChild.getAssignmentInformation().getReserved());
- assignment.getAssignmentInformation().incrAllocations(
- assignedToChild.getAssignmentInformation().getNumAllocations());
- assignment.getAssignmentInformation().incrReservations(
- assignedToChild.getAssignmentInformation().getNumReservations());
- assignment.getAssignmentInformation().getAllocationDetails().addAll(
- assignedToChild.getAssignmentInformation()
- .getAllocationDetails());
- assignment.getAssignmentInformation().getReservationDetails().addAll(
- assignedToChild.getAssignmentInformation()
- .getReservationDetails());
- assignment.setIncreasedAllocation(
- assignedToChild.isIncreasedAllocation());
-
- LOG.info("assignedContainer" + " queue=" + getQueueName()
- + " usedCapacity=" + getUsedCapacity() + " absoluteUsedCapacity="
- + getAbsoluteUsedCapacity() + " used=" + queueUsage.getUsed()
- + " cluster=" + clusterResource);
-
} else{
- assignment.setSkippedType(assignedToChild.getSkippedType());
-
- ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
- getParentName(), getQueueName(), ActivityState.SKIPPED,
- ActivityDiagnosticConstant.EMPTY);
if (rootQueue) {
- ActivitiesLogger.NODE.finishSkippedNodeAllocation(activitiesManager,
- node);
+ ActivitiesLogger.NODE.finishAllocatedNodeAllocation(
+ activitiesManager, node,
+ assignedToChild.getAssignmentInformation()
+ .getFirstAllocatedOrReservedContainerId(),
+ AllocationState.RESERVED);
}
-
- break;
}
+ // Track resource utilization in this pass of the scheduler
+ Resources.addTo(assignment.getResource(),
+ assignedToChild.getResource());
+ Resources.addTo(assignment.getAssignmentInformation().getAllocated(),
+ assignedToChild.getAssignmentInformation().getAllocated());
+ Resources.addTo(assignment.getAssignmentInformation().getReserved(),
+ assignedToChild.getAssignmentInformation().getReserved());
+ assignment.getAssignmentInformation().incrAllocations(
+ assignedToChild.getAssignmentInformation().getNumAllocations());
+ assignment.getAssignmentInformation().incrReservations(
+ assignedToChild.getAssignmentInformation().getNumReservations());
+ assignment.getAssignmentInformation().getAllocationDetails().addAll(
+ assignedToChild.getAssignmentInformation()
+ .getAllocationDetails());
+ assignment.getAssignmentInformation().getReservationDetails().addAll(
+ assignedToChild.getAssignmentInformation()
+ .getReservationDetails());
+ assignment.setIncreasedAllocation(
+ assignedToChild.isIncreasedAllocation());
+
+ LOG.info("assignedContainer" + " queue=" + getQueueName()
+ + " usedCapacity=" + getUsedCapacity() + " absoluteUsedCapacity="
+ + getAbsoluteUsedCapacity() + " used=" + queueUsage.getUsed()
+ + " cluster=" + clusterResource);
+
if (LOG.isDebugEnabled()) {
LOG.debug(
"ParentQ=" + getQueueName() + " assignedSoFarInThisIteration="
@@ -592,39 +575,47 @@ public class ParentQueue extends AbstractCSQueue {
+ getUsedCapacity() + " absoluteUsedCapacity="
+ getAbsoluteUsedCapacity());
}
+ } else{
+ assignment.setSkippedType(assignedToChild.getSkippedType());
- if (assignment.getType() == NodeType.OFF_SWITCH) {
- offswitchCount++;
+ ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node,
+ getParentName(), getQueueName(), ActivityState.SKIPPED,
+ ActivityDiagnosticConstant.EMPTY);
+ if (rootQueue) {
+ ActivitiesLogger.NODE.finishSkippedNodeAllocation(activitiesManager,
+ node);
}
- // Do not assign more containers if this isn't the root queue
- // or if we've already assigned enough OFF_SWITCH containers in
- // this pass
- if (!rootQueue || offswitchCount >= getOffSwitchPerHeartbeatLimit()) {
- if (LOG.isDebugEnabled()) {
- if (rootQueue && offswitchCount >= getOffSwitchPerHeartbeatLimit()) {
- LOG.debug("Assigned maximum number of off-switch containers: " +
- offswitchCount + ", assignments so far: " + assignment);
- }
- }
- break;
- }
+ break;
}
- return assignment;
- } finally {
- writeLock.unlock();
+ /*
+ * Previously here, we can allocate more than one container for each
+ * allocation under rootQ. Now this logic is not proper any more
+ * in global scheduling world.
+ *
+ * So here do not try to allocate more than one container for each
+ * allocation, let top scheduler make the decision.
+ */
+ break;
}
+
+ return assignment;
}
private boolean canAssign(Resource clusterResource, FiCaSchedulerNode node) {
+ // When node == null means global scheduling is enabled, always return true
+ if (null == node) {
+ return true;
+ }
+
// Two conditions need to meet when trying to allocate:
// 1) Node doesn't have reserved container
// 2) Node's available-resource + killable-resource should > 0
return node.getReservedContainer() == null && Resources.greaterThanOrEqual(
resourceCalculator, clusterResource, Resources
- .add(node.getUnallocatedResource(), node.getTotalKillableResources()),
- minimumAllocation);
+ .add(node.getUnallocatedResource(),
+ node.getTotalKillableResources()), minimumAllocation);
}
private ResourceLimits getResourceLimitsOfChild(CSQueue child,
@@ -662,28 +653,20 @@ public class ParentQueue extends AbstractCSQueue {
return new ResourceLimits(childLimit);
}
-
- private Iterator<CSQueue> sortAndGetChildrenAllocationIterator(FiCaSchedulerNode node) {
- if (node.getPartition().equals(RMNodeLabelsManager.NO_LABEL)) {
- if (needToResortQueuesAtNextAllocation) {
- // If we skipped resort queues last time, we need to re-sort queue
- // before allocation
- List<CSQueue> childrenList = new ArrayList<>(childQueues);
- childQueues.clear();
- childQueues.addAll(childrenList);
- needToResortQueuesAtNextAllocation = false;
- }
- return childQueues.iterator();
- }
- partitionQueueComparator.setPartitionToLookAt(node.getPartition());
+ private Iterator<CSQueue> sortAndGetChildrenAllocationIterator(
+ String partition) {
+ // Previously we keep a sorted list for default partition, it is not good
+ // when multi-threading scheduler is enabled, so to make a simpler code
+ // now re-sort queue every time irrespective to node partition.
+ partitionQueueComparator.setPartitionToLookAt(partition);
List<CSQueue> childrenList = new ArrayList<>(childQueues);
Collections.sort(childrenList, partitionQueueComparator);
return childrenList.iterator();
}
-
- private CSAssignment assignContainersToChildQueues(
- Resource cluster, FiCaSchedulerNode node, ResourceLimits limits,
+
+ private CSAssignment assignContainersToChildQueues(Resource cluster,
+ PlacementSet<FiCaSchedulerNode> ps, ResourceLimits limits,
SchedulingMode schedulingMode) {
CSAssignment assignment = CSAssignment.NULL_ASSIGNMENT;
@@ -691,8 +674,8 @@ public class ParentQueue extends AbstractCSQueue {
printChildQueues();
// Try to assign to most 'under-served' sub-queue
- for (Iterator<CSQueue> iter = sortAndGetChildrenAllocationIterator(node); iter
- .hasNext();) {
+ for (Iterator<CSQueue> iter = sortAndGetChildrenAllocationIterator(
+ ps.getPartition()); iter.hasNext(); ) {
CSQueue childQueue = iter.next();
if(LOG.isDebugEnabled()) {
LOG.debug("Trying to assign to queue: " + childQueue.getQueuePath()
@@ -702,9 +685,9 @@ public class ParentQueue extends AbstractCSQueue {
// Get ResourceLimits of child queue before assign containers
ResourceLimits childLimits =
getResourceLimitsOfChild(childQueue, cluster, parentLimits,
- node.getPartition());
+ ps.getPartition());
- CSAssignment childAssignment = childQueue.assignContainers(cluster, node,
+ CSAssignment childAssignment = childQueue.assignContainers(cluster, ps,
childLimits, schedulingMode);
if(LOG.isDebugEnabled()) {
LOG.debug("Assigned to queue: " + childQueue.getQueuePath() +
@@ -712,22 +695,9 @@ public class ParentQueue extends AbstractCSQueue {
childAssignment.getResource() + ", " + childAssignment.getType());
}
- // If we do assign, remove the queue and re-insert in-order to re-sort
if (Resources.greaterThan(
resourceCalculator, cluster,
childAssignment.getResource(), Resources.none())) {
- // Only update childQueues when we doing non-partitioned node
- // allocation.
- if (RMNodeLabelsManager.NO_LABEL.equals(node.getPartition())) {
- // Remove and re-insert to sort
- iter.remove();
- LOG.info("Re-sorting assigned queue: " + childQueue.getQueuePath()
- + " stats: " + childQueue);
- childQueues.add(childQueue);
- if (LOG.isDebugEnabled()) {
- printChildQueues();
- }
- }
assignment = childAssignment;
break;
} else if (childAssignment.getSkippedType() ==
@@ -770,10 +740,10 @@ public class ParentQueue extends AbstractCSQueue {
+ " child-queues: " + getChildQueuesToPrint());
}
}
-
+
private void internalReleaseResource(Resource clusterResource,
- FiCaSchedulerNode node, Resource releasedResource, boolean changeResource,
- CSQueue completedChildQueue, boolean sortQueues) {
+ FiCaSchedulerNode node, Resource releasedResource,
+ boolean changeResource) {
try {
writeLock.lock();
super.releaseResource(clusterResource, releasedResource,
@@ -784,29 +754,6 @@ public class ParentQueue extends AbstractCSQueue {
"completedContainer " + this + ", cluster=" + clusterResource);
}
- // Note that this is using an iterator on the childQueues so this can't
- // be called if already within an iterator for the childQueues. Like
- // from assignContainersToChildQueues.
- if (sortQueues) {
- // reinsert the updated queue
- for (Iterator<CSQueue> iter = childQueues.iterator();
- iter.hasNext(); ) {
- CSQueue csqueue = iter.next();
- if (csqueue.equals(completedChildQueue)) {
- iter.remove();
- if (LOG.isDebugEnabled()) {
- LOG.debug("Re-sorting completed queue: " + csqueue);
- }
- childQueues.add(csqueue);
- break;
- }
- }
- }
-
- // If we skipped sort queue this time, we need to resort queues to make
- // sure we allocate from least usage (or order defined by queue policy)
- // queues.
- needToResortQueuesAtNextAllocation = !sortQueues;
} finally {
writeLock.unlock();
}
@@ -821,8 +768,7 @@ public class ParentQueue extends AbstractCSQueue {
Resources.negate(decreaseRequest.getDeltaCapacity());
internalReleaseResource(clusterResource,
- csContext.getNode(decreaseRequest.getNodeId()), absDeltaCapacity, false,
- null, false);
+ csContext.getNode(decreaseRequest.getNodeId()), absDeltaCapacity, false);
// Inform the parent
if (parent != null) {
@@ -835,7 +781,7 @@ public class ParentQueue extends AbstractCSQueue {
FiCaSchedulerApp app, FiCaSchedulerNode node, RMContainer rmContainer) {
if (app != null) {
internalReleaseResource(clusterResource, node,
- rmContainer.getReservedResource(), false, null, false);
+ rmContainer.getReservedResource(), false);
// Inform the parent
if (parent != null) {
@@ -853,8 +799,7 @@ public class ParentQueue extends AbstractCSQueue {
boolean sortQueues) {
if (application != null) {
internalReleaseResource(clusterResource, node,
- rmContainer.getContainer().getResource(), false, completedChildQueue,
- sortQueues);
+ rmContainer.getContainer().getResource(), false);
// Inform the parent
if (parent != null) {
@@ -1062,4 +1007,37 @@ public class ParentQueue extends AbstractCSQueue {
}
}
}
+
+ public void apply(Resource cluster,
+ ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> request) {
+ if (request.anythingAllocatedOrReserved()) {
+ ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode>
+ allocation = request.getFirstAllocatedOrReservedContainer();
+ SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode>
+ schedulerContainer = allocation.getAllocatedOrReservedContainer();
+
+ // Do not modify queue when allocation from reserved container
+ if (allocation.getAllocateFromReservedContainer() == null) {
+ try {
+ writeLock.lock();
+ // Book-keeping
+ // Note: Update headroom to account for current allocation too...
+ allocateResource(cluster, allocation.getAllocatedOrReservedResource(),
+ schedulerContainer.getNodePartition(),
+ allocation.isIncreasedAllocation());
+
+ LOG.info("assignedContainer" + " queue=" + getQueueName()
+ + " usedCapacity=" + getUsedCapacity() + " absoluteUsedCapacity="
+ + getAbsoluteUsedCapacity() + " used=" + queueUsage.getUsed()
+ + " cluster=" + cluster);
+ } finally {
+ writeLock.unlock();
+ }
+ }
+ }
+
+ if (parent != null) {
+ parent.apply(cluster, request);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/AbstractContainerAllocator.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/AbstractContainerAllocator.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/AbstractContainerAllocator.java
index fa13df4..5bb91e2 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/AbstractContainerAllocator.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/AbstractContainerAllocator.java
@@ -33,6 +33,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSAssign
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.SchedulingMode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
import org.apache.hadoop.yarn.util.resource.Resources;
@@ -77,11 +78,13 @@ public abstract class AbstractContainerAllocator {
// Handle excess reservation
assignment.setExcessReservation(result.getContainerToBeUnreserved());
+ assignment.setRequestLocalityType(result.requestLocalityType);
+
// If we allocated something
if (Resources.greaterThan(rc, clusterResource,
result.getResourceToBeAllocated(), Resources.none())) {
Resource allocatedResource = result.getResourceToBeAllocated();
- Container updatedContainer = result.getUpdatedContainer();
+ RMContainer updatedContainer = result.getUpdatedContainer();
assignment.setResource(allocatedResource);
assignment.setType(result.getContainerNodeType());
@@ -92,8 +95,7 @@ public abstract class AbstractContainerAllocator {
+ application.getApplicationId() + " resource=" + allocatedResource
+ " queue=" + this.toString() + " cluster=" + clusterResource);
assignment.getAssignmentInformation().addReservationDetails(
- updatedContainer.getId(),
- application.getCSLeafQueue().getQueuePath());
+ updatedContainer, application.getCSLeafQueue().getQueuePath());
assignment.getAssignmentInformation().incrReservations();
Resources.addTo(assignment.getAssignmentInformation().getReserved(),
allocatedResource);
@@ -111,41 +113,37 @@ public abstract class AbstractContainerAllocator {
ActivityState.RESERVED);
ActivitiesLogger.APP.finishAllocatedAppAllocationRecording(
activitiesManager, application.getApplicationId(),
- updatedContainer.getId(), ActivityState.RESERVED,
+ updatedContainer.getContainerId(), ActivityState.RESERVED,
ActivityDiagnosticConstant.EMPTY);
}
} else if (result.getAllocationState() == AllocationState.ALLOCATED){
// This is a new container
// Inform the ordering policy
- LOG.info("assignedContainer" + " application attempt="
- + application.getApplicationAttemptId() + " container="
- + updatedContainer.getId() + " queue=" + this + " clusterResource="
+ LOG.info("assignedContainer" + " application attempt=" + application
+ .getApplicationAttemptId() + " container=" + updatedContainer
+ .getContainerId() + " queue=" + this + " clusterResource="
+ clusterResource + " type=" + assignment.getType());
- application
- .getCSLeafQueue()
- .getOrderingPolicy()
- .containerAllocated(application,
- application.getRMContainer(updatedContainer.getId()));
-
assignment.getAssignmentInformation().addAllocationDetails(
- updatedContainer.getId(),
- application.getCSLeafQueue().getQueuePath());
+ updatedContainer, application.getCSLeafQueue().getQueuePath());
assignment.getAssignmentInformation().incrAllocations();
Resources.addTo(assignment.getAssignmentInformation().getAllocated(),
allocatedResource);
if (rmContainer != null) {
assignment.setFulfilledReservation(true);
+ assignment.setFulfilledReservedContainer(rmContainer);
}
ActivitiesLogger.APP.recordAppActivityWithAllocation(activitiesManager,
node, application, updatedContainer, ActivityState.ALLOCATED);
ActivitiesLogger.APP.finishAllocatedAppAllocationRecording(
activitiesManager, application.getApplicationId(),
- updatedContainer.getId(), ActivityState.ACCEPTED,
+ updatedContainer.getContainerId(), ActivityState.ACCEPTED,
ActivityDiagnosticConstant.EMPTY);
+ // Update unformed resource
+ application.incUnconfirmedRes(allocatedResource);
}
assignment.setContainersToKill(result.getToKillContainers());
@@ -170,8 +168,15 @@ public abstract class AbstractContainerAllocator {
* <li>Do allocation: this will decide/create allocated/reserved
* container, this will also update metrics</li>
* </ul>
+ *
+ * @param clusterResource clusterResource
+ * @param ps PlacementSet
+ * @param schedulingMode scheduling mode (exclusive or nonexclusive)
+ * @param resourceLimits resourceLimits
+ * @param reservedContainer reservedContainer
+ * @return CSAssignemnt proposal
*/
public abstract CSAssignment assignContainers(Resource clusterResource,
- FiCaSchedulerNode node, SchedulingMode schedulingMode,
+ PlacementSet<FiCaSchedulerNode> ps, SchedulingMode schedulingMode,
ResourceLimits resourceLimits, RMContainer reservedContainer);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/ContainerAllocation.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/ContainerAllocation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/ContainerAllocation.java
index 8f749f6..f408508 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/ContainerAllocation.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/ContainerAllocation.java
@@ -23,6 +23,7 @@ import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeType;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
import org.apache.hadoop.yarn.util.resource.Resources;
import java.util.List;
@@ -57,8 +58,13 @@ public class ContainerAllocation {
private Resource resourceToBeAllocated = Resources.none();
AllocationState state;
NodeType containerNodeType = NodeType.NODE_LOCAL;
- NodeType requestNodeType = NodeType.NODE_LOCAL;
- Container updatedContainer;
+ NodeType requestLocalityType = null;
+
+ /**
+ * When some (new) container allocated/reserved or some increase container
+ * request allocated/reserved, updatedContainer will be set.
+ */
+ RMContainer updatedContainer;
private List<RMContainer> toKillContainers;
public ContainerAllocation(RMContainer containerToBeUnreserved,
@@ -87,7 +93,7 @@ public class ContainerAllocation {
return containerNodeType;
}
- public Container getUpdatedContainer() {
+ public RMContainer getUpdatedContainer() {
return updatedContainer;
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/ContainerAllocator.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/ContainerAllocator.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/ContainerAllocator.java
index 4eaa24b..57188d8 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/ContainerAllocator.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/ContainerAllocator.java
@@ -28,12 +28,13 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSAssign
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.SchedulingMode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
import org.apache.hadoop.yarn.util.resource.Resources;
public class ContainerAllocator extends AbstractContainerAllocator {
- AbstractContainerAllocator increaseContainerAllocator;
- AbstractContainerAllocator regularContainerAllocator;
+ private AbstractContainerAllocator increaseContainerAllocator;
+ private AbstractContainerAllocator regularContainerAllocator;
public ContainerAllocator(FiCaSchedulerApp application,
ResourceCalculator rc, RMContext rmContext) {
@@ -52,17 +53,17 @@ public class ContainerAllocator extends AbstractContainerAllocator {
@Override
public CSAssignment assignContainers(Resource clusterResource,
- FiCaSchedulerNode node, SchedulingMode schedulingMode,
+ PlacementSet<FiCaSchedulerNode> ps, SchedulingMode schedulingMode,
ResourceLimits resourceLimits, RMContainer reservedContainer) {
if (reservedContainer != null) {
if (reservedContainer.getState() == RMContainerState.RESERVED) {
// It's a regular container
return regularContainerAllocator.assignContainers(clusterResource,
- node, schedulingMode, resourceLimits, reservedContainer);
+ ps, schedulingMode, resourceLimits, reservedContainer);
} else {
// It's a increase container
return increaseContainerAllocator.assignContainers(clusterResource,
- node, schedulingMode, resourceLimits, reservedContainer);
+ ps, schedulingMode, resourceLimits, reservedContainer);
}
} else {
/*
@@ -70,14 +71,14 @@ public class ContainerAllocator extends AbstractContainerAllocator {
* anything, we will try to allocate regular container
*/
CSAssignment assign =
- increaseContainerAllocator.assignContainers(clusterResource, node,
+ increaseContainerAllocator.assignContainers(clusterResource, ps,
schedulingMode, resourceLimits, null);
if (Resources.greaterThan(rc, clusterResource, assign.getResource(),
Resources.none())) {
return assign;
}
- return regularContainerAllocator.assignContainers(clusterResource, node,
+ return regularContainerAllocator.assignContainers(clusterResource, ps,
schedulingMode, resourceLimits, null);
}
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/IncreaseContainerAllocator.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/IncreaseContainerAllocator.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/IncreaseContainerAllocator.java
index 509dfba..74a64c1 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/IncreaseContainerAllocator.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/IncreaseContainerAllocator.java
@@ -18,12 +18,6 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.allocator;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.yarn.api.records.ContainerId;
@@ -36,16 +30,21 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.AppSchedulingInfo
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeType;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedContainerChangeRequest;
-
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerRequestKey;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerRequestKey;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSAssignment;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.SchedulingMode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSetUtils;
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
import org.apache.hadoop.yarn.util.resource.Resources;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
public class IncreaseContainerAllocator extends AbstractContainerAllocator {
private static final Log LOG =
LogFactory.getLog(IncreaseContainerAllocator.class);
@@ -76,7 +75,7 @@ public class IncreaseContainerAllocator extends AbstractContainerAllocator {
request.getDeltaCapacity());
assignment.getAssignmentInformation().incrReservations();
assignment.getAssignmentInformation().addReservationDetails(
- request.getContainerId(), application.getCSLeafQueue().getQueuePath());
+ request.getRMContainer(), application.getCSLeafQueue().getQueuePath());
assignment.setIncreasedAllocation(true);
LOG.info("Reserved increase container request:" + request.toString());
@@ -93,8 +92,12 @@ public class IncreaseContainerAllocator extends AbstractContainerAllocator {
request.getDeltaCapacity());
assignment.getAssignmentInformation().incrAllocations();
assignment.getAssignmentInformation().addAllocationDetails(
- request.getContainerId(), application.getCSLeafQueue().getQueuePath());
+ request.getRMContainer(), application.getCSLeafQueue().getQueuePath());
assignment.setIncreasedAllocation(true);
+
+ if (fromReservation) {
+ assignment.setFulfilledReservedContainer(request.getRMContainer());
+ }
// notify application
application
@@ -114,19 +117,6 @@ public class IncreaseContainerAllocator extends AbstractContainerAllocator {
SchedContainerChangeRequest increaseRequest) {
if (Resources.fitsIn(rc, cluster, increaseRequest.getDeltaCapacity(),
node.getUnallocatedResource())) {
- // OK, we can allocate this increase request
- // Unreserve it first
- application.unreserve(
- increaseRequest.getRMContainer().getAllocatedSchedulerKey(),
- (FiCaSchedulerNode) node, increaseRequest.getRMContainer());
-
- // Notify application
- application.increaseContainer(increaseRequest);
-
- // Notify node
- node.increaseContainer(increaseRequest.getContainerId(),
- increaseRequest.getDeltaCapacity());
-
return createSuccessfullyIncreasedCSAssignment(increaseRequest, true);
} else {
if (LOG.isDebugEnabled()) {
@@ -144,40 +134,26 @@ public class IncreaseContainerAllocator extends AbstractContainerAllocator {
Resource cluster, SchedContainerChangeRequest increaseRequest) {
if (Resources.fitsIn(rc, cluster, increaseRequest.getDeltaCapacity(),
node.getUnallocatedResource())) {
- // Notify node
- node.increaseContainer(increaseRequest.getContainerId(),
- increaseRequest.getDeltaCapacity());
-
- // OK, we can allocate this increase request
- // Notify application
- application.increaseContainer(increaseRequest);
return createSuccessfullyIncreasedCSAssignment(increaseRequest, false);
- } else {
- boolean reservationSucceeded =
- application.reserveIncreasedContainer(
- increaseRequest.getRMContainer().getAllocatedSchedulerKey(),
- node, increaseRequest.getRMContainer(),
- increaseRequest.getDeltaCapacity());
-
- if (reservationSucceeded) {
- // We cannot allocate this container, but since queue capacity /
- // user-limit matches, we can reserve this container on this node.
- return createReservedIncreasedCSAssignment(increaseRequest);
- } else {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Reserve increase request=" + increaseRequest.toString()
- + " failed. Skipping..");
- }
- return CSAssignment.SKIP_ASSIGNMENT;
- }
+ } else{
+ // We cannot allocate this container, but since queue capacity /
+ // user-limit matches, we can reserve this container on this node.
+ return createReservedIncreasedCSAssignment(increaseRequest);
}
}
@Override
public CSAssignment assignContainers(Resource clusterResource,
- FiCaSchedulerNode node, SchedulingMode schedulingMode,
+ PlacementSet<FiCaSchedulerNode> ps, SchedulingMode schedulingMode,
ResourceLimits resourceLimits, RMContainer reservedContainer) {
AppSchedulingInfo sinfo = application.getAppSchedulingInfo();
+ FiCaSchedulerNode node = PlacementSetUtils.getSingleNode(ps);
+
+ if (null == node) {
+ // This is global scheduling enabled
+ // FIXME, support container increase when global scheduling enabled
+ return CSAssignment.SKIP_ASSIGNMENT;
+ }
NodeId nodeId = node.getNodeID();
if (reservedContainer == null) {
@@ -258,8 +234,6 @@ public class IncreaseContainerAllocator extends AbstractContainerAllocator {
}
Iterator<Entry<ContainerId, SchedContainerChangeRequest>> iter =
increaseRequestMap.entrySet().iterator();
- List<SchedContainerChangeRequest> toBeRemovedRequests =
- new ArrayList<>();
while (iter.hasNext()) {
Entry<ContainerId, SchedContainerChangeRequest> entry =
@@ -289,7 +263,7 @@ public class IncreaseContainerAllocator extends AbstractContainerAllocator {
if (LOG.isDebugEnabled()) {
LOG.debug(" Container is not running any more, skip...");
}
- toBeRemovedRequests.add(increaseRequest);
+ application.addToBeRemovedIncreaseRequest(increaseRequest);
continue;
}
@@ -304,7 +278,7 @@ public class IncreaseContainerAllocator extends AbstractContainerAllocator {
LOG.debug(" Target capacity is more than what node can offer,"
+ " node.resource=" + node.getTotalResource());
}
- toBeRemovedRequests.add(increaseRequest);
+ application.addToBeRemovedIncreaseRequest(increaseRequest);
continue;
}
@@ -318,15 +292,6 @@ public class IncreaseContainerAllocator extends AbstractContainerAllocator {
break;
}
}
-
- // Remove invalid in request requests
- if (!toBeRemovedRequests.isEmpty()) {
- for (SchedContainerChangeRequest req : toBeRemovedRequests) {
- sinfo.removeIncreaseRequest(req.getNodeId(),
- req.getRMContainer().getAllocatedSchedulerKey(),
- req.getContainerId());
- }
- }
// We may have allocated something
if (assigned != null && assigned.getSkippedType()
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/RegularContainerAllocator.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/RegularContainerAllocator.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/RegularContainerAllocator.java
index 1a3f71f..3e8282f 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/RegularContainerAllocator.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/RegularContainerAllocator.java
@@ -19,13 +19,13 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.allocator;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.yarn.api.records.Container;
-import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.api.records.Resource;
@@ -34,6 +34,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeType;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppUtils;
@@ -50,6 +51,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSAssign
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.SchedulingMode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSet;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.PlacementSetUtils;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SchedulingPlacementSet;
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
import org.apache.hadoop.yarn.util.resource.Resources;
@@ -71,12 +75,12 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
private boolean checkHeadroom(Resource clusterResource,
ResourceLimits currentResourceLimits, Resource required,
- FiCaSchedulerNode node) {
+ String nodePartition) {
// If headroom + currentReservation < required, we cannot allocate this
// require
Resource resourceCouldBeUnReserved = application.getCurrentReservation();
if (!application.getCSLeafQueue().getReservationContinueLooking()
- || !node.getPartition().equals(RMNodeLabelsManager.NO_LABEL)) {
+ || !nodePartition.equals(RMNodeLabelsManager.NO_LABEL)) {
// If we don't allow reservation continuous looking, OR we're looking at
// non-default node partition, we won't allow to unreserve before
// allocation.
@@ -87,20 +91,17 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
required);
}
-
- private ContainerAllocation preCheckForNewContainer(Resource clusterResource,
- FiCaSchedulerNode node, SchedulingMode schedulingMode,
+ /*
+ * Pre-check if we can allocate a pending resource request
+ * (given schedulerKey) to a given PlacementSet.
+ * We will consider stuffs like exclusivity, pending resource, node partition,
+ * headroom, etc.
+ */
+ private ContainerAllocation preCheckForPlacementSet(Resource clusterResource,
+ PlacementSet<FiCaSchedulerNode> ps, SchedulingMode schedulingMode,
ResourceLimits resourceLimits, SchedulerRequestKey schedulerKey) {
Priority priority = schedulerKey.getPriority();
-
- if (SchedulerAppUtils.isPlaceBlacklisted(application, node, LOG)) {
- application.updateAppSkipNodeDiagnostics(
- CSAMContainerLaunchDiagnosticsConstants.SKIP_AM_ALLOCATION_IN_BLACK_LISTED_NODE);
- ActivitiesLogger.APP.recordSkippedAppActivityWithoutAllocation(
- activitiesManager, node, application, priority,
- ActivityDiagnosticConstant.SKIP_BLACK_LISTED_NODE);
- return ContainerAllocation.APP_SKIPPED;
- }
+ FiCaSchedulerNode node = PlacementSetUtils.getSingleNode(ps);
ResourceRequest anyRequest =
application.getResourceRequest(schedulerKey, ResourceRequest.ANY);
@@ -144,7 +145,7 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
// matches the node's label?
// If not match, jump to next priority.
if (!SchedulerUtils.checkResourceRequestMatchingNodePartition(
- anyRequest.getNodeLabelExpression(), node.getPartition(),
+ anyRequest.getNodeLabelExpression(), ps.getPartition(),
schedulingMode)) {
ActivitiesLogger.APP.recordSkippedAppActivityWithoutAllocation(
activitiesManager, node, application, priority,
@@ -165,7 +166,8 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
}
}
- if (!checkHeadroom(clusterResource, resourceLimits, required, node)) {
+ if (!checkHeadroom(clusterResource, resourceLimits, required,
+ ps.getPartition())) {
if (LOG.isDebugEnabled()) {
LOG.debug("cannot allocate required resource=" + required
+ " because of headroom");
@@ -176,9 +178,6 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
return ContainerAllocation.QUEUE_SKIPPED;
}
- // Inform the application it is about to get a scheduling opportunity
- application.addSchedulingOpportunity(schedulerKey);
-
// Increase missed-non-partitioned-resource-request-opportunity.
// This is to make sure non-partitioned-resource-request will prefer
// to be allocated to non-partitioned nodes
@@ -210,32 +209,43 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
return ContainerAllocation.APP_SKIPPED;
}
}
-
+
return null;
}
- ContainerAllocation preAllocation(Resource clusterResource,
+ private ContainerAllocation checkIfNodeBlackListed(FiCaSchedulerNode node,
+ SchedulerRequestKey schedulerKey) {
+ Priority priority = schedulerKey.getPriority();
+
+ if (SchedulerAppUtils.isPlaceBlacklisted(application, node, LOG)) {
+ application.updateAppSkipNodeDiagnostics(
+ CSAMContainerLaunchDiagnosticsConstants.SKIP_AM_ALLOCATION_IN_BLACK_LISTED_NODE);
+ ActivitiesLogger.APP.recordSkippedAppActivityWithoutAllocation(
+ activitiesManager, node, application, priority,
+ ActivityDiagnosticConstant.SKIP_BLACK_LISTED_NODE);
+ return ContainerAllocation.APP_SKIPPED;
+ }
+
+ return null;
+ }
+
+ ContainerAllocation tryAllocateOnNode(Resource clusterResource,
FiCaSchedulerNode node, SchedulingMode schedulingMode,
ResourceLimits resourceLimits, SchedulerRequestKey schedulerKey,
RMContainer reservedContainer) {
ContainerAllocation result;
- if (null == reservedContainer) {
- // pre-check when allocating new container
- result =
- preCheckForNewContainer(clusterResource, node, schedulingMode,
- resourceLimits, schedulerKey);
- if (null != result) {
- return result;
- }
- } else {
- // pre-check when allocating reserved container
- if (application.getTotalRequiredResources(schedulerKey) == 0) {
- // Release
- return new ContainerAllocation(reservedContainer, null,
- AllocationState.QUEUE_SKIPPED);
- }
+
+ // Sanity checks before assigning to this node
+ result = checkIfNodeBlackListed(node, schedulerKey);
+ if (null != result) {
+ return result;
}
+ // Inform the application it is about to get a scheduling opportunity
+ // TODO, we may need to revisit here to see if we should add scheduling
+ // opportunity here
+ application.addSchedulingOpportunity(schedulerKey);
+
// Try to allocate containers on node
result =
assignContainersOnNode(clusterResource, node, schedulerKey,
@@ -383,20 +393,20 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
Priority priority = schedulerKey.getPriority();
ContainerAllocation allocation;
+ NodeType requestLocalityType = null;
- NodeType requestType = null;
// Data-local
ResourceRequest nodeLocalResourceRequest =
application.getResourceRequest(schedulerKey, node.getNodeName());
if (nodeLocalResourceRequest != null) {
- requestType = NodeType.NODE_LOCAL;
+ requestLocalityType = NodeType.NODE_LOCAL;
allocation =
assignNodeLocalContainers(clusterResource, nodeLocalResourceRequest,
node, schedulerKey, reservedContainer, schedulingMode,
currentResoureLimits);
if (Resources.greaterThan(rc, clusterResource,
allocation.getResourceToBeAllocated(), Resources.none())) {
- allocation.requestNodeType = requestType;
+ allocation.requestLocalityType = requestLocalityType;
return allocation;
}
}
@@ -412,9 +422,9 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
return ContainerAllocation.PRIORITY_SKIPPED;
}
- if (requestType != NodeType.NODE_LOCAL) {
- requestType = NodeType.RACK_LOCAL;
- }
+ requestLocalityType = requestLocalityType == null ?
+ NodeType.RACK_LOCAL :
+ requestLocalityType;
allocation =
assignRackLocalContainers(clusterResource, rackLocalResourceRequest,
@@ -422,7 +432,7 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
currentResoureLimits);
if (Resources.greaterThan(rc, clusterResource,
allocation.getResourceToBeAllocated(), Resources.none())) {
- allocation.requestNodeType = requestType;
+ allocation.requestLocalityType = requestLocalityType;
return allocation;
}
}
@@ -437,22 +447,22 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
ActivityDiagnosticConstant.SKIP_PRIORITY_BECAUSE_OF_RELAX_LOCALITY);
return ContainerAllocation.PRIORITY_SKIPPED;
}
- if (requestType != NodeType.NODE_LOCAL
- && requestType != NodeType.RACK_LOCAL) {
- requestType = NodeType.OFF_SWITCH;
- }
+
+ requestLocalityType = requestLocalityType == null ?
+ NodeType.OFF_SWITCH :
+ requestLocalityType;
allocation =
assignOffSwitchContainers(clusterResource, offSwitchResourceRequest,
node, schedulerKey, reservedContainer, schedulingMode,
currentResoureLimits);
- allocation.requestNodeType = requestType;
-
+
// When a returned allocation is LOCALITY_SKIPPED, since we're in
// off-switch request now, we will skip this app w.r.t priorities
if (allocation.state == AllocationState.LOCALITY_SKIPPED) {
allocation.state = AllocationState.APP_SKIPPED;
}
+ allocation.requestLocalityType = requestLocalityType;
return allocation;
}
@@ -671,33 +681,27 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
private Container createContainer(FiCaSchedulerNode node, Resource capability,
SchedulerRequestKey schedulerKey) {
-
NodeId nodeId = node.getRMNode().getNodeID();
- ContainerId containerId =
- BuilderUtils.newContainerId(application.getApplicationAttemptId(),
- application.getNewContainerId());
// Create the container
- return BuilderUtils.newContainer(containerId, nodeId,
+ // Now set the containerId to null first, because it is possible the
+ // container will be rejected because of concurrent resource allocation.
+ // new containerId will be generated and assigned to the container
+ // after confirmed.
+ return BuilderUtils.newContainer(null, nodeId,
node.getRMNode().getHttpAddress(), capability,
schedulerKey.getPriority(), null,
schedulerKey.getAllocationRequestId());
}
-
+
private ContainerAllocation handleNewContainerAllocation(
ContainerAllocation allocationResult, FiCaSchedulerNode node,
- SchedulerRequestKey schedulerKey, RMContainer reservedContainer,
- Container container) {
- // Handling container allocation
- // Did we previously reserve containers at this 'priority'?
- if (reservedContainer != null) {
- application.unreserve(schedulerKey, node, reservedContainer);
- }
-
+ SchedulerRequestKey schedulerKey, Container container) {
// Inform the application
- RMContainer allocatedContainer =
- application.allocate(allocationResult.containerNodeType, node,
- schedulerKey, lastResourceRequest, container);
+ RMContainer allocatedContainer = application.allocate(node, schedulerKey,
+ lastResourceRequest, container);
+
+ allocationResult.updatedContainer = allocatedContainer;
// Does the application need this resource?
if (allocatedContainer == null) {
@@ -710,13 +714,6 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
ActivityDiagnosticConstant.FAIL_TO_ALLOCATE, ActivityState.REJECTED);
return ret;
}
-
- // Inform the node
- node.allocateContainer(allocatedContainer);
-
- // update locality statistics
- application.incNumAllocatedContainers(allocationResult.containerNodeType,
- allocationResult.requestNodeType);
return allocationResult;
}
@@ -743,14 +740,18 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
if (allocationResult.getAllocationState() == AllocationState.ALLOCATED) {
// When allocating container
- allocationResult =
- handleNewContainerAllocation(allocationResult, node, schedulerKey,
- reservedContainer, container);
+ allocationResult = handleNewContainerAllocation(allocationResult, node,
+ schedulerKey, container);
} else {
// When reserving container
- application.reserve(schedulerKey, node, reservedContainer, container);
+ RMContainer updatedContainer = reservedContainer;
+ if (updatedContainer == null) {
+ updatedContainer = new RMContainerImpl(container,
+ application.getApplicationAttemptId(), node.getNodeID(),
+ application.getAppSchedulingInfo().getUser(), rmContext);
+ }
+ allocationResult.updatedContainer = updatedContainer;
}
- allocationResult.updatedContainer = container;
// Only reset opportunities when we FIRST allocate the container. (IAW, When
// reservedContainer != null, it's not the first time)
@@ -788,16 +789,46 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
}
private ContainerAllocation allocate(Resource clusterResource,
- FiCaSchedulerNode node, SchedulingMode schedulingMode,
+ PlacementSet<FiCaSchedulerNode> ps, SchedulingMode schedulingMode,
ResourceLimits resourceLimits, SchedulerRequestKey schedulerKey,
RMContainer reservedContainer) {
- ContainerAllocation result =
- preAllocation(clusterResource, node, schedulingMode, resourceLimits,
- schedulerKey, reservedContainer);
+ // Do checks before determining which node to allocate
+ // Directly return if this check fails.
+ ContainerAllocation result;
+ if (reservedContainer == null) {
+ result = preCheckForPlacementSet(clusterResource, ps, schedulingMode,
+ resourceLimits, schedulerKey);
+ if (null != result) {
+ return result;
+ }
+ } else {
+ // pre-check when allocating reserved container
+ if (application.getTotalRequiredResources(schedulerKey) == 0) {
+ // Release
+ return new ContainerAllocation(reservedContainer, null,
+ AllocationState.QUEUE_SKIPPED);
+ }
+ }
+
+ SchedulingPlacementSet<FiCaSchedulerNode> schedulingPS =
+ application.getAppSchedulingInfo().getSchedulingPlacementSet(
+ schedulerKey);
+
+ result = ContainerAllocation.PRIORITY_SKIPPED;
- if (AllocationState.ALLOCATED == result.state
- || AllocationState.RESERVED == result.state) {
- result = doAllocation(result, node, schedulerKey, reservedContainer);
+ Iterator<FiCaSchedulerNode> iter = schedulingPS.getPreferredNodeIterator(
+ ps);
+ while (iter.hasNext()) {
+ FiCaSchedulerNode node = iter.next();
+
+ result = tryAllocateOnNode(clusterResource, node, schedulingMode,
+ resourceLimits, schedulerKey, reservedContainer);
+
+ if (AllocationState.ALLOCATED == result.state
+ || AllocationState.RESERVED == result.state) {
+ result = doAllocation(result, node, schedulerKey, reservedContainer);
+ break;
+ }
}
return result;
@@ -805,17 +836,19 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
@Override
public CSAssignment assignContainers(Resource clusterResource,
- FiCaSchedulerNode node, SchedulingMode schedulingMode,
+ PlacementSet<FiCaSchedulerNode> ps, SchedulingMode schedulingMode,
ResourceLimits resourceLimits,
RMContainer reservedContainer) {
+ FiCaSchedulerNode node = PlacementSetUtils.getSingleNode(ps);
+
if (reservedContainer == null) {
// Check if application needs more resource, skip if it doesn't need more.
if (!application.hasPendingResourceRequest(rc,
- node.getPartition(), clusterResource, schedulingMode)) {
+ ps.getPartition(), clusterResource, schedulingMode)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Skip app_attempt=" + application.getApplicationAttemptId()
+ ", because it doesn't need more resource, schedulingMode="
- + schedulingMode.name() + " node-label=" + node.getPartition());
+ + schedulingMode.name() + " node-label=" + ps.getPartition());
}
ActivitiesLogger.APP.recordSkippedAppActivityWithoutAllocation(
activitiesManager, node, application, application.getPriority(),
@@ -826,7 +859,7 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
// Schedule in priority order
for (SchedulerRequestKey schedulerKey : application.getSchedulerKeys()) {
ContainerAllocation result =
- allocate(clusterResource, node, schedulingMode, resourceLimits,
+ allocate(clusterResource, ps, schedulingMode, resourceLimits,
schedulerKey, null);
AllocationState allocationState = result.getAllocationState();
@@ -845,7 +878,7 @@ public class RegularContainerAllocator extends AbstractContainerAllocator {
return CSAssignment.SKIP_ASSIGNMENT;
} else {
ContainerAllocation result =
- allocate(clusterResource, node, schedulingMode, resourceLimits,
+ allocate(clusterResource, ps, schedulingMode, resourceLimits,
reservedContainer.getReservedSchedulerKey(), reservedContainer);
return getCSAssignmentFromAllocateResult(clusterResource, result,
reservedContainer, node);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/AssignmentInformation.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/AssignmentInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/AssignmentInformation.java
index aad3bc7..63d8a89 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/AssignmentInformation.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/AssignmentInformation.java
@@ -38,11 +38,13 @@ public class AssignmentInformation {
}
public static class AssignmentDetails {
+ public RMContainer rmContainer;
public ContainerId containerId;
public String queue;
- public AssignmentDetails(ContainerId containerId, String queue) {
- this.containerId = containerId;
+ public AssignmentDetails(RMContainer rmContainer, String queue) {
+ this.containerId = rmContainer.getContainerId();
+ this.rmContainer = rmContainer;
this.queue = queue;
}
}
@@ -58,7 +60,7 @@ public class AssignmentInformation {
for (Operation op : Operation.values()) {
operationCounts.put(op, 0);
operationResources.put(op, Resource.newInstance(0, 0));
- operationDetails.put(op, new ArrayList<AssignmentDetails>());
+ operationDetails.put(op, new ArrayList<>());
}
}
@@ -98,17 +100,17 @@ public class AssignmentInformation {
return operationResources.get(Operation.RESERVATION);
}
- private void addAssignmentDetails(Operation op, ContainerId containerId,
+ private void addAssignmentDetails(Operation op, RMContainer rmContainer,
String queue) {
- operationDetails.get(op).add(new AssignmentDetails(containerId, queue));
+ operationDetails.get(op).add(new AssignmentDetails(rmContainer, queue));
}
- public void addAllocationDetails(ContainerId containerId, String queue) {
- addAssignmentDetails(Operation.ALLOCATION, containerId, queue);
+ public void addAllocationDetails(RMContainer rmContainer, String queue) {
+ addAssignmentDetails(Operation.ALLOCATION, rmContainer, queue);
}
- public void addReservationDetails(ContainerId containerId, String queue) {
- addAssignmentDetails(Operation.RESERVATION, containerId, queue);
+ public void addReservationDetails(RMContainer rmContainer, String queue) {
+ addAssignmentDetails(Operation.RESERVATION, rmContainer, queue);
}
public List<AssignmentDetails> getAllocationDetails() {
@@ -119,23 +121,31 @@ public class AssignmentInformation {
return operationDetails.get(Operation.RESERVATION);
}
- private ContainerId getFirstContainerIdFromOperation(Operation op) {
+ private RMContainer getFirstRMContainerFromOperation(Operation op) {
if (null != operationDetails.get(op)) {
List<AssignmentDetails> assignDetails =
operationDetails.get(op);
if (!assignDetails.isEmpty()) {
- return assignDetails.get(0).containerId;
+ return assignDetails.get(0).rmContainer;
}
}
return null;
}
+ public RMContainer getFirstAllocatedOrReservedRMContainer() {
+ RMContainer rmContainer;
+ rmContainer = getFirstRMContainerFromOperation(Operation.ALLOCATION);
+ if (null != rmContainer) {
+ return rmContainer;
+ }
+ return getFirstRMContainerFromOperation(Operation.RESERVATION);
+ }
+
public ContainerId getFirstAllocatedOrReservedContainerId() {
- ContainerId containerId;
- containerId = getFirstContainerIdFromOperation(Operation.ALLOCATION);
- if (null != containerId) {
- return containerId;
+ RMContainer rmContainer = getFirstAllocatedOrReservedRMContainer();
+ if (null != rmContainer) {
+ return rmContainer.getContainerId();
}
- return getFirstContainerIdFromOperation(Operation.RESERVATION);
+ return null;
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/ContainerAllocationProposal.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/ContainerAllocationProposal.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/ContainerAllocationProposal.java
new file mode 100644
index 0000000..ac83d6f
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/ContainerAllocationProposal.java
@@ -0,0 +1,111 @@
+/**
+ * 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.scheduler.common;
+
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeType;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.SchedulingMode;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Proposal to allocate/reserve a new container
+ */
+public class ContainerAllocationProposal<A extends SchedulerApplicationAttempt,
+ N extends SchedulerNode> {
+ // Container we allocated or reserved
+ private SchedulerContainer<A, N> allocatedOrReservedContainer;
+
+ // Containers we need to release before allocating or reserving the
+ // new container
+ private List<SchedulerContainer<A, N>> toRelease = Collections.emptyList();
+
+ // When trying to allocate from a reserved container, set this, and this will
+ // not be included by toRelease list
+ private SchedulerContainer<A, N> allocateFromReservedContainer;
+
+ private boolean isIncreasedAllocation;
+
+ private NodeType allocationLocalityType;
+
+ private NodeType requestLocalityType;
+
+ private SchedulingMode schedulingMode;
+
+ private Resource allocatedResource; // newly allocated resource
+
+ public ContainerAllocationProposal(
+ SchedulerContainer<A, N> allocatedOrReservedContainer,
+ List<SchedulerContainer<A, N>> toRelease,
+ SchedulerContainer<A, N> allocateFromReservedContainer,
+ boolean isIncreasedAllocation, NodeType allocationLocalityType,
+ NodeType requestLocalityType, SchedulingMode schedulingMode,
+ Resource allocatedResource) {
+ this.allocatedOrReservedContainer = allocatedOrReservedContainer;
+ if (null != toRelease) {
+ this.toRelease = toRelease;
+ }
+ this.allocateFromReservedContainer = allocateFromReservedContainer;
+ this.isIncreasedAllocation = isIncreasedAllocation;
+ this.allocationLocalityType = allocationLocalityType;
+ this.requestLocalityType = requestLocalityType;
+ this.schedulingMode = schedulingMode;
+ this.allocatedResource = allocatedResource;
+ }
+
+ public SchedulingMode getSchedulingMode() {
+ return schedulingMode;
+ }
+
+ public Resource getAllocatedOrReservedResource() {
+ return allocatedResource;
+ }
+
+ public NodeType getAllocationLocalityType() {
+ return allocationLocalityType;
+ }
+
+ public boolean isIncreasedAllocation() {
+ return isIncreasedAllocation;
+ }
+
+ public SchedulerContainer<A, N> getAllocateFromReservedContainer() {
+ return allocateFromReservedContainer;
+ }
+
+ public SchedulerContainer<A, N> getAllocatedOrReservedContainer() {
+ return allocatedOrReservedContainer;
+ }
+
+ public List<SchedulerContainer<A, N>> getToRelease() {
+ return toRelease;
+ }
+
+ @Override
+ public String toString() {
+ return allocatedOrReservedContainer.toString();
+ }
+
+ public NodeType getRequestLocalityType() {
+ return requestLocalityType;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/ResourceAllocationCommitter.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/ResourceAllocationCommitter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/ResourceAllocationCommitter.java
new file mode 100644
index 0000000..bdea97d
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/ResourceAllocationCommitter.java
@@ -0,0 +1,29 @@
+/**
+ * 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.scheduler.common;
+
+import org.apache.hadoop.yarn.api.records.Resource;
+
+/**
+ * Scheduler should implement this interface if it wants to have multi-threading
+ * plus global scheduling functionality
+ */
+public interface ResourceAllocationCommitter {
+ void tryCommit(Resource cluster, ResourceCommitRequest proposal);
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/de3b4aac/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/ResourceCommitRequest.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/ResourceCommitRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/ResourceCommitRequest.java
new file mode 100644
index 0000000..5aca202
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/ResourceCommitRequest.java
@@ -0,0 +1,164 @@
+/**
+ * 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.scheduler.common;
+
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
+import org.apache.hadoop.yarn.util.resource.Resources;
+
+import java.util.Collections;
+import java.util.List;
+
+public class ResourceCommitRequest<A extends SchedulerApplicationAttempt,
+ N extends SchedulerNode> {
+ // New containers to be allocated
+ private List<ContainerAllocationProposal<A, N>> containersToAllocate =
+ Collections.emptyList();
+
+ // New containers to be released
+ private List<ContainerAllocationProposal<A, N>> containersToReserve =
+ Collections.emptyList();
+
+ // We don't need these containers anymore
+ private List<SchedulerContainer<A, N>> toReleaseContainers =
+ Collections.emptyList();
+
+ private Resource totalAllocatedResource;
+ private Resource totalReservedResource;
+ private Resource totalReleasedResource;
+
+ public ResourceCommitRequest(
+ List<ContainerAllocationProposal<A, N>> containersToAllocate,
+ List<ContainerAllocationProposal<A, N>> containersToReserve,
+ List<SchedulerContainer<A, N>> toReleaseContainers) {
+ if (null != containersToAllocate) {
+ this.containersToAllocate = containersToAllocate;
+ }
+ if (null != containersToReserve) {
+ this.containersToReserve = containersToReserve;
+ }
+ if (null != toReleaseContainers) {
+ this.toReleaseContainers = toReleaseContainers;
+ }
+
+ totalAllocatedResource = Resources.createResource(0);
+ totalReservedResource = Resources.createResource(0);
+
+ /*
+ * For total-release resource, it has two parts:
+ * 1) Unconditional release: for example, an app reserved a container,
+ * but the app doesn't has any pending resource.
+ * 2) Conditional release: for example, reservation continuous looking, or
+ * Lazy preemption -- which we need to kill some resource to allocate
+ * or reserve the new container.
+ *
+ * For the 2nd part, it is inside:
+ * ContainerAllocationProposal#toRelease, which means we will kill/release
+ * these containers to allocate/reserve the given container.
+ *
+ * So we need to account both of conditional/unconditional to-release
+ * containers to the total release-able resource.
+ */
+ totalReleasedResource = Resources.createResource(0);
+
+ for (ContainerAllocationProposal<A,N> c : this.containersToAllocate) {
+ Resources.addTo(totalAllocatedResource,
+ c.getAllocatedOrReservedResource());
+ for (SchedulerContainer<A,N> r : c.getToRelease()) {
+ Resources.addTo(totalReleasedResource,
+ r.getRmContainer().getAllocatedOrReservedResource());
+ }
+ }
+
+ for (ContainerAllocationProposal<A,N> c : this.containersToReserve) {
+ Resources.addTo(totalReservedResource,
+ c.getAllocatedOrReservedResource());
+ for (SchedulerContainer<A,N> r : c.getToRelease()) {
+ Resources.addTo(totalReleasedResource,
+ r.getRmContainer().getAllocatedOrReservedResource());
+ }
+ }
+
+ for (SchedulerContainer<A,N> r : this.toReleaseContainers) {
+ Resources.addTo(totalReleasedResource,
+ r.getRmContainer().getAllocatedOrReservedResource());
+ }
+ }
+
+ public List<ContainerAllocationProposal<A, N>> getContainersToAllocate() {
+ return containersToAllocate;
+ }
+
+ public List<ContainerAllocationProposal<A, N>> getContainersToReserve() {
+ return containersToReserve;
+ }
+
+ public List<SchedulerContainer<A, N>> getContainersToRelease() {
+ return toReleaseContainers;
+ }
+
+ public Resource getTotalAllocatedResource() {
+ return totalAllocatedResource;
+ }
+
+ public Resource getTotalReservedResource() {
+ return totalReservedResource;
+ }
+
+ public Resource getTotalReleasedResource() {
+ return totalReleasedResource;
+ }
+
+ /*
+ * Util functions to make your life easier
+ */
+ public boolean anythingAllocatedOrReserved() {
+ return (!containersToAllocate.isEmpty()) || (!containersToReserve
+ .isEmpty());
+ }
+
+ public ContainerAllocationProposal<A, N> getFirstAllocatedOrReservedContainer() {
+ ContainerAllocationProposal<A, N> c = null;
+ if (!containersToAllocate.isEmpty()) {
+ c = containersToAllocate.get(0);
+ }
+ if (c == null && !containersToReserve.isEmpty()) {
+ c = containersToReserve.get(0);
+ }
+
+ return c;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("New " + getClass().getName() + ":" + "\n");
+ if (null != containersToAllocate && !containersToAllocate.isEmpty()) {
+ sb.append("\t ALLOCATED=" + containersToAllocate.toString());
+ }
+ if (null != containersToReserve && !containersToReserve.isEmpty()) {
+ sb.append("\t RESERVED=" + containersToReserve.toString());
+ }
+ if (null != toReleaseContainers && !toReleaseContainers.isEmpty()) {
+ sb.append("\t RELEASED=" + toReleaseContainers.toString());
+ }
+ return sb.toString();
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[37/50] [abbrv] hadoop git commit: YARN-5611. Provide an API to
update lifetime of an application. Contributed by Rohith Sharma K S
Posted by ka...@apache.org.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/monitor/RMAppLifetimeMonitor.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/monitor/RMAppLifetimeMonitor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/monitor/RMAppLifetimeMonitor.java
index e550c97..d194204 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/monitor/RMAppLifetimeMonitor.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/monitor/RMAppLifetimeMonitor.java
@@ -18,9 +18,8 @@
package org.apache.hadoop.yarn.server.resourcemanager.rmapp.monitor;
-import java.util.EnumSet;
-import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -33,7 +32,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEventType;
-import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
import org.apache.hadoop.yarn.util.AbstractLivelinessMonitor;
import org.apache.hadoop.yarn.util.SystemClock;
@@ -47,12 +45,6 @@ public class RMAppLifetimeMonitor
private static final Log LOG = LogFactory.getLog(RMAppLifetimeMonitor.class);
private RMContext rmContext;
- private Map<RMAppToMonitor, Long> monitoredApps =
- new HashMap<RMAppToMonitor, Long>();
-
- private static final EnumSet<RMAppState> COMPLETED_APP_STATES =
- EnumSet.of(RMAppState.FINISHED, RMAppState.FINISHING, RMAppState.FAILED,
- RMAppState.KILLED, RMAppState.FINAL_SAVING, RMAppState.KILLING);
public RMAppLifetimeMonitor(RMContext rmContext) {
super(RMAppLifetimeMonitor.class.getName(), SystemClock.getInstance());
@@ -61,14 +53,16 @@ public class RMAppLifetimeMonitor
@Override
protected void serviceInit(Configuration conf) throws Exception {
- long monitorInterval = conf.getLong(
- YarnConfiguration.RM_APPLICATION_LIFETIME_MONITOR_INTERVAL_MS,
- YarnConfiguration.DEFAULT_RM_APPLICATION_LIFETIME_MONITOR_INTERVAL_MS);
+ long monitorInterval =
+ conf.getLong(YarnConfiguration.RM_APPLICATION_MONITOR_INTERVAL_MS,
+ YarnConfiguration.DEFAULT_RM_APPLICATION_MONITOR_INTERVAL_MS);
if (monitorInterval <= 0) {
monitorInterval =
- YarnConfiguration.DEFAULT_RM_APPLICATION_LIFETIME_MONITOR_INTERVAL_MS;
+ YarnConfiguration.DEFAULT_RM_APPLICATION_MONITOR_INTERVAL_MS;
}
setMonitorInterval(monitorInterval);
+ setExpireInterval(0); // No need of expire interval for App.
+ setResetTimeOnStart(false); // do not reset expire time on restart
LOG.info("Application lifelime monitor interval set to " + monitorInterval
+ " ms.");
super.serviceInit(conf);
@@ -77,54 +71,42 @@ public class RMAppLifetimeMonitor
@SuppressWarnings("unchecked")
@Override
protected synchronized void expire(RMAppToMonitor monitoredAppKey) {
- Long remove = monitoredApps.remove(monitoredAppKey);
ApplicationId appId = monitoredAppKey.getApplicationId();
RMApp app = rmContext.getRMApps().get(appId);
if (app == null) {
return;
}
- // Don't trigger a KILL event if application is in completed states
- if (!COMPLETED_APP_STATES.contains(app.getState())) {
- String diagnostics =
- "Application killed due to exceeding its lifetime period " + remove
- + " milliseconds";
- rmContext.getDispatcher().getEventHandler()
- .handle(new RMAppEvent(appId, RMAppEventType.KILL, diagnostics));
- } else {
- LOG.info("Application " + appId
- + " is about to complete. So not killing the application.");
- }
+ String diagnostics =
+ "Application killed due to exceeding its lifetime period";
+ rmContext.getDispatcher().getEventHandler()
+ .handle(new RMAppEvent(appId, RMAppEventType.KILL, diagnostics));
}
- public synchronized void registerApp(ApplicationId appId,
- ApplicationTimeoutType timeoutType, long monitorStartTime, long timeout) {
+ public void registerApp(ApplicationId appId,
+ ApplicationTimeoutType timeoutType, long expireTime) {
RMAppToMonitor appToMonitor = new RMAppToMonitor(appId, timeoutType);
- register(appToMonitor, monitorStartTime);
- monitoredApps.putIfAbsent(appToMonitor, timeout);
- }
-
- @Override
- protected synchronized long getExpireInterval(
- RMAppToMonitor monitoredAppKey) {
- return monitoredApps.get(monitoredAppKey);
+ register(appToMonitor, expireTime);
}
- public synchronized void unregisterApp(ApplicationId appId,
+ public void unregisterApp(ApplicationId appId,
ApplicationTimeoutType timeoutType) {
- RMAppToMonitor appToRemove = new RMAppToMonitor(appId, timeoutType);
- unregister(appToRemove);
- monitoredApps.remove(appToRemove);
+ RMAppToMonitor remove = new RMAppToMonitor(appId, timeoutType);
+ unregister(remove);
}
- public synchronized void unregisterApp(ApplicationId appId,
- Set<ApplicationTimeoutType> types) {
- for (ApplicationTimeoutType type : types) {
- unregisterApp(appId, type);
+ public void unregisterApp(ApplicationId appId,
+ Set<ApplicationTimeoutType> timeoutTypes) {
+ for (ApplicationTimeoutType timeoutType : timeoutTypes) {
+ unregisterApp(appId, timeoutType);
}
}
- public synchronized void updateApplicationTimeouts(ApplicationId appId,
+ public void updateApplicationTimeouts(ApplicationId appId,
Map<ApplicationTimeoutType, Long> timeouts) {
- // TODO in YARN-5611
+ for (Entry<ApplicationTimeoutType, Long> entry : timeouts.entrySet()) {
+ ApplicationTimeoutType timeoutType = entry.getKey();
+ RMAppToMonitor update = new RMAppToMonitor(appId, timeoutType);
+ register(update, entry.getValue());
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
index 7e98f10..af51f3c 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
@@ -2418,8 +2418,9 @@ public class CapacityScheduler extends
ApplicationStateData.newInstance(rmApp.getSubmitTime(),
rmApp.getStartTime(), rmApp.getApplicationSubmissionContext(),
rmApp.getUser(), rmApp.getCallerContext());
+ appState.setApplicationTimeouts(rmApp.getApplicationTimeouts());
rmContext.getStateStore().updateApplicationStateSynchronously(appState,
- false);
+ false, null);
// As we use iterator over a TreeSet for OrderingPolicy, once we change
// priority then reinsert back to make order correct.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/proto/yarn_server_resourcemanager_recovery.proto
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/proto/yarn_server_resourcemanager_recovery.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/proto/yarn_server_resourcemanager_recovery.proto
index 6e2398a..4693818 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/proto/yarn_server_resourcemanager_recovery.proto
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/proto/yarn_server_resourcemanager_recovery.proto
@@ -69,6 +69,7 @@ message ApplicationStateDataProto {
optional string diagnostics = 6 [default = "N/A"];
optional int64 finish_time = 7;
optional hadoop.common.RPCCallerContextProto caller_context = 8;
+ repeated ApplicationTimeoutMapProto application_timeouts = 9;
}
message ApplicationAttemptStateDataProto {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java
index 19ee0b1..e5b166d 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java
@@ -30,6 +30,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
@@ -229,6 +230,11 @@ public abstract class MockAsm extends MockApps {
public CallerContext getCallerContext() {
throw new UnsupportedOperationException("Not supported yet.");
}
+
+ @Override
+ public Map<ApplicationTimeoutType, Long> getApplicationTimeouts() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
}
public static RMApp newApplication(int i) {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/MockRMApp.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/MockRMApp.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/MockRMApp.java
index 62a5c52..bbfa60f 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/MockRMApp.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/MockRMApp.java
@@ -29,6 +29,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.LogAggregationStatus;
import org.apache.hadoop.yarn.api.records.NodeId;
@@ -315,4 +316,9 @@ public class MockRMApp implements RMApp {
public void setCollectorAddr(String collectorAddr) {
throw new UnsupportedOperationException("Not supported yet.");
}
+
+ @Override
+ public Map<ApplicationTimeoutType, Long> getApplicationTimeouts() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bcc15c62/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestApplicationLifetimeMonitor.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestApplicationLifetimeMonitor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestApplicationLifetimeMonitor.java
index 3f2db1d..e803a88 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestApplicationLifetimeMonitor.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestApplicationLifetimeMonitor.java
@@ -19,6 +19,7 @@
package org.apache.hadoop.yarn.server.resourcemanager.rmapp;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.Arrays;
@@ -27,11 +28,14 @@ import java.util.Map;
import java.util.Set;
import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerState;
import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus;
import org.apache.hadoop.yarn.server.resourcemanager.MockAM;
import org.apache.hadoop.yarn.server.resourcemanager.MockNM;
@@ -39,8 +43,10 @@ import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
import org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart;
import org.apache.hadoop.yarn.server.resourcemanager.TestWorkPreservingRMRestart;
import org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore;
+import org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerState;
import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeImpl;
+import org.apache.hadoop.yarn.util.Times;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
@@ -60,15 +66,11 @@ public class TestApplicationLifetimeMonitor {
Logger rootLogger = LogManager.getRootLogger();
rootLogger.setLevel(Level.DEBUG);
UserGroupInformation.setConfiguration(conf);
- conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
- conf.setBoolean(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED,
- true);
- conf.set(YarnConfiguration.RM_STORE, MemoryRMStateStore.class.getName());
- conf.setLong(YarnConfiguration.RM_APPLICATION_LIFETIME_MONITOR_INTERVAL_MS,
+ conf.setLong(YarnConfiguration.RM_APPLICATION_MONITOR_INTERVAL_MS,
3000L);
}
- @Test(timeout = 90000)
+ @Test(timeout = 60000)
public void testApplicationLifetimeMonitor() throws Exception {
MockRM rm = null;
try {
@@ -81,22 +83,64 @@ public class TestApplicationLifetimeMonitor {
new HashMap<ApplicationTimeoutType, Long>();
timeouts.put(ApplicationTimeoutType.LIFETIME, 10L);
RMApp app1 = rm.submitApp(1024, appPriority, timeouts);
+
+ // 20L seconds
+ timeouts.put(ApplicationTimeoutType.LIFETIME, 20L);
+ RMApp app2 = rm.submitApp(1024, appPriority, timeouts);
+
nm1.nodeHeartbeat(true);
// Send launch Event
MockAM am1 =
rm.sendAMLaunched(app1.getCurrentAppAttempt().getAppAttemptId());
am1.registerAppAttempt();
rm.waitForState(app1.getApplicationId(), RMAppState.KILLED);
- Assert.assertTrue("Applicaiton killed before lifetime value",
+ Assert.assertTrue("Application killed before lifetime value",
(System.currentTimeMillis() - app1.getSubmitTime()) > 10000);
+
+ Map<ApplicationTimeoutType, String> updateTimeout =
+ new HashMap<ApplicationTimeoutType, String>();
+ long newLifetime = 10L;
+ // update 10L seconds more to timeout
+ updateTimeout.put(ApplicationTimeoutType.LIFETIME,
+ Times.formatISO8601(System.currentTimeMillis() + newLifetime * 1000));
+ UpdateApplicationTimeoutsRequest request =
+ UpdateApplicationTimeoutsRequest.newInstance(app2.getApplicationId(),
+ updateTimeout);
+
+ Map<ApplicationTimeoutType, Long> applicationTimeouts =
+ app2.getApplicationTimeouts();
+ // has old timeout time
+ long beforeUpdate =
+ applicationTimeouts.get(ApplicationTimeoutType.LIFETIME);
+
+ // update app2 lifetime to new time i.e now + timeout
+ rm.getRMContext().getClientRMService().updateApplicationTimeouts(request);
+
+ applicationTimeouts =
+ app2.getApplicationTimeouts();
+ long afterUpdate =
+ applicationTimeouts.get(ApplicationTimeoutType.LIFETIME);
+
+ Assert.assertTrue("Application lifetime value not updated",
+ afterUpdate > beforeUpdate);
+
+ rm.waitForState(app2.getApplicationId(), RMAppState.KILLED);
+ // verify for app killed with updated lifetime
+ Assert.assertTrue("Application killed before lifetime value",
+ app2.getFinishTime() > afterUpdate);
+
} finally {
stopRM(rm);
}
}
- @SuppressWarnings("rawtypes")
@Test(timeout = 180000)
public void testApplicationLifetimeOnRMRestart() throws Exception {
+ conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
+ conf.setBoolean(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED,
+ true);
+ conf.set(YarnConfiguration.RM_STORE, MemoryRMStateStore.class.getName());
+
MemoryRMStateStore memStore = new MemoryRMStateStore();
memStore.init(conf);
MockRM rm1 = new MockRM(conf, memStore);
@@ -115,6 +159,12 @@ public class TestApplicationLifetimeMonitor {
// Re-start RM
MockRM rm2 = new MockRM(conf, memStore);
+
+ // make sure app has been unregistered with old RM else both will trigger
+ // Expire event
+ rm1.getRMContext().getRMAppLifetimeMonitor().unregisterApp(
+ app1.getApplicationId(), ApplicationTimeoutType.LIFETIME);
+
rm2.start();
nm1.setResourceTrackerService(rm2.getResourceTrackerService());
@@ -152,9 +202,87 @@ public class TestApplicationLifetimeMonitor {
// wait for app life time and application to be in killed state.
rm2.waitForState(recoveredApp1.getApplicationId(), RMAppState.KILLED);
- Assert.assertTrue("Applicaiton killed before lifetime value",
- (System.currentTimeMillis()
- - recoveredApp1.getSubmitTime()) > appLifetime);
+ Assert.assertTrue("Application killed before lifetime value",
+ recoveredApp1.getFinishTime() > (recoveredApp1.getSubmitTime()
+ + appLifetime * 1000));
+ }
+
+ @Test(timeout = 60000)
+ public void testUpdateApplicationTimeoutForStateStoreUpdateFail()
+ throws Exception {
+ MockRM rm1 = null;
+ try {
+ conf.set(YarnConfiguration.RM_STORE, MemoryRMStateStore.class.getName());
+
+ MemoryRMStateStore memStore = new MemoryRMStateStore() {
+ private int count = 0;
+
+ @Override
+ public synchronized void updateApplicationStateInternal(
+ ApplicationId appId, ApplicationStateData appState)
+ throws Exception {
+ // fail only 1 time.
+ if (count++ == 0) {
+ throw new Exception("State-store update failed");
+ }
+ super.updateApplicationStateInternal(appId, appState);
+ }
+ };
+ memStore.init(conf);
+ rm1 = new MockRM(conf, memStore);
+ rm1.start();
+ MockNM nm1 =
+ new MockNM("127.0.0.1:1234", 8192, rm1.getResourceTrackerService());
+ nm1.registerNode();
+ nm1.nodeHeartbeat(true);
+
+ long appLifetime = 30L;
+ Map<ApplicationTimeoutType, Long> timeouts =
+ new HashMap<ApplicationTimeoutType, Long>();
+ timeouts.put(ApplicationTimeoutType.LIFETIME, appLifetime);
+ RMApp app1 = rm1.submitApp(200, Priority.newInstance(0), timeouts);
+
+ Map<ApplicationTimeoutType, String> updateTimeout =
+ new HashMap<ApplicationTimeoutType, String>();
+ long newLifetime = 10L;
+ // update 10L seconds more to timeout i.e 30L seconds overall
+ updateTimeout.put(ApplicationTimeoutType.LIFETIME,
+ Times.formatISO8601(System.currentTimeMillis() + newLifetime * 1000));
+ UpdateApplicationTimeoutsRequest request =
+ UpdateApplicationTimeoutsRequest.newInstance(app1.getApplicationId(),
+ updateTimeout);
+
+ Map<ApplicationTimeoutType, Long> applicationTimeouts =
+ app1.getApplicationTimeouts();
+ // has old timeout time
+ long beforeUpdate =
+ applicationTimeouts.get(ApplicationTimeoutType.LIFETIME);
+
+ try {
+ // update app2 lifetime to new time i.e now + timeout
+ rm1.getRMContext().getClientRMService()
+ .updateApplicationTimeouts(request);
+ fail("Update application should fail.");
+ } catch (YarnException e) {
+ // expected
+ assertTrue("State-store exception does not containe appId",
+ e.getMessage().contains(app1.getApplicationId().toString()));
+ }
+
+ applicationTimeouts = app1.getApplicationTimeouts();
+ // has old timeout time
+ long afterUpdate =
+ applicationTimeouts.get(ApplicationTimeoutType.LIFETIME);
+
+ Assert.assertEquals("Application timeout is updated", beforeUpdate,
+ afterUpdate);
+ rm1.waitForState(app1.getApplicationId(), RMAppState.KILLED);
+ // verify for app killed with updated lifetime
+ Assert.assertTrue("Application killed before lifetime value",
+ app1.getFinishTime() > afterUpdate);
+ } finally {
+ stopRM(rm1);
+ }
}
private void stopRM(MockRM rm) {
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[02/50] [abbrv] hadoop git commit: YARN-5497. [YARN-3368] Use
different color for Undefined and Succeeded for Final State in applications
page. (Akhil P B Tan via Sunil G)
Posted by ka...@apache.org.
YARN-5497. [YARN-3368] Use different color for Undefined and Succeeded for Final State in applications page. (Akhil P B Tan via Sunil G)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/12ddbbc6
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/12ddbbc6
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/12ddbbc6
Branch: refs/heads/YARN-4752
Commit: 12ddbbc61d0c90ac4c0057fd7b151eaa778123c8
Parents: bc273c4
Author: sunilg <su...@apache.org>
Authored: Thu Oct 27 14:45:23 2016 +0530
Committer: Wangda Tan <wa...@apache.org>
Committed: Sun Nov 6 13:13:31 2016 -0800
----------------------------------------------------------------------
.../hadoop-yarn-ui/src/main/webapp/app/models/yarn-app.js | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/12ddbbc6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app.js
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app.js
index 0a5df87..8b5474f 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app.js
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app.js
@@ -86,14 +86,17 @@ export default DS.Model.extend({
}.property("progress"),
finalStatusStyle: function() {
- var style = "default";
var finalStatus = this.get("finalStatus");
+ var style = "";
+
if (finalStatus == "KILLED") {
style = "warning";
} else if (finalStatus == "FAILED") {
style = "danger";
- } else {
+ } else if (finalStatus == "SUCCEEDED") {
style = "success";
+ } else {
+ style = "default";
}
return "label label-" + style;
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[34/50] [abbrv] hadoop git commit: HADOOP-13346.
DelegationTokenAuthenticationHandler writes via closed writer. Contributed by
Gregory Chanan and Hrishikesh Gadre.
Posted by ka...@apache.org.
HADOOP-13346. DelegationTokenAuthenticationHandler writes via closed writer. Contributed by Gregory Chanan and Hrishikesh Gadre.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/822ae88f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/822ae88f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/822ae88f
Branch: refs/heads/YARN-4752
Commit: 822ae88f7da638e15a25747f6965caee8198aca6
Parents: c619e9b
Author: Xiao Chen <xi...@apache.org>
Authored: Wed Nov 9 09:32:15 2016 -0800
Committer: Xiao Chen <xi...@apache.org>
Committed: Wed Nov 9 09:33:00 2016 -0800
----------------------------------------------------------------------
.../DelegationTokenAuthenticationHandler.java | 32 ++++++++++++-
...tionTokenAuthenticationHandlerWithMocks.java | 50 ++++++++++++++++++++
2 files changed, 81 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/822ae88f/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticationHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticationHandler.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticationHandler.java
index c23a94f..315c9d6 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticationHandler.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/web/DelegationTokenAuthenticationHandler.java
@@ -48,6 +48,8 @@ import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenIdenti
import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager;
import org.apache.hadoop.util.HttpExceptionUtils;
import org.apache.hadoop.util.StringUtils;
+import org.codehaus.jackson.JsonFactory;
+import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.ObjectMapper;
import com.google.common.annotations.VisibleForTesting;
@@ -89,6 +91,8 @@ public abstract class DelegationTokenAuthenticationHandler
public static final String DELEGATION_TOKEN_UGI_ATTRIBUTE =
"hadoop.security.delegation-token.ugi";
+ public static final String JSON_MAPPER_PREFIX = PREFIX + "json-mapper.";
+
static {
DELEGATION_TOKEN_OPS.add(KerberosDelegationTokenAuthenticator.
DelegationTokenOperation.GETDELEGATIONTOKEN.toString());
@@ -101,6 +105,7 @@ public abstract class DelegationTokenAuthenticationHandler
private AuthenticationHandler authHandler;
private DelegationTokenManager tokenManager;
private String authType;
+ private JsonFactory jsonFactory;
public DelegationTokenAuthenticationHandler(AuthenticationHandler handler) {
authHandler = handler;
@@ -120,6 +125,7 @@ public abstract class DelegationTokenAuthenticationHandler
public void init(Properties config) throws ServletException {
authHandler.init(config);
initTokenManager(config);
+ initJsonFactory(config);
}
/**
@@ -153,6 +159,30 @@ public abstract class DelegationTokenAuthenticationHandler
tokenManager.init();
}
+ @VisibleForTesting
+ public void initJsonFactory(Properties config) {
+ boolean hasFeature = false;
+ JsonFactory tmpJsonFactory = new JsonFactory();
+
+ for (Map.Entry entry : config.entrySet()) {
+ String key = (String)entry.getKey();
+ if (key.startsWith(JSON_MAPPER_PREFIX)) {
+ JsonGenerator.Feature feature =
+ JsonGenerator.Feature.valueOf(key.substring(JSON_MAPPER_PREFIX
+ .length()));
+ if (feature != null) {
+ hasFeature = true;
+ boolean enabled = Boolean.parseBoolean((String)entry.getValue());
+ tmpJsonFactory.configure(feature, enabled);
+ }
+ }
+ }
+
+ if (hasFeature) {
+ jsonFactory = tmpJsonFactory;
+ }
+ }
+
@Override
public void destroy() {
tokenManager.destroy();
@@ -298,7 +328,7 @@ public abstract class DelegationTokenAuthenticationHandler
if (map != null) {
response.setContentType(MediaType.APPLICATION_JSON);
Writer writer = response.getWriter();
- ObjectMapper jsonMapper = new ObjectMapper();
+ ObjectMapper jsonMapper = new ObjectMapper(jsonFactory);
jsonMapper.writeValue(writer, map);
writer.write(ENTER);
writer.flush();
http://git-wip-us.apache.org/repos/asf/hadoop/blob/822ae88f/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/web/TestDelegationTokenAuthenticationHandlerWithMocks.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/web/TestDelegationTokenAuthenticationHandlerWithMocks.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/web/TestDelegationTokenAuthenticationHandlerWithMocks.java
index d9c4f02..361d7fd 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/web/TestDelegationTokenAuthenticationHandlerWithMocks.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/web/TestDelegationTokenAuthenticationHandlerWithMocks.java
@@ -17,6 +17,9 @@
*/
package org.apache.hadoop.security.token.delegation.web;
+import static org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticator.DelegationTokenOperation.*;
+
+import org.apache.commons.lang.mutable.MutableBoolean;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authentication.client.AuthenticationException;
@@ -458,4 +461,51 @@ public class TestDelegationTokenAuthenticationHandlerWithMocks {
Assert.assertFalse(handler.managementOperation(null, request, response));
Mockito.verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
+
+ @Test
+ public void testWriterNotClosed() throws Exception {
+ Properties conf = new Properties();
+ conf.put(KerberosDelegationTokenAuthenticationHandler.TOKEN_KIND, "foo");
+ conf.put(DelegationTokenAuthenticationHandler.JSON_MAPPER_PREFIX
+ + "AUTO_CLOSE_TARGET", "false");
+ DelegationTokenAuthenticationHandler noAuthCloseHandler =
+ new MockDelegationTokenAuthenticationHandler();
+ try {
+ noAuthCloseHandler.initTokenManager(conf);
+ noAuthCloseHandler.initJsonFactory(conf);
+
+ DelegationTokenAuthenticator.DelegationTokenOperation op =
+ GETDELEGATIONTOKEN;
+ HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+ HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
+ Mockito.when(request.getQueryString()).thenReturn(
+ DelegationTokenAuthenticator.OP_PARAM + "=" + op.toString());
+ Mockito.when(request.getMethod()).thenReturn(op.getHttpMethod());
+
+ AuthenticationToken token = Mockito.mock(AuthenticationToken.class);
+ Mockito.when(token.getUserName()).thenReturn("user");
+ final MutableBoolean closed = new MutableBoolean();
+ PrintWriter printWriterCloseCount = new PrintWriter(new StringWriter()) {
+ @Override
+ public void close() {
+ closed.setValue(true);
+ super.close();
+ }
+
+ @Override
+ public void write(String str) {
+ if (closed.booleanValue()) {
+ throw new RuntimeException("already closed!");
+ }
+ super.write(str);
+ }
+
+ };
+ Mockito.when(response.getWriter()).thenReturn(printWriterCloseCount);
+ Assert.assertFalse(noAuthCloseHandler.managementOperation(token, request,
+ response));
+ } finally {
+ noAuthCloseHandler.destroy();
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org