MetaConfig 是 metaq 加载配置的一个关键类,
一 主要属性如下表
|
属性名 |
属性类型 |
默认值 |
描述 |
|
brokerId |
int |
0 |
broker的编号,集群唯一 |
|
dataPath |
String |
系统当前用户目录下的 meta 文件夹内 |
数据存储路径 |
|
serverPort |
int |
8123 |
nio port |
|
dashboardHttpPort |
int |
8120 |
|
|
hostName |
string |
|
|
|
numPartitions |
int |
1 |
这个broker指定的分区数 |
|
unflushThreshold |
int |
1000 |
异步刷盘策略,为0表示同步刷盘 |
|
unflushInterval |
int |
10000 |
异步刷盘间隔,为0表示同步刷盘 |
|
maxSegmentSize |
int |
1 * 1024 * 1024 * 1024 = 1073741824 |
单个消息文件的最大size |
|
maxTransferSize |
int |
1024 * 1024 = 1048576 |
单个请求最大传输size |
|
topics |
List<String> |
new ArrayList<String>() |
|
|
slaveConfig |
SlaveConfig |
|
见 SlaveConfig |
|
getProcessThreadCount |
int |
10 * Runtime.getRuntime().availableProcessors() |
|
|
putProcessThreadCount |
int |
10 * Runtime.getRuntime().availableProcessors() |
|
|
zkConfig |
ZKConfig |
| 见 ZK Config |
|
deletePolicy |
String |
delete,168 |
文件删除策略:"策略名称,设定值列表",默认为保存7天 |
|
topicConfigMap |
ConcurrentHashMap<String, TopicConfig> |
<String/* topic */, TopicConfig> |
<String/* topic */, TopicConfig> |
|
propertyChangeSupport |
PropertyChangeSupport |
new PropertyChangeSupport(this) |
监听属性名变化 |
|
lastModified |
long |
-1 |
属性文件的最后修改时间 |
|
path |
volatile String |
|
配置文件的路径 |
|
appClassPath |
String |
默认为配置文件目录的父级目录的父级目录 |
App class path |
|
maxCheckpoints |
int |
3 |
事务相关配置,最大保存的checkpoint数目,超过将淘汰最老的 |
|
checkpointInterval |
long |
60 * 60 * 1000L |
自动checkpoint间隔,默认1小时 |
|
maxTxTimeoutTimerCapacity |
int |
30000 |
最大事务超时时间个数,默认3万个 |
|
flushTxLogAtCommit |
int |
1 |
事务日志刷盘设置,0表示让操作系统决定,1表示每次commit都刷盘,2表示每隔一秒刷盘一次 |
|
maxTxTimeoutInSeconds |
int |
60 |
事务最大超时时间,默认一分钟 |
|
dataLogPath |
String |
this.dataPath |
日志存储目录,默认使用dataPath |
|
deleteWhen |
String |
0 0 6,18 * * ? |
全局的删除crontab表达式,每天早上6点和晚上6点执行 |
|
quartzThreadCount |
int |
5 |
quartz使用的线程池大小 |
|
configFileChecksum |
long |
|
使用 crc32 校验配置文件的校验值 |
|
acceptPublish |
boolean |
true |
|
|
acceptSubscribe |
boolean |
true |
|
|
stat |
boolean |
|
|
|
updateConsumerOffsets |
Boolean |
System.getProperty("meta.get.tellMaxOffset", "false") |
|
|
loadMessageStoresInParallel |
boolean |
false |
|
二 主要方法的关键点
A. loadFromFile 方法:
1.传入文件路径path
2.设置 属性path 为 传入的值
3.通过path获取file
4.通过path获取 类路径(即path的../../)并设置 属性appClassPath
5.如果file不存在则抛出异常
6.根据file创建Ini对象,同时设置属性 lastModified configFileChecksum
7.调用方法 populateAttributes 设置系统属性,包括 systemConfig ,zookeeperConfig topicsConfig
B.reload 方法:
该方法用来重新读取配置文件,需要注意的地方在于 其 只更新 TopicConfig 相关的内容
C ClosePartition 方法
从属性 closedPartitionMap 中根据topic 获取 closedPartitionsset集合,如果 set 为null 则 设置一个空set进去,向对应的set中添加关闭的partition值
D isClosedPartition 方法
1. 传入 topic 和 partition
2.从 closedPartitionMap 通过topic 获取 closedPartitions的Set ,然后返回这个集合中是否有这个 partition
E openPartitions 方法
从 属性 closedPartitionMap 中移除对应的 topic ,这里需要注意的是 ,移除的是 topic 对应的 partitions集合,而不是一个单独的 partition值
本文介绍MetaConfig类的主要属性和方法,包括broker配置、数据存储路径、消息文件大小限制等,并详细解析了loadFromFile、reload等关键方法的工作原理。
2616

被折叠的 条评论
为什么被折叠?



