StorageService: Sort the results of getTokenToEndpointMap
This patch takes the implementation of getTokenToEndpointMap from Origin which sorts the map result. Fixes scylladb/scylla#722 Signed-off-by: Amnon Heiman <amnon@scylladb.com> Message-Id: <1456142885-20838-1-git-send-email-amnon@scylladb.com>
This commit is contained in:
parent
15ad444c40
commit
d589f3a3a3
@ -332,7 +332,16 @@ public class StorageService extends NotificationBroadcasterSupport
|
||||
*/
|
||||
public Map<String, String> getTokenToEndpointMap() {
|
||||
log(" getTokenToEndpointMap()");
|
||||
return c.getMapStrValue("/storage_service/tokens_endpoint");
|
||||
Map<String, String> mapInetAddress = c.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;
|
||||
}
|
||||
|
||||
/** Retrieve this hosts unique ID */
|
||||
|
Loading…
x
Reference in New Issue
Block a user