private void sendStats(Job job, List<IResponseTO> responses) { List<TaskStatusInfo> tasksList = new ArrayList<TaskStatusInfo>(); for (Task task : job.getTasks()) { tasksList.add(fillTask(task)); } JobStatusInfo jobInfo = new JobStatusInfo( job.getJobId(), job.getSpec(), UtilConverter.getJobState(job.getState()), tasksList, job.getCreationTime(), job.getFinalizationTime()); Map<String, Long> peersIdToReport = new TreeMap<String, Long>(); for (Request request : job.getRequests()) { peersIdToReport.put(request.getPeerID(), request.getSpecification().getRequestId()); } jobInfo.setPeersToRequests(peersIdToReport); LWPHereIsJobStatsResponseTO response = new LWPHereIsJobStatsResponseTO(); response.setJobStatusInfo(jobInfo); responses.add(response); }
private void finishRequests(Job job, List<IResponseTO> responses) { RequestSpecification spec = null; for (Request request : job.getRequests()) { spec = request.getSpecification(); String peerAddress = StringUtil.deploymentIDToAddress(request.getPeerID()); FinishRequestResponseTO to = new FinishRequestResponseTO(); to.setJobID(Integer.parseInt("" + spec.getJobId())); to.setJobSpec(spec.getJobSpecification()); to.setMaxFails(spec.getMaxFails()); to.setMaxReplicas(spec.getMaxReplicas()); to.setPeerAddress(peerAddress); to.setRequestID(spec.getRequestId()); to.setRequiredWorkers(spec.getRequiredWorkers()); responses.add(to); } job.finishRequests(); }
public void executionFailed(GridProcess execution, List<IResponseTO> responses) { reportReplicaAccounting(execution, responses); Job job = execution.getJob(); GridProcessExecutionResult executionResult = execution.getResult(); try { job.newReplicaResult( executionResult, GridProcessState.FAILED, verifyFailure(execution.getTask(), GridProcessState.FAILED), canReplicate(execution.getTask())); } catch (IllegalResultException e) { responses.add( new LoggerResponseTO( "Illegal result on replica " + execution.getState() + " : " + e.getMessage(), LoggerResponseTO.ERROR)); } GridProcessHandle handle = executionResult.getReplicaHandle(); WorkerEntry workerEntry = execution.getWorkerEntry(); workerEntry.deallocate(); GridProcessErrorTypes type = null; if (executionResult != null && executionResult.getExecutionError() != null) { type = executionResult.getExecutionError().getType(); } boolean enteredTaskBlacklist = executionFailedOnWorker(workerEntry, type, execution, responses); if (enteredTaskBlacklist) { if (!isWorkerNeeded(workerEntry, execution)) { unwantWorker(job, workerEntry, responses); } } else { disposeWorker(workerEntry, responses); } boolean hasJobEnded = hasJobEnded(job); String executorMsg = ""; if (executionResult != null && executionResult.getExecutionError() != null && executionResult.getExecutionError().getErrorCause() != null) { executorMsg = executionResult.getExecutionError().getErrorCause().toString(); } responses.add( new LoggerResponseTO( "Grid process " + execution.getState() + " " + handle + ". Job ended: " + hasJobEnded + " " + executorMsg + ".", LoggerResponseTO.DEBUG)); if (hasJobEnded) { finishJob(execution.getJob(), responses); } if (!isJobSatisfied(job) && !hasJobEnded) { Request request = execution.getJob().getRequest(workerEntry.getRequestID()); if (request != null) { request.setPaused(false); } ResumeRequestResponseTO to = new ResumeRequestResponseTO(); to.setPeerAddress(StringUtil.deploymentIDToAddress(workerEntry.getPeerID())); to.setRequestID(workerEntry.getRequestID()); responses.add(to); } updateScheduler(responses); }