升级 xxl-rpc 依赖;

master
xuxueli 6 years ago
parent bce7cc4676
commit d54d679edb
  1. 2
      doc/XXL-JOB官方文档.md
  2. 4
      pom.xml
  3. 26
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/schedule/XxlJobDynamicScheduler.java
  4. 29
      xxl-job-admin/src/test/java/com/xxl/job/adminbiz/AdminBizTest.java
  5. 15
      xxl-job-admin/src/test/java/com/xxl/job/executor/ExecutorBizTest.java
  6. 20
      xxl-job-core/pom.xml
  7. 31
      xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java

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

@ -24,7 +24,8 @@
<maven.compiler.target>1.7</maven.compiler.target>
<maven.test.skip>true</maven.test.skip>
<xxl-rpc.version>1.2.1</xxl-rpc.version>
<xxl-rpc.version>1.3.1</xxl-rpc.version>
<jetty-server.version>9.2.26.v20180806</jetty-server.version>
<spring-boot.version>1.5.18.RELEASE</spring-boot.version>
<mybatis-spring-boot-starter.version>1.3.2</mybatis-spring-boot-starter.version>
@ -42,7 +43,6 @@
<quartz.version>2.3.0</quartz.version>
<jackson.version>2.9.8</jackson.version>
<jetty-server.version>9.2.26.v20180806</jetty-server.version>
</properties>

@ -13,6 +13,7 @@ import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
import com.xxl.rpc.remoting.invoker.XxlRpcInvokerFactory;
import com.xxl.rpc.remoting.invoker.call.CallType;
import com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean;
import com.xxl.rpc.remoting.invoker.route.LoadBalance;
import com.xxl.rpc.remoting.net.NetEnum;
import com.xxl.rpc.remoting.net.impl.jetty.server.JettyServerHandler;
import com.xxl.rpc.remoting.provider.XxlRpcProviderFactory;
@ -98,7 +99,14 @@ public final class XxlJobDynamicScheduler {
private void initRpcProvider(){
// init
XxlRpcProviderFactory xxlRpcProviderFactory = new XxlRpcProviderFactory();
xxlRpcProviderFactory.initConfig(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), null, 0, XxlJobAdminConfig.getAdminConfig().getAccessToken(), null, null);
xxlRpcProviderFactory.initConfig(
NetEnum.JETTY,
Serializer.SerializeEnum.HESSIAN.getSerializer(),
null,
0,
XxlJobAdminConfig.getAdminConfig().getAccessToken(),
null,
null);
// add services
xxlRpcProviderFactory.addService(AdminBiz.class.getName(), null, XxlJobAdminConfig.getAdminConfig().getAdminBiz());
@ -107,7 +115,7 @@ public final class XxlJobDynamicScheduler {
jettyServerHandler = new JettyServerHandler(xxlRpcProviderFactory);
}
private void stopRpcProvider() throws Exception {
new XxlRpcInvokerFactory().stop();
XxlRpcInvokerFactory.getInstance().stop();
}
public static void invokeAdminService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
jettyServerHandler.handle(null, new Request(null, null), request, response);
@ -130,8 +138,18 @@ public final class XxlJobDynamicScheduler {
}
// set-cache
executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC,
ExecutorBiz.class, null, 10000, address, XxlJobAdminConfig.getAdminConfig().getAccessToken(), null).getObject();
executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(
NetEnum.JETTY,
Serializer.SerializeEnum.HESSIAN.getSerializer(),
CallType.SYNC,
LoadBalance.ROUND,
ExecutorBiz.class,
null,
10000,
address,
XxlJobAdminConfig.getAdminConfig().getAccessToken(),
null,
null).getObject();
executorBizRepository.put(address, executorBiz);
return executorBiz;

@ -6,6 +6,7 @@ import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.enums.RegistryConfig;
import com.xxl.rpc.remoting.invoker.call.CallType;
import com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean;
import com.xxl.rpc.remoting.invoker.route.LoadBalance;
import com.xxl.rpc.remoting.net.NetEnum;
import com.xxl.rpc.serialize.Serializer;
import org.junit.Assert;
@ -30,8 +31,18 @@ public class AdminBizTest {
@Test
public void registryTest() throws Exception {
addressUrl = addressUrl.replace("http://", "");
AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC,
AdminBiz.class, null, 10000, addressUrl, accessToken, null).getObject();
AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(
NetEnum.JETTY,
Serializer.SerializeEnum.HESSIAN.getSerializer(),
CallType.SYNC,
LoadBalance.ROUND,
AdminBiz.class,
null,
10000,
addressUrl,
accessToken,
null,
null).getObject();
// test executor registry
RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
@ -47,8 +58,18 @@ public class AdminBizTest {
@Test
public void registryRemove() throws Exception {
addressUrl = addressUrl.replace("http://", "");
AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC,
AdminBiz.class, null, 10000, addressUrl, accessToken, null).getObject();
AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(
NetEnum.JETTY,
Serializer.SerializeEnum.HESSIAN.getSerializer(),
CallType.SYNC,
LoadBalance.ROUND,
AdminBiz.class,
null,
10000,
addressUrl,
accessToken,
null,
null).getObject();
// test executor registry remove
RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");

@ -7,6 +7,7 @@ import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
import com.xxl.job.core.glue.GlueTypeEnum;
import com.xxl.rpc.remoting.invoker.call.CallType;
import com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean;
import com.xxl.rpc.remoting.invoker.route.LoadBalance;
import com.xxl.rpc.remoting.net.NetEnum;
import com.xxl.rpc.serialize.Serializer;
@ -47,8 +48,18 @@ public class ExecutorBizTest {
// do remote trigger
String accessToken = null;
ExecutorBiz executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC,
ExecutorBiz.class, null, 10000, "127.0.0.1:9999", null, null).getObject();
ExecutorBiz executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(
NetEnum.JETTY,
Serializer.SerializeEnum.HESSIAN.getSerializer(),
CallType.SYNC,
LoadBalance.ROUND,
ExecutorBiz.class,
null,
10000,
"127.0.0.1:9999",
null,
null,
null).getObject();
ReturnT<String> runResult = executorBiz.run(triggerParam);
}

@ -20,6 +20,26 @@
<groupId>com.xuxueli</groupId>
<artifactId>xxl-rpc-core</artifactId>
<version>${xxl-rpc.version}</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty-server.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<version>${jetty-server.version}</version>
</dependency>
<!-- groovy-all -->

@ -13,6 +13,7 @@ import com.xxl.rpc.registry.ServiceRegistry;
import com.xxl.rpc.remoting.invoker.XxlRpcInvokerFactory;
import com.xxl.rpc.remoting.invoker.call.CallType;
import com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean;
import com.xxl.rpc.remoting.invoker.route.LoadBalance;
import com.xxl.rpc.remoting.net.NetEnum;
import com.xxl.rpc.remoting.provider.XxlRpcProviderFactory;
import com.xxl.rpc.serialize.Serializer;
@ -113,8 +114,19 @@ public class XxlJobExecutor {
String addressUrl = address.concat(AdminBiz.MAPPING);
AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC,
AdminBiz.class, null, 10000, addressUrl, accessToken, null).getObject();
AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(
NetEnum.JETTY,
Serializer.SerializeEnum.HESSIAN.getSerializer(),
CallType.SYNC,
LoadBalance.ROUND,
AdminBiz.class,
null,
10000,
addressUrl,
accessToken,
null,
null
).getObject();
if (adminBizList == null) {
adminBizList = new ArrayList<AdminBiz>();
@ -130,12 +142,9 @@ public class XxlJobExecutor {
// ---------------------- executor-server (rpc provider) ----------------------
private XxlRpcInvokerFactory xxlRpcInvokerFactory = null;
private XxlRpcProviderFactory xxlRpcProviderFactory = null;
private void initRpcProvider(String ip, int port, String appName, String accessToken) throws Exception {
// init invoker factory
xxlRpcInvokerFactory = new XxlRpcInvokerFactory();
// init, provider factory
String address = IpUtil.getIpPort(ip, port);
@ -150,7 +159,7 @@ public class XxlJobExecutor {
xxlRpcProviderFactory.addService(ExecutorBiz.class.getName(), null, new ExecutorBizImpl());
// start
xxlRpcProviderFactory.start();
xxlRpcProviderFactory.start();
}
@ -168,14 +177,18 @@ public class XxlJobExecutor {
}
@Override
public boolean registry(String key, String value) {
public boolean registry(Set<String> keys, String value) {
return false;
}
@Override
public boolean remove(String key, String value) {
public boolean remove(Set<String> keys, String value) {
return false;
}
@Override
public Map<String, TreeSet<String>> discovery(Set<String> keys) {
return null;
}
@Override
public TreeSet<String> discovery(String key) {
return null;
}
@ -185,7 +198,7 @@ public class XxlJobExecutor {
private void stopRpcProvider() {
// stop invoker factory
try {
xxlRpcInvokerFactory.stop();
XxlRpcInvokerFactory.getInstance().stop();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}

Loading…
Cancel
Save