This is an automated email from the ASF dual-hosted git repository.
lta pushed a commit to branch cluster
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/cluster by this push:
new 0f37d35 fix a bug of router
0f37d35 is described below
commit 0f37d35505d8c833234b2a00b33d267a2855fc12
Author: lta <[email protected]>
AuthorDate: Sun Mar 31 09:31:34 2019 +0800
fix a bug of router
---
.../apache/iotdb/cluster/config/ClusterConfig.java | 6 +--
.../apache/iotdb/cluster/utils/hash/Router.java | 45 ++++++++++------------
2 files changed, 24 insertions(+), 27 deletions(-)
diff --git
a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConfig.java
b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConfig.java
index ca9b554..83b129f 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConfig.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConfig.java
@@ -31,7 +31,7 @@ public class ClusterConfig {
private static final Logger LOGGER =
LoggerFactory.getLogger(ClusterConfig.class);
public static final String CONFIG_NAME = "iotdb-cluster.properties";
- public static final String DEFAULT_NODE =
"192.168.130.19:8888,192.168.130.12:8888,192.168.130.14:8888,192.168.130.16:8888,192.168.130.18:8888";
+ public static final String DEFAULT_NODE = "127.0.0.1:8888";
public static final String METADATA_GROUP_ID = "metadata";
private static final String DEFAULT_RAFT_DIR = "raft";
private static final String DEFAULT_RAFT_METADATA_DIR = "metadata";
@@ -41,14 +41,14 @@ public class ClusterConfig {
/**
* Cluster node: {ip1,ip2,...,ipn}
*/
- private String[] nodes =
{"192.168.130.19:8888","192.168.130.12:8888","192.168.130.14:8888","192.168.130.16:8888","192.168.130.18:8888"};
+ private String[] nodes = {DEFAULT_NODE};
/**
* Replication number
*/
private int replication = 3;
- private String ip = "192.168.130.19";
+ private String ip = "127.0.0.1";
private int port = 8888;
diff --git
a/cluster/src/main/java/org/apache/iotdb/cluster/utils/hash/Router.java
b/cluster/src/main/java/org/apache/iotdb/cluster/utils/hash/Router.java
index 3dab29f..c353afb 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/utils/hash/Router.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/utils/hash/Router.java
@@ -98,32 +98,29 @@ public class Router {
}
PhysicalNode[] nodes = physicalRing.values().toArray(new
PhysicalNode[physicalRing.size()]);
int len = nodes.length;
- if (len == replicator) {
- PhysicalNode first = nodes[0];
- PhysicalNode[][] val = new PhysicalNode[1][len];
- nodeMapGroupIdCache.put(first, DATA_GROUP_STR + "0");
- groupIdMapNodeCache.put(DATA_GROUP_STR + "0", first);
- for (int j = 0; j < len; j++) {
- val[0][j] = nodes[j];
- }
- dataPartitionCache.put(first, val);
- } else {
- for (int i = 0; i < len; i++) {
- PhysicalNode first = nodes[i];
- if (len < replicator) {
- throw new ErrorConfigureExecption(String.format("Replicator number
%d is greater "
- + "than cluster number %d", replicator, len));
- } else {
- PhysicalNode[][] val = new PhysicalNode[replicator][replicator];
- nodeMapGroupIdCache.put(first, DATA_GROUP_STR + i);
- groupIdMapNodeCache.put(DATA_GROUP_STR + i, first);
- for (int j = 0; j < replicator; j++) {
- for (int k = 0; k < replicator; k++) {
- val[j][k] = nodes[(i - j + k + len) % len];
- }
+ for (int i = 0; i < len; i++) {
+ PhysicalNode first = nodes[i];
+ if (len < replicator) {
+ throw new ErrorConfigureExecption(String.format("Replicator number %d
is greater "
+ + "than cluster number %d", replicator, len));
+ } else if (len == replicator) {
+ PhysicalNode[][] val = new PhysicalNode[1][len];
+ nodeMapGroupIdCache.put(first, DATA_GROUP_STR + "0");
+ groupIdMapNodeCache.put(DATA_GROUP_STR + "0", first);
+ for (int j = 0; j < len; j++) {
+ val[0][j] = nodes[(i + j) % len];
+ }
+ dataPartitionCache.put(first, val);
+ } else {
+ PhysicalNode[][] val = new PhysicalNode[replicator][replicator];
+ nodeMapGroupIdCache.put(first, DATA_GROUP_STR + i);
+ groupIdMapNodeCache.put(DATA_GROUP_STR + i, first);
+ for (int j = 0; j < replicator; j++) {
+ for (int k = 0; k < replicator; k++) {
+ val[j][k] = nodes[(i - j + k + len) % len];
}
- dataPartitionCache.put(first, val);
}
+ dataPartitionCache.put(first, val);
}
}
}