Search in sources :

Example 6 with Application

use of com.webank.wedatasphere.qualitis.entity.Application in project Qualitis by WeBankFinTech.

the class CheckerRunnable method getJobs.

private List<JobChecker> getJobs() {
    List<Application> notEndApplications = applicationDao.findByStatusNotIn(END_APPLICATION_STATUS_LIST);
    List<JobChecker> jobCheckers = new ArrayList<>();
    for (Application app : notEndApplications) {
        // Find not end task
        List<Task> notEndTasks = taskDao.findByApplicationAndStatusInAndTaskRemoteIdNotNull(app, NOT_END_TASK_STATUS_LIST);
        for (Task task : notEndTasks) {
            JobChecker tmp = new JobChecker(app.getId(), TaskStatusEnum.getTaskStateByCode(task.getStatus()), task.getProgress(), StringUtils.isNotBlank(task.getTaskProxyUser()) ? task.getTaskProxyUser() : app.getExecuteUser(), task.getSubmitAddress(), task.getClusterName(), task);
            jobCheckers.add(tmp);
        }
        if (notEndTasks.isEmpty()) {
            LOGGER.info("Find abnormal application, which tasks is all end, but application is not end.");
            List<Task> allTasks = taskDao.findByApplication(app);
            app.resetTask();
            applicationDao.saveApplication(app);
            LOGGER.info("Finish to reset application status num.");
            LOGGER.info("Start to recover application status.");
            try {
                for (Task task : allTasks) {
                    if (task.getStatus().equals(TaskStatusEnum.FAILED.getCode())) {
                        iChecker.checkIfLastJob(app, false, false, false);
                    } else if (task.getAbortOnFailure() != null && !task.getAbortOnFailure() && task.getStatus().equals(TaskStatusEnum.FAIL_CHECKOUT.getCode())) {
                        iChecker.checkIfLastJob(app, true, false, false);
                    } else if (task.getStatus().equals(TaskStatusEnum.PASS_CHECKOUT.getCode())) {
                        iChecker.checkIfLastJob(app, true, true, false);
                    } else if (task.getStatus().equals(TaskStatusEnum.TASK_NOT_EXIST.getCode())) {
                        iChecker.checkIfLastJob(app, false, false, true);
                    } else if (task.getStatus().equals(TaskStatusEnum.CANCELLED.getCode())) {
                        app.setApplicationComment(ApplicationCommentEnum.TIMEOUT_KILL.getCode());
                        iChecker.checkIfLastJob(app, false, false, false);
                    }
                }
                LOGGER.info("Succeed to recover application status.");
            } catch (Exception e) {
                LOGGER.error("Failed to recover applications that are not end.");
                LOGGER.error(e.getMessage(), e);
            }
        }
    }
    return jobCheckers;
}
Also used : Task(com.webank.wedatasphere.qualitis.entity.Task) ArrayList(java.util.ArrayList) JobChecker(com.webank.wedatasphere.qualitis.bean.JobChecker) Application(com.webank.wedatasphere.qualitis.entity.Application)

Example 7 with Application

use of com.webank.wedatasphere.qualitis.entity.Application in project Qualitis by WeBankFinTech.

the class ApplicationServiceImpl method filterStatusApplication.

@Override
public GeneralResponse<?> filterStatusApplication(FilterStatusRequest request) throws UnExpectedRequestException {
    // Check arguments
    FilterStatusRequest.checkRequest(request);
    String userName = HttpUtils.getUserName(httpServletRequest);
    if (request.getStatus() != null) {
        LOGGER.info("User: {} wants to find applications with status: {}", userName, request.getStatus());
    } else {
        LOGGER.info("User: {} wants to find all applications", userName);
    }
    List<Application> applicationList;
    Long total;
    Integer page = request.getPage();
    Integer size = request.getSize();
    if (request.getStatus() == null || request.getStatus().intValue() == 0) {
        // Paging find applications by user
        long currentTimeUser = System.currentTimeMillis();
        applicationList = applicationDao.findByCreateUser(userName, page, size);
        LOGGER.info("timechecker find page application :" + (System.currentTimeMillis() - currentTimeUser));
        long currentTimeCountUser = System.currentTimeMillis();
        total = applicationDao.countByCreateUser(userName);
        LOGGER.info("timechecker count application :" + (System.currentTimeMillis() - currentTimeCountUser));
    } else {
        // Paging find applications by user and status
        applicationList = applicationDao.findByCreateUserAndStatus(userName, request.getStatus(), request.getCommentType(), page, size);
        total = applicationDao.countByCreateUserAndStatus(userName, request.getStatus(), request.getCommentType());
    }
    long currentTimeResponse = System.currentTimeMillis();
    GetAllResponse<ApplicationResponse> getAllResponse = new GetAllResponse<>();
    List<ApplicationResponse> applicationResponses = new ArrayList<>();
    for (Application application : applicationList) {
        List<Task> tasks = taskDao.findByApplication(application);
        ApplicationResponse response = new ApplicationResponse(application, tasks, httpServletRequest.getHeader("Content-Language"));
        if (application.getCreateUser().equals(userName) || application.getExecuteUser().equals(userName)) {
            response.setKillOption(true);
        } else {
            response.setKillOption(false);
        }
        applicationResponses.add(response);
    }
    getAllResponse.setData(applicationResponses);
    getAllResponse.setTotal(total);
    List<String> applicationIdList = getAllResponse.getData().stream().map(ApplicationResponse::getApplicationId).collect(Collectors.toList());
    LOGGER.info("timechecker response :" + (System.currentTimeMillis() - currentTimeResponse));
    LOGGER.info("Succeed to find applications. size: {}, id of applications: {}", total, applicationIdList);
    return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_APPLICATIONS}", getAllResponse);
}
Also used : Task(com.webank.wedatasphere.qualitis.entity.Task) ApplicationResponse(com.webank.wedatasphere.qualitis.response.ApplicationResponse) ArrayList(java.util.ArrayList) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse) Application(com.webank.wedatasphere.qualitis.entity.Application)

Example 8 with Application

use of com.webank.wedatasphere.qualitis.entity.Application in project Qualitis by WeBankFinTech.

the class ApplicationServiceImpl method filterProjectApplication.

@Override
public GeneralResponse<?> filterProjectApplication(FilterProjectRequest request) throws UnExpectedRequestException {
    // Check arguments
    FilterProjectRequest.checkRequest(request);
    Long userId = HttpUtils.getUserId(httpServletRequest);
    User user = userDao.findById(userId);
    Integer page = request.getPage();
    Integer size = request.getSize();
    Long projectId = request.getProjectId();
    int total = applicationDao.countByCreateUserAndProject(user.getUserName(), projectId).intValue();
    List<Application> applicationList = applicationDao.findByCreateUserAndProject(user.getUserName(), projectId, page, size);
    GetAllResponse<ApplicationResponse> getAllResponse = new GetAllResponse<>();
    List<ApplicationResponse> applicationResponses = new ArrayList<>();
    for (Application application : applicationList) {
        List<Task> tasks = taskDao.findByApplication(application);
        ApplicationResponse response = new ApplicationResponse(application, tasks, httpServletRequest.getHeader("Content-Language"));
        if (application.getCreateUser().equals(user.getUserName()) || application.getExecuteUser().equals(user.getUserName())) {
            response.setKillOption(true);
        } else {
            response.setKillOption(false);
        }
        applicationResponses.add(response);
    }
    getAllResponse.setData(applicationResponses);
    getAllResponse.setTotal(total);
    List<String> applicationIdList = getAllResponse.getData().stream().map(ApplicationResponse::getApplicationId).collect(Collectors.toList());
    LOGGER.info("Succeed to find applications. size: {}, id of applications: {}", total, applicationIdList);
    return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_APPLICATIONS}", getAllResponse);
}
Also used : Task(com.webank.wedatasphere.qualitis.entity.Task) User(com.webank.wedatasphere.qualitis.entity.User) ApplicationResponse(com.webank.wedatasphere.qualitis.response.ApplicationResponse) ArrayList(java.util.ArrayList) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse) Application(com.webank.wedatasphere.qualitis.entity.Application)

Example 9 with Application

use of com.webank.wedatasphere.qualitis.entity.Application in project Qualitis by WeBankFinTech.

the class IndexServiceImpl method getTodaySubmitApplications.

@Override
public IndexApplicationTodayResponse getTodaySubmitApplications(String username, PageRequest pageRequest) {
    // Find applications submitted today
    String today = DateFormatUtils.format(new Date(), DATE_FORMAT_PATTERN);
    List<Application> applications = getUserApplications(username, today, pageRequest);
    if (applications == null || applications.isEmpty()) {
        LOGGER.info("[Home overview]user:{},date:{},The user and the task submitted by the specified date were not found.", username, today);
        return null;
    }
    // Get total num of applications today
    long totalNum = countUserApplications(username, today);
    // Get successful total num of applications today
    long totalSuccNum = countUserSuccApplications(username, today);
    // Get failed total num of applications today
    long totalFailNum = countUserFailApplications(username, today);
    // Get not pass total num of applications today
    long totalFailCheckNum = countUserFailCheckApplications(username, today);
    LOGGER.info("[Home overview]user:{},date:{},Find {} tasks submitted by the user's specified date, for a total of {}.", username, today, applications.size(), totalNum);
    List<IndexApplicationResponse> applicationResponses = new ArrayList<>();
    for (Application application : applications) {
        List<Task> tasks = taskDao.findByApplication(application);
        IndexApplicationResponse applicationResponse = new IndexApplicationResponse(application, tasks);
        applicationResponses.add(applicationResponse);
    }
    return new IndexApplicationTodayResponse(applicationResponses, totalNum, totalSuccNum, totalFailNum, totalFailCheckNum);
}
Also used : Task(com.webank.wedatasphere.qualitis.entity.Task) IndexApplicationTodayResponse(com.webank.wedatasphere.qualitis.response.IndexApplicationTodayResponse) IndexApplicationResponse(com.webank.wedatasphere.qualitis.response.IndexApplicationResponse) ArrayList(java.util.ArrayList) Application(com.webank.wedatasphere.qualitis.entity.Application) Date(java.util.Date)

Example 10 with Application

use of com.webank.wedatasphere.qualitis.entity.Application in project Qualitis by WeBankFinTech.

the class IndexServiceImpl method getApplicationChart.

@Override
public List<IndexApplicationChartResponse> getApplicationChart(IndexRequest param) throws ParseException {
    // 7/30
    if (param.getStepSize() != null) {
        List<Application> applications = getUserApplications(param.getUser(), param.getStepSize());
        if (applications == null || applications.isEmpty()) {
            LOGGER.info("[Home overview]user:{},recent:{} days,The user and the task submitted by the specified date were not found.", param.getUser(), param.getStepSize());
            return null;
        }
        LOGGER.info("[Home overview]user:{},recent:{} days,Find {} tasks submitted by the user's specified date.", param.getUser(), param.getStepSize(), applications.size());
        return getApplicationChartPerDayRecent(new Date(), param.getStepSize(), applications);
    }
    // Find in limitation of time
    List<Application> applications = getUserApplications(param.getUser(), param.getStartDate(), param.getEndDate());
    if (applications == null || applications.isEmpty()) {
        LOGGER.info("[Home overview]user:{},between start date:{},and end date:{},The user and the task submitted by the specified date were not found.", param.getUser(), param.getStartDate(), param.getEndDate());
        return null;
    }
    LOGGER.info("[Home overview]user:{},between start date:{},and end date:{},Find {} tasks submitted by the user's specified date.", param.getUser(), param.getStartDate(), param.getEndDate(), applications.size());
    return getApplicationChartPerDayRange(param.getStartDate(), param.getEndDate(), applications);
}
Also used : Application(com.webank.wedatasphere.qualitis.entity.Application) Date(java.util.Date)

Aggregations

Application (com.webank.wedatasphere.qualitis.entity.Application)22 Task (com.webank.wedatasphere.qualitis.entity.Task)15 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)14 ArrayList (java.util.ArrayList)13 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)10 Date (java.util.Date)9 TaskRuleSimple (com.webank.wedatasphere.qualitis.entity.TaskRuleSimple)7 HashMap (java.util.HashMap)7 TaskDataSource (com.webank.wedatasphere.qualitis.entity.TaskDataSource)6 TaskRuleAlarmConfig (com.webank.wedatasphere.qualitis.entity.TaskRuleAlarmConfig)6 User (com.webank.wedatasphere.qualitis.entity.User)6 TaskSubmitResult (com.webank.wedatasphere.qualitis.bean.TaskSubmitResult)5 LinkisConfig (com.webank.wedatasphere.qualitis.config.LinkisConfig)5 AlarmConfigStatusEnum (com.webank.wedatasphere.qualitis.constant.AlarmConfigStatusEnum)5 TaskStatusEnum (com.webank.wedatasphere.qualitis.constant.TaskStatusEnum)5 ApplicationDao (com.webank.wedatasphere.qualitis.dao.ApplicationDao)5 ClusterInfoDao (com.webank.wedatasphere.qualitis.dao.ClusterInfoDao)5 TaskDao (com.webank.wedatasphere.qualitis.dao.TaskDao)5 TaskResultDao (com.webank.wedatasphere.qualitis.dao.TaskResultDao)5 ClusterInfo (com.webank.wedatasphere.qualitis.entity.ClusterInfo)5