Showing
2 changed files
with
1 additions
and
20 deletions
... | ... | @@ -131,21 +131,15 @@ public class ConsistentClusterRoutingService implements ClusterRoutingService { |
131 | 131 | private void addNode(ServerInstance instance) { |
132 | 132 | for (int i = 0; i < virtualNodesSize; i++) { |
133 | 133 | circles[instance.getServerAddress().getServerType().ordinal()].put(hash(instance, i).asLong(), instance); |
134 | -// circles[instance.getServerAddress().getServerType().ordinal()].put(classic(instance, i), instance); | |
135 | 134 | } |
136 | 135 | } |
137 | 136 | |
138 | 137 | private void removeNode(ServerInstance instance) { |
139 | 138 | for (int i = 0; i < virtualNodesSize; i++) { |
140 | 139 | circles[instance.getServerAddress().getServerType().ordinal()].remove(hash(instance, i).asLong()); |
141 | -// circles[instance.getServerAddress().getServerType().ordinal()].remove(classic(instance, i)); | |
142 | 140 | } |
143 | 141 | } |
144 | 142 | |
145 | - private long classic(ServerInstance instance, int i) { | |
146 | - return (instance.getHost() + instance.getPort() + i).hashCode() * (Long.MAX_VALUE / Integer.MAX_VALUE); | |
147 | - } | |
148 | - | |
149 | 143 | private HashCode hash(ServerInstance instance, int i) { |
150 | 144 | return hashFunction.newHasher().putString(instance.getHost(), MiscUtils.UTF8).putInt(instance.getPort()).putInt(i).hash(); |
151 | 145 | } | ... | ... |
... | ... | @@ -54,7 +54,7 @@ public class ConsistentClusterRoutingServiceTest { |
54 | 54 | private DiscoveryService discoveryService; |
55 | 55 | |
56 | 56 | private String hashFunctionName = "murmur3_128"; |
57 | - private Integer virtualNodesSize = 1024*64; | |
57 | + private Integer virtualNodesSize = 1024*4; | |
58 | 58 | private ServerAddress currentServer = new ServerAddress(" 100.96.1.0", 9001, ServerType.CORE); |
59 | 59 | |
60 | 60 | |
... | ... | @@ -84,19 +84,6 @@ public class ConsistentClusterRoutingServiceTest { |
84 | 84 | testDevicesDispersion(devices); |
85 | 85 | } |
86 | 86 | |
87 | - @Test | |
88 | - public void testDispersionOnDevicesFromFile() throws IOException { | |
89 | - List<String> deviceIdsStrList = Files.readAllLines(Paths.get("/home/ashvayka/Downloads/deviceIds.out")); | |
90 | - List<DeviceId> devices = deviceIdsStrList.stream().map(String::trim).filter(s -> !s.isEmpty()).map(UUIDConverter::fromString).map(DeviceId::new).collect(Collectors.toList()); | |
91 | - System.out.println("Devices: " + devices.size()); | |
92 | - testDevicesDispersion(devices); | |
93 | - testDevicesDispersion(devices); | |
94 | - testDevicesDispersion(devices); | |
95 | - testDevicesDispersion(devices); | |
96 | - testDevicesDispersion(devices); | |
97 | - | |
98 | - } | |
99 | - | |
100 | 87 | private void testDevicesDispersion(List<DeviceId> devices) { |
101 | 88 | long start = System.currentTimeMillis(); |
102 | 89 | Map<ServerAddress, Integer> map = new HashMap<>(); | ... | ... |