private String getBody() { String status = jobState.getStatus().toString(); String version = Main.version; String hostname = "UNKNOWN"; try { hostname = InetAddress.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException e) { logger.debug("Could not get hostname", e); } return String.format(BODY_TEMPLATE, status, version, hostname); }
private JobInfo waitForJobEvent( JobId id, long timeout, JobStatus jobStatusAfterEvent, SchedulerEvent jobEvent) throws Exception { JobState jobState = null; try { jobState = getSchedulerInterface().getJobState(id); } catch (UnknownJobException ignored) { } if (jobState != null && jobState.getStatus().equals(jobStatusAfterEvent)) { System.err.println("Job is already finished - do not wait for the 'job finished' event"); return jobState.getJobInfo(); } else { try { System.err.println("Waiting for the job finished event"); return getSchedulerMonitorsHandler().waitForEventJob(jobEvent, id, timeout); } catch (ProActiveTimeoutException e) { // unreachable block, 0 means infinite, no timeout // log something ? return null; } } }
/** * Check if the job concerned by this notification is awaited. Retrieve corresponding data if * needed * * @param notification */ protected void update(NotificationData<?> notification) { // am I interested in this job? JobId id = ((NotificationData<JobInfo>) notification).getData().getJobId(); AwaitedJob aj = awaitedJobs.get(id.toString()); if (aj == null) return; JobState jobState = null; try { jobState = this.getJobState(id); } catch (NotConnectedException e) { logger.error("Could not retreive output data for job " + id, e); } catch (UnknownJobException e) { logger.error("Could not retreive output data for job " + id, e); } catch (PermissionException e) { logger.error( "Could not retreive output data for job " + id + ". Did you connect with a diffrent user ? ", e); } if (jobState == null) { logger.warn( "The job " + id + " is listed as awaited but is unknown bby the scheduler. It will be removed from local list"); removeAwaitedJob(id.toString()); } JobStatus status = jobState.getStatus(); switch (status) { case KILLED: { logger.info("The job " + id + "has been killed. No data will be transfered"); removeAwaitedJob(id.toString()); break; } case FINISHED: { logger.info("Transfering data for finished job " + id); pullData(aj); this.removeAwaitedJob(id.toString()); logger.info("Data transfer finished for finished job " + id); break; } case CANCELED: { logger.info("Transfering data for canceled job " + id); pullData(aj); this.removeAwaitedJob(id.toString()); break; } case FAILED: { logger.info("Transfering data for failed job " + id); pullData(aj); this.removeAwaitedJob(id.toString()); break; } } }