|
@@ -35,6 +35,7 @@ import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
|
import org.apache.hadoop.io.BytesWritable;
|
|
import org.apache.hadoop.io.BytesWritable;
|
|
|
|
+import org.apache.hadoop.mapred.TaskTracker;
|
|
import org.apache.hadoop.mapred.JobStatusChangeEvent.EventType;
|
|
import org.apache.hadoop.mapred.JobStatusChangeEvent.EventType;
|
|
import org.apache.hadoop.util.StringUtils;
|
|
import org.apache.hadoop.util.StringUtils;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
@@ -97,8 +98,9 @@ public class TestCapacityScheduler extends TestCase {
|
|
|
|
|
|
public ControlledInitializationPoller(JobQueuesManager mgr,
|
|
public ControlledInitializationPoller(JobQueuesManager mgr,
|
|
CapacitySchedulerConf rmConf,
|
|
CapacitySchedulerConf rmConf,
|
|
- Set<String> queues) {
|
|
|
|
- super(mgr, rmConf, queues);
|
|
|
|
|
|
+ Set<String> queues,
|
|
|
|
+ TaskTrackerManager ttm) {
|
|
|
|
+ super(mgr, rmConf, queues, ttm);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -468,6 +470,27 @@ public class TestCapacityScheduler extends TestCase {
|
|
job.kill();
|
|
job.kill();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public synchronized void failJob(JobInProgress job) {
|
|
|
|
+ finalizeJob(job, JobStatus.FAILED);
|
|
|
|
+ job.fail();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void initJob(JobInProgress jip) {
|
|
|
|
+ try {
|
|
|
|
+ JobStatus oldStatus = (JobStatus)jip.getStatus().clone();
|
|
|
|
+ jip.initTasks();
|
|
|
|
+ JobStatus newStatus = (JobStatus)jip.getStatus().clone();
|
|
|
|
+ JobStatusChangeEvent event = new JobStatusChangeEvent(jip,
|
|
|
|
+ EventType.RUN_STATE_CHANGED, oldStatus, newStatus);
|
|
|
|
+ for (JobInProgressListener listener : listeners) {
|
|
|
|
+ listener.jobUpdated(event);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception ioe) {
|
|
|
|
+ failJob(jip);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public void removeJob(JobID jobid) {
|
|
public void removeJob(JobID jobid) {
|
|
jobs.remove(jobid);
|
|
jobs.remove(jobid);
|
|
}
|
|
}
|
|
@@ -705,7 +728,7 @@ public class TestCapacityScheduler extends TestCase {
|
|
controlledInitializationPoller = new ControlledInitializationPoller(
|
|
controlledInitializationPoller = new ControlledInitializationPoller(
|
|
scheduler.jobQueuesManager,
|
|
scheduler.jobQueuesManager,
|
|
resConf,
|
|
resConf,
|
|
- resConf.getQueues());
|
|
|
|
|
|
+ resConf.getQueues(), taskTrackerManager);
|
|
scheduler.setInitializationPoller(controlledInitializationPoller);
|
|
scheduler.setInitializationPoller(controlledInitializationPoller);
|
|
scheduler.setConf(conf);
|
|
scheduler.setConf(conf);
|
|
//by default disable speculative execution.
|
|
//by default disable speculative execution.
|
|
@@ -733,7 +756,7 @@ public class TestCapacityScheduler extends TestCase {
|
|
private FakeJobInProgress submitJobAndInit(int state, JobConf jobConf)
|
|
private FakeJobInProgress submitJobAndInit(int state, JobConf jobConf)
|
|
throws IOException {
|
|
throws IOException {
|
|
FakeJobInProgress j = submitJob(state, jobConf);
|
|
FakeJobInProgress j = submitJob(state, jobConf);
|
|
- scheduler.jobQueuesManager.jobUpdated(initTasksAndReportEvent(j));
|
|
|
|
|
|
+ taskTrackerManager.initJob(j);
|
|
return j;
|
|
return j;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -753,21 +776,10 @@ public class TestCapacityScheduler extends TestCase {
|
|
String queue, String user)
|
|
String queue, String user)
|
|
throws IOException {
|
|
throws IOException {
|
|
FakeJobInProgress j = submitJob(state, maps, reduces, queue, user);
|
|
FakeJobInProgress j = submitJob(state, maps, reduces, queue, user);
|
|
- scheduler.jobQueuesManager.jobUpdated(initTasksAndReportEvent(j));
|
|
|
|
|
|
+ taskTrackerManager.initJob(j);
|
|
return j;
|
|
return j;
|
|
}
|
|
}
|
|
|
|
|
|
- // Note that there is no concept of setup tasks here. So init itself should
|
|
|
|
- // report the job-status change
|
|
|
|
- private JobStatusChangeEvent initTasksAndReportEvent(FakeJobInProgress jip)
|
|
|
|
- throws IOException {
|
|
|
|
- JobStatus oldStatus = (JobStatus)jip.getStatus().clone();
|
|
|
|
- jip.initTasks();
|
|
|
|
- JobStatus newStatus = (JobStatus)jip.getStatus().clone();
|
|
|
|
- return new JobStatusChangeEvent(jip, EventType.RUN_STATE_CHANGED,
|
|
|
|
- oldStatus, newStatus);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// test job run-state change
|
|
// test job run-state change
|
|
public void testJobRunStateChange() throws IOException {
|
|
public void testJobRunStateChange() throws IOException {
|
|
// start the scheduler
|
|
// start the scheduler
|
|
@@ -794,16 +806,10 @@ public class TestCapacityScheduler extends TestCase {
|
|
// first (may be because of the setup tasks).
|
|
// first (may be because of the setup tasks).
|
|
|
|
|
|
// init the lower ranked job first
|
|
// init the lower ranked job first
|
|
- JobChangeEvent event = initTasksAndReportEvent(fjob2);
|
|
|
|
-
|
|
|
|
- // inform the scheduler
|
|
|
|
- scheduler.jobQueuesManager.jobUpdated(event);
|
|
|
|
|
|
+ taskTrackerManager.initJob(fjob2);
|
|
|
|
|
|
// init the higher ordered job later
|
|
// init the higher ordered job later
|
|
- event = initTasksAndReportEvent(fjob1);
|
|
|
|
-
|
|
|
|
- // inform the scheduler
|
|
|
|
- scheduler.jobQueuesManager.jobUpdated(event);
|
|
|
|
|
|
+ taskTrackerManager.initJob(fjob1);
|
|
|
|
|
|
// check if the jobs are missing from the waiting queue
|
|
// check if the jobs are missing from the waiting queue
|
|
// The jobs are not removed from waiting queue until they are scheduled
|
|
// The jobs are not removed from waiting queue until they are scheduled
|