fuweng11 commented on code in PR #10254:
URL: https://github.com/apache/inlong/pull/10254#discussion_r1609560208


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/service/InLongScheduleApi.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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 org.apache.inlong.manager.client.api.service;
+
+import org.apache.inlong.manager.pojo.common.Response;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfo;
+
+import retrofit2.Call;
+import retrofit2.http.Body;
+import retrofit2.http.DELETE;
+import retrofit2.http.GET;
+import retrofit2.http.POST;
+import retrofit2.http.Path;
+import retrofit2.http.Query;
+
+public interface InLongScheduleApi {
+
+    @POST("schedule/save")
+    Call<Response<Integer>> createSchedule(@Body ScheduleInfo scheduleInfo);
+
+    @GET("schedule/exist/{groupId}")
+    Call<Response<Boolean>> exist(@Path("groupId") String groupId);
+
+    @POST("schedule/update")
+    Call<Response<Boolean>> update(@Body ScheduleInfo scheduleInfo);

Review Comment:
   @Body ScheduleInfoRequest request



##########
inlong-manager/manager-dao/src/main/resources/mappers/ScheduleEntityMapper.xml:
##########
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper namespace="org.apache.inlong.manager.dao.mapper.ScheduleEntityMapper">
+    <resultMap id="BaseResultMap" 
type="org.apache.inlong.manager.dao.entity.ScheduleEntity">
+        <id column="id" jdbcType="INTEGER" property="id"/>
+        <result column="group_id" jdbcType="VARCHAR" property="groupId"/>
+        <result column="schedule_type" jdbcType="INTEGER" 
property="scheduleType"/>
+        <result column="schedule_unit" jdbcType="VARCHAR" 
property="scheduleUnit"/>
+        <result column="schedule_interval" jdbcType="INTEGER" 
property="scheduleInterval"/>
+        <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
+        <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
+        <result column="delay_time" jdbcType="INTEGER" property="delayTime"/>
+        <result column="self_depend" jdbcType="INTEGER" property="selfDepend"/>
+        <result column="task_parallelism" jdbcType="INTEGER" 
property="taskParallelism"/>
+        <result column="crontab_expression" jdbcType="VARCHAR" 
property="crontabExpression"/>
+
+        <result column="status" jdbcType="INTEGER" property="status"/>
+        <result column="previous_status" jdbcType="INTEGER" 
property="previousStatus"/>
+        <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
+        <result column="creator" jdbcType="VARCHAR" property="creator"/>
+        <result column="modifier" jdbcType="VARCHAR" property="modifier"/>
+        <result column="create_time" jdbcType="TIMESTAMP" 
property="createTime"/>
+        <result column="modify_time" jdbcType="TIMESTAMP" 
property="modifyTime"/>
+        <result column="version" jdbcType="INTEGER" property="version"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id, group_id, schedule_type, schedule_unit, schedule_interval, 
start_time,
+          end_time, delay_time, self_depend, task_parallelism, 
crontab_expression,
+           status, previous_status, is_deleted, creator, modifier, 
create_time, modify_time, version
+    </sql>
+
+    <insert id="insert" useGeneratedKeys="true" keyProperty="id"
+            
parameterType="org.apache.inlong.manager.dao.entity.ScheduleEntity">
+        insert into schedule_config (id, group_id, schedule_type, 
schedule_unit,
+                                     schedule_interval, start_time, end_time, 
delay_time,
+                                     self_depend, task_parallelism, 
crontab_expression,
+                                     status, previous_status, is_deleted, 
creator, modifier)
+        values (#{id, jdbcType=INTEGER}, #{groupId, jdbcType=VARCHAR},
+                #{scheduleType, jdbcType=INTEGER}, #{scheduleUnit, 
jdbcType=VARCHAR},
+                #{scheduleInterval, jdbcType=INTEGER}, #{startTime, 
jdbcType=TIMESTAMP},
+                #{endTime, jdbcType=TIMESTAMP}, #{delayTime, jdbcType=INTEGER},
+                #{selfDepend, jdbcType=INTEGER}, #{taskParallelism, 
jdbcType=INTEGER},
+                #{crontabExpression, jdbcType=VARCHAR}, 
#{status,jdbcType=INTEGER},
+                #{previousStatus,jdbcType=INTEGER}, 
#{isDeleted,jdbcType=INTEGER},
+                #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" 
resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from schedule_config
+        where id = #{id,jdbcType=INTEGER}
+    </select>
+
+    <select id="selectByGroupId" parameterType="java.lang.String" 
resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from schedule_config
+        where group_id = #{groupId,jdbcType=VARCHAR}

Review Comment:
   and is_deleted = 0



##########
inlong-manager/manager-dao/src/main/resources/mappers/ScheduleEntityMapper.xml:
##########
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper namespace="org.apache.inlong.manager.dao.mapper.ScheduleEntityMapper">
+    <resultMap id="BaseResultMap" 
type="org.apache.inlong.manager.dao.entity.ScheduleEntity">
+        <id column="id" jdbcType="INTEGER" property="id"/>
+        <result column="group_id" jdbcType="VARCHAR" property="groupId"/>
+        <result column="schedule_type" jdbcType="INTEGER" 
property="scheduleType"/>
+        <result column="schedule_unit" jdbcType="VARCHAR" 
property="scheduleUnit"/>
+        <result column="schedule_interval" jdbcType="INTEGER" 
property="scheduleInterval"/>
+        <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
+        <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
+        <result column="delay_time" jdbcType="INTEGER" property="delayTime"/>
+        <result column="self_depend" jdbcType="INTEGER" property="selfDepend"/>
+        <result column="task_parallelism" jdbcType="INTEGER" 
property="taskParallelism"/>
+        <result column="crontab_expression" jdbcType="VARCHAR" 
property="crontabExpression"/>
+
+        <result column="status" jdbcType="INTEGER" property="status"/>
+        <result column="previous_status" jdbcType="INTEGER" 
property="previousStatus"/>
+        <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
+        <result column="creator" jdbcType="VARCHAR" property="creator"/>
+        <result column="modifier" jdbcType="VARCHAR" property="modifier"/>
+        <result column="create_time" jdbcType="TIMESTAMP" 
property="createTime"/>
+        <result column="modify_time" jdbcType="TIMESTAMP" 
property="modifyTime"/>
+        <result column="version" jdbcType="INTEGER" property="version"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id, group_id, schedule_type, schedule_unit, schedule_interval, 
start_time,
+          end_time, delay_time, self_depend, task_parallelism, 
crontab_expression,
+           status, previous_status, is_deleted, creator, modifier, 
create_time, modify_time, version
+    </sql>
+
+    <insert id="insert" useGeneratedKeys="true" keyProperty="id"
+            
parameterType="org.apache.inlong.manager.dao.entity.ScheduleEntity">
+        insert into schedule_config (id, group_id, schedule_type, 
schedule_unit,
+                                     schedule_interval, start_time, end_time, 
delay_time,
+                                     self_depend, task_parallelism, 
crontab_expression,
+                                     status, previous_status, is_deleted, 
creator, modifier)
+        values (#{id, jdbcType=INTEGER}, #{groupId, jdbcType=VARCHAR},
+                #{scheduleType, jdbcType=INTEGER}, #{scheduleUnit, 
jdbcType=VARCHAR},
+                #{scheduleInterval, jdbcType=INTEGER}, #{startTime, 
jdbcType=TIMESTAMP},
+                #{endTime, jdbcType=TIMESTAMP}, #{delayTime, jdbcType=INTEGER},
+                #{selfDepend, jdbcType=INTEGER}, #{taskParallelism, 
jdbcType=INTEGER},
+                #{crontabExpression, jdbcType=VARCHAR}, 
#{status,jdbcType=INTEGER},
+                #{previousStatus,jdbcType=INTEGER}, 
#{isDeleted,jdbcType=INTEGER},
+                #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" 
resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from schedule_config
+        where id = #{id,jdbcType=INTEGER}

Review Comment:
   and is_deleted = 0



##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/service/InLongScheduleApi.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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 org.apache.inlong.manager.client.api.service;
+
+import org.apache.inlong.manager.pojo.common.Response;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfo;
+
+import retrofit2.Call;
+import retrofit2.http.Body;
+import retrofit2.http.DELETE;
+import retrofit2.http.GET;
+import retrofit2.http.POST;
+import retrofit2.http.Path;
+import retrofit2.http.Query;
+
+public interface InLongScheduleApi {
+
+    @POST("schedule/save")
+    Call<Response<Integer>> createSchedule(@Body ScheduleInfo scheduleInfo);

Review Comment:
   Call<Response<Integer>> createSchedule(@Body ScheduleInfoRequest request);
   



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/schedule/ScheduleService.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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 org.apache.inlong.manager.service.schedule;
+
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfo;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfoRequest;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+public interface ScheduleService {
+
+    /**
+     * Save schedule info.
+     *
+     * @param scheduleInfo schedule request need to save
+     * @param operator name of operator
+     * @return schedule info id in backend storage
+     */
+    int save(@Valid @NotNull(message = "schedule request cannot be null") 
ScheduleInfoRequest scheduleInfo,
+            String operator);
+
+    /**
+     * Query whether schedule info exists for specified inlong group
+     *
+     * @param groupId the group id to be queried
+     * @return does it exist
+     */
+    Boolean exist(String groupId);
+
+    /**
+     * Get schedule info based on inlong group id
+     *
+     * @param groupId inlong group id
+     * @return detail of inlong group
+     */
+    ScheduleInfo get(String groupId);
+
+    /**
+     * Modify schedule information
+     *
+     * @param scheduleInfo schedule request that needs to be modified
+     * @param operator name of operator
+     * @return whether succeed
+     */
+    Boolean update(@Valid @NotNull(message = "schedule request cannot be 
null") ScheduleInfoRequest scheduleInfo,

Review Comment:
     Boolean update(@Valid @NotNull(message = "schedule request cannot be 
null") ScheduleInfoRequest request



##########
inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InLongSchedulerController.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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 org.apache.inlong.manager.web.controller;
+
+import org.apache.inlong.manager.common.enums.OperationTarget;
+import org.apache.inlong.manager.common.enums.OperationType;
+import org.apache.inlong.manager.common.validation.UpdateValidation;
+import org.apache.inlong.manager.pojo.common.Response;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfo;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfoRequest;
+import org.apache.inlong.manager.pojo.user.LoginUserUtils;
+import org.apache.inlong.manager.service.operationlog.OperationLog;
+import org.apache.inlong.manager.service.schedule.ScheduleService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/api")
+@Api(tags = "Inlong-Schedule-API")
+public class InLongSchedulerController {
+
+    @Autowired
+    private ScheduleService scheduleService;
+
+    @RequestMapping(value = "/schedule/save", method = RequestMethod.POST)
+    @OperationLog(operation = OperationType.CREATE, operationTarget = 
OperationTarget.SCHEDULE)
+    @ApiOperation(value = "Save schedule info")
+    public Response<Integer> save(@RequestBody ScheduleInfoRequest request) {
+        int result = scheduleService.save(request, 
LoginUserUtils.getLoginUser().getName());
+        return Response.success(result);
+    }
+
+    @RequestMapping(value = "/schedule/exist/{groupId}", method = 
RequestMethod.GET)
+    @ApiOperation(value = "Is the schedule info exists for inlong group")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "groupId", dataTypeClass = String.class, 
required = true)
+    })
+    public Response<Boolean> exist(@PathVariable String groupId) {
+        return Response.success(scheduleService.exist(groupId));
+    }
+
+    @RequestMapping(value = "/schedule/get", method = RequestMethod.GET)
+    @ApiOperation(value = "Get schedule info for inlong group")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "groupId", dataTypeClass = String.class, 
required = true)

Review Comment:
   @ApiImplicitParam(name = "groupId", dataTypeClass = String.class, required = 
true)



##########
inlong-manager/manager-web/sql/apache_inlong_manager.sql:
##########
@@ -1021,4 +1021,33 @@ CREATE TABLE IF NOT EXISTS `cluster_config`
     DEFAULT CHARSET = utf8mb4 COMMENT = 'cluster_config';
 -- ----------------------------
 
+-- ----------------------------
+-- Table structure for schedule_config
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `schedule_config`
+(
+    `id`                     int(11)      NOT NULL AUTO_INCREMENT COMMENT 
'Incremental primary key',
+    `group_id`               varchar(256) NOT NULL COMMENT 'Inlong group id, 
undeleted ones cannot be repeated',
+    `schedule_type`          int(4)       NOT NULL DEFAULT '0' COMMENT 
'Schedule type, 0 for normal, 1 for crontab',
+    `schedule_unit`          varchar(64)  NOT NULL COMMENT 'Schedule 
unit,M=month, W=week, D=day, H=hour, M=minute, O=oneway',
+    `schedule_interval`      int(11)      DEFAULT '1' COMMENT 'Schedule 
interval',
+    `start_time`             timestamp    NOT NULL DEFAULT CURRENT_TIMESTAMP 
COMMENT 'Start time for schedule',
+    `end_time`               timestamp    NOT NULL DEFAULT CURRENT_TIMESTAMP 
COMMENT 'End time for schedule',
+    `delay_time`             int(11)      DEFAULT '0' COMMENT 'Delay time in 
minutes to schedule',
+    `self_depend`            int(11)      DEFAULT NULL COMMENT 'Self depend 
info',
+    `task_parallelism`       int(11)      DEFAULT NULL COMMENT 'Task 
parallelism',
+    `crontab_expression`     varchar(256) DEFAULT NULL COMMENT 'Crontab 
expression if schedule type is crontab',
+    `status`                 int(4)       DEFAULT '100' COMMENT 'Schedule 
status',
+    `previous_status`        int(4)       DEFAULT '100' COMMENT 'Previous 
schedule status',
+    `is_deleted`             int(11)      DEFAULT '0' COMMENT 'Whether to 
delete, 0: not deleted, > 0: deleted',
+    `creator`                varchar(64)  NOT NULL COMMENT 'Creator name',
+    `modifier`               varchar(64)  DEFAULT NULL COMMENT 'Modifier name',
+    `create_time`            timestamp    NOT NULL DEFAULT CURRENT_TIMESTAMP 
COMMENT 'Create time',
+    `modify_time`            timestamp    NOT NULL DEFAULT CURRENT_TIMESTAMP 
ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
+    `version`                int(11)      NOT NULL DEFAULT '1' COMMENT 
'Version number, which will be incremented by 1 after modification',
+    PRIMARY KEY (`id`)

Review Comment:
   Ditto.



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/schedule/ScheduleServiceImpl.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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 org.apache.inlong.manager.service.schedule;
+
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.enums.ScheduleStatus;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.common.util.Preconditions;
+import org.apache.inlong.manager.dao.entity.InlongGroupEntity;
+import org.apache.inlong.manager.dao.entity.ScheduleEntity;
+import org.apache.inlong.manager.dao.mapper.InlongGroupEntityMapper;
+import org.apache.inlong.manager.dao.mapper.ScheduleEntityMapper;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfo;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfoRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ScheduleServiceImpl implements ScheduleService {
+
+    private static Logger LOGGER = 
LoggerFactory.getLogger(ScheduleServiceImpl.class);
+
+    @Autowired
+    private InlongGroupEntityMapper groupMapper;
+    @Autowired
+    private ScheduleEntityMapper scheduleEntityMapper;
+
+    @Override
+    public int save(ScheduleInfoRequest scheduleInfo, String operator) {
+        LOGGER.debug("begin to save schedule info, scheduleInfo: {}, operator: 
{}", scheduleInfo, operator);
+        Preconditions.expectNotNull(scheduleInfo, "schedule info request can't 
be null");
+
+        String groupId = scheduleInfo.getGroupId();
+        checkGroupExist(groupId);
+        if (scheduleEntityMapper.selectByGroupId(groupId) != null) {
+            LOGGER.error("schedule info for group : {} already exists", 
groupId);
+            throw new BusinessException(ErrorCodeEnum.SCHEDULE_DUPLICATE);
+        }
+
+        ScheduleEntity scheduleEntity = 
CommonBeanUtils.copyProperties(scheduleInfo, ScheduleEntity::new);
+        scheduleEntity.setStatus(ScheduleStatus.NEW.getCode());
+        scheduleEntity.setCreator(operator);
+        scheduleEntity.setModifier(operator);
+        return scheduleEntityMapper.insert(scheduleEntity);
+    }
+
+    @Override
+    public Boolean exist(String groupId) {
+        checkGroupExist(groupId);
+        return scheduleEntityMapper.selectByGroupId(groupId) != null;
+    }
+
+    @Override
+    public ScheduleInfo get(String groupId) {
+        LOGGER.debug("begin to get schedule info by groupId={}", groupId);
+        ScheduleEntity entity = getScheduleEntity(groupId);
+        return CommonBeanUtils.copyProperties(entity, ScheduleInfo::new);
+    }
+
+    @Override
+    public Boolean update(ScheduleInfoRequest request, String operator) {
+        LOGGER.debug("begin to update schedule info={}", request);
+        String groupId = request.getGroupId();
+        ScheduleEntity entity = getScheduleEntity(groupId);
+        CommonBeanUtils.copyProperties(request, entity, true);
+        entity.setModifier(operator);
+        scheduleEntityMapper.updateByIdSelective(entity);
+        LOGGER.info("success to update schedule info for groupId={}", groupId);
+        return true;
+    }
+
+    @Override
+    public Boolean deleteByGroupId(String groupId, String operator) {
+        LOGGER.debug("begin to delete schedule info for groupId={}", groupId);
+        checkGroupExist(groupId);
+        ScheduleEntity entity = scheduleEntityMapper.selectByGroupId(groupId);
+        if (entity == null) {
+            LOGGER.error("schedule info for groupId {} does not exist", 
groupId);
+            return false;
+        }
+        int res = scheduleEntityMapper.deleteByGroupId(groupId);

Review Comment:
   Please use logical deletion method.



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/schedule/ScheduleServiceImpl.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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 org.apache.inlong.manager.service.schedule;
+
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.enums.ScheduleStatus;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.common.util.Preconditions;
+import org.apache.inlong.manager.dao.entity.InlongGroupEntity;
+import org.apache.inlong.manager.dao.entity.ScheduleEntity;
+import org.apache.inlong.manager.dao.mapper.InlongGroupEntityMapper;
+import org.apache.inlong.manager.dao.mapper.ScheduleEntityMapper;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfo;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfoRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ScheduleServiceImpl implements ScheduleService {
+
+    private static Logger LOGGER = 
LoggerFactory.getLogger(ScheduleServiceImpl.class);
+
+    @Autowired
+    private InlongGroupEntityMapper groupMapper;
+    @Autowired
+    private ScheduleEntityMapper scheduleEntityMapper;
+
+    @Override
+    public int save(ScheduleInfoRequest scheduleInfo, String operator) {

Review Comment:
   public int save(ScheduleInfoRequest requst, String operator)



##########
inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql:
##########
@@ -957,4 +957,34 @@ CREATE TABLE IF NOT EXISTS `cluster_config`
 
 -- ----------------------------
 
+-- ----------------------------
+-- Table structure for schedule_config
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `schedule_config`
+(
+    `id`                     int(11)      NOT NULL AUTO_INCREMENT COMMENT 
'Incremental primary key',
+    `group_id`               varchar(256) NOT NULL COMMENT 'Inlong group id, 
undeleted ones cannot be repeated',
+    `schedule_type`          int(4)       NOT NULL DEFAULT '0' COMMENT 
'Schedule type, 0 for normal, 1 for crontab',
+    `schedule_unit`          varchar(64)  NOT NULL COMMENT 'Schedule 
unit,M=month, W=week, D=day, H=hour, M=minute, O=oneway',
+    `schedule_interval`      int(11)      DEFAULT '1' COMMENT 'Schedule 
interval',
+    `start_time`             timestamp    NOT NULL DEFAULT CURRENT_TIMESTAMP 
COMMENT 'Start time for schedule',
+    `end_time`               timestamp    NOT NULL DEFAULT CURRENT_TIMESTAMP 
COMMENT 'End time for schedule',
+    `delay_time`             int(11)      DEFAULT '0' COMMENT 'Delay time in 
minutes to schedule',
+    `self_depend`            int(11)      DEFAULT NULL COMMENT 'Self depend 
info',
+    `task_parallelism`       int(11)      DEFAULT NULL COMMENT 'Task 
parallelism',
+    `crontab_expression`     varchar(256) DEFAULT NULL COMMENT 'Crontab 
expression if schedule type is crontab',
+    `status`                 int(4)       DEFAULT '100' COMMENT 'Schedule 
status',
+    `previous_status`        int(4)       DEFAULT '100' COMMENT 'Previous 
schedule status',
+    `is_deleted`             int(11)      DEFAULT '0' COMMENT 'Whether to 
delete, 0: not deleted, > 0: deleted',
+    `creator`                varchar(64)  NOT NULL COMMENT 'Creator name',
+    `modifier`               varchar(64)  DEFAULT NULL COMMENT 'Modifier name',
+    `create_time`            timestamp    NOT NULL DEFAULT CURRENT_TIMESTAMP 
COMMENT 'Create time',
+    `modify_time`            timestamp    NOT NULL DEFAULT CURRENT_TIMESTAMP 
ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
+    `version`                int(11)      NOT NULL DEFAULT '1' COMMENT 
'Version number, which will be incremented by 1 after modification',
+    PRIMARY KEY (`id`)

Review Comment:
   Is (groupId, is_deleted) a unique key?



##########
inlong-manager/manager-dao/src/main/resources/mappers/ScheduleEntityMapper.xml:
##########
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper namespace="org.apache.inlong.manager.dao.mapper.ScheduleEntityMapper">
+    <resultMap id="BaseResultMap" 
type="org.apache.inlong.manager.dao.entity.ScheduleEntity">
+        <id column="id" jdbcType="INTEGER" property="id"/>
+        <result column="group_id" jdbcType="VARCHAR" property="groupId"/>
+        <result column="schedule_type" jdbcType="INTEGER" 
property="scheduleType"/>
+        <result column="schedule_unit" jdbcType="VARCHAR" 
property="scheduleUnit"/>
+        <result column="schedule_interval" jdbcType="INTEGER" 
property="scheduleInterval"/>
+        <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
+        <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
+        <result column="delay_time" jdbcType="INTEGER" property="delayTime"/>
+        <result column="self_depend" jdbcType="INTEGER" property="selfDepend"/>
+        <result column="task_parallelism" jdbcType="INTEGER" 
property="taskParallelism"/>
+        <result column="crontab_expression" jdbcType="VARCHAR" 
property="crontabExpression"/>
+
+        <result column="status" jdbcType="INTEGER" property="status"/>
+        <result column="previous_status" jdbcType="INTEGER" 
property="previousStatus"/>
+        <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
+        <result column="creator" jdbcType="VARCHAR" property="creator"/>
+        <result column="modifier" jdbcType="VARCHAR" property="modifier"/>
+        <result column="create_time" jdbcType="TIMESTAMP" 
property="createTime"/>
+        <result column="modify_time" jdbcType="TIMESTAMP" 
property="modifyTime"/>
+        <result column="version" jdbcType="INTEGER" property="version"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id, group_id, schedule_type, schedule_unit, schedule_interval, 
start_time,
+          end_time, delay_time, self_depend, task_parallelism, 
crontab_expression,
+           status, previous_status, is_deleted, creator, modifier, 
create_time, modify_time, version
+    </sql>
+
+    <insert id="insert" useGeneratedKeys="true" keyProperty="id"
+            
parameterType="org.apache.inlong.manager.dao.entity.ScheduleEntity">
+        insert into schedule_config (id, group_id, schedule_type, 
schedule_unit,
+                                     schedule_interval, start_time, end_time, 
delay_time,
+                                     self_depend, task_parallelism, 
crontab_expression,
+                                     status, previous_status, is_deleted, 
creator, modifier)
+        values (#{id, jdbcType=INTEGER}, #{groupId, jdbcType=VARCHAR},
+                #{scheduleType, jdbcType=INTEGER}, #{scheduleUnit, 
jdbcType=VARCHAR},
+                #{scheduleInterval, jdbcType=INTEGER}, #{startTime, 
jdbcType=TIMESTAMP},
+                #{endTime, jdbcType=TIMESTAMP}, #{delayTime, jdbcType=INTEGER},
+                #{selfDepend, jdbcType=INTEGER}, #{taskParallelism, 
jdbcType=INTEGER},
+                #{crontabExpression, jdbcType=VARCHAR}, 
#{status,jdbcType=INTEGER},
+                #{previousStatus,jdbcType=INTEGER}, 
#{isDeleted,jdbcType=INTEGER},
+                #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" 
resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from schedule_config
+        where id = #{id,jdbcType=INTEGER}
+    </select>
+
+    <select id="selectByGroupId" parameterType="java.lang.String" 
resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from schedule_config
+        where group_id = #{groupId,jdbcType=VARCHAR}
+    </select>
+
+    <update id="updateByIdSelective" 
parameterType="org.apache.inlong.manager.dao.entity.ScheduleEntity">
+        update schedule_config
+        <set>
+            <if test="groupId != null">
+                group_id = #{groupId, jdbcType=VARCHAR},
+            </if>
+            <if test="scheduleType != null">
+                schedule_type = #{scheduleType, jdbcType=INTEGER},
+            </if>
+            <if test="scheduleUnit !=null">
+                schedule_unit = #{scheduleUnit, jdbcType=VARCHAR},
+            </if>
+            <if test="scheduleInterval != null">
+                schedule_interval = #{scheduleInterval, jdbcType=INTEGER},
+            </if>
+            <if test="startTime != null">
+                start_time = #{startTime, jdbcType=TIMESTAMP},
+            </if>
+            <if test="endTime != null">
+                end_time = #{endTime, jdbcType=TIMESTAMP},
+            </if>
+            <if test="delayTime != null">
+                delay_time = #{delayTime, jdbcType=INTEGER},
+            </if>
+            <if test="selfDepend != null">
+                self_depend = #{selfDepend, jdbcType=INTEGER},
+            </if>
+            <if test="taskParallelism != null">
+                task_parallelism = #{taskParallelism, jdbcType=INTEGER},
+            </if>
+            <if test="crontabExpression != null">
+                crontab_expression = #{crontabExpression, jdbcType=VARCHAR},
+            </if>
+        </set>
+        <where>
+            id = #{id, jdbcType=INTEGER}
+        </where>

Review Comment:
    and version = #{version,jdbcType=INTEGER}



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/schedule/ScheduleServiceImpl.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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 org.apache.inlong.manager.service.schedule;
+
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.enums.ScheduleStatus;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.common.util.Preconditions;
+import org.apache.inlong.manager.dao.entity.InlongGroupEntity;
+import org.apache.inlong.manager.dao.entity.ScheduleEntity;
+import org.apache.inlong.manager.dao.mapper.InlongGroupEntityMapper;
+import org.apache.inlong.manager.dao.mapper.ScheduleEntityMapper;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfo;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfoRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ScheduleServiceImpl implements ScheduleService {
+
+    private static Logger LOGGER = 
LoggerFactory.getLogger(ScheduleServiceImpl.class);
+
+    @Autowired
+    private InlongGroupEntityMapper groupMapper;
+    @Autowired
+    private ScheduleEntityMapper scheduleEntityMapper;
+
+    @Override
+    public int save(ScheduleInfoRequest scheduleInfo, String operator) {
+        LOGGER.debug("begin to save schedule info, scheduleInfo: {}, operator: 
{}", scheduleInfo, operator);
+        Preconditions.expectNotNull(scheduleInfo, "schedule info request can't 
be null");
+
+        String groupId = scheduleInfo.getGroupId();
+        checkGroupExist(groupId);
+        if (scheduleEntityMapper.selectByGroupId(groupId) != null) {
+            LOGGER.error("schedule info for group : {} already exists", 
groupId);
+            throw new BusinessException(ErrorCodeEnum.SCHEDULE_DUPLICATE);
+        }
+
+        ScheduleEntity scheduleEntity = 
CommonBeanUtils.copyProperties(scheduleInfo, ScheduleEntity::new);
+        scheduleEntity.setStatus(ScheduleStatus.NEW.getCode());
+        scheduleEntity.setCreator(operator);
+        scheduleEntity.setModifier(operator);
+        return scheduleEntityMapper.insert(scheduleEntity);
+    }
+
+    @Override
+    public Boolean exist(String groupId) {
+        checkGroupExist(groupId);
+        return scheduleEntityMapper.selectByGroupId(groupId) != null;
+    }
+
+    @Override
+    public ScheduleInfo get(String groupId) {
+        LOGGER.debug("begin to get schedule info by groupId={}", groupId);
+        ScheduleEntity entity = getScheduleEntity(groupId);
+        return CommonBeanUtils.copyProperties(entity, ScheduleInfo::new);
+    }
+
+    @Override
+    public Boolean update(ScheduleInfoRequest request, String operator) {
+        LOGGER.debug("begin to update schedule info={}", request);
+        String groupId = request.getGroupId();
+        ScheduleEntity entity = getScheduleEntity(groupId);
+        CommonBeanUtils.copyProperties(request, entity, true);
+        entity.setModifier(operator);
+        scheduleEntityMapper.updateByIdSelective(entity);

Review Comment:
   The update may fail and an exception needs to be thrown.



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/schedule/ScheduleService.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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 org.apache.inlong.manager.service.schedule;
+
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfo;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfoRequest;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+public interface ScheduleService {
+
+    /**
+     * Save schedule info.
+     *
+     * @param scheduleInfo schedule request need to save
+     * @param operator name of operator
+     * @return schedule info id in backend storage
+     */
+    int save(@Valid @NotNull(message = "schedule request cannot be null") 
ScheduleInfoRequest scheduleInfo,

Review Comment:
    int save(@Valid @NotNull(message = "schedule request cannot be null") 
ScheduleInfoRequest request,



##########
inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InLongSchedulerController.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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 org.apache.inlong.manager.web.controller;
+
+import org.apache.inlong.manager.common.enums.OperationTarget;
+import org.apache.inlong.manager.common.enums.OperationType;
+import org.apache.inlong.manager.common.validation.UpdateValidation;
+import org.apache.inlong.manager.pojo.common.Response;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfo;
+import org.apache.inlong.manager.pojo.schedule.ScheduleInfoRequest;
+import org.apache.inlong.manager.pojo.user.LoginUserUtils;
+import org.apache.inlong.manager.service.operationlog.OperationLog;
+import org.apache.inlong.manager.service.schedule.ScheduleService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/api")
+@Api(tags = "Inlong-Schedule-API")
+public class InLongSchedulerController {
+
+    @Autowired
+    private ScheduleService scheduleService;
+
+    @RequestMapping(value = "/schedule/save", method = RequestMethod.POST)
+    @OperationLog(operation = OperationType.CREATE, operationTarget = 
OperationTarget.SCHEDULE)
+    @ApiOperation(value = "Save schedule info")
+    public Response<Integer> save(@RequestBody ScheduleInfoRequest request) {
+        int result = scheduleService.save(request, 
LoginUserUtils.getLoginUser().getName());
+        return Response.success(result);
+    }
+
+    @RequestMapping(value = "/schedule/exist/{groupId}", method = 
RequestMethod.GET)
+    @ApiOperation(value = "Is the schedule info exists for inlong group")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "groupId", dataTypeClass = String.class, 
required = true)

Review Comment:
   @ApiImplicitParam(name = "groupId", dataTypeClass = String.class, required = 
true)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to