Search in sources :

Example 1 with JobState

use of io.hops.hopsworks.persistence.entity.jobs.configuration.history.JobState in project hopsworks by logicalclocks.

the class JobFacade method setFilterQuery.

private void setFilterQuery(AbstractFacade.FilterBy filterBy, Query q) {
    switch(Filters.valueOf(filterBy.getValue())) {
        case JOBTYPE:
        case JOBTYPE_NEQ:
            Set<JobType> jobTypes = new HashSet<>(getJobTypes(filterBy.getField(), filterBy.getParam()));
            q.setParameter(filterBy.getField(), jobTypes);
            break;
        case DATE_CREATED:
        case DATE_CREATED_GT:
        case DATE_CREATED_LT:
            Date date = getDate(filterBy.getField(), filterBy.getParam());
            q.setParameter(filterBy.getField(), date);
            break;
        case NAME:
            q.setParameter(filterBy.getField(), filterBy.getParam());
            break;
        case CREATOR:
        case LATEST_EXECUTION:
            q.setParameter(filterBy.getField(), filterBy.getParam());
            q.setParameter("searchUpper", filterBy.getParam().toUpperCase());
            break;
        case LATEST_EXECUTION_STATE:
            Set<JobState> jobStates = new HashSet<>(getJobStates(filterBy.getField(), filterBy.getParam()));
            q.setParameter(filterBy.getField(), jobStates);
            break;
        default:
            break;
    }
}
Also used : JobType(io.hops.hopsworks.persistence.entity.jobs.configuration.JobType) JobState(io.hops.hopsworks.persistence.entity.jobs.configuration.history.JobState) Date(java.util.Date) HashSet(java.util.HashSet)

Example 2 with JobState

use of io.hops.hopsworks.persistence.entity.jobs.configuration.history.JobState in project hopsworks by logicalclocks.

the class JobFacade method getJobStates.

private Set<JobState> getJobStates(String field, String values) {
    String[] jobStatesArr = values.split(",");
    Set<JobState> jobStates = new HashSet<>();
    for (String jobState : jobStatesArr) {
        try {
            jobStates.add(JobState.valueOf(jobState.trim().toUpperCase()));
        } catch (IllegalArgumentException ie) {
            throw new InvalidQueryException("Filter value for " + field + " needs to set a valid " + field + ", but found: " + jobState);
        }
    }
    if (jobStates.isEmpty()) {
        throw new InvalidQueryException("Filter value for " + field + " needs to set valid job state, but found: " + values);
    }
    return jobStates;
}
Also used : JobState(io.hops.hopsworks.persistence.entity.jobs.configuration.history.JobState) InvalidQueryException(io.hops.hopsworks.exceptions.InvalidQueryException) HashSet(java.util.HashSet)

Example 3 with JobState

use of io.hops.hopsworks.persistence.entity.jobs.configuration.history.JobState in project hopsworks by logicalclocks.

the class ExecutionFacade method setFilterQuery.

private void setFilterQuery(AbstractFacade.FilterBy filterBy, Query q) {
    switch(Filters.valueOf(filterBy.getValue())) {
        case STATE:
        case STATE_NEQ:
            Set<JobState> jobTypes = new HashSet<>(getJobStates(filterBy.getField(), filterBy.getParam()));
            q.setParameter(filterBy.getField(), jobTypes);
            break;
        case SUBMISSIONTIME_GT:
        case SUBMISSIONTIME_LT:
        case SUBMISSIONTIME:
            Date date = getDate(filterBy.getField(), filterBy.getParam());
            q.setParameter(filterBy.getField(), date);
            break;
        case FINALSTATUS:
        case FINALSTATUS_NEQ:
            Set<JobFinalStatus> jobFinalStatuses = new HashSet<>(getJobFinalStatus(filterBy.getField(), filterBy.getParam()));
            q.setParameter(filterBy.getField(), jobFinalStatuses);
            break;
        default:
            break;
    }
}
Also used : JobFinalStatus(io.hops.hopsworks.persistence.entity.jobs.configuration.history.JobFinalStatus) JobState(io.hops.hopsworks.persistence.entity.jobs.configuration.history.JobState) Date(java.util.Date) HashSet(java.util.HashSet)

Aggregations

JobState (io.hops.hopsworks.persistence.entity.jobs.configuration.history.JobState)3 HashSet (java.util.HashSet)3 Date (java.util.Date)2 InvalidQueryException (io.hops.hopsworks.exceptions.InvalidQueryException)1 JobType (io.hops.hopsworks.persistence.entity.jobs.configuration.JobType)1 JobFinalStatus (io.hops.hopsworks.persistence.entity.jobs.configuration.history.JobFinalStatus)1