From 0276559cba8915f5a5a4aa9e8a8bc57ba414cfd1 Mon Sep 17 00:00:00 2001 From: hugui <254963746@qq.com> Date: Sun, 17 Apr 2016 07:55:45 +0800 Subject: [PATCH] init --- lts-example-jobclient/pom.xml | 15 ++++++ .../lts-example-jobtracker-springboot/pom.xml | 25 +++++++++ .../example/springboot/Application.java | 20 +++++++ .../springboot/MasterNodeChangeListener.java | 31 +++++++++++ .../src/main/resources/application.properties | 8 +++ .../src/main/resources/log4j.properties | 7 +++ lts-example-jobtracker/pom.xml | 52 +++++++++++++++++++ lts-example-monitor/pom.xml | 15 ++++++ lts-example-tasktracker/pom.xml | 15 ++++++ 9 files changed, 188 insertions(+) create mode 100644 lts-example-jobclient/pom.xml create mode 100644 lts-example-jobtracker/lts-example-jobtracker-springboot/pom.xml create mode 100644 lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/java/com/github/ltsopensource/example/springboot/Application.java create mode 100644 lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/java/com/github/ltsopensource/example/springboot/MasterNodeChangeListener.java create mode 100644 lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/resources/application.properties create mode 100644 lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/resources/log4j.properties create mode 100644 lts-example-jobtracker/pom.xml create mode 100644 lts-example-monitor/pom.xml create mode 100644 lts-example-tasktracker/pom.xml diff --git a/lts-example-jobclient/pom.xml b/lts-example-jobclient/pom.xml new file mode 100644 index 0000000..62d72b4 --- /dev/null +++ b/lts-example-jobclient/pom.xml @@ -0,0 +1,15 @@ + + + + lts-examples + com.github.ltsopensource + 1.6.7 + + 4.0.0 + + lts-example-jobclient + + + \ No newline at end of file diff --git a/lts-example-jobtracker/lts-example-jobtracker-springboot/pom.xml b/lts-example-jobtracker/lts-example-jobtracker-springboot/pom.xml new file mode 100644 index 0000000..7108dfa --- /dev/null +++ b/lts-example-jobtracker/lts-example-jobtracker-springboot/pom.xml @@ -0,0 +1,25 @@ + + + + lts-example-jobtracker + com.github.ltsopensource + 1.6.7 + + 4.0.0 + + lts-example-jobtracker-springboot + + + + org.springframework.boot + spring-boot + + + org.springframework.boot + spring-boot-autoconfigure + + + + \ No newline at end of file diff --git a/lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/java/com/github/ltsopensource/example/springboot/Application.java b/lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/java/com/github/ltsopensource/example/springboot/Application.java new file mode 100644 index 0000000..a94204f --- /dev/null +++ b/lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/java/com/github/ltsopensource/example/springboot/Application.java @@ -0,0 +1,20 @@ +package com.github.ltsopensource.example.springboot; + +import com.github.ltsopensource.spring.boot.annotation.EnableJobTracker; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +/** + * @author Robert HG (254963746@qq.com) on 4/9/16. + */ +@SpringBootApplication +@EnableJobTracker +@ComponentScan("com.github.ltsopensource.example") +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/java/com/github/ltsopensource/example/springboot/MasterNodeChangeListener.java b/lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/java/com/github/ltsopensource/example/springboot/MasterNodeChangeListener.java new file mode 100644 index 0000000..5883bbc --- /dev/null +++ b/lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/java/com/github/ltsopensource/example/springboot/MasterNodeChangeListener.java @@ -0,0 +1,31 @@ +package com.github.ltsopensource.example.springboot; + +import com.github.ltsopensource.core.cluster.Node; +import com.github.ltsopensource.core.commons.utils.StringUtils; +import com.github.ltsopensource.core.listener.MasterChangeListener; +import com.github.ltsopensource.core.logger.Logger; +import com.github.ltsopensource.core.logger.LoggerFactory; +import com.github.ltsopensource.spring.boot.annotation.MasterNodeListener; + +/** + * @author Robert HG (254963746@qq.com) on 4/9/16. + */ +@MasterNodeListener +public class MasterNodeChangeListener implements MasterChangeListener { + + private static final Logger LOGGER = LoggerFactory.getLogger(MasterNodeChangeListener.class); + + /** + * @param master master节点 + * @param isMaster 表示当前节点是不是master节点 + */ + @Override + public void change(Node master, boolean isMaster) { + // 一个节点组master节点变化后的处理 , 譬如我多个JobClient, 但是有些事情只想只有一个节点能做。 + if (isMaster) { + LOGGER.info("我变成了节点组中的master节点了, 恭喜, 我要放大招了"); + } else { + LOGGER.info(StringUtils.format("master节点变成了{},不是我,我不能放大招,要猥琐", master)); + } + } +} diff --git a/lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/resources/application.properties b/lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/resources/application.properties new file mode 100644 index 0000000..fe5439a --- /dev/null +++ b/lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/resources/application.properties @@ -0,0 +1,8 @@ +lts.jobtracker.cluster-name=test_cluster +lts.jobtracker.listen-port=35001 +lts.jobtracker.registry-address=zookeeper://127.0.0.1:2181 +lts.jobtracker.configs.job.logger=mysql +lts.jobtracker.configs.job.queue=mysql +lts.jobtracker.configs.jdbc.url=jdbc:mysql://127.0.0.1:3306/lts +lts.jobtracker.configs.jdbc.username=root +lts.jobtracker.configs.jdbc.password=root diff --git a/lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/resources/log4j.properties b/lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/resources/log4j.properties new file mode 100644 index 0000000..4e3c103 --- /dev/null +++ b/lts-example-jobtracker/lts-example-jobtracker-springboot/src/main/resources/log4j.properties @@ -0,0 +1,7 @@ + +log4j.rootLogger=INFO,stdout + +log4j.appender.stdout.Threshold=INFO +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=[%-5p] [%d{HH:mm:ss}] %c - %m%n \ No newline at end of file diff --git a/lts-example-jobtracker/pom.xml b/lts-example-jobtracker/pom.xml new file mode 100644 index 0000000..067e0c7 --- /dev/null +++ b/lts-example-jobtracker/pom.xml @@ -0,0 +1,52 @@ + + + + lts-examples + com.github.ltsopensource + 1.6.7 + + 4.0.0 + lts-example-jobtracker + pom + + lts-example-jobtracker-springboot + + + + + com.github.ltsopensource + lts-jobtracker + + + com.github.ltsopensource + lts-spring + + + log4j + log4j + + + com.github.sgroschupf + zkclient + + + io.netty + netty-all + + + mysql + mysql-connector-java + + + com.alibaba + druid + + + com.alibaba + fastjson + + + + \ No newline at end of file diff --git a/lts-example-monitor/pom.xml b/lts-example-monitor/pom.xml new file mode 100644 index 0000000..fccc9cc --- /dev/null +++ b/lts-example-monitor/pom.xml @@ -0,0 +1,15 @@ + + + + lts-examples + com.github.ltsopensource + 1.6.7 + + 4.0.0 + + lts-example-monitor + + + \ No newline at end of file diff --git a/lts-example-tasktracker/pom.xml b/lts-example-tasktracker/pom.xml new file mode 100644 index 0000000..310bc1d --- /dev/null +++ b/lts-example-tasktracker/pom.xml @@ -0,0 +1,15 @@ + + + + lts-examples + com.github.ltsopensource + 1.6.7 + + 4.0.0 + + lts-example-tasktracker + + + \ No newline at end of file