-
Notifications
You must be signed in to change notification settings - Fork 167
/
ketama_test_multi.php
33 lines (27 loc) · 1011 Bytes
/
ketama_test_multi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
echo "Starting\n";
// try loading server definitions from specified file.
// ketama_roll will automatically re-read the contents
// whenever the file changes.
$continuum1 = ketama_roll( "ketama.servers" );
if ( !$continuum1 )
die( "Continuum one doesn't exist!\n" );
$continuum2 = ketama_roll( "ketama.two.servers" );
if ( !$continuum2 )
die( "Continuum two doesn't exist!\n" );
// find the matching server for key $i in the continuum
// specified by resource $continuum.
for ( $i = 0; $i < 25; $i++ )
{
$server = ketama_get_server( $i, $continuum1 );
echo "Continuum 1: Key " .$i. " is mapped to server " . $server[ "ip" ] . " ".
"at point: " . $server[ "point" ] . "\n";
$server = ketama_get_server( $i, $continuum2 );
echo "Continuum 2: Key " .$i. " is mapped to server " . $server[ "ip" ] . " ".
"at point: " . $server[ "point" ] . "\n";
}
// not strictly needed (will be auto-cleaned)
ketama_destroy( $continuum1 );
ketama_destroy( $continuum2 );
echo "Finished\n";
?>