use of io.mantisrx.server.master.store.InvalidNamedJobException in project mantis by Netflix.
the class SimpleCachedFileStorageProvider method deleteJobCluster.
@Override
public void deleteJobCluster(String name) {
File jobFile = new File(JOB_CLUSTERS_DIR + File.separator + name);
try {
if (!jobFile.exists()) {
throw new InvalidNamedJobException(name + " doesn't exist");
}
boolean jobClusterDeleted = jobFile.delete();
File completedJobsFile = new File(JOB_CLUSTERS_DIR + File.separator + name + JOB_CLUSTERS_COMPLETED_JOBS_FILE_NAME_SUFFIX);
boolean completedJobClusterDeleted = completedJobsFile.delete();
if (!jobClusterDeleted) {
// || !completedJobClusterDeleted) {
throw new Exception("JobCluster " + name + " could not be deleted");
} else {
logger.info(" job cluster " + name + " deleted ");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of io.mantisrx.server.master.store.InvalidNamedJobException in project mantis by Netflix.
the class SimpleCachedFileStorageProvider method updateJobCluster.
@Override
public void updateJobCluster(IJobClusterMetadata jobCluster) {
String name = jobCluster.getJobClusterDefinition().getName();
File tmpFile = new File(JOB_CLUSTERS_DIR + "/" + name);
logger.info("Updating job cluster " + name + " to file " + tmpFile.getAbsolutePath());
try {
if (!tmpFile.exists()) {
throw new InvalidNamedJobException(name + " does not exist");
}
tmpFile.delete();
tmpFile.createNewFile();
PrintWriter pwrtr = new PrintWriter(tmpFile);
mapper.writeValue(pwrtr, jobCluster);
} catch (IOException | InvalidNamedJobException e) {
throw new RuntimeException(e);
}
}
Aggregations