File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ void addServer(K key, V value){
70
70
for (int replicaId = 0 ; replicaId < noOfAliasForEachServer ; replicaId ++){
71
71
String keyStr = key .toString () + " replica ~ " +replicaId ;
72
72
put (keyStr , value );
73
+ nodeListMap .get (value ).add (keyStr );
73
74
}
74
75
}
75
76
@@ -80,7 +81,13 @@ void removeServer(K key){
80
81
remove (keyStr );
81
82
}
82
83
}
83
-
84
+
85
+ public V getServerNode (String val ) {
86
+ Long hashing = getHash (val );
87
+ SortedMap <Long , V > tail = circle .tailMap (hashing );
88
+ return circle .get (tail .size () == 0 ? circle .firstKey () : tail .firstKey ());
89
+ }
90
+
84
91
public static void main (String ... args ){
85
92
try {
86
93
ConsistentHashing <String , ConsistentHashDataNode <String >> cHash = new ConsistentHashing <>(5 );
You can’t perform that action at this time.
0 commit comments