-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使 ClusterInfo
包含每個節點的 data folder 資訊。
#1106
Comments
#1108 開始之前會先完成這個 Issue,#1108 有需要自己偽造一個假的叢集,對此這些 Data Folder 的資訊先包含進去
目前 我目前是想做成 default Set<NodeInfo> nodes() {
return brokerFolders().keySet();
}
Map<NodeInfo, Set<String>> brokerFolders(); 基本上 @chia7712 能幫我看看這個概念嗎,謝謝 |
同意
這個概念不錯,或者更簡化一點,我們讓 |
所以 public class Ignore {
public static class NodeInfo {
public final String host;
public final int port;
public final int id;
public final Set<String> folders;
public NodeInfo(String host, int port, int id, Set<String> folders) {
this.host = host;
this.port = port;
this.id = id;
this.folders = folders;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
NodeInfo nodeInfo = (NodeInfo) o;
return port == nodeInfo.port && id == nodeInfo.id && host.equals(nodeInfo.host);
}
@Override
public int hashCode() {
return Objects.hash(host, port, id);
}
@Override
public String toString() {
return "NodeInfo{" +
"host='" + host + '\'' +
", port=" + port +
", id=" + id +
", folders=" + folders +
'}';
}
}
public static void main(String[] args) {
NodeInfo broker3333_1 = new NodeInfo("host", 9092, 3333, Set.of());
NodeInfo broker3333_2 = new NodeInfo("host", 9092, 3333, Set.of("/ssd1", "/ssd2"));
Set<NodeInfo> set12 = Stream.of(broker3333_1, broker3333_2).collect(Collectors.toUnmodifiableSet());
Set<NodeInfo> set21 = Stream.of(broker3333_2, broker3333_1).collect(Collectors.toUnmodifiableSet());
System.out.println(set12);
System.out.println(set21);
System.out.println();
if(!set12.toString().equals(set21.toString()))
throw new IllegalStateException("Information loss");
}
}
因為 |
蠻有道理的,由於 |
現在要討論的是怎麼填寫這個方法,看起來有兩種:
第二個方法的好處是如果我們之後要添加除了 |
我覺得方法 1 的特色是他和真實的節點比較抽離,但大概要和真實叢集之間多一段轉換的 code,方法 2 讓 用方法 2 可能改動可以少一點,黏太緊我不確定會不會有問題,不過等問題顯現的時候再轉去用方法 1 應該也沒問題。 或許我先用方法 2 做,如果遇到問題再討論。 |
@garyparrot 這兩個方法我覺得都可以,由你決定要先採取哪個作法,如果有碰到技術問題我們再討論 |
Context: #1103 (comment)
The text was updated successfully, but these errors were encountered: