|
@@ -61,7 +61,7 @@ import org.apache.hadoop.security.token.Token;
|
|
|
import org.apache.hadoop.yarn.YarnException;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationReport;
|
|
|
-import org.apache.hadoop.yarn.api.records.ApplicationState;
|
|
|
+import org.apache.hadoop.yarn.api.records.YarnApplicationState;
|
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
|
|
|
import org.apache.hadoop.yarn.factories.RecordFactory;
|
|
@@ -89,7 +89,7 @@ public class ClientServiceDelegate {
|
|
|
private static String UNKNOWN_USER = "Unknown User";
|
|
|
private String trackingUrl;
|
|
|
|
|
|
- public ClientServiceDelegate(Configuration conf, ResourceMgrDelegate rm,
|
|
|
+ public ClientServiceDelegate(Configuration conf, ResourceMgrDelegate rm,
|
|
|
JobID jobId, MRClientProtocol historyServerProxy) {
|
|
|
this.conf = new Configuration(conf); // Cloning for modifying.
|
|
|
// For faster redirects from AM to HS.
|
|
@@ -103,7 +103,7 @@ public class ClientServiceDelegate {
|
|
|
|
|
|
// Get the instance of the NotRunningJob corresponding to the specified
|
|
|
// user and state
|
|
|
- private NotRunningJob getNotRunningJob(ApplicationReport applicationReport,
|
|
|
+ private NotRunningJob getNotRunningJob(ApplicationReport applicationReport,
|
|
|
JobState state) {
|
|
|
synchronized (notRunningJobs) {
|
|
|
HashMap<String, NotRunningJob> map = notRunningJobs.get(state);
|
|
@@ -111,8 +111,8 @@ public class ClientServiceDelegate {
|
|
|
map = new HashMap<String, NotRunningJob>();
|
|
|
notRunningJobs.put(state, map);
|
|
|
}
|
|
|
- String user =
|
|
|
- (applicationReport == null) ?
|
|
|
+ String user =
|
|
|
+ (applicationReport == null) ?
|
|
|
UNKNOWN_USER : applicationReport.getUser();
|
|
|
NotRunningJob notRunningJob = map.get(user);
|
|
|
if (notRunningJob == null) {
|
|
@@ -135,7 +135,7 @@ public class ClientServiceDelegate {
|
|
|
trackingUrl = application.getTrackingUrl();
|
|
|
}
|
|
|
String serviceAddr = null;
|
|
|
- while (application == null || ApplicationState.RUNNING.equals(application.getState())) {
|
|
|
+ while (application == null || YarnApplicationState.RUNNING.equals(application.getYarnApplicationState())) {
|
|
|
if (application == null) {
|
|
|
LOG.info("Could not get Job info from RM for job " + jobId
|
|
|
+ ". Redirecting to job history server.");
|
|
@@ -145,8 +145,8 @@ public class ClientServiceDelegate {
|
|
|
if (application.getHost() == null || "".equals(application.getHost())) {
|
|
|
LOG.debug("AM not assigned to Job. Waiting to get the AM ...");
|
|
|
Thread.sleep(2000);
|
|
|
-
|
|
|
- LOG.debug("Application state is " + application.getState());
|
|
|
+
|
|
|
+ LOG.debug("Application state is " + application.getYarnApplicationState());
|
|
|
application = rm.getApplicationReport(appId);
|
|
|
continue;
|
|
|
}
|
|
@@ -168,7 +168,7 @@ public class ClientServiceDelegate {
|
|
|
//possibly the AM has crashed
|
|
|
//there may be some time before AM is restarted
|
|
|
//keep retrying by getting the address from RM
|
|
|
- LOG.info("Could not connect to " + serviceAddr +
|
|
|
+ LOG.info("Could not connect to " + serviceAddr +
|
|
|
". Waiting for getting the latest AM address...");
|
|
|
try {
|
|
|
Thread.sleep(2000);
|
|
@@ -189,35 +189,36 @@ public class ClientServiceDelegate {
|
|
|
}
|
|
|
|
|
|
/** we just want to return if its allocating, so that we don't
|
|
|
- * block on it. This is to be able to return job status
|
|
|
+ * block on it. This is to be able to return job status
|
|
|
* on an allocating Application.
|
|
|
*/
|
|
|
-
|
|
|
+
|
|
|
String user = application.getUser();
|
|
|
if (user == null) {
|
|
|
throw RPCUtil.getRemoteException("User is not set in the application report");
|
|
|
}
|
|
|
- if (application.getState() == ApplicationState.NEW ||
|
|
|
- application.getState() == ApplicationState.SUBMITTED) {
|
|
|
+ if (application.getYarnApplicationState() == YarnApplicationState.NEW ||
|
|
|
+ application.getYarnApplicationState() == YarnApplicationState.SUBMITTED) {
|
|
|
realProxy = null;
|
|
|
return getNotRunningJob(application, JobState.NEW);
|
|
|
}
|
|
|
-
|
|
|
- if (application.getState() == ApplicationState.FAILED) {
|
|
|
+
|
|
|
+ if (application.getYarnApplicationState() == YarnApplicationState.FAILED) {
|
|
|
realProxy = null;
|
|
|
return getNotRunningJob(application, JobState.FAILED);
|
|
|
}
|
|
|
-
|
|
|
- if (application.getState() == ApplicationState.KILLED) {
|
|
|
+
|
|
|
+ if (application.getYarnApplicationState() == YarnApplicationState.KILLED) {
|
|
|
realProxy = null;
|
|
|
return getNotRunningJob(application, JobState.KILLED);
|
|
|
}
|
|
|
-
|
|
|
- //History server can serve a job only if application
|
|
|
+
|
|
|
+ //History server can serve a job only if application
|
|
|
//succeeded.
|
|
|
- if (application.getState() == ApplicationState.SUCCEEDED) {
|
|
|
- LOG.info("Application state is completed. " +
|
|
|
- "Redirecting to job history server");
|
|
|
+ if (application.getYarnApplicationState() == YarnApplicationState.FINISHED) {
|
|
|
+ LOG.info("Application state is completed. FinalApplicationStatus="
|
|
|
+ + application.getFinalApplicationStatus().toString()
|
|
|
+ + ". Redirecting to job history server");
|
|
|
realProxy = checkAndGetHSProxy(application, JobState.SUCCEEDED);
|
|
|
}
|
|
|
return realProxy;
|
|
@@ -241,7 +242,7 @@ public class ClientServiceDelegate {
|
|
|
Configuration myConf = new Configuration(conf);
|
|
|
myConf.setClass(
|
|
|
YarnConfiguration.YARN_SECURITY_INFO,
|
|
|
- SchedulerSecurityInfo.class, SecurityInfo.class);
|
|
|
+ SchedulerSecurityInfo.class, SecurityInfo.class);
|
|
|
YarnRPC rpc = YarnRPC.create(myConf);
|
|
|
return (MRClientProtocol) rpc.getProxy(MRClientProtocol.class,
|
|
|
NetUtils.createSocketAddr(serviceAddr), myConf);
|
|
@@ -250,7 +251,7 @@ public class ClientServiceDelegate {
|
|
|
LOG.trace("Connected to ApplicationMaster at: " + serviceAddr);
|
|
|
}
|
|
|
|
|
|
- private synchronized Object invoke(String method, Class argClass,
|
|
|
+ private synchronized Object invoke(String method, Class argClass,
|
|
|
Object args) throws YarnRemoteException {
|
|
|
Method methodOb = null;
|
|
|
try {
|
|
@@ -289,10 +290,10 @@ public class ClientServiceDelegate {
|
|
|
org.apache.hadoop.mapreduce.v2.api.records.JobId jobID = TypeConverter.toYarn(arg0);
|
|
|
GetCountersRequest request = recordFactory.newRecordInstance(GetCountersRequest.class);
|
|
|
request.setJobId(jobID);
|
|
|
- Counters cnt = ((GetCountersResponse)
|
|
|
+ Counters cnt = ((GetCountersResponse)
|
|
|
invoke("getCounters", GetCountersRequest.class, request)).getCounters();
|
|
|
return TypeConverter.fromYarn(cnt);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public TaskCompletionEvent[] getTaskCompletionEvents(JobID arg0, int arg1, int arg2)
|
|
@@ -304,7 +305,7 @@ public class ClientServiceDelegate {
|
|
|
request.setJobId(jobID);
|
|
|
request.setFromEventId(arg1);
|
|
|
request.setMaxEvents(arg2);
|
|
|
- List<org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptCompletionEvent> list =
|
|
|
+ List<org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptCompletionEvent> list =
|
|
|
((GetTaskAttemptCompletionEventsResponse) invoke(
|
|
|
"getTaskAttemptCompletionEvents", GetTaskAttemptCompletionEventsRequest.class, request)).
|
|
|
getCompletionEventList();
|
|
@@ -332,12 +333,12 @@ public class ClientServiceDelegate {
|
|
|
}
|
|
|
|
|
|
public JobStatus getJobStatus(JobID oldJobID) throws YarnRemoteException {
|
|
|
- org.apache.hadoop.mapreduce.v2.api.records.JobId jobId =
|
|
|
+ org.apache.hadoop.mapreduce.v2.api.records.JobId jobId =
|
|
|
TypeConverter.toYarn(oldJobID);
|
|
|
- GetJobReportRequest request =
|
|
|
+ GetJobReportRequest request =
|
|
|
recordFactory.newRecordInstance(GetJobReportRequest.class);
|
|
|
request.setJobId(jobId);
|
|
|
- JobReport report = ((GetJobReportResponse) invoke("getJobReport",
|
|
|
+ JobReport report = ((GetJobReportResponse) invoke("getJobReport",
|
|
|
GetJobReportRequest.class, request)).getJobReport();
|
|
|
if (StringUtils.isEmpty(report.getJobFile())) {
|
|
|
String jobFile = MRApps.getJobFile(conf, report.getUser(), oldJobID);
|
|
@@ -351,24 +352,24 @@ public class ClientServiceDelegate {
|
|
|
|
|
|
public org.apache.hadoop.mapreduce.TaskReport[] getTaskReports(JobID oldJobID, TaskType taskType)
|
|
|
throws YarnRemoteException, YarnRemoteException {
|
|
|
- org.apache.hadoop.mapreduce.v2.api.records.JobId jobId =
|
|
|
+ org.apache.hadoop.mapreduce.v2.api.records.JobId jobId =
|
|
|
TypeConverter.toYarn(oldJobID);
|
|
|
- GetTaskReportsRequest request =
|
|
|
+ GetTaskReportsRequest request =
|
|
|
recordFactory.newRecordInstance(GetTaskReportsRequest.class);
|
|
|
request.setJobId(jobId);
|
|
|
request.setTaskType(TypeConverter.toYarn(taskType));
|
|
|
-
|
|
|
- List<org.apache.hadoop.mapreduce.v2.api.records.TaskReport> taskReports =
|
|
|
- ((GetTaskReportsResponse) invoke("getTaskReports", GetTaskReportsRequest.class,
|
|
|
+
|
|
|
+ List<org.apache.hadoop.mapreduce.v2.api.records.TaskReport> taskReports =
|
|
|
+ ((GetTaskReportsResponse) invoke("getTaskReports", GetTaskReportsRequest.class,
|
|
|
request)).getTaskReportList();
|
|
|
-
|
|
|
+
|
|
|
return TypeConverter.fromYarn
|
|
|
(taskReports).toArray(new org.apache.hadoop.mapreduce.TaskReport[0]);
|
|
|
}
|
|
|
|
|
|
public boolean killTask(TaskAttemptID taskAttemptID, boolean fail)
|
|
|
throws YarnRemoteException {
|
|
|
- org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId attemptID
|
|
|
+ org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId attemptID
|
|
|
= TypeConverter.toYarn(taskAttemptID);
|
|
|
if (fail) {
|
|
|
FailTaskAttemptRequest failRequest = recordFactory.newRecordInstance(FailTaskAttemptRequest.class);
|
|
@@ -381,10 +382,10 @@ public class ClientServiceDelegate {
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public boolean killJob(JobID oldJobID)
|
|
|
throws YarnRemoteException {
|
|
|
- org.apache.hadoop.mapreduce.v2.api.records.JobId jobId
|
|
|
+ org.apache.hadoop.mapreduce.v2.api.records.JobId jobId
|
|
|
= TypeConverter.toYarn(oldJobID);
|
|
|
KillJobRequest killRequest = recordFactory.newRecordInstance(KillJobRequest.class);
|
|
|
killRequest.setJobId(jobId);
|
|
@@ -392,5 +393,5 @@ public class ClientServiceDelegate {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|