新增elastic-job,简单整合未完成

This commit is contained in:
大帅比冷冷 2018-02-07 23:11:36 +08:00
parent 76b02938cb
commit 23815654da
7 changed files with 190 additions and 0 deletions

View File

@ -28,6 +28,7 @@ pig
├── pig-eureka -- 服务注册与发现[1025]
├── pig-gateway -- ZUUL网关[9999]
├── pig-modules -- 微服务模块
├ ├── pig-daemon-service -- 分布式调度中心[4060]
├ ├── pig-mc-service -- 消息中心[4050]
├ ├── pig-sso-client-demo -- 单点登录客户端示例[4040]
├ └── pig-upms-service -- 权限管理提供[4000]
@ -54,6 +55,7 @@ pig
- 代码生成前后端代码的生成支持Vue
- 缓存管理基于Cache Cloud 保证Redis 的高可用
- 服务监控: Spring Boot Admin
- 分布式任务调度: 基于elastic-job的分布式文件系统zookeeper做调度中心
- zipkin链路追踪 数据保存ELK图形化展示
- pinpoint链路追踪 数据保存hbase图形化展示

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.pig</groupId>
<artifactId>pig-daemon-service</artifactId>
<version>${pig.version}</version>
<packaging>jar</packaging>
<name>pig-daemon-service</name>
<description>后台跑批定时任务模块</description>
<parent>
<groupId>com.github.pig</groupId>
<artifactId>pig-modules</artifactId>
<version>${pig.version}</version>
</parent>
<properties>
<elastic-job.version>2.1.5</elastic-job.version>
<curator.version>2.10.0</curator.version>
</properties>
<dependencies>
<dependency>
<groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId>
<version>${pig.version}</version>
</dependency>
<dependency>
<groupId>com.github.xjzrc.spring.boot</groupId>
<artifactId>elastic-job-lite-spring-boot-starter</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>${curator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>${curator.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,20 @@
package com.github.pig.daemon;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* @author lengleng
* @date 2018年02月07日20:35:35
* 分布式任务调度模块
*/
@EnableDiscoveryClient
@SpringBootApplication
public class PigDaemonApplication {
public static void main(String[] args) {
SpringApplication.run(PigDaemonApplication.class, args);
}
}

View File

@ -0,0 +1,28 @@
package com.github.pig.daemon.job;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.zen.elasticjob.spring.boot.annotation.ElasticJobConfig;
import lombok.extern.slf4j.Slf4j;
/**
* @author lengleng
* @date 2018/2/7
* 测试Job
*/
@Slf4j
@ElasticJobConfig(cron = "0/2 * * * * ?", shardingTotalCount = 3,
shardingItemParameters = "0=Beijing,1=Shanghai,2=Guangzhou",
startedTimeoutMilliseconds = 5000L,
completedTimeoutMilliseconds = 10000L)
public class DemoSimpleJob implements SimpleJob {
/**
* 业务执行逻辑
*
* @param shardingContext 分片信息
*/
@Override
public void execute(ShardingContext shardingContext) {
log.info("--------------");
}
}

View File

@ -0,0 +1,34 @@
spring:
application:
name: pig-daemon-service
profiles:
active: dev
cloud:
config:
fail-fast: true
discovery:
service-id: pig-config-server
enabled: true
profile: ${spring.profiles.active}
label: ${spring.profiles.active}
---
spring:
profiles: dev
eureka:
instance:
prefer-ip-address: true
lease-renewal-interval-in-seconds: 5
lease-expiration-duration-in-seconds: 20
client:
serviceUrl:
defaultZone: http://pig:gip6666@localhost:1025/eureka
---
spring:
profiles: prd
eureka:
instance:
prefer-ip-address: true
client:
serviceUrl:
defaultZone: http://pig:gip6666@pig-eureka:1025/eureka

View File

@ -0,0 +1,28 @@
package com.github.pig.admin;
import org.jasypt.encryption.StringEncryptor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = PigAdminApplication.class)
public class PigAdminApplicationTest {
@Autowired
private StringEncryptor stringEncryptor;
@Test
public void testEnvironmentProperties() {
System.out.println(stringEncryptor.encrypt("redis"));
System.out.println(stringEncryptor.encrypt("pig"));
System.out.println(stringEncryptor.encrypt("lengleng"));
System.out.println(stringEncryptor.encrypt("root"));
System.out.println(stringEncryptor.encrypt("g0HJr2Ltrs0k6tJDY6pDI2aVMUCPSWZDTROLcFMs"));
System.out.println(stringEncryptor.encrypt("24760324"));
System.out.println(stringEncryptor.encrypt("175d516debb916d3842d981dd3b76061"));
System.out.println(stringEncryptor.encrypt("101322838"));
System.out.println(stringEncryptor.encrypt("fe6ec1ed3fc45e664ce8ddbf78376ab7"));
}
}

View File

@ -20,6 +20,7 @@
</properties>
<modules>
<module>pig-daemon-service</module>
<module>pig-mc-service</module>
<module>pig-sso-client-demo</module>
<module>pig-upms-service</module>