Search in sources :

Example 1 with ApplicationMasterLogs

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);
    }
}
Also used : App(com.microsoft.azure.hdinsight.sdk.rest.yarn.rm.App) Optional(java.util.Optional) JobRequestDetails(com.microsoft.azure.hdinsight.spark.jobs.framework.JobRequestDetails) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ApplicationMasterLogs(com.microsoft.azure.hdinsight.sdk.rest.yarn.rm.ApplicationMasterLogs)

Aggregations

App (com.microsoft.azure.hdinsight.sdk.rest.yarn.rm.App)1 ApplicationMasterLogs (com.microsoft.azure.hdinsight.sdk.rest.yarn.rm.ApplicationMasterLogs)1 JobRequestDetails (com.microsoft.azure.hdinsight.spark.jobs.framework.JobRequestDetails)1 IOException (java.io.IOException)1 Optional (java.util.Optional)1 ExecutionException (java.util.concurrent.ExecutionException)1