long PER_TASK_LIMIT = 500L;
Matcher mat = null;
TTTaskInfo[] ttTaskinfo = null;
String pid = null;
TTClient ttClientIns = null;
TTProtocol ttIns = null;
TaskID tID = null;
int counter = 0;
String taskOverLimitPatternString =
"TaskTree \\[pid=[0-9]*,tipID=.*\\] is "
+ "running beyond memory-limits. "
+ "Current usage : [0-9]*bytes. Limit : %sbytes. Killing task.";
Pattern taskOverLimitPattern = Pattern.compile(String.format(
taskOverLimitPatternString,
String.valueOf(PER_TASK_LIMIT * 1024 * 1024L)));
JobConf jobConf = new JobConf(conf);
jobConf.setJobName("String Appending");
jobConf.setJarByClass(GenerateTaskChildProcess.class);
jobConf.setMapperClass(GenerateTaskChildProcess.StrAppendMapper.class);
jobConf.setNumMapTasks(1);
jobConf.setNumReduceTasks(0);
cleanup(outputDir, conf);
FileInputFormat.setInputPaths(jobConf, inputDir);
FileOutputFormat.setOutputPath(jobConf, outputDir);
jobConf.setMemoryForMapTask(PER_TASK_LIMIT);
jobConf.setMemoryForReduceTask(PER_TASK_LIMIT);
JTClient jtClient = cluster.getJTClient();
JobClient client = jtClient.getClient();
JTProtocol wovenClient = cluster.getJTClient().getProxy();
RunningJob runJob = client.submitJob(jobConf);
JobID id = runJob.getID();
JobInfo jInfo = wovenClient.getJobInfo(id);
Assert.assertNotNull("Job information is null", jInfo);
Assert.assertTrue("Job has not been started for 1 min.",
jtClient.isJobStarted(id));
TaskInfo[] taskInfos = wovenClient.getTaskInfo(id);
for (TaskInfo taskinfo : taskInfos) {
if (!taskinfo.isSetupOrCleanup()) {
taskInfo = taskinfo;
break;
}
}
Assert.assertNotNull("Task information is null.", taskInfo);
Assert.assertTrue("Task has not been started for 1 min.",
jtClient.isTaskStarted(taskInfo));
tID = TaskID.downgrade(taskInfo.getTaskID());
TaskAttemptID tAttID = new TaskAttemptID(tID,0);
FinishTaskControlAction action = new FinishTaskControlAction(tID);
Collection<TTClient> ttClients = cluster.getTTClients();
for (TTClient ttClient : ttClients) {
TTProtocol tt = ttClient.getProxy();
tt.sendAction(action);
ttTaskinfo = tt.getTasks();
for (TTTaskInfo tttInfo : ttTaskinfo) {
if (!tttInfo.isTaskCleanupTask()) {
pid = tttInfo.getPid();
ttClientIns = ttClient;
ttIns = tt;