Hydra-Io Java 分布式作业流调度框架 项目简介
Java 分布式作业流调度框架 Hydra-IoHydra 是由 Java 实现的作业流调度框架,它可以支持复杂作业流的调度。主要有以下特点:1. 支持分布式作业分片2. 支持本地并发执行3. 支持复杂作业树(作业流) 4. 实现业务代码和框架代码的解耦5. 内部实现分布式调度,无需zookeeper等第三方分布式组件6. 抛弃传统的cron表达,采用简单易懂的作业配置note: 目前Hydra-Io 处于测试版本,暂没有在生产环境下运行的先例计划:在1.0 版本中 将支持一下特性1. 同步支持zookeeper 、Redis 作为分布式组件2. 实现基于XML的作业配置3. 支持spring测试版体验:1.定义作业 testInvokeTask@Task("testInvokeTask")
public class TestInvokeTask {
@Executor("executorA")
@Expression(strategy = ExpressionStrategyEnum.TIMING, measure = ExpressionMeasureEnum.MINUTE,factor = "15")
@Distributed(strategy = DistributedStrategyEnum.SHARDING,number = 2)
public String executorA(EnvironmentParams context){
String jobName = context.getJobName();
int invokeIndex = context.getInvokeIndex();
String str = jobName + " - " + invokeIndex + " running at " + new Date();
System.out.println(str);
return str;
}
@Join("testInvokeTask@executorA")
@Executor("executorB")
public String executorB(EnvironmentParams context, String values){
String jobName = context.getJobName();
int invokeIndex = context.getInvokeIndex();
String str = jobName + " - " + invokeIndex + " running at " + new Date() + " param is:[" + values + " ]" ;
System.out.println(str);
return jobName;
}
@Join("testInvokeTask@executorB")
@Executor("executorC")
public String executorC(EnvironmentParams context, String values){
String jobName = context.getJobName();
int invokeIndex = context.getInvokeIndex();
String str = jobName + " - " + invokeIndex + " running at " + new Date() + " param is:[" + values + " ]" ;
System.out.println(str);
return jobName;
}
}注解说明:执行作业:public class Main {
public static void main(String[] strings){
BatchSystem system = AnnotationBatchSystem.getInstance().setScanPackage("com.xxxx.xxxx.test");
system.start();
}
}
public class TestInvokeTask {
@Executor("executorA")
@Expression(strategy = ExpressionStrategyEnum.TIMING, measure = ExpressionMeasureEnum.MINUTE,factor = "15")
@Distributed(strategy = DistributedStrategyEnum.SHARDING,number = 2)
public String executorA(EnvironmentParams context){
String jobName = context.getJobName();
int invokeIndex = context.getInvokeIndex();
String str = jobName + " - " + invokeIndex + " running at " + new Date();
System.out.println(str);
return str;
}
@Join("testInvokeTask@executorA")
@Executor("executorB")
public String executorB(EnvironmentParams context, String values){
String jobName = context.getJobName();
int invokeIndex = context.getInvokeIndex();
String str = jobName + " - " + invokeIndex + " running at " + new Date() + " param is:[" + values + " ]" ;
System.out.println(str);
return jobName;
}
@Join("testInvokeTask@executorB")
@Executor("executorC")
public String executorC(EnvironmentParams context, String values){
String jobName = context.getJobName();
int invokeIndex = context.getInvokeIndex();
String str = jobName + " - " + invokeIndex + " running at " + new Date() + " param is:[" + values + " ]" ;
System.out.println(str);
return jobName;
}
}注解说明:执行作业:public class Main {
public static void main(String[] strings){
BatchSystem system = AnnotationBatchSystem.getInstance().setScanPackage("com.xxxx.xxxx.test");
system.start();
}
}