Search in sources :

Example 21 with JobException

use of io.hops.hopsworks.exceptions.JobException in project hopsworks by logicalclocks.

the class HopsUtils method prepJupyterNotebookConversion.

public static String prepJupyterNotebookConversion(Execution execution, DistributedFileSystemOps udfso) throws JobException {
    String outPath = "hdfs://" + Utils.getProjectPath(execution.getJob().getProject().getName()) + Settings.PROJECT_STAGING_DIR;
    String pyJobPath = outPath + "/jobs/" + execution.getJob().getName();
    String pyAppPath = pyJobPath + "/" + execution.getId() + ".py";
    Path pyJobDir = new Path(pyJobPath);
    try {
        if (udfso.exists(pyJobDir)) {
            FileStatus fileStatus = udfso.getFileStatus(pyJobDir);
            if (!fileStatus.isDirectory()) {
                throw new JobException(RESTCodes.JobErrorCode.JOB_CREATION_ERROR, Level.INFO, "Failed to convert notebook - Job Directory name is used by a file");
            }
        } else {
            udfso.mkdirs(new org.apache.hadoop.fs.Path(pyJobPath), udfso.getParentPermission(pyJobDir));
        }
    } catch (IOException e) {
        throw new JobException(RESTCodes.JobErrorCode.JOB_CREATION_ERROR, Level.INFO, "Failed to convert notebook.", "HopsFS write failure.", e);
    }
    return pyAppPath;
}
Also used : Path(org.apache.hadoop.fs.Path) JobException(io.hops.hopsworks.exceptions.JobException) FileStatus(org.apache.hadoop.fs.FileStatus) Path(org.apache.hadoop.fs.Path) IOException(java.io.IOException)

Example 22 with JobException

use of io.hops.hopsworks.exceptions.JobException in project hopsworks by logicalclocks.

the class HopsUtils method cleanupExecutionDatasetResources.

public static void cleanupExecutionDatasetResources(Execution execution, String hdfsUsername, DistributedFsService dfs) throws JobException {
    String outPath = "hdfs://" + Utils.getProjectPath(execution.getJob().getProject().getName()) + Settings.PROJECT_STAGING_DIR;
    String pyJobPath = outPath + "/jobs/" + execution.getJob().getName();
    String pyAppPath = pyJobPath + "/" + execution.getId() + ".py";
    try {
        removeFiles(pyAppPath, hdfsUsername, dfs);
    } catch (DatasetException e) {
        String msg = "failed to cleanup execution dataset resoureces";
        throw new JobException(RESTCodes.JobErrorCode.JOB_DELETION_ERROR, Level.INFO, msg, msg, e);
    }
}
Also used : JobException(io.hops.hopsworks.exceptions.JobException) DatasetException(io.hops.hopsworks.exceptions.DatasetException)

Example 23 with JobException

use of io.hops.hopsworks.exceptions.JobException in project hopsworks by logicalclocks.

the class HopsUtils method cleanupJobDatasetResources.

public static void cleanupJobDatasetResources(Jobs job, String hdfsUsername, DistributedFsService dfs) throws JobException {
    String outPath = "hdfs://" + Utils.getProjectPath(job.getProject().getName()) + Settings.PROJECT_STAGING_DIR;
    String pyJobPath = outPath + "/jobs/" + job.getName();
    try {
        removeFiles(pyJobPath, hdfsUsername, dfs);
    } catch (DatasetException e) {
        String msg = "failed to cleanup job dataset resoureces";
        throw new JobException(RESTCodes.JobErrorCode.JOB_DELETION_ERROR, Level.INFO, msg, msg, e);
    }
}
Also used : JobException(io.hops.hopsworks.exceptions.JobException) DatasetException(io.hops.hopsworks.exceptions.DatasetException)

Aggregations

JobException (io.hops.hopsworks.exceptions.JobException)23 IOException (java.io.IOException)11 Path (javax.ws.rs.Path)8 Produces (javax.ws.rs.Produces)8 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)7 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)7 GenericException (io.hops.hopsworks.exceptions.GenericException)6 ServiceException (io.hops.hopsworks.exceptions.ServiceException)6 Users (io.hops.hopsworks.persistence.entity.user.Users)6 DistributedFileSystemOps (io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)5 ProjectException (io.hops.hopsworks.exceptions.ProjectException)4 SparkJobConfiguration (io.hops.hopsworks.persistence.entity.jobs.configuration.spark.SparkJobConfiguration)4 Execution (io.hops.hopsworks.persistence.entity.jobs.history.Execution)4 ApiOperation (io.swagger.annotations.ApiOperation)4 TransactionAttribute (javax.ejb.TransactionAttribute)4 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)3 YarnAppUrlsDTO (io.hops.hopsworks.common.dao.jobs.description.YarnAppUrlsDTO)3 DatasetException (io.hops.hopsworks.exceptions.DatasetException)3 ArrayList (java.util.ArrayList)3 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)3