diff --git a/README.md b/README.md index df02a65c..e76b7d46 100644 --- a/README.md +++ b/README.md @@ -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,图形化展示 diff --git a/pig-modules/pig-daemon-service/pom.xml b/pig-modules/pig-daemon-service/pom.xml new file mode 100644 index 00000000..6e42b837 --- /dev/null +++ b/pig-modules/pig-daemon-service/pom.xml @@ -0,0 +1,77 @@ + + + 4.0.0 + + com.github.pig + pig-daemon-service + ${pig.version} + jar + + pig-daemon-service + 后台跑批定时任务模块 + + + com.github.pig + pig-modules + ${pig.version} + + + + 2.1.5 + 2.10.0 + + + + + com.github.pig + pig-common + ${pig.version} + + + com.github.xjzrc.spring.boot + elastic-job-lite-spring-boot-starter + 1.0.0 + + + org.apache.curator + curator-framework + + + org.apache.curator + curator-recipes + + + + + org.apache.curator + curator-framework + ${curator.version} + + + org.apache.curator + curator-recipes + ${curator.version} + + + org.apache.curator + curator-framework + + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + ${project.name} + + + + + + diff --git a/pig-modules/pig-daemon-service/src/main/java/com/github/pig/daemon/PigDaemonApplication.java b/pig-modules/pig-daemon-service/src/main/java/com/github/pig/daemon/PigDaemonApplication.java new file mode 100644 index 00000000..86374a76 --- /dev/null +++ b/pig-modules/pig-daemon-service/src/main/java/com/github/pig/daemon/PigDaemonApplication.java @@ -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); + } + +} diff --git a/pig-modules/pig-daemon-service/src/main/java/com/github/pig/daemon/job/DemoSimpleJob.java b/pig-modules/pig-daemon-service/src/main/java/com/github/pig/daemon/job/DemoSimpleJob.java new file mode 100644 index 00000000..00cb84ca --- /dev/null +++ b/pig-modules/pig-daemon-service/src/main/java/com/github/pig/daemon/job/DemoSimpleJob.java @@ -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("--------------"); + } +} diff --git a/pig-modules/pig-daemon-service/src/main/resources/bootstrap.yml b/pig-modules/pig-daemon-service/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..cc00f360 --- /dev/null +++ b/pig-modules/pig-daemon-service/src/main/resources/bootstrap.yml @@ -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 \ No newline at end of file diff --git a/pig-modules/pig-upms-service/src/test/java/com/github/pig/admin/PigAdminApplicationTest.java b/pig-modules/pig-upms-service/src/test/java/com/github/pig/admin/PigAdminApplicationTest.java new file mode 100644 index 00000000..7a0834c7 --- /dev/null +++ b/pig-modules/pig-upms-service/src/test/java/com/github/pig/admin/PigAdminApplicationTest.java @@ -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")); + } + +} diff --git a/pig-modules/pom.xml b/pig-modules/pom.xml index f3ce242e..63278a93 100644 --- a/pig-modules/pom.xml +++ b/pig-modules/pom.xml @@ -20,6 +20,7 @@ + pig-daemon-service pig-mc-service pig-sso-client-demo pig-upms-service