com.github.hengboy.job.schedule.store.delegate.DriverDelegate 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.delegate;
import com.github.hengboy.job.core.exception.JobException;
import com.github.hengboy.job.core.wrapper.JobWrapper;
import com.github.hengboy.job.schedule.store.model.JobExecuteLog;
import com.github.hengboy.job.schedule.store.model.JobExecuteQueue;
import java.sql.Connection;
import java.sql.Timestamp;
/**
* 这是所有数据库驱动程序委托类的基本接口。
*
* @author:恒宇少年 - 于起宇
*
* DateTime:2019-01-28 14:34
* Blog:http://blog.yuqiyu.com
* WebSite:http://www.jianshu.com/u/092df3f77bca
* Gitee:https://gitee.com/hengboy
* GitHub:https://github.com/hengyuboy
*/
public interface DriverDelegate {
/**
* 初始化delegate所需要的相关配置信息
*
* @param tablePrefix 表前缀
* @param connection 数据库连接对象
*/
default void initialize(String tablePrefix, Connection connection) {
}
/**
* 添加任务队列基本信息
*
* @param newJobKey jobKey
* @param jobWrapper 任务封装对象
* @return 任务队列的主键值
* @throws JobException 任务异常
*/
String addJobQueue(String newJobKey, JobWrapper jobWrapper) throws JobException;
/**
* 更新任务队列cron表达式
*
* @param jobQueueId 任务队列主键
* @param cron cron表达式
* @throws JobException 任务异常
*/
void updateJobQueueCron(String jobQueueId, String cron) throws JobException;
/**
* 更新loop类型任务所需要的配置
*
* @param jobQueueId 任务队列主键
* @param loopTimes 循环次数
* @param loopIntervalMillis 每次的间隔毫秒值
* @throws JobException 任务异常
*/
void updateJobQueueLoop(String jobQueueId, int loopTimes, long loopIntervalMillis) throws JobException;
/**
* 根据自定义的任务队列key进行删除任务
*
* @param jobQueueId 任务队列主键
* @throws JobException 任务异常
*/
void removeJobQueue(String jobQueueId) throws JobException;
/**
* 根据任务队列主键查询任务队列信息
*
* @param jobQueueId 任务队列主键值
* @return 任务执行队列
* @throws JobException 任务异常
*/
JobExecuteQueue selectQueueById(String jobQueueId) throws JobException;
/**
* 根据任务队列自定义key查询队列信息
*
* @param jobQueueKey 任务队列自定义key
* @return 任务执行队列
* @throws JobException 任务异常
*/
JobExecuteQueue selectQueueByKey(String jobQueueKey) throws JobException;
/**
* 添加任务执行日志
*
* @param jobExecuteLog 任务执行日志数据实体
* @throws JobException 任务异常
*/
void addLog(JobExecuteLog jobExecuteLog) throws JobException;
/**
* 根据任务队列主键值查询日志信息
*
* @param jobLogId 任务日志编号
* @return 任务执行日志
* @throws JobException 任务异常
*/
JobExecuteLog selectLog(String jobLogId) throws JobException;
/**
* 更新日志状态
*
* @param jobLogId 任务日志编号
* @param logState 任务日志状态
* @throws JobException 任务异常
*/
void updateLogState(String jobLogId, String logState) throws JobException;
/**
* 更新日志消费者地址
*
* @param jobLogId 任务日志编号
* @param consumerAddress 任务消费者地址
* @throws JobException 任务异常
*/
void updateLogConsumerAddress(String jobLogId, String consumerAddress) throws JobException;
/**
* 更新日志重试次数
*
* @param jobLogId 任务日志编号
* @param retryCount 重试次数
* @throws JobException 任务异常
*/
void updateLogRetryCount(String jobLogId, int retryCount) throws JobException;
/**
* 更新任务日志执行成功时间
*
* @param jobLogId 任务日志编号
* @param successTime 执行成功时间
* @throws JobException 任务异常
*/
void updateLogSuccessTime(String jobLogId, Timestamp successTime) throws JobException;
}