Search in sources :

Example 1 with InvalidNamedJobException

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);
    }
}
Also used : InvalidNamedJobException(io.mantisrx.server.master.store.InvalidNamedJobException) File(java.io.File) JobClusterAlreadyExistsException(io.mantisrx.server.master.persistence.exceptions.JobClusterAlreadyExistsException) JobAlreadyExistsException(io.mantisrx.server.master.store.JobAlreadyExistsException) IOException(java.io.IOException) InvalidNamedJobException(io.mantisrx.server.master.store.InvalidNamedJobException) InvalidJobException(io.mantisrx.server.master.persistence.exceptions.InvalidJobException)

Example 2 with InvalidNamedJobException

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);
    }
}
Also used : InvalidNamedJobException(io.mantisrx.server.master.store.InvalidNamedJobException) IOException(java.io.IOException) File(java.io.File) PrintWriter(java.io.PrintWriter)

Aggregations

InvalidNamedJobException (io.mantisrx.server.master.store.InvalidNamedJobException)2 File (java.io.File)2 IOException (java.io.IOException)2 InvalidJobException (io.mantisrx.server.master.persistence.exceptions.InvalidJobException)1 JobClusterAlreadyExistsException (io.mantisrx.server.master.persistence.exceptions.JobClusterAlreadyExistsException)1 JobAlreadyExistsException (io.mantisrx.server.master.store.JobAlreadyExistsException)1 PrintWriter (java.io.PrintWriter)1