Skip to content

Commit

Permalink
优化元数据相关 (#328)
Browse files Browse the repository at this point in the history
* 优化元数据
* nameeserver-sql修改默认配置,无需配置默认使用h2
* 删除ignite和composition模块
* 删除ignite相关配置
* 自动选择多协调者
* 去掉无用变量
* 调整补偿
* 修复空列表的sql错误
* broker添加模糊搜索和精确搜索选项
* 调整默认schema
  • Loading branch information
llIlll committed Dec 28, 2020
1 parent b1e5390 commit b1ee76c
Show file tree
Hide file tree
Showing 133 changed files with 564 additions and 10,235 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.joyqueue.domain;

import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.commons.collections.MapUtils;

import java.io.Serializable;
Expand All @@ -41,6 +42,8 @@ public class TopicConfig extends Topic implements Serializable {

private Map<Integer,PartitionGroup> partitionGroups;

private Set<Integer> replicas;

/**
* 主题配置转换
*
Expand Down Expand Up @@ -89,12 +92,7 @@ public Map<Integer,PartitionGroup> getPartitionGroups() {
}

public boolean isReplica(int brokerId) {
for (Map.Entry<Integer, PartitionGroup> entry : partitionGroups.entrySet()) {
if (entry.getValue().getReplicas().contains(brokerId)) {
return true;
}
}
return false;
return replicas.contains(brokerId);
}

public List<PartitionGroup> fetchTopicPartitionGroupsByBrokerId(int brokerId) {
Expand All @@ -110,6 +108,15 @@ public List<PartitionGroup> fetchTopicPartitionGroupsByBrokerId(int brokerId) {
public void setPartitionGroups(Map<Integer,PartitionGroup> partitionGroups) {
this.partitionGroups = partitionGroups;
this.partitionGroupMap = buildPartitionGroupMap(partitionGroups);
this.replicas = buildReplica(partitionGroups);
}

private Set<Integer> buildReplica(Map<Integer, PartitionGroup> partitionGroups) {
Set<Integer> result = Sets.newHashSet();
for (Map.Entry<Integer, PartitionGroup> partitionGroupEntry : partitionGroups.entrySet()) {
result.addAll(partitionGroupEntry.getValue().getReplicas());
}
return result;
}

private Map<Short, PartitionGroup> buildPartitionGroupMap(Map<Integer,PartitionGroup> partitionGroups) {
Expand Down
Loading

0 comments on commit b1ee76c

Please sign in to comment.