why I am so stupid? How can I find the way to ensure Scheduler HA?

This commit is contained in:
tjq 2020-03-30 13:02:23 +08:00
parent 26206a90cf
commit 1267b3a34f
9 changed files with 240 additions and 0 deletions

View File

@ -13,5 +13,60 @@
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<swagger.version>2.9.2</swagger.version>
<springboot.version>2.2.6.RELEASE</springboot.version>
</properties>
<dependencies>
<!-- SpringBoot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<!-- swagger2 ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
</dependencies>
<!-- SpringBoot专用的打包插件 -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
<configuration>
<mainClass>com.github.kfcfans.oms.server.OhMyApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,19 @@
package com.github.kfcfans.oms.server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* SpringBoot 启动入口
*
* @author tjq
* @since 2020/3/29
*/
@SpringBootApplication
public class OhMyApplication {
public static void main(String[] args) {
SpringApplication.run(OhMyApplication.class, args);
}
}

View File

@ -0,0 +1,43 @@
package com.github.kfcfans.oms.server.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static springfox.documentation.builders.PathSelectors.any;
/**
* Swagger UI 配置
*
* @author tjq
* @since 2020/3/29
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
// apiInfo()用来创建该Api的基本信息这些基本信息会展现在文档页面中
ApiInfo apiInfo = new ApiInfoBuilder()
.title("OhMyScheduler")
.description("Distributed scheduling and computing framework.")
.license("GPL")
.termsOfServiceUrl("https://github.com/KFCFans/OhMyScheduler")
.version("DEVELOP-VERSION")
.build();
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo)
// select()函数返回一个ApiSelectorBuilder实例
.select()
// 决定了暴露哪些接口给 Swagger
.paths(any())
.build();
}
}

View File

@ -0,0 +1,22 @@
package com.github.kfcfans.oms.server.model;
import java.util.Date;
/**
* 数据库实体类基类
*
* @author tjq
* @since 2020/3/29
*/
public abstract class BaseDO {
/**
* 主键
*/
private Long id;
private Date gmtCreate;
private Date gmtModified;
private String attribute;
}

View File

@ -0,0 +1,20 @@
package com.github.kfcfans.oms.server.model;
/**
* 分组信息表
*
* @author tjq
* @since 2020/3/29
*/
public class GroupInfoDO extends BaseDO {
/**
* 分组名称
*/
private String groupName;
/**
* 分组描述
*/
private String groupDescription;
}

View File

@ -0,0 +1,43 @@
package com.github.kfcfans.oms.server.model;
/**
* 任务信息表
*
* @author tjq
* @since 2020/3/29
*/
public class JobInfoDO extends BaseDO {
/* ************************** 任务基本信息 ************************** */
// 任务名称
private String jobName;
// 任务描述
private String jobDescription;
// 任务分组名称
private String groupName;
/* ************************** 定时参数 ************************** */
// 时间表达式类型CRON/API/FIX_RATE/FIX_DELAY
private int timeExpressionType;
// 时间表达式CRON/NULL/LONG/LONG
private String timeExpression;
/* ************************** 执行方式 ************************** */
// 执行类型单机/广播/MR
private int executeType;
// 执行器类型Java/Shell
private int processorType;
// 执行器信息
private String processorInfo;
/* ************************** 运行时配置 ************************** */
// 并发度同时执行的线程数量
private int concurrency;
// 任务整体超时时间
private long instanceTimeLimit;
// 任务的每一个Task超时时间
private long taskTimeLimit;
}

View File

@ -0,0 +1,22 @@
package com.github.kfcfans.oms.server.model;
/**
* 任务运行日志表
*
* @author tjq
* @since 2020/3/30
*/
public class JobLogDO extends BaseDO {
// 任务ID
private Long jobId;
// 任务实例ID
private String instanceId;
// 任务状态 运行中/成功/失败...
private int status;
// 执行结果
private String result;
// 耗时
private Long usedTime;
}

View File

@ -0,0 +1,14 @@
package com.github.kfcfans.oms.server.model;
/**
* 注册信息表用于服务发现
*
* @author tjq
* @since 2020/3/30
*/
public class RegisterInfoDO extends BaseDO {
private String appName;
private String currentServerAddress;
private String lastServerAddress;
}

View File

@ -0,0 +1,2 @@
# server port config
server.port=7700