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){
7070 for (int replicaId = 0 ; replicaId < noOfAliasForEachServer ; replicaId ++){
7171 String keyStr = key .toString () + " replica ~ " +replicaId ;
7272 put (keyStr , value );
73+ nodeListMap .get (value ).add (keyStr );
7374 }
7475 }
7576
@@ -80,7 +81,13 @@ void removeServer(K key){
8081 remove (keyStr );
8182 }
8283 }
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+
8491 public static void main (String ... args ){
8592 try {
8693 ConsistentHashing <String , ConsistentHashDataNode <String >> cHash = new ConsistentHashing <>(5 );
You can’t perform that action at this time.
0 commit comments