r3分散式实时处理框架
R3 FRAMEWORK - 分散式实时处理框架
简介基于Spring的分散式实时处理框架。
逻辑架构设计

包结构设计

配置样例
界面样例
public interface SayHelloService {
@Out(SayHelloOutHandler.class)
@In(SayHelloInHandler.class)
List sayHello(List names);
}
分流类
public class SayHelloOutHandler extends OutHandler {
@Override
public List shard(Object[] parameters, int shardCount) throws Throwable {
List result = new ArrayList();
List param = (List) parameters[0];
int perSize = param.size() / shardCount;
for(int i=0;i result.add(new Object[]{param.subList(i*perSize,(i!=shardCount-1?(i+1)*perSize:param.size()))});
}
return result;
}
}
合流类
public class SayHelloInHandler extends InHandler {
@Override
public Object join(Object[] results) throws Throwable {
List list = new ArrayList();
for(Object object : results){
list.addAll((List)object);
}
return list;
}
}
实现类样例
public class SayHelloServiceImpl implements SayHelloService {
@Override
public List sayHello(List names) {
List newNames = new ArrayList();
for (String name : names) {
String newName = "hello " + name;
newNames.add(newName);
}
return newNames;
}
}
Worker端
Leader端
配置属性
@Out 界面配置
注解类,应用于API界面上,用于引数分流。
AttributeDescriptionvalue使用者自定义引数分流类,需要继承自r3.flow.OutHandler
@In 界面配置
注解类,应用于API界面上,用于引数合流
AttributeDescriptionvalue使用者自定义引数合流类,需要继承自r3.flow.InHandler
r3:application 应用配置
AttributeDescriptionname应用名称,必须项,同名的application为同组,组内软负载取其一。host监听地址,预设为“AUTO”,如果为“AUTO”的话,会自动采用本机IP地址。多网络卡的情况下可以手动设定IP。port监听埠,预设为20080。
r3:registry 注册中心配置
AttributeDescriptionaddress注册中心zookeeper的地址,预设为“localhost:2181”。namespace应用注册的名称空间,zookeeper的根节点,预设为:r3。sessionTimeout回话超时时间设定,单位为毫秒,预设为3000。connectionTimeout连线的超时时间,单位为毫秒,预设为3000。interval多次尝试注册服务的时间间隔,单位为毫秒,预设为30000。
r3:worker 工作者配置
AttributeDescriptionidspring bean id。ref引用的spring的bean。interface实现的界面类。
r3:leader 代理者配置
AttributeDescriptionidspring bean id。interface代理的界面类。loadbalance负载策略,预设为“random”,尚不支援其他策略。
版本说明
采用行星名称命名。