Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
16d8177c
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
16d8177c
编写于
4月 05, 2017
作者:
B
bobbeyreese
提交者:
Matteo Merli
4月 05, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use historical data from old API in new API (#329)
上级
e34b595b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
0 deletion
+26
-0
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java
...ulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java
+26
-0
未找到文件。
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java
浏览文件 @
16d8177c
...
...
@@ -31,7 +31,9 @@ import java.util.concurrent.Executors;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
import
com.yahoo.pulsar.broker.TimeAverageMessageData
;
import
com.yahoo.pulsar.broker.loadbalance.LoadManager
;
import
com.yahoo.pulsar.common.policies.data.ResourceQuota
;
import
org.apache.bookkeeper.util.ZkUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.SystemUtils
;
...
...
@@ -89,6 +91,9 @@ public class ModularLoadManagerImpl implements ModularLoadManager, ZooKeeperCach
// The number of effective samples to keep for observing short term data.
public
static
final
int
NUM_SHORT_SAMPLES
=
10
;
// Path to ZNode whose children contain ResourceQuota jsons.
public
static
final
String
RESOURCE_QUOTA_ZPATH
=
"/loadbalance/resource-quota/namespace"
;
// Path to ZNode containing TimeAverageBrokerData jsons for each broker.
public
static
final
String
TIME_AVERAGE_BROKER_ZPATH
=
"/loadbalance/broker-time-average"
;
...
...
@@ -265,8 +270,29 @@ public class ModularLoadManagerImpl implements ModularLoadManager, ZooKeeperCach
BundleData
bundleData
=
null
;
try
{
final
String
bundleZPath
=
getBundleDataZooKeeperPath
(
bundle
);
final
String
quotaZPath
=
String
.
format
(
"%s/%s"
,
RESOURCE_QUOTA_ZPATH
,
bundle
);
if
(
zkClient
.
exists
(
bundleZPath
,
null
)
!=
null
)
{
bundleData
=
readJson
(
zkClient
.
getData
(
bundleZPath
,
null
,
null
),
BundleData
.
class
);
}
else
if
(
zkClient
.
exists
(
quotaZPath
,
null
)
!=
null
)
{
final
ResourceQuota
quota
=
readJson
(
zkClient
.
getData
(
quotaZPath
,
null
,
null
),
ResourceQuota
.
class
);
bundleData
=
new
BundleData
(
NUM_SHORT_SAMPLES
,
NUM_LONG_SAMPLES
);
// Initialize from existing resource quotas if new API ZNodes do not exist.
final
TimeAverageMessageData
shortTermData
=
bundleData
.
getShortTermData
();
final
TimeAverageMessageData
longTermData
=
bundleData
.
getLongTermData
();
shortTermData
.
setMsgRateIn
(
quota
.
getMsgRateIn
());
shortTermData
.
setMsgRateOut
(
quota
.
getMsgRateOut
());
shortTermData
.
setMsgThroughputIn
(
quota
.
getBandwidthIn
());
shortTermData
.
setMsgThroughputOut
(
quota
.
getBandwidthOut
());
longTermData
.
setMsgRateIn
(
quota
.
getMsgRateIn
());
longTermData
.
setMsgRateOut
(
quota
.
getMsgRateOut
());
longTermData
.
setMsgThroughputIn
(
quota
.
getBandwidthIn
());
longTermData
.
setMsgThroughputOut
(
quota
.
getBandwidthOut
());
// Assume ample history.
shortTermData
.
setNumSamples
(
NUM_SHORT_SAMPLES
);
longTermData
.
setNumSamples
(
NUM_LONG_SAMPLES
);
}
}
catch
(
Exception
e
)
{
log
.
warn
(
"Error when trying to find bundle {} on zookeeper: {}"
,
bundle
,
e
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录