179 '10.0.1.1:11211' => 600,
180 '10.0.1.2:11211' => 300,
181 '10.0.1.3:11211' => 200,
182 '10.0.1.4:11211' => 350,
183 '10.0.1.5:11211' => 1000,
184 '10.0.1.6:11211' => 800,
185 '10.0.1.7:11211' => 950,
186 '10.0.1.8:11211' => 100
188 $ring =
new HashRing( $map,
'md5' );
189 $wrapper = \Wikimedia\TestingAccessWrapper::newFromObject( $ring );
191 $ketama_test =
function ( $count ) use ( $wrapper ) {
192 $baseRing = $wrapper->baseRing;
195 for ( $key = 0; $key < $count; ++$key ) {
196 $location = $wrapper->getLocation( $key );
198 $itemPos = $wrapper->getItemPosition( $key );
199 $nodeIndex = $wrapper->findNodeIndexForPosition( $itemPos, $baseRing );
202 $lines[] = sprintf(
"%u %u %s\n", $itemPos, $nodePos, $location );
205 return "\n" . implode(
'',
$lines );
2122216742351 2217271743 10.0.1.1:11211
213943901380 949045552 10.0.1.5:11211
2142373066440 2374693370 10.0.1.6:11211
2152127088620 2130338203 10.0.1.6:11211
2162046197672 2051996197 10.0.1.7:11211
2172134629092 2135172435 10.0.1.1:11211
218470382870 472541453 10.0.1.7:11211
2191608782991 1609789509 10.0.1.3:11211
2202516119753 2520092206 10.0.1.2:11211
2213465331781 3466294492 10.0.1.4:11211
2221749342675 1753760600 10.0.1.5:11211
2231136464485 1137779711 10.0.1.1:11211
2243620997826 3621580689 10.0.1.7:11211
225283385029 285581365 10.0.1.6:11211
2262300818346 2302165654 10.0.1.5:11211
2272132603803 2134614475 10.0.1.8:11211
2282962705863 2969767984 10.0.1.2:11211
229786427760 786565633 10.0.1.5:11211
2304095887727 4096760944 10.0.1.6:11211
2312906459679 2906987515 10.0.1.6:11211
232137884056 138922607 10.0.1.4:11211
23381549628 82491298 10.0.1.6:11211
2343530020790 3530525869 10.0.1.6:11211
2354231817527 4234960467 10.0.1.7:11211
2362011099423 2014738083 10.0.1.7:11211
237107620750 120968799 10.0.1.6:11211
2383979113294 3981926993 10.0.1.4:11211
239273671938 276355738 10.0.1.4:11211
2404032816947 4033300359 10.0.1.5:11211
241464234862 466093615 10.0.1.1:11211
2423007059764 3007671127 10.0.1.5:11211
243542337729 542491760 10.0.1.7:11211
2444040385635 4044064727 10.0.1.5:11211
2453319802648 3320661601 10.0.1.7:11211
2461032153571 1035085391 10.0.1.1:11211
2473543939100 3545608820 10.0.1.5:11211
2483876899353 3885324049 10.0.1.2:11211
2493771318181 3773259708 10.0.1.8:11211
2503457906597 3459285639 10.0.1.5:11211
2513028975062 3031083168 10.0.1.7:11211
252244467158 250943416 10.0.1.5:11211
2531604785716 1609789509 10.0.1.3:11211
2543905343649 3905751132 10.0.1.1:11211
2551713497623 1725056963 10.0.1.5:11211
2561668356087 1668827816 10.0.1.5:11211
2573427369836 3438933308 10.0.1.1:11211
2582515850457 2520092206 10.0.1.2:11211
2593886138983 3887390208 10.0.1.1:11211
2604019334756 4023153300 10.0.1.8:11211
2611170561012 1170785765 10.0.1.7:11211
2621841809344 1848425105 10.0.1.6:11211
263973223976 973369204 10.0.1.1:11211
264358093210 359562433 10.0.1.6:11211
265378350808 380841931 10.0.1.5:11211
2664008477862 4012085095 10.0.1.7:11211
2671027226549 1028630030 10.0.1.6:11211
2682386583967 2387706118 10.0.1.1:11211
269522892146 524831677 10.0.1.7:11211
2703779194982 3788912803 10.0.1.5:11211
2713764731657 3771312500 10.0.1.7:11211
272184756999 187529415 10.0.1.6:11211
273838351231 845886003 10.0.1.3:11211
2742827220548 2828019973 10.0.1.6:11211
2753604721411 3607668249 10.0.1.6:11211
276472866282 475506254 10.0.1.5:11211
2772752268796 2754833471 10.0.1.5:11211
2781791464754 1795042583 10.0.1.7:11211
2793029359475 3031083168 10.0.1.7:11211
2803633378211 3639985542 10.0.1.6:11211
2813148267284 3149217023 10.0.1.6:11211
282163887996 166705043 10.0.1.7:11211
2833642803426 3649125922 10.0.1.7:11211
2843901799218 3902199881 10.0.1.7:11211
285418045394 425867331 10.0.1.6:11211
286346775981 348578169 10.0.1.6:11211
287368352208 372224616 10.0.1.7:11211
2882643711995 2644259911 10.0.1.5:11211
2892032983336 2033860601 10.0.1.6:11211
2903567842357 3572867530 10.0.1.2:11211
2911024982737 1028630030 10.0.1.6:11211
292933966832 938106828 10.0.1.7:11211
2932102520899 2103402846 10.0.1.7:11211
2943537205399 3538094881 10.0.1.7:11211
2952311233534 2314593262 10.0.1.1:11211
2962500514664 2503565236 10.0.1.7:11211
2971091958846 1093484995 10.0.1.6:11211
2983984972691 3987453644 10.0.1.1:11211
2992669994439 2670911201 10.0.1.4:11211
3002846111786 2846115813 10.0.1.5:11211
3011805010806 1808593732 10.0.1.8:11211
3021587024774 1587746378 10.0.1.5:11211
3033214549588 3215619351 10.0.1.2:11211
3041965214866 1970922428 10.0.1.7:11211
3051038671000 1040777775 10.0.1.7:11211
306820820468 823114475 10.0.1.6:11211
3072722835329 2723166435 10.0.1.5:11211
3081602053414 1604196066 10.0.1.5:11211
3091330835426 1335097278 10.0.1.5:11211
310556547565 557075710 10.0.1.4:11211
3112977587884 2978402952 10.0.1.1:11211
315 $this->assertEquals( $expected, $ketama_test( 100 ),
'Ketama mode (diff check)' );
319 'd1a4912a80e4654ec2e4e462c8b911c6',
320 md5( $ketama_test( 1e3 ) ),
321 'Ketama mode (large, MD5 check)'