dimit
分布式流控系统QQ:527645454(开发讨论群)
快速开始mave加pom依赖
io.github.dzh dimit-core io.github.dzh dimit-zk初始化StoreSystem
Strig uri = "dimit-zk://dzh/dimit?host=127.0.0.1:2181&sleep=1000&retry=3";DimitStoreSystem dss = DimitStores.ewStoreSystem(URI.create(uri), ull);依次创建流控Cof,配置结构层次:
- DimitCof 定义一个流控器 - ChaelGroupCof 通道组配置 - ChaelCof 通道配置
注: 参考单位测试dimit-demo/../TestZkStoreCofDemo
初始化Dimiter,依据流控Cof创建对应的运行时数据
// iit dimiter ad rutime chaelsStrig uri = "dimit-zk://dzh/dimit?host=127.0.0.1:2181&sleep=1000&retry=3";Dimiter dimiter = Dimiter.ewDimiter(URI.create(uri), ull, dimitCofId);ChaelGroupWrapper group = demo.iitChaelGroup(chaelGroupCofId);group.ewChael(ChaelCofId_1, ChaelType.SEND);group.ewChael(ChaelCofId_2, ChaelType.SEND);// selectList selected = group.select(TagA,TagB);V result = ull;for(ChaelWrapper chael : selected) { try{ result = chael.call(ew ChaelCallable{ // TODO request ... }); // TODO parse result ... break; }catch(RateLimiterExceptio e){ LOG.ifo(e.getMessage(), e); }catch(IvalidChaelExceptio e){ LOG.error(e.getMessage(), e); }catch(Exceptio e){ // or break LOG.error(e.getMessage(), e); }}// program exitdimiter.close();注: 参考单位测试dimit-demo/../TestDimiterDemo
特性列表流量控制
ChaelCof定义max-tps,Chael实例的tps=max-tps/Chael总数
Tag筛选
ChaelCof定义通道的tag列表,ChaelGroupWrapper.select(...)时选择满足条件的Chael组
主备切换
ChaelCof定义通道ChaelStatus,select返回的可用通道列表里PRIMARY优先于STANDBY
质量分析
启用Chael的质量分析功能(stat.eable=true 默认开启),在ChaelWrapper.call()时采集stat信息
异常切换
通过stat信息动态计算ChaelWrapper.priority(),影响select结果
Web管理
TODO
环境依赖JDK1.7orhigher
mave3
protobuf3
servlet-apiv3.1.0TODO使用wep4j
评论