@Override public RunningJobsRegistry getRunningJobsRegistry() throws IOException { enter(); try { // IMPORTANT: The registry must NOT place its data in a directory that is // cleaned up by these services. return new FsNegativeRunningJobsRegistry(flinkFileSystem, workingDirectory); } finally { exit(); } }
@Override public void setJobRunning(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); final Path filePath = createMarkerFilePath(RUNNING_PREFIX, jobID); // create the file // to avoid an exception if the job already exists, set overwrite=true createFile(filePath, true); }
@Override public void clearJob(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); final Path runningFilePath = createMarkerFilePath(RUNNING_PREFIX, jobID); final Path doneFilePath = createMarkerFilePath(DONE_PREFIX, jobID); // delete the running marker file, if it exists try { fileSystem.delete(runningFilePath, false); } catch (FileNotFoundException ignored) {} // delete the finished marker file, if it exists try { fileSystem.delete(doneFilePath, false); } catch (FileNotFoundException ignored) {} }
/** * Creates a new registry that writes its files to the given FileSystem at * the given working directory path. * * <p>The initialization will attempt to write to the given working directory, in * order to catch setup/configuration errors early. * * @param fileSystem The FileSystem to use for the marker files. * @param workingDirectory The working directory for files to track the job status. * * @throws IOException Thrown, if the specified directory cannot be accessed. */ public FsNegativeRunningJobsRegistry(FileSystem fileSystem, Path workingDirectory) throws IOException { this.fileSystem = checkNotNull(fileSystem, "fileSystem"); this.basePath = checkNotNull(workingDirectory, "workingDirectory"); // to be safe, attempt to write to the working directory, to // catch problems early final Path testFile = new Path(workingDirectory, ".registry_test"); try { createFile(testFile, false); } catch (IOException e) { throw new IOException("Unable to write to working directory: " + workingDirectory, e); } finally { fileSystem.delete(testFile, false); } }
@Override public void setJobRunning(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); final Path filePath = createMarkerFilePath(RUNNING_PREFIX, jobID); // create the file // to avoid an exception if the job already exists, set overwrite=true createFile(filePath, true); }
@Override public void clearJob(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); final Path runningFilePath = createMarkerFilePath(RUNNING_PREFIX, jobID); final Path doneFilePath = createMarkerFilePath(DONE_PREFIX, jobID); // delete the running marker file, if it exists try { fileSystem.delete(runningFilePath, false); } catch (FileNotFoundException ignored) {} // delete the finished marker file, if it exists try { fileSystem.delete(doneFilePath, false); } catch (FileNotFoundException ignored) {} }
/** * Creates a new registry that writes its files to the given FileSystem at * the given working directory path. * * <p>The initialization will attempt to write to the given working directory, in * order to catch setup/configuration errors early. * * @param fileSystem The FileSystem to use for the marker files. * @param workingDirectory The working directory for files to track the job status. * * @throws IOException Thrown, if the specified directory cannot be accessed. */ public FsNegativeRunningJobsRegistry(FileSystem fileSystem, Path workingDirectory) throws IOException { this.fileSystem = checkNotNull(fileSystem, "fileSystem"); this.basePath = checkNotNull(workingDirectory, "workingDirectory"); // to be safe, attempt to write to the working directory, to // catch problems early final Path testFile = new Path(workingDirectory, ".registry_test"); try { createFile(testFile, false); } catch (IOException e) { throw new IOException("Unable to write to working directory: " + workingDirectory, e); } finally { fileSystem.delete(testFile, false); } }
@Override public void setJobFinished(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); final Path filePath = createMarkerFilePath(DONE_PREFIX, jobID); // create the file // to avoid an exception if the job already exists, set overwrite=true createFile(filePath, true); }
@Override public void clearJob(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); final Path runningFilePath = createMarkerFilePath(RUNNING_PREFIX, jobID); final Path doneFilePath = createMarkerFilePath(DONE_PREFIX, jobID); // delete the running marker file, if it exists try { fileSystem.delete(runningFilePath, false); } catch (FileNotFoundException ignored) {} // delete the finished marker file, if it exists try { fileSystem.delete(doneFilePath, false); } catch (FileNotFoundException ignored) {} }
/** * Creates a new registry that writes its files to the given FileSystem at * the given working directory path. * * <p>The initialization will attempt to write to the given working directory, in * order to catch setup/configuration errors early. * * @param fileSystem The FileSystem to use for the marker files. * @param workingDirectory The working directory for files to track the job status. * * @throws IOException Thrown, if the specified directory cannot be accessed. */ public FsNegativeRunningJobsRegistry(FileSystem fileSystem, Path workingDirectory) throws IOException { this.fileSystem = checkNotNull(fileSystem, "fileSystem"); this.basePath = checkNotNull(workingDirectory, "workingDirectory"); // to be safe, attempt to write to the working directory, to // catch problems early final Path testFile = new Path(workingDirectory, ".registry_test"); try { createFile(testFile, false); } catch (IOException e) { throw new IOException("Unable to write to working directory: " + workingDirectory, e); } finally { fileSystem.delete(testFile, false); } }
@Override public RunningJobsRegistry getRunningJobsRegistry() throws IOException { enter(); try { // IMPORTANT: The registry must NOT place its data in a directory that is // cleaned up by these services. return new FsNegativeRunningJobsRegistry(flinkFileSystem, workingDirectory); } finally { exit(); } }
@Override public void setJobFinished(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); final Path filePath = createMarkerFilePath(DONE_PREFIX, jobID); // create the file // to avoid an exception if the job already exists, set overwrite=true createFile(filePath, true); }
@Override public void clearJob(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); final Path runningFilePath = createMarkerFilePath(RUNNING_PREFIX, jobID); final Path doneFilePath = createMarkerFilePath(DONE_PREFIX, jobID); // delete the running marker file, if it exists try { fileSystem.delete(runningFilePath, false); } catch (FileNotFoundException ignored) {} // delete the finished marker file, if it exists try { fileSystem.delete(doneFilePath, false); } catch (FileNotFoundException ignored) {} }
/** * Creates a new registry that writes its files to the given FileSystem at * the given working directory path. * * <p>The initialization will attempt to write to the given working directory, in * order to catch setup/configuration errors early. * * @param fileSystem The FileSystem to use for the marker files. * @param workingDirectory The working directory for files to track the job status. * * @throws IOException Thrown, if the specified directory cannot be accessed. */ public FsNegativeRunningJobsRegistry(FileSystem fileSystem, Path workingDirectory) throws IOException { this.fileSystem = checkNotNull(fileSystem, "fileSystem"); this.basePath = checkNotNull(workingDirectory, "workingDirectory"); // to be safe, attempt to write to the working directory, to // catch problems early final Path testFile = new Path(workingDirectory, ".registry_test"); try { createFile(testFile, false); } catch (IOException e) { throw new IOException("Unable to write to working directory: " + workingDirectory, e); } finally { fileSystem.delete(testFile, false); } }
@Override public RunningJobsRegistry getRunningJobsRegistry() throws IOException { enter(); try { // IMPORTANT: The registry must NOT place its data in a directory that is // cleaned up by these services. return new FsNegativeRunningJobsRegistry(flinkFileSystem, workingDirectory); } finally { exit(); } }
@Override public void setJobRunning(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); final Path filePath = createMarkerFilePath(RUNNING_PREFIX, jobID); // create the file // to avoid an exception if the job already exists, set overwrite=true createFile(filePath, true); }
@Override public JobSchedulingStatus getJobSchedulingStatus(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); // first check for the existence of the complete file if (fileSystem.exists(createMarkerFilePath(DONE_PREFIX, jobID))) { // complete file was found --> job is terminated return JobSchedulingStatus.DONE; } // check for the existence of the running file else if (fileSystem.exists(createMarkerFilePath(RUNNING_PREFIX, jobID))) { // running file was found --> job is terminated return JobSchedulingStatus.RUNNING; } else { // file does not exist, job is not scheduled return JobSchedulingStatus.PENDING; } }
@Override public void setJobRunning(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); final Path filePath = createMarkerFilePath(RUNNING_PREFIX, jobID); // create the file // to avoid an exception if the job already exists, set overwrite=true createFile(filePath, true); }
@Override public JobSchedulingStatus getJobSchedulingStatus(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); // first check for the existence of the complete file if (fileSystem.exists(createMarkerFilePath(DONE_PREFIX, jobID))) { // complete file was found --> job is terminated return JobSchedulingStatus.DONE; } // check for the existence of the running file else if (fileSystem.exists(createMarkerFilePath(RUNNING_PREFIX, jobID))) { // running file was found --> job is terminated return JobSchedulingStatus.RUNNING; } else { // file does not exist, job is not scheduled return JobSchedulingStatus.PENDING; } }
@Override public void setJobFinished(JobID jobID) throws IOException { checkNotNull(jobID, "jobID"); final Path filePath = createMarkerFilePath(DONE_PREFIX, jobID); // create the file // to avoid an exception if the job already exists, set overwrite=true createFile(filePath, true); }