List of usage examples for org.apache.hadoop.yarn.api.records YarnApplicationState NEW
YarnApplicationState NEW
To view the source code for org.apache.hadoop.yarn.api.records YarnApplicationState NEW.
Click Source Link
From source file:org.apache.tez.client.TestTezClient.java
License:Apache License
@Test(timeout = 5000) public void testWaitTillReadyAppFailed() throws Exception { final TezClientForTest client = configure(); client.start();//from ww w . j a v a2s .co m String msg = "Application Test Failed"; when(client.mockYarnClient.getApplicationReport(client.mockAppId).getYarnApplicationState()) .thenReturn(YarnApplicationState.NEW).thenReturn(YarnApplicationState.FAILED); when(client.mockYarnClient.getApplicationReport(client.mockAppId).getDiagnostics()).thenReturn(msg); try { client.waitTillReady(); Assert.fail(); } catch (SessionNotRunning e) { Assert.assertTrue(e.getMessage().contains(msg)); } client.stop(); }
From source file:org.apache.tez.client.TestTezClient.java
License:Apache License
@Test(timeout = 5000) public void testWaitTillReadyAppFailedNoDiagnostics() throws Exception { final TezClientForTest client = configure(); client.start();/* w w w . j a v a 2s.co m*/ when(client.mockYarnClient.getApplicationReport(client.mockAppId).getYarnApplicationState()) .thenReturn(YarnApplicationState.NEW).thenReturn(YarnApplicationState.FAILED); try { client.waitTillReady(); Assert.fail(); } catch (SessionNotRunning e) { Assert.assertTrue(e.getMessage().contains(TezClient.NO_CLUSTER_DIAGNOSTICS_MSG)); } client.stop(); }
From source file:org.apache.tez.history.ATSImportTool_V2.java
License:Apache License
private void waitForApplicationToComplete() throws IOException, ATSImportException, InterruptedException, JSONException { YarnApplicationState state = getAppStatus(appId); while (state == YarnApplicationState.RUNNING || state == YarnApplicationState.NEW || state == YarnApplicationState.SUBMITTED || state == YarnApplicationState.ACCEPTED) { //keep trying until the app finishes LOG.info("App state: " + state + ", sleeping for 10 seconds to check state again"); Thread.sleep(10000);/* www . j a v a2 s. c om*/ state = getAppStatus(appId); } LOG.info("App state: " + state); }
From source file:org.apache.tez.mapreduce.client.NotRunningJob.java
License:Apache License
private ApplicationReport getUnknownApplicationReport() { ApplicationId unknownAppId = recordFactory.newRecordInstance(ApplicationId.class); ApplicationAttemptId unknownAttemptId = recordFactory.newRecordInstance(ApplicationAttemptId.class); // Setting AppState to NEW and finalStatus to UNDEFINED as they are never // used for a non running job return ApplicationReport.newInstance(unknownAppId, unknownAttemptId, "N/A", "N/A", "N/A", "N/A", 0, null, YarnApplicationState.NEW, "N/A", "N/A", 0, 0, FinalApplicationStatus.UNDEFINED, null, "N/A", 0.0f, "TEZ_MRR", null); }
From source file:org.apache.tez.test.MiniTezCluster.java
License:Apache License
private void waitForAppsToFinish() { YarnClient yarnClient = YarnClient.createYarnClient(); yarnClient.init(getConfig());/* www .j a v a 2 s . c o m*/ yarnClient.start(); try { while (true) { List<ApplicationReport> appReports = yarnClient.getApplications(); Collection<ApplicationReport> unCompletedApps = Collections2.filter(appReports, new Predicate<ApplicationReport>() { @Override public boolean apply(ApplicationReport appReport) { return EnumSet .of(YarnApplicationState.NEW, YarnApplicationState.NEW_SAVING, YarnApplicationState.SUBMITTED, YarnApplicationState.ACCEPTED, YarnApplicationState.RUNNING) .contains(appReport.getYarnApplicationState()); } }); if (unCompletedApps.size() == 0) { break; } LOG.info("wait for applications to finish in MiniTezCluster"); Thread.sleep(1000); } } catch (Exception e) { e.printStackTrace(); } finally { yarnClient.stop(); } }
From source file:org.apache.tez.tests.MiniTezClusterWithTimeline.java
License:Apache License
private void waitForAppsToFinish() { YarnClient yarnClient = YarnClient.createYarnClient(); yarnClient.init(getConfig());/*from w ww. ja va 2 s . co m*/ yarnClient.start(); try { while (true) { List<ApplicationReport> appReports = yarnClient.getApplications(); Collection<ApplicationReport> unCompletedApps = Collections2.filter(appReports, new Predicate<ApplicationReport>() { @Override public boolean apply(ApplicationReport appReport) { return EnumSet .of(YarnApplicationState.NEW, YarnApplicationState.NEW_SAVING, YarnApplicationState.SUBMITTED, YarnApplicationState.ACCEPTED, YarnApplicationState.RUNNING) .contains(appReport.getYarnApplicationState()); } }); if (unCompletedApps.size() == 0) { break; } LOG.info("wait for applications to finish in MiniTezClusterWithTimeline"); Thread.sleep(1000); } } catch (Exception e) { e.printStackTrace(); } finally { yarnClient.stop(); } }
From source file:org.huahinframework.manager.rest.service.ApplicationService.java
License:Apache License
@Path("/list") @GET//from w w w .ja va 2 s . com @Produces(MediaType.APPLICATION_JSON) public JSONObject list() { JSONObject jsonObject = new JSONObject(); try { GetAllApplicationsRequest request = recordFactory.newRecordInstance(GetAllApplicationsRequest.class); GetAllApplicationsResponse response = applicationsManager.getAllApplications(request); JSONObject appObject = new JSONObject(); List<JSONObject> apps = new ArrayList<JSONObject>(); for (ApplicationReport ar : response.getApplicationList()) { JSONObject app = new JSONObject(); app.put(Response.ID, ar.getApplicationId().toString()); app.put(Response.USER, ar.getUser()); app.put(Response.NAME, ar.getName()); app.put(Response.QUEUE, ar.getQueue()); YarnApplicationState state = ar.getYarnApplicationState(); app.put(Response.STATE, state); app.put(Response.FINAL_STATUS, ar.getFinalApplicationStatus().name()); String trackingUrl = ar.getTrackingUrl(); boolean trackingUrlIsNotReady = trackingUrl == null || trackingUrl.isEmpty() || YarnApplicationState.NEW == state || YarnApplicationState.SUBMITTED == state || YarnApplicationState.ACCEPTED == state; String trackingUI = trackingUrlIsNotReady ? "UNASSIGNED" : (ar.getFinishTime() == 0 ? "ApplicationMaster" : "History"); app.put(Response.TRACKING_UI, trackingUI); app.put(Response.TRACKING_URL, trackingUrl); app.put(Response.DIAGNOSTICS, ar.getDiagnostics()); app.put(Response.START_TIME, new Date(ar.getStartTime())); app.put(Response.FINISHED_TIME, ar.getFinishTime() == 0 ? "" : new Date(ar.getFinishTime())); app.put(Response.ELAPSED_TIME, (Times.elapsed(ar.getStartTime(), ar.getFinishTime()) / 1000) + "sec"); apps.add(app); } appObject.put(Response.APP, new JSONArray(apps)); jsonObject.put(Response.APPS, appObject); } catch (Exception e) { e.printStackTrace(); log.error(e); Map<String, String> status = new HashMap<String, String>(); status.put(Response.STATUS, e.getMessage()); jsonObject = new JSONObject(status); } return jsonObject; }