Keep tokensEndPointMap sorted by the API order

This patch change the sorting of tokensEndpointMap so it will use the
order returned by the API.

See Scylladb/scylla#1945

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This commit is contained in:
Amnon Heiman 2016-12-28 12:48:03 +02:00
parent b9328960cc
commit 0c7afef8f4
1 changed files with 1 additions and 10 deletions

View File

@ -371,16 +371,7 @@ public class StorageService extends MetricsMBean implements StorageServiceMBean,
@Override
public Map<String, String> getTokenToEndpointMap() {
log(" getTokenToEndpointMap()");
Map<String, String> mapInetAddress = client.getMapStrValue("/storage_service/tokens_endpoint");
// in order to preserve tokens in ascending order, we use LinkedHashMap
// here
Map<String, String> mapString = new LinkedHashMap<>(mapInetAddress.size());
List<String> tokens = new ArrayList<>(mapInetAddress.keySet());
Collections.sort(tokens);
for (String token : tokens) {
mapString.put(token, mapInetAddress.get(token));
}
return mapString;
return client.getMapStrValue("/storage_service/tokens_endpoint");
}
/** Retrieve this hosts unique ID */