Pārlūkot izejas kodu

升级 xxl-rpc 依赖;

xuxueli 6 gadus atpakaļ
vecāks
revīzija
d54d679edb

+ 1 - 1
doc/XXL-JOB官方文档.md Parādīt failu

@@ -1396,7 +1396,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
1396 1396
 - 1、调度中心告警邮件发送组件改为 “spring-boot-starter-mail”;
1397 1397
 - 2、任务告警逻辑调整,改为通过扫描失败日志方式触发。一方面精确扫描失败任务,降低扫描范围;另一方面取消内存队列,降低线程内存消耗;
1398 1398
 - 3、记住密码功能优化,选中时永久记住;非选中时关闭浏览器即登出;
1399
-- 4、项目依赖升级至较新稳定版本,如spring、jackson、groovy等等;
1399
+- 4、项目依赖升级至较新稳定版本,如spring、jackson、groovy、xxl-rpc等等;
1400 1400
 - 5、精简项目,取消第三方依赖,如 commons-collections4 ;
1401 1401
 - [迭代中]注册中心优化,实时性注册发现:心跳注册间隔10s,refresh失败则首次注册并立即更新注册信息,心跳类似;30s过期销毁;
1402 1402
 - [迭代中]脚本任务,支持数据参数,新版本仅支持单参数不支持需要兼容;

+ 2 - 2
pom.xml Parādīt failu

@@ -24,7 +24,8 @@
24 24
 		<maven.compiler.target>1.7</maven.compiler.target>
25 25
 		<maven.test.skip>true</maven.test.skip>
26 26
 
27
-		<xxl-rpc.version>1.2.1</xxl-rpc.version>
27
+		<xxl-rpc.version>1.3.1</xxl-rpc.version>
28
+		<jetty-server.version>9.2.26.v20180806</jetty-server.version>
28 29
 
29 30
 		<spring-boot.version>1.5.18.RELEASE</spring-boot.version>
30 31
 		<mybatis-spring-boot-starter.version>1.3.2</mybatis-spring-boot-starter.version>
@@ -42,7 +43,6 @@
42 43
 		<quartz.version>2.3.0</quartz.version>
43 44
 
44 45
 		<jackson.version>2.9.8</jackson.version>
45
-		<jetty-server.version>9.2.26.v20180806</jetty-server.version>
46 46
 
47 47
 	</properties>
48 48
 

+ 22 - 4
xxl-job-admin/src/main/java/com/xxl/job/admin/core/schedule/XxlJobDynamicScheduler.java Parādīt failu

@@ -13,6 +13,7 @@ import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
13 13
 import com.xxl.rpc.remoting.invoker.XxlRpcInvokerFactory;
14 14
 import com.xxl.rpc.remoting.invoker.call.CallType;
15 15
 import com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean;
16
+import com.xxl.rpc.remoting.invoker.route.LoadBalance;
16 17
 import com.xxl.rpc.remoting.net.NetEnum;
17 18
 import com.xxl.rpc.remoting.net.impl.jetty.server.JettyServerHandler;
18 19
 import com.xxl.rpc.remoting.provider.XxlRpcProviderFactory;
@@ -98,7 +99,14 @@ public final class XxlJobDynamicScheduler {
98 99
     private void initRpcProvider(){
99 100
         // init
100 101
         XxlRpcProviderFactory xxlRpcProviderFactory = new XxlRpcProviderFactory();
101
-        xxlRpcProviderFactory.initConfig(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), null, 0, XxlJobAdminConfig.getAdminConfig().getAccessToken(), null, null);
102
+        xxlRpcProviderFactory.initConfig(
103
+                NetEnum.JETTY,
104
+                Serializer.SerializeEnum.HESSIAN.getSerializer(),
105
+                null,
106
+                0,
107
+                XxlJobAdminConfig.getAdminConfig().getAccessToken(),
108
+                null,
109
+                null);
102 110
 
103 111
         // add services
104 112
         xxlRpcProviderFactory.addService(AdminBiz.class.getName(), null, XxlJobAdminConfig.getAdminConfig().getAdminBiz());
@@ -107,7 +115,7 @@ public final class XxlJobDynamicScheduler {
107 115
         jettyServerHandler = new JettyServerHandler(xxlRpcProviderFactory);
108 116
     }
109 117
     private void stopRpcProvider() throws Exception {
110
-        new XxlRpcInvokerFactory().stop();
118
+        XxlRpcInvokerFactory.getInstance().stop();
111 119
     }
112 120
     public static void invokeAdminService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
113 121
         jettyServerHandler.handle(null, new Request(null, null), request, response);
@@ -130,8 +138,18 @@ public final class XxlJobDynamicScheduler {
130 138
         }
131 139
 
132 140
         // set-cache
133
-        executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC,
134
-                ExecutorBiz.class, null, 10000, address, XxlJobAdminConfig.getAdminConfig().getAccessToken(), null).getObject();
141
+        executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(
142
+                NetEnum.JETTY,
143
+                Serializer.SerializeEnum.HESSIAN.getSerializer(),
144
+                CallType.SYNC,
145
+                LoadBalance.ROUND,
146
+                ExecutorBiz.class,
147
+                null,
148
+                10000,
149
+                address,
150
+                XxlJobAdminConfig.getAdminConfig().getAccessToken(),
151
+                null,
152
+                null).getObject();
135 153
 
136 154
         executorBizRepository.put(address, executorBiz);
137 155
         return executorBiz;

+ 25 - 4
xxl-job-admin/src/test/java/com/xxl/job/adminbiz/AdminBizTest.java Parādīt failu

@@ -6,6 +6,7 @@ import com.xxl.job.core.biz.model.ReturnT;
6 6
 import com.xxl.job.core.enums.RegistryConfig;
7 7
 import com.xxl.rpc.remoting.invoker.call.CallType;
8 8
 import com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean;
9
+import com.xxl.rpc.remoting.invoker.route.LoadBalance;
9 10
 import com.xxl.rpc.remoting.net.NetEnum;
10 11
 import com.xxl.rpc.serialize.Serializer;
11 12
 import org.junit.Assert;
@@ -30,8 +31,18 @@ public class AdminBizTest {
30 31
     @Test
31 32
     public void registryTest() throws Exception {
32 33
         addressUrl = addressUrl.replace("http://", "");
33
-        AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC,
34
-                AdminBiz.class, null, 10000, addressUrl, accessToken, null).getObject();
34
+        AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(
35
+                NetEnum.JETTY,
36
+                Serializer.SerializeEnum.HESSIAN.getSerializer(),
37
+                CallType.SYNC,
38
+                LoadBalance.ROUND,
39
+                AdminBiz.class,
40
+                null,
41
+                10000,
42
+                addressUrl,
43
+                accessToken,
44
+                null,
45
+                null).getObject();
35 46
 
36 47
         // test executor registry
37 48
         RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
@@ -47,8 +58,18 @@ public class AdminBizTest {
47 58
     @Test
48 59
     public void registryRemove() throws Exception {
49 60
         addressUrl = addressUrl.replace("http://", "");
50
-        AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC,
51
-                AdminBiz.class, null, 10000, addressUrl, accessToken, null).getObject();
61
+        AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(
62
+                NetEnum.JETTY,
63
+                Serializer.SerializeEnum.HESSIAN.getSerializer(),
64
+                CallType.SYNC,
65
+                LoadBalance.ROUND,
66
+                AdminBiz.class,
67
+                null,
68
+                10000,
69
+                addressUrl,
70
+                accessToken,
71
+                null,
72
+                null).getObject();
52 73
 
53 74
         // test executor registry remove
54 75
         RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");

+ 13 - 2
xxl-job-admin/src/test/java/com/xxl/job/executor/ExecutorBizTest.java Parādīt failu

@@ -7,6 +7,7 @@ import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
7 7
 import com.xxl.job.core.glue.GlueTypeEnum;
8 8
 import com.xxl.rpc.remoting.invoker.call.CallType;
9 9
 import com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean;
10
+import com.xxl.rpc.remoting.invoker.route.LoadBalance;
10 11
 import com.xxl.rpc.remoting.net.NetEnum;
11 12
 import com.xxl.rpc.serialize.Serializer;
12 13
 
@@ -47,8 +48,18 @@ public class ExecutorBizTest {
47 48
 
48 49
         // do remote trigger
49 50
         String accessToken = null;
50
-        ExecutorBiz executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC,
51
-                ExecutorBiz.class, null, 10000, "127.0.0.1:9999", null, null).getObject();
51
+        ExecutorBiz executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(
52
+                NetEnum.JETTY,
53
+                Serializer.SerializeEnum.HESSIAN.getSerializer(),
54
+                CallType.SYNC,
55
+                LoadBalance.ROUND,
56
+                ExecutorBiz.class,
57
+                null,
58
+                10000,
59
+                "127.0.0.1:9999",
60
+                null,
61
+                null,
62
+                null).getObject();
52 63
 
53 64
         ReturnT<String> runResult = executorBiz.run(triggerParam);
54 65
     }

+ 20 - 0
xxl-job-core/pom.xml Parādīt failu

@@ -20,6 +20,26 @@
20 20
 			<groupId>com.xuxueli</groupId>
21 21
 			<artifactId>xxl-rpc-core</artifactId>
22 22
 			<version>${xxl-rpc.version}</version>
23
+			<exclusions>
24
+				<exclusion>
25
+					<groupId>io.netty</groupId>
26
+					<artifactId>netty-all</artifactId>
27
+				</exclusion>
28
+				<exclusion>
29
+					<groupId>org.apache.commons</groupId>
30
+					<artifactId>commons-pool2</artifactId>
31
+				</exclusion>
32
+			</exclusions>
33
+		</dependency>
34
+		<dependency>
35
+			<groupId>org.eclipse.jetty</groupId>
36
+			<artifactId>jetty-server</artifactId>
37
+			<version>${jetty-server.version}</version>
38
+		</dependency>
39
+		<dependency>
40
+			<groupId>org.eclipse.jetty</groupId>
41
+			<artifactId>jetty-client</artifactId>
42
+			<version>${jetty-server.version}</version>
23 43
 		</dependency>
24 44
 
25 45
 		<!-- groovy-all -->

+ 22 - 9
xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java Parādīt failu

@@ -13,6 +13,7 @@ import com.xxl.rpc.registry.ServiceRegistry;
13 13
 import com.xxl.rpc.remoting.invoker.XxlRpcInvokerFactory;
14 14
 import com.xxl.rpc.remoting.invoker.call.CallType;
15 15
 import com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean;
16
+import com.xxl.rpc.remoting.invoker.route.LoadBalance;
16 17
 import com.xxl.rpc.remoting.net.NetEnum;
17 18
 import com.xxl.rpc.remoting.provider.XxlRpcProviderFactory;
18 19
 import com.xxl.rpc.serialize.Serializer;
@@ -113,8 +114,19 @@ public class XxlJobExecutor  {
113 114
 
114 115
                     String addressUrl = address.concat(AdminBiz.MAPPING);
115 116
 
116
-                    AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC,
117
-                            AdminBiz.class, null, 10000, addressUrl, accessToken, null).getObject();
117
+                    AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(
118
+                            NetEnum.JETTY,
119
+                            Serializer.SerializeEnum.HESSIAN.getSerializer(),
120
+                            CallType.SYNC,
121
+                            LoadBalance.ROUND,
122
+                            AdminBiz.class,
123
+                            null,
124
+                            10000,
125
+                            addressUrl,
126
+                            accessToken,
127
+                            null,
128
+                            null
129
+                    ).getObject();
118 130
 
119 131
                     if (adminBizList == null) {
120 132
                         adminBizList = new ArrayList<AdminBiz>();
@@ -130,12 +142,9 @@ public class XxlJobExecutor  {
130 142
 
131 143
 
132 144
     // ---------------------- executor-server (rpc provider) ----------------------
133
-    private XxlRpcInvokerFactory xxlRpcInvokerFactory = null;
134 145
     private XxlRpcProviderFactory xxlRpcProviderFactory = null;
135 146
 
136 147
     private void initRpcProvider(String ip, int port, String appName, String accessToken) throws Exception {
137
-        // init invoker factory
138
-        xxlRpcInvokerFactory = new XxlRpcInvokerFactory();
139 148
 
140 149
         // init, provider factory
141 150
         String address = IpUtil.getIpPort(ip, port);
@@ -150,7 +159,7 @@ public class XxlJobExecutor  {
150 159
         xxlRpcProviderFactory.addService(ExecutorBiz.class.getName(), null, new ExecutorBizImpl());
151 160
 
152 161
         // start
153
-       xxlRpcProviderFactory.start();
162
+        xxlRpcProviderFactory.start();
154 163
 
155 164
     }
156 165
 
@@ -168,14 +177,18 @@ public class XxlJobExecutor  {
168 177
         }
169 178
 
170 179
         @Override
171
-        public boolean registry(String key, String value) {
180
+        public boolean registry(Set<String> keys, String value) {
172 181
             return false;
173 182
         }
174 183
         @Override
175
-        public boolean remove(String key, String value) {
184
+        public boolean remove(Set<String> keys, String value) {
176 185
             return false;
177 186
         }
178 187
         @Override
188
+        public Map<String, TreeSet<String>> discovery(Set<String> keys) {
189
+            return null;
190
+        }
191
+        @Override
179 192
         public TreeSet<String> discovery(String key) {
180 193
             return null;
181 194
         }
@@ -185,7 +198,7 @@ public class XxlJobExecutor  {
185 198
     private void stopRpcProvider() {
186 199
         // stop invoker factory
187 200
         try {
188
-            xxlRpcInvokerFactory.stop();
201
+            XxlRpcInvokerFactory.getInstance().stop();
189 202
         } catch (Exception e) {
190 203
             logger.error(e.getMessage(), e);
191 204
         }