设为首页 加入收藏

TOP

kemata处理
2014-11-23 22:53:52 来源: 作者: 【 】 浏览:2
Tags:kemata 处理

/*

* Using a known ketama.servers file, and a fixed set of keys

* print and hash the output of this program using your modified

* libketama, compare the hash of the output to the known correct

* hash in the test harness.

*/

#include

#include

#include

int main(int argc, char **argv)

{

if(argc==1){

printf("Usage: %s \n", *argv);//相当于*argv[]

return 1;//返回异常

}

ketama_continuum c; //声明一个全类型的变量

ketama_roll( &c, *++argv ); //将服务器分散到圈中的个个地点

printf( "%s\n", ketama_error() );

int i;

for ( i = 0; i < 10; i++ )

{

char k[10];

sprintf( k, "%d", i ); //格式化字符串后赋值

unsigned int kh = ketama_hashi( k ); //进行散列处理,获得散列值

mcs* m = ketama_get_server( k, c ); //将散列值放入圈中,并返回mcs结构体指针

printf( "%u %u %s\n", kh, m->point, m->ip );

}

ketama_smoke(c);

return 0;

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇hdu 1496 Equations(非常巧妙的h.. 下一篇 protocolbuffer添加ActionScript..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: