Commit 8a1db01a authored by ligang's avatar ligang
Browse files

Merge remote-tracking branch 'remotes/upstream/dev-20190415' into dev-20190415

parents b0a90331 4a6912e4
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -66,13 +66,15 @@ public class ExecutorController extends BaseController {
                                       @RequestParam(value = "receiversCc", required = false) String receiversCc,
                                       @RequestParam(value = "runMode", required = false) RunMode runMode,
                                       @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority,
                                       @RequestParam(value = "workerGroupId", required = false, defaultValue = "-1") int workerGroupId,
                                       @RequestParam(value = "timeout", required = false) Integer timeout) {
        try {
            logger.info("login user {}, start process instance, project name: {}, process definition id: {}, schedule time: {}, "
                            + "failure policy: {}, node name: {}, node dep: {}, notify type: {}, "
                            + "notify group id: {},receivers:{},receiversCc:{}, run mode: {},process instance priority:{}, timeout: {}",
                            + "notify group id: {},receivers:{},receiversCc:{}, run mode: {},process instance priority:{}, workerGroupId: {}, timeout: {}",
                    loginUser.getUserName(), projectName, processDefinitionId, scheduleTime, failureStrategy,
                    taskDependType, warningType, warningGroupId,receivers,receiversCc,runMode,processInstancePriority,timeout);
                    taskDependType, warningType, warningGroupId,receivers,receiversCc,runMode,processInstancePriority,
                    workerGroupId, timeout);

            if (timeout == null) {
                timeout = cn.escheduler.common.Constants.MAX_TASK_TIMEOUT;
@@ -80,7 +82,7 @@ public class ExecutorController extends BaseController {

            Map<String, Object> result = execService.execProcessInstance(loginUser, projectName, processDefinitionId, scheduleTime, execType, failureStrategy,
                            startNodeList, taskDependType, warningType,
                    warningGroupId,receivers,receiversCc, runMode,processInstancePriority,timeout);
                    warningGroupId,receivers,receiversCc, runMode,processInstancePriority, workerGroupId, timeout);
            return returnDataList(result);
        } catch (Exception e) {
            logger.error(START_PROCESS_INSTANCE_ERROR.getMsg(),e);
+10 −6
Original line number Diff line number Diff line
@@ -76,13 +76,15 @@ public class SchedulerController extends BaseController{
                                                       @RequestParam(value = "failureStrategy", required = false, defaultValue = DEFAULT_FAILURE_POLICY) FailureStrategy failureStrategy,
                                                       @RequestParam(value = "receivers", required = false) String receivers,
                                                       @RequestParam(value = "receiversCc", required = false) String receiversCc,
                                                       @RequestParam(value = "workerGroupId", required = false, defaultValue = "-1") int workerGroupId,
                                                       @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) {
    logger.info("login user {}, project name: {}, process name: {}, create schedule: {}, warning type: {}, warning group id: {}," +
                    "failure policy: {},receivers : {},receiversCc : {},processInstancePriority : {}",
            loginUser.getUserName(), projectName, processDefinitionId, schedule, warningType, warningGroupId, failureStrategy,receivers,receiversCc,processInstancePriority);
                    "failure policy: {},receivers : {},receiversCc : {},processInstancePriority : {}, workGroupId:{}",
            loginUser.getUserName(), projectName, processDefinitionId, schedule, warningType, warningGroupId,
            failureStrategy,receivers,receiversCc,processInstancePriority,workerGroupId);
      try {
          Map<String, Object> result = schedulerService.insertSchedule(loginUser, projectName, processDefinitionId, schedule,
                  warningType, warningGroupId, failureStrategy, receivers,receiversCc,processInstancePriority);
                  warningType, warningGroupId, failureStrategy, receivers,receiversCc,processInstancePriority,workerGroupId);

          return returnDataList(result);
      }catch (Exception e){
@@ -113,14 +115,16 @@ public class SchedulerController extends BaseController{
                                                       @RequestParam(value = "failureStrategy", required = false, defaultValue = "END") FailureStrategy failureStrategy,
                                                       @RequestParam(value = "receivers", required = false) String receivers,
                                                       @RequestParam(value = "receiversCc", required = false) String receiversCc,
                                                       @RequestParam(value = "workerGroupId", required = false, defaultValue = "-1") int workerGroupId,
                                                       @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) {
    logger.info("login user {}, project name: {},id: {}, updateProcessInstance schedule: {}, notify type: {}, notify mails: {}, " +
                    "failure policy: {},receivers : {},receiversCc : {},processInstancePriority : {}",
            loginUser.getUserName(), projectName, id, schedule, warningType, warningGroupId, failureStrategy,receivers,receiversCc,processInstancePriority);
                    "failure policy: {},receivers : {},receiversCc : {},processInstancePriority : {},workerGroupId:{}",
            loginUser.getUserName(), projectName, id, schedule, warningType, warningGroupId, failureStrategy,
            receivers,receiversCc,processInstancePriority,workerGroupId);

      try {
          Map<String, Object> result = schedulerService.updateSchedule(loginUser, projectName, id, schedule,
                  warningType, warningGroupId, failureStrategy, receivers,receiversCc,null,processInstancePriority);
                  warningType, warningGroupId, failureStrategy, receivers,receiversCc,null,processInstancePriority, workerGroupId);
          return returnDataList(result);

      }catch (Exception e){
+144 −0
Original line number Diff line number Diff line
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.escheduler.api.controller;


import cn.escheduler.api.enums.Status;
import cn.escheduler.api.service.WorkerGroupService;
import cn.escheduler.api.utils.Constants;
import cn.escheduler.api.utils.Result;
import cn.escheduler.dao.model.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * worker group controller
 */
@RestController
@RequestMapping("/worker-group")
public class WorkerGroupController extends BaseController{

    private static final Logger logger = LoggerFactory.getLogger(WorkerGroupController.class);


    @Autowired
    WorkerGroupService workerGroupService;


    /**
     * create or update a worker group
     * @param loginUser
     * @param id
     * @param name
     * @param ipList
     * @return
     */
    @PostMapping(value = "/save")
    @ResponseStatus(HttpStatus.OK)
    public Result saveWorkerGroup(@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
                             @RequestParam(value = "id", required = false, defaultValue = "0") int id,
                             @RequestParam(value = "name") String name,
                             @RequestParam(value = "ipList") String ipList
                             ) {
        logger.info("save worker group: login user {}, id:{}, name: {}, ipList: {} ",
                loginUser.getUserName(), id, name, ipList);

        try {
            Map<String, Object> result = workerGroupService.saveWorkerGroup(id, name, ipList);
            return returnDataList(result);
        }catch (Exception e){
            logger.error(Status.SAVE_ERROR.getMsg(),e);
            return error(Status.SAVE_ERROR.getCode(), Status.SAVE_ERROR.getMsg());
        }
    }

    /**
     * query worker groups paging
     * @param loginUser
     * @param pageNo
     * @param searchVal
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/list-paging")
    @ResponseStatus(HttpStatus.OK)
    public Result queryAllWorkerGroupsPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
                                             @RequestParam("pageNo") Integer pageNo,
                                             @RequestParam(value = "searchVal", required = false) String searchVal,
                                             @RequestParam("pageSize") Integer pageSize
    ) {
        logger.info("query all worker group paging: login user {}, pageNo:{}, pageSize:{}, searchVal:{}",
                loginUser.getUserName() , pageNo, pageSize, searchVal);

        try {
            Map<String, Object> result = workerGroupService.queryAllGroupPaging(pageNo, pageSize, searchVal);
            return returnDataListPaging(result);
        }catch (Exception e){
            logger.error(Status.SAVE_ERROR.getMsg(),e);
            return error(Status.SAVE_ERROR.getCode(), Status.SAVE_ERROR.getMsg());
        }
    }

    /**
     * query all worker groups
     * @param loginUser
     * @return
     */
    @GetMapping(value = "/all-groups")
    @ResponseStatus(HttpStatus.OK)
    public Result queryAllWorkerGroups(@RequestAttribute(value = Constants.SESSION_USER) User loginUser
    ) {
        logger.info("query all worker group: login user {}",
                loginUser.getUserName() );

        try {
            Map<String, Object> result = workerGroupService.queryAllGroup();
            return returnDataList(result);
        }catch (Exception e){
            logger.error(Status.SAVE_ERROR.getMsg(),e);
            return error(Status.SAVE_ERROR.getCode(), Status.SAVE_ERROR.getMsg());
        }
    }

    /**
     * delete worker group by id
     * @param loginUser
     * @param id
     * @return
     */
    @GetMapping(value = "/delete-by-id")
    @ResponseStatus(HttpStatus.OK)
    public Result deleteById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
                                             @RequestParam("id") Integer id
    ) {
        logger.info("delete worker group: login user {}, id:{} ",
                loginUser.getUserName() , id);

        try {
            Map<String, Object> result = workerGroupService.deleteWorkerGroupById(id);
            return returnDataList(result);
        }catch (Exception e){
            logger.error(Status.SAVE_ERROR.getMsg(),e);
            return error(Status.SAVE_ERROR.getCode(), Status.SAVE_ERROR.getMsg());
        }
    }
}
+60 −0
Original line number Diff line number Diff line
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.escheduler.api.dto;

import cn.escheduler.common.enums.ExecutionStatus;

/**
 * command state count
 */
public class CommandStateCount {

    private int errorCount;
    private int normalCount;
    private ExecutionStatus commandState;

    public CommandStateCount(){}
    public CommandStateCount(int errorCount, int normalCount, ExecutionStatus commandState) {
        this.errorCount = errorCount;
        this.normalCount = normalCount;
        this.commandState = commandState;
    }

    public int getErrorCount() {
        return errorCount;
    }

    public void setErrorCount(int errorCount) {
        this.errorCount = errorCount;
    }

    public int getNormalCount() {
        return normalCount;
    }

    public void setNormalCount(int normalCount) {
        this.normalCount = normalCount;
    }

    public ExecutionStatus getCommandState() {
        return commandState;
    }

    public void setCommandState(ExecutionStatus commandState) {
        this.commandState = commandState;
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -156,6 +156,10 @@ public enum Status {
    UPDATE_QUEUE_ERROR(10131, "update queue error"),
    NEED_NOT_UPDATE_QUEUE(10132, "no content changes, no updates are required"),
    VERIFY_QUEUE_ERROR(10133,"verify queue error"),
    NAME_NULL(10134,"name must be not null"),
    NAME_EXIST(10135, "name {0} already exists"),
    SAVE_ERROR(10136, "save error"),



    UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found"),
Loading