Code cleanup
This commit is contained in:
parent
75931abd89
commit
da9b2b4960
@ -131,21 +131,15 @@ public class ConsistentClusterRoutingService implements ClusterRoutingService {
|
||||
private void addNode(ServerInstance instance) {
|
||||
for (int i = 0; i < virtualNodesSize; i++) {
|
||||
circles[instance.getServerAddress().getServerType().ordinal()].put(hash(instance, i).asLong(), instance);
|
||||
// circles[instance.getServerAddress().getServerType().ordinal()].put(classic(instance, i), instance);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeNode(ServerInstance instance) {
|
||||
for (int i = 0; i < virtualNodesSize; i++) {
|
||||
circles[instance.getServerAddress().getServerType().ordinal()].remove(hash(instance, i).asLong());
|
||||
// circles[instance.getServerAddress().getServerType().ordinal()].remove(classic(instance, i));
|
||||
}
|
||||
}
|
||||
|
||||
private long classic(ServerInstance instance, int i) {
|
||||
return (instance.getHost() + instance.getPort() + i).hashCode() * (Long.MAX_VALUE / Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
private HashCode hash(ServerInstance instance, int i) {
|
||||
return hashFunction.newHasher().putString(instance.getHost(), MiscUtils.UTF8).putInt(instance.getPort()).putInt(i).hash();
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public class ConsistentClusterRoutingServiceTest {
|
||||
private DiscoveryService discoveryService;
|
||||
|
||||
private String hashFunctionName = "murmur3_128";
|
||||
private Integer virtualNodesSize = 1024*64;
|
||||
private Integer virtualNodesSize = 1024*4;
|
||||
private ServerAddress currentServer = new ServerAddress(" 100.96.1.0", 9001, ServerType.CORE);
|
||||
|
||||
|
||||
@ -84,19 +84,6 @@ public class ConsistentClusterRoutingServiceTest {
|
||||
testDevicesDispersion(devices);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDispersionOnDevicesFromFile() throws IOException {
|
||||
List<String> deviceIdsStrList = Files.readAllLines(Paths.get("/home/ashvayka/Downloads/deviceIds.out"));
|
||||
List<DeviceId> devices = deviceIdsStrList.stream().map(String::trim).filter(s -> !s.isEmpty()).map(UUIDConverter::fromString).map(DeviceId::new).collect(Collectors.toList());
|
||||
System.out.println("Devices: " + devices.size());
|
||||
testDevicesDispersion(devices);
|
||||
testDevicesDispersion(devices);
|
||||
testDevicesDispersion(devices);
|
||||
testDevicesDispersion(devices);
|
||||
testDevicesDispersion(devices);
|
||||
|
||||
}
|
||||
|
||||
private void testDevicesDispersion(List<DeviceId> devices) {
|
||||
long start = System.currentTimeMillis();
|
||||
Map<ServerAddress, Integer> map = new HashMap<>();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user