use of com.microsoft.azure.hdinsight.sdk.rest.yarn.rm.ApplicationMasterLogs in project azure-tools-for-java by Microsoft.
the class YarnJobHttpHandler method handle.
@Override
public void handle(HttpExchange httpExchange) throws IOException {
httpExchange.getResponseHeaders().add("Access-Control-Allow-Origin", "*");
JobRequestDetails requestDetail = JobRequestDetails.getJobRequestDetail(httpExchange);
String path = requestDetail.getRequestPath();
try {
if (path.contains("/apps/app") && requestDetail.isSpecificApp()) {
App app = JobViewCacheManager.getYarnApp(new ApplicationKey(requestDetail.getCluster(), requestDetail.getAppId()));
Optional<String> responseString = ObjectConvertUtils.convertObjectToJsonString(app);
JobUtils.setResponse(httpExchange, responseString.orElseThrow(IOException::new));
} else if (path.contains("/apps/logs") && requestDetail.isSpecificApp()) {
ApplicationMasterLogs logs = JobViewCacheManager.getYarnLogs(new ApplicationKey(requestDetail.getCluster(), requestDetail.getAppId()));
Optional<String> responseString = ObjectConvertUtils.convertObjectToJsonString(logs);
JobUtils.setResponse(httpExchange, responseString.orElseThrow(IOException::new));
}
} catch (ExecutionException e) {
JobUtils.setResponse(httpExchange, e.getMessage(), 500);
}
}
Aggregations