|
@@ -36,7 +36,7 @@ public class TestResourceEstimation extends TestCase {
|
|
|
//unfortunately, we can't set job input size from here.
|
|
|
ResourceEstimator re = new ResourceEstimator(jip);
|
|
|
|
|
|
- for(int i = 0; i < maps / 10 -1; ++i) {
|
|
|
+ for(int i = 0; i < maps / 10 ; ++i) {
|
|
|
|
|
|
long estOutSize = re.getEstimatedMapOutputSize();
|
|
|
System.out.println(estOutSize);
|
|
@@ -49,10 +49,56 @@ public class TestResourceEstimation extends TestCase {
|
|
|
TaskInProgress tip = new TaskInProgress(jid, "", split, null, jc, jip, 0);
|
|
|
re.updateWithCompletedTask(ts, tip);
|
|
|
}
|
|
|
+ assertEquals(2* singleMapOutputSize, re.getEstimatedMapOutputSize());
|
|
|
+ assertEquals(2* singleMapOutputSize * maps / reduces, re.getEstimatedReduceInputSize());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void testWithNonZeroInput() throws Exception {
|
|
|
+ final int maps = 100;
|
|
|
+ final int reduces = 2;
|
|
|
+ final int singleMapOutputSize = 1000;
|
|
|
+ final int singleMapInputSize = 500;
|
|
|
+ JobConf jc = new JobConf();
|
|
|
+ JobID jid = new JobID("testJT", 0);
|
|
|
+ jc.setNumMapTasks(maps);
|
|
|
+ jc.setNumReduceTasks(reduces);
|
|
|
+
|
|
|
+ JobInProgress jip = new JobInProgress(jid, jc) {
|
|
|
+ long getInputLength() {
|
|
|
+ return singleMapInputSize*desiredMaps();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ ResourceEstimator re = new ResourceEstimator(jip);
|
|
|
+
|
|
|
+ for(int i = 0; i < maps / 10 ; ++i) {
|
|
|
+
|
|
|
+ long estOutSize = re.getEstimatedMapOutputSize();
|
|
|
+ System.out.println(estOutSize);
|
|
|
+ assertEquals(0, estOutSize);
|
|
|
+
|
|
|
+ TaskStatus ts = new MapTaskStatus();
|
|
|
+ ts.setOutputSize(singleMapOutputSize);
|
|
|
+ RawSplit split = new RawSplit();
|
|
|
+ split.setDataLength(singleMapInputSize);
|
|
|
+ TaskInProgress tip = new TaskInProgress(jid, "", split, null, jc, jip, 0);
|
|
|
+ re.updateWithCompletedTask(ts, tip);
|
|
|
+ }
|
|
|
|
|
|
assertEquals(2* singleMapOutputSize, re.getEstimatedMapOutputSize());
|
|
|
assertEquals(2* singleMapOutputSize * maps / reduces, re.getEstimatedReduceInputSize());
|
|
|
+
|
|
|
+ //add one more map task with input size as 0
|
|
|
+ TaskStatus ts = new MapTaskStatus();
|
|
|
+ ts.setOutputSize(singleMapOutputSize);
|
|
|
+ RawSplit split = new RawSplit();
|
|
|
+ split.setDataLength(0);
|
|
|
+ TaskInProgress tip = new TaskInProgress(jid, "", split, null, jc, jip, 0);
|
|
|
+ re.updateWithCompletedTask(ts, tip);
|
|
|
|
|
|
+ long expectedTotalMapOutSize = (singleMapOutputSize*11) *
|
|
|
+ ((maps*singleMapInputSize)+maps)/((singleMapInputSize+1)*10+1);
|
|
|
+ assertEquals(2* expectedTotalMapOutSize/maps, re.getEstimatedMapOutputSize());
|
|
|
}
|
|
|
|
|
|
}
|