/** * Archive a result * * @param taskData task data of this result * @param data the result data * @param quality the quality of the result * @param advocatingWorkers the advocating workers of this result */ public void archiveResult( TaskData taskData, ByteArray data, double quality, Set<WorkerID> advocatingWorkers) { PathManager pathManager = PathManager.jobOwner(taskData.getJobName()); File location = new File(pathManager.getCanonicalResultFilePath(taskData.getTaskMeta().getTaskName())); resultMap.put( taskData.taskID(), new CanonicalResult(data, quality, advocatingWorkers, location)); }
/** * Copies files from jobs/ to data/ folder in order to perform local work. * * @throws IOException */ private void copyFiles() throws IOException { // PathManager workerPathManager = PathManager.worker(jobPathManager.getProjectName()); FileUtils.copyDirectory( new File(jobPathManager.taskResourcesDir()), new File(workerPathManager.taskResourcesDir())); FileUtils.copyDirectory( new File(jobPathManager.taskCodeDir()), new File(workerPathManager.taskCodeDir())); }
/** * Creates a Task object for the local job owner to work on himself. * * @param taskMeta Meta info of this replica * @param listener Listener for success or failure * @return Runnable Task * @throws TaskMetaDataException */ public Task workSelf(TaskMeta taskMeta, TaskListener listener) throws TaskMetaDataException { try { copyFiles(); } catch (IOException e) { e.printStackTrace(); listener.taskFailed(taskName, e.getMessage()); } return new Task( jobPathManager.getProjectName(), taskMeta.getTaskName(), FileManagementUtils.moduleName(taskMeta), FileManagementUtils.getResourceFiles(jobPathManager, taskMeta), listener); }
/** * Returns absolute path to result file from this self work. This file will be in the /data * directory. * * @return Absolute path */ public String futureResultFilePath() { // return jobPathManager.getResultFilePath(taskName); return workerPathManager.getResultFilePath(taskName); }
public SelfWorker(TaskMeta taskMeta, String jobName) throws TaskMetaDataException { taskName = taskMeta.getTaskName(); jobPathManager = PathManager.jobOwner(jobName); workerPathManager = PathManager.worker(jobName); }