com.github.hengboy.job.schedule.store.JobStore Maven / Gradle / Ivy
/*
* Copyright [2019] [恒宇少年 - 于起宇]
*
* Licensed 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 com.github.hengboy.job.schedule.store;
import com.github.hengboy.job.core.exception.JobException;
import com.github.hengboy.job.core.wrapper.JobWrapper;
import com.github.hengboy.job.schedule.store.model.JobDetail;
import com.github.hengboy.job.schedule.store.model.JobExecuteQueue;
import java.util.List;
/**
* 任务数据操作接口定义
*
* @author:恒宇少年 - 于起宇
*
* DateTime:2019-01-28 14:05
* Blog:http://blog.yuqiyu.com
* WebSite:http://www.jianshu.com/u/092df3f77bca
* Gitee:https://gitee.com/hengboy
* GitHub:https://github.com/hengyuboy
*/
public interface JobStore {
/**
* 添加任务
*
* @param jobWrapper 任务封装对象
* @return 任务队列主键值
* @throws JobException 任务异常
*/
String addJob(JobWrapper jobWrapper) throws JobException;
/**
* 根据任务的定义key查询任务详细信息
*
* @param jobKey 任务定义Key
* @return 任务数据详情
* @throws JobException 任务异常
*/
JobDetail selectJob(String jobKey) throws JobException;
/**
* 根据主键查询任务队列
*
* @param jobQueueId 任务队列主键
* @return 任务执行队列
* @throws JobException 任务异常
*/
JobExecuteQueue selectJobQueueById(String jobQueueId) throws JobException;
/**
* 根据自定义任务key查询任务队列信息
*
* @param jobQueueKey 任务队列自定义key
* @return 任务执行队列
* @throws JobException 任务异常
*/
JobExecuteQueue selectJobQueueByKey(String jobQueueKey) throws JobException;
/**
* 根据任务编号删除单个任务
*
* @param jobQueueId 任务队列主键
* @throws JobException 任务异常
*/
void removeJob(String jobQueueId) throws JobException;
/**
* 根据任务编号列表删除多个任务
*
* @param jobQueueIds 任务队列主键集合
* @throws JobException 任务异常
*/
void removeJobs(List jobQueueIds) throws JobException;
/**
* 暂停任务
*
* @param jobQueueId 任务队列主键
* @throws JobException 任务异常
*/
void pauseJob(String jobQueueId) throws JobException;
/**
* 启动任务
*
* @param jobQueueId 任务队列主键
* @throws JobException 任务异常
*/
void startJob(String jobQueueId) throws JobException;
/**
* 验证任务是否存在
*
* @param jobQueueId 任务队列主键
* @return true:存在,false:不存在任务
* @throws JobException 任务异常
*/
boolean checkExists(String jobQueueId) throws JobException;
/**
* 添加任务执行日志信息
*
* @param jobQueueId 任务队列编号
* @return 任务日志编号
* @throws JobException 任务异常
*/
String addJobLog(String jobQueueId) throws JobException;
/**
* 更新任务状态
*
* @param jobExecuteLogId 任务日志编号
* @param jobState 任务状态
* @throws JobException 任务异常
*/
void updateJobState(String jobExecuteLogId, String jobState) throws JobException;
/**
* 更新任务执行成功时间
*
* @param jobExecuteLogId 任务日志编号
* @throws JobException 任务异常
*/
void updateJobExecuteSuccessTime(String jobExecuteLogId) throws JobException;
/**
* 更新任务执行消费者地址
*
* @param jobExecuteLogId 任务日志编号
* @param consumerAddress 任务消费的消费者地址
* @throws JobException 任务异常
*/
void updateJobExecuteConsumer(String jobExecuteLogId, String consumerAddress) throws JobException;
/**
* 更新日志重试次数
*
* @param jobExecuteLogId 任务执行日志编号
* @param retryTimes 重试次数
* @throws JobException 任务异常
*/
void updateJobRetryTimes(String jobExecuteLogId, int retryTimes) throws JobException;
}