You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tez.apache.org by bi...@apache.org on 2014/09/29 02:35:47 UTC
[41/50] [abbrv] git commit: TEZ-1618.
LocalTaskSchedulerService.getTotalResources() and getAvailableResources() can
get negative if JVM memory is larger than 2GB (Chen He via jeagles)
TEZ-1618. LocalTaskSchedulerService.getTotalResources() and getAvailableResources() can get negative if JVM memory is larger than 2GB (Chen He via jeagles)
Project: http://git-wip-us.apache.org/repos/asf/tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/2cee9aca
Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/2cee9aca
Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/2cee9aca
Branch: refs/heads/branch-0.5
Commit: 2cee9acaa2617bd8e6263f3d42003c98d907edf0
Parents: d1588c2
Author: Jonathan Eagles <je...@gmail.com>
Authored: Thu Sep 25 14:13:57 2014 -0500
Committer: Jonathan Eagles <je...@gmail.com>
Committed: Thu Sep 25 14:13:57 2014 -0500
----------------------------------------------------------------------
.../app/rm/TestLocalTaskSchedulerService.java | 68 ++++++++++++++++++++
1 file changed, 68 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tez/blob/2cee9aca/tez-dag/src/test/java/org/apache/tez/dag/app/rm/TestLocalTaskSchedulerService.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/rm/TestLocalTaskSchedulerService.java b/tez-dag/src/test/java/org/apache/tez/dag/app/rm/TestLocalTaskSchedulerService.java
new file mode 100644
index 0000000..5fc5a7d
--- /dev/null
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/rm/TestLocalTaskSchedulerService.java
@@ -0,0 +1,68 @@
+/**
+* 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.tez.dag.app.rm;
+
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+
+public class TestLocalTaskSchedulerService {
+
+ LocalTaskSchedulerService ltss ;
+ int core =10;
+
+ @Test
+ public void testCreateResource() {
+ Resource resource;
+ //value in integer
+ long value = 4*1024*1024;
+ resource = ltss.createResource(value,core);
+ Assert.assertEquals((int)(value/(1024*1024)),resource.getMemory());
+ }
+
+ @Test
+ public void testCreateResourceLargerThanIntMax() {
+ //value beyond integer but within Long.MAX_VALUE
+ try {
+ ltss.createResource(Long.MAX_VALUE, core);
+ fail("No exception thrown.");
+ } catch (Exception ex) {
+ assertTrue(ex instanceof IllegalArgumentException);
+ assertTrue(ex.getMessage().contains("Out of range:"));
+ }
+ }
+
+ @Test
+ public void testCreateResourceWithNegativeValue() {
+ //value is Long.MAX_VALUE*1024*1024,
+ // it will be negative after it is passed to createResource
+
+ try {
+ ltss.createResource((Long.MAX_VALUE*1024*1024), core);
+ fail("No exception thrown.");
+ } catch (Exception ex) {
+ assertTrue(ex instanceof IllegalArgumentException);
+ assertTrue(ex.getMessage().contains("Negative Memory or Core provided!"));
+ }
+ }
+}