├── src
└── main
│ ├── resources
│ ├── schedule.properties
│ ├── log4j.properties
│ ├── applicationContext.xml
│ └── spring-mvc.xml
│ ├── webapp
│ ├── static
│ │ ├── bootstrap-3.3.0
│ │ │ ├── fonts
│ │ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ │ ├── glyphicons-halflings-regular.woff
│ │ │ │ └── glyphicons-halflings-regular.svg
│ │ │ ├── js
│ │ │ │ ├── npm.js
│ │ │ │ └── bootstrap.min.js
│ │ │ └── css
│ │ │ │ ├── blog.css
│ │ │ │ ├── bootstrap-theme.min.css
│ │ │ │ ├── bootstrap-theme.css
│ │ │ │ └── bootstrap-theme.css.map
│ │ └── css
│ │ │ └── extraCSS.css
│ ├── index.jsp
│ └── WEB-INF
│ │ ├── web.xml
│ │ └── manage.jsp
│ └── java
│ └── com
│ └── rabbit
│ └── manage
│ ├── model
│ └── TaskDefineShow.java
│ ├── util
│ └── HttpClientUtil.java
│ └── controller
│ └── MainController.java
├── .gitignore
├── README.md
└── pom.xml
/src/main/resources/schedule.properties:
--------------------------------------------------------------------------------
1 | uncode.schedule.server.code=1000000001
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | .classpath
3 | .project
4 | .settings/
5 | .idea/
6 | *.iml
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # uncode-schedule-manage
2 | 这个作为uncode-schedule定时任务的管理节点,完善管理功能。
3 |
4 | 功能正在完善中...
5 |
6 | >特别感谢前端工程师刘芳同学的技术支持,她的[github](https://github.com/lf-liufang)
7 |
--------------------------------------------------------------------------------
/src/main/webapp/static/bootstrap-3.3.0/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rabbitgyk/uncode-schedule-manage/HEAD/src/main/webapp/static/bootstrap-3.3.0/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/src/main/webapp/static/bootstrap-3.3.0/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rabbitgyk/uncode-schedule-manage/HEAD/src/main/webapp/static/bootstrap-3.3.0/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/src/main/webapp/static/bootstrap-3.3.0/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rabbitgyk/uncode-schedule-manage/HEAD/src/main/webapp/static/bootstrap-3.3.0/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=INFO, stdout
2 |
3 | log4j.appender.stdout.encoding=UTF-8
4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender
5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
6 | log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss}\:%p(%L)%t %C - %M - %m%n
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/main/webapp/static/bootstrap-3.3.0/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/src/main/webapp/index.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
2 | <%
3 | String path = request.getContextPath();
4 | String basePath = path + "/";
5 | //String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
6 | %>
7 |
8 |
9 | uncode schedule manage
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | uncode schedule 任务调度系统管理界面
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/main/webapp/static/css/extraCSS.css:
--------------------------------------------------------------------------------
1 | th,td{
2 | font-size:14px;
3 | }
4 |
5 | a:focus{outline:none;}
6 | .table th,.table td{
7 | text-align: center;
8 | }
9 | .table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{
10 | vertical-align: middle;
11 | }
12 | .blog-masthead .container{
13 | width: 970px;
14 | }
15 | .table caption{
16 | font-size:18px;
17 | font-weight:bold;
18 | }
19 | .table-bordered > thead > tr > th{
20 | border-bottom-width: 1px;
21 | }
22 | .add-btn{
23 | float:right;
24 | border: none;
25 | border-radius: 3px;
26 | background: #2a6496;
27 | color: #fff;
28 | font-weight: normal;
29 | font-size: 14px;
30 | width: 60px;
31 | height: 30px;
32 | line-height: 30px;
33 | padding: 0;
34 | }
--------------------------------------------------------------------------------
/src/main/resources/applicationContext.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/main/java/com/rabbit/manage/model/TaskDefineShow.java:
--------------------------------------------------------------------------------
1 | package com.rabbit.manage.model;
2 |
3 | import cn.uncode.schedule.core.TaskDefine;
4 |
5 | public class TaskDefineShow extends TaskDefine {
6 |
7 | private String lastRunningTimeShow;
8 | private String startTimeShow;
9 | private String periodShow;
10 |
11 | public TaskDefineShow(){
12 |
13 | }
14 |
15 | public TaskDefineShow(TaskDefine taskDefine){
16 | this.setCronExpression(taskDefine.getCronExpression());
17 | this.setCurrentServer(taskDefine.getCurrentServer());
18 | this.setLastRunningTime(taskDefine.getLastRunningTime());
19 | this.setParams(taskDefine.getParams());
20 | this.setPeriod(taskDefine.getPeriod());
21 | this.setRunTimes(taskDefine.getRunTimes());
22 | this.setStartTime(taskDefine.getStartTime());
23 | this.setTargetBean(taskDefine.getTargetBean());
24 | this.setTargetMethod(taskDefine.getTargetMethod());
25 | this.setType(taskDefine.getType());
26 | }
27 |
28 | public String getLastRunningTimeShow() {
29 | return lastRunningTimeShow;
30 | }
31 |
32 | public void setLastRunningTimeShow(String lastRunningTimeShow) {
33 | this.lastRunningTimeShow = lastRunningTimeShow;
34 | }
35 |
36 | public String getStartTimeShow() {
37 | return startTimeShow;
38 | }
39 |
40 | public void setStartTimeShow(String startTimeShow) {
41 | this.startTimeShow = startTimeShow;
42 | }
43 |
44 | public String getPeriodShow() {
45 | return periodShow;
46 | }
47 |
48 | public void setPeriodShow(String periodShow) {
49 | this.periodShow = periodShow;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/resources/spring-mvc.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | application/json;charset=UTF-8
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
35 |
--------------------------------------------------------------------------------
/src/main/java/com/rabbit/manage/util/HttpClientUtil.java:
--------------------------------------------------------------------------------
1 | package com.rabbit.manage.util;
2 |
3 | import java.io.IOException;
4 | import java.security.KeyManagementException;
5 | import java.security.KeyStoreException;
6 | import java.security.NoSuchAlgorithmException;
7 | import java.security.cert.CertificateException;
8 | import java.security.cert.X509Certificate;
9 |
10 | import javax.net.ssl.SSLContext;
11 |
12 | import org.apache.http.HttpEntity;
13 | import org.apache.http.client.methods.CloseableHttpResponse;
14 | import org.apache.http.client.methods.HttpGet;
15 | import org.apache.http.client.methods.HttpPost;
16 | import org.apache.http.client.methods.HttpUriRequest;
17 | import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
18 | import org.apache.http.conn.ssl.TrustStrategy;
19 | import org.apache.http.impl.client.CloseableHttpClient;
20 | import org.apache.http.impl.client.HttpClients;
21 | import org.apache.http.ssl.SSLContextBuilder;
22 | import org.apache.http.util.EntityUtils;
23 |
24 | public class HttpClientUtil {
25 |
26 | private static String HTTP = "http";
27 | private static String HTTPS = "https";
28 |
29 | public static String httpPost(String url) throws Exception{
30 | HttpPost httppost = new HttpPost(url);
31 | return executeHttp(httppost, getHttpType(url));
32 | }
33 |
34 | public static String httpGet(String url) throws Exception{
35 | HttpGet httpget = new HttpGet(url);
36 | return executeHttp(httpget, getHttpType(url));
37 | }
38 |
39 | private static String getHttpType(String url){
40 | return url.split(":")[0];
41 | }
42 |
43 | /**
44 | * 创建ssl的client
45 | * @return
46 | */
47 | private static CloseableHttpClient createSSLClientDefault() {
48 | try {
49 | SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(
50 | null, new TrustStrategy() {
51 | // 信任所有
52 | public boolean isTrusted(X509Certificate[] chain,
53 | String authType) throws CertificateException {
54 | return true;
55 | }
56 | }).build();
57 | SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);
58 | return HttpClients.custom().setSSLSocketFactory(sslsf).build();
59 | } catch (KeyManagementException e) {
60 | e.printStackTrace();
61 | } catch (NoSuchAlgorithmException e) {
62 | e.printStackTrace();
63 | } catch (KeyStoreException e) {
64 | e.printStackTrace();
65 | }
66 | return HttpClients.createDefault();
67 | }
68 |
69 | /**
70 | * 执行http/https请求的方法
71 | * @param request
72 | * @return
73 | */
74 | private static String executeHttp(HttpUriRequest request, String type) throws Exception{
75 | String result = null;
76 | CloseableHttpResponse response = null;
77 | CloseableHttpClient httpclient = null;
78 | if(type.equals(HTTP)){
79 | httpclient = HttpClients.createDefault();
80 | }else if(type.equals(HTTPS)){
81 | httpclient = createSSLClientDefault();
82 | }
83 | try {
84 | response = httpclient.execute(request);
85 | HttpEntity myEntity = response.getEntity();
86 | result = EntityUtils.toString(myEntity);
87 | } catch (Exception e) {
88 | throw e;
89 | }finally{
90 | try {
91 | response.close();
92 | } catch (IOException e) {
93 | e.printStackTrace();
94 | }
95 | }
96 | return result;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/webapp/static/bootstrap-3.3.0/css/blog.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Globals
3 | */
4 |
5 | body {
6 | font-family: Georgia, "Times New Roman", Times, serif;
7 | color: #555;
8 | }
9 |
10 | h1, .h1,
11 | h2, .h2,
12 | h3, .h3,
13 | h4, .h4,
14 | h5, .h5,
15 | h6, .h6 {
16 | margin-top: 0;
17 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
18 | font-weight: normal;
19 | color: #333;
20 | }
21 |
22 |
23 | /*
24 | * Override Bootstrap's default container.
25 | */
26 |
27 | @media (min-width: 1200px) {
28 | .container {
29 | width: 970px;
30 | }
31 | }
32 |
33 |
34 | /*
35 | * Masthead for nav
36 | */
37 |
38 | .blog-masthead {
39 | background-color: #428bca;
40 | -webkit-box-shadow: inset 0 -2px 5px rgba(0,0,0,.1);
41 | box-shadow: inset 0 -2px 5px rgba(0,0,0,.1);
42 | }
43 |
44 | /* Nav links */
45 | .blog-nav-item {
46 | position: relative;
47 | display: inline-block;
48 | padding: 10px;
49 | font-weight: 500;
50 | color: #cdddeb;
51 | }
52 | .blog-nav-item:hover,
53 | .blog-nav-item:focus {
54 | color: #fff;
55 | text-decoration: none;
56 | }
57 |
58 | /* Active state gets a caret at the bottom */
59 | .blog-nav .active {
60 | color: #fff;
61 | }
62 | .blog-nav .active:after {
63 | position: absolute;
64 | bottom: 0;
65 | left: 50%;
66 | width: 0;
67 | height: 0;
68 | margin-left: -5px;
69 | vertical-align: middle;
70 | content: " ";
71 | border-right: 5px solid transparent;
72 | border-bottom: 5px solid;
73 | border-left: 5px solid transparent;
74 | }
75 |
76 |
77 | /*
78 | * Blog name and description
79 | */
80 |
81 | .blog-header {
82 | padding-top: 20px;
83 | padding-bottom: 20px;
84 | }
85 | .blog-title {
86 | margin-top: 30px;
87 | margin-bottom: 0;
88 | font-size: 60px;
89 | font-weight: normal;
90 | }
91 | .blog-description {
92 | font-size: 20px;
93 | color: #999;
94 | }
95 |
96 |
97 | /*
98 | * Main column and sidebar layout
99 | */
100 |
101 | .blog-main {
102 | font-size: 18px;
103 | line-height: 1.5;
104 | }
105 |
106 | /* Sidebar modules for boxing content */
107 | .sidebar-module {
108 | padding: 15px;
109 | margin: 0 -15px 15px;
110 | }
111 | .sidebar-module-inset {
112 | padding: 15px;
113 | background-color: #f5f5f5;
114 | border-radius: 4px;
115 | }
116 | .sidebar-module-inset p:last-child,
117 | .sidebar-module-inset ul:last-child,
118 | .sidebar-module-inset ol:last-child {
119 | margin-bottom: 0;
120 | }
121 |
122 |
123 | /* Pagination */
124 | .pager {
125 | margin-bottom: 60px;
126 | text-align: left;
127 | }
128 | .pager > li > a {
129 | width: 140px;
130 | padding: 10px 20px;
131 | text-align: center;
132 | border-radius: 30px;
133 | }
134 |
135 |
136 | /*
137 | * Blog posts
138 | */
139 |
140 | .blog-post {
141 | margin-bottom: 60px;
142 | }
143 | .blog-post-title {
144 | margin-bottom: 5px;
145 | font-size: 40px;
146 | }
147 | .blog-post-meta {
148 | margin-bottom: 20px;
149 | color: #999;
150 | }
151 |
152 |
153 | /*
154 | * Footer
155 | */
156 |
157 | .blog-footer {
158 | padding: 40px 0;
159 | color: #999;
160 | text-align: center;
161 | background-color: #f9f9f9;
162 | border-top: 1px solid #e5e5e5;
163 | }
164 | .blog-footer p:last-child {
165 | margin-bottom: 0;
166 | }
167 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | com.rabbit.schedule
4 | uncode-schedule-manage
5 | 0.0.1-SNAPSHOT
6 | war
7 |
8 |
9 | UTF-8
10 | UTF-8
11 | -Dfile.encoding=UTF-8
12 | 4.0.0.RELEASE
13 |
14 |
15 |
16 | cn.uncode
17 | uncode-schedule
18 | 0.8.0
19 |
20 |
21 | org.springframework
22 | spring-core
23 | ${spring.version}
24 |
25 |
26 | org.springframework
27 | spring-webmvc
28 | ${spring.version}
29 |
30 |
31 | log4j
32 | log4j
33 | 1.2.16
34 |
35 |
36 | org.slf4j
37 | slf4j-api
38 | 1.6.4
39 |
40 |
41 | org.slf4j
42 | slf4j-log4j12
43 | 1.6.4
44 |
45 |
46 | com.alibaba
47 | fastjson
48 | 1.2.21
49 |
50 |
51 | org.apache.httpcomponents
52 | httpclient
53 | 4.5.2
54 |
55 |
56 |
57 |
58 |
59 |
60 | ${project.basedir}/src/main/resources
61 | true
62 |
63 | **.xml
64 | **.properties
65 |
66 |
67 |
68 |
69 |
70 | org.apache.maven.plugins
71 | maven-compiler-plugin
72 | 3.1
73 |
74 | 1.7
75 | 1.7
76 | UTF-8
77 |
78 |
79 |
80 | maven-war-plugin
81 |
82 | uncode-schedule-manage
83 |
84 |
85 | ${project.basedir}/src/main/resources
86 | WEB-INF/classes
87 | true
88 |
89 |
90 | ${project.basedir}/src/main/webapp/WEB-INF
91 | true
92 | WEB-INF
93 |
94 | **/web.xml
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | uncode-schedule-manage
9 |
10 |
11 |
12 |
13 |
14 |
15 | contextConfigLocation
16 |
17 | classpath:applicationContext.xml
18 |
19 |
20 |
21 |
22 |
23 |
24 | org.springframework.web.context.ContextLoaderListener
25 |
26 |
27 |
28 |
29 |
30 |
31 | springmvc
32 | org.springframework.web.servlet.DispatcherServlet
33 |
34 | contextConfigLocation
35 | classpath:spring-mvc.xml
36 |
37 | 1
38 |
39 |
40 |
41 | springmvc
42 | /
43 |
44 |
45 |
46 |
47 | UncodeSchedule
48 | cn.uncode.schedule.web.ManagerServlet
49 |
50 |
51 | UncodeSchedule
52 | /uncode/schedule
53 |
54 |
55 |
56 |
57 |
58 | encodingFilter
59 | org.springframework.web.filter.CharacterEncodingFilter
60 |
61 | encoding
62 | UTF-8
63 |
64 |
65 | forceEncoding
66 | true
67 |
68 |
69 |
70 | encodingFilter
71 | /*
72 |
73 |
74 |
75 |
76 | default
77 | *.css
78 |
79 |
80 | default
81 | *.gif
82 |
83 |
84 | default
85 | *.jpg
86 |
87 |
88 | default
89 | *.js
90 |
91 |
92 | default
93 | *.ico
94 |
95 |
96 | default
97 | *.html
98 |
99 |
100 | default
101 | *.png
102 |
103 |
104 | default
105 | *.dmg
106 |
107 |
108 | default
109 | *.cab
110 |
111 |
112 | default
113 | *.msi
114 |
115 |
116 |
117 |
118 | 30
119 |
120 |
121 |
122 | index.jsp
123 |
124 |
--------------------------------------------------------------------------------
/src/main/java/com/rabbit/manage/controller/MainController.java:
--------------------------------------------------------------------------------
1 | package com.rabbit.manage.controller;
2 |
3 | import java.text.SimpleDateFormat;
4 | import java.util.ArrayList;
5 | import java.util.Date;
6 | import java.util.HashMap;
7 | import java.util.List;
8 | import java.util.Map;
9 |
10 | import org.apache.commons.lang3.StringUtils;
11 | import org.slf4j.Logger;
12 | import org.slf4j.LoggerFactory;
13 | import org.springframework.stereotype.Controller;
14 | import org.springframework.web.bind.annotation.ModelAttribute;
15 | import org.springframework.web.bind.annotation.RequestMapping;
16 | import org.springframework.web.bind.annotation.RequestMethod;
17 | import org.springframework.web.bind.annotation.ResponseBody;
18 |
19 | import cn.uncode.schedule.ConsoleManager;
20 | import cn.uncode.schedule.ZKScheduleManager;
21 | import cn.uncode.schedule.core.TaskDefine;
22 |
23 | import com.alibaba.fastjson.JSONObject;
24 | import com.rabbit.manage.model.TaskDefineShow;
25 | import com.rabbit.manage.util.HttpClientUtil;
26 |
27 | @Controller
28 | @RequestMapping("/main")
29 | public class MainController {
30 | private Logger log = LoggerFactory.getLogger(MainController.class);
31 |
32 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
33 |
34 | /**
35 | * 打开定时任务的管理页面
36 | * @return
37 | */
38 | @RequestMapping("/page")
39 | public String mPage(){
40 | return "manage";
41 | }
42 |
43 | /**
44 | * 获取所有的定时任务的执行节点的信息
45 | * @return
46 | */
47 | @RequestMapping(value="/servers", method =RequestMethod.GET)
48 | @ResponseBody
49 | public String servers(){
50 | ZKScheduleManager manager = null;
51 | try {
52 | manager = ConsoleManager.getScheduleManager();
53 | } catch (Exception e1) {
54 | e1.printStackTrace();
55 | }
56 | List servers = null;
57 | try {
58 | servers = manager.getScheduleDataManager().loadScheduleServerNames();
59 | } catch (Exception e) {
60 | e.printStackTrace();
61 | }
62 | log.info("获取到的所有的server node:{}", JSONObject.toJSONString(servers));
63 | List