int table_builder2::is_this_node_OK(server_id_type node_id, int line_num, size_t node_idx, hash_table_type & hash_table_dest, int option_level, bool node_in_use) { if(is_node_availble(node_id) == false) return INVALID_NODE; int turn = 0; int tokenPerNode_min = (node_id.second == max_machine_room_id) ? mtokens_per_node_min : otokens_per_node_min; int tokenPerNode_max_count = (node_id.second == max_machine_room_id) ? mtokens_per_node_max_count : otokens_per_node_max_count; if(node_in_use == true) turn = 1; if(line_num == 0) { if(mtokens_count_in_node[node_id] >= master_server_capable[node_id] + turn) { return TOOMANY_MASTER; } } else if(option_level == CONSIDER_ALL) { if(tokens_count_in_node[node_id] >= server_capable[node_id] + turn) { return TOOMANY_BUCKET; } } else { if(option_level != CONSIDER_FORCE && tokens_count_in_node_now[node_id] >= tokenPerNode_min + turn && max_count_now >= tokenPerNode_max_count + turn) { return TOOMANY_BUCKET; } } if(line_num == 0 && option_level == CONSIDER_BASE) { return NODE_OK; } set<uint32_t> pos_limit; pos_limit.insert(node_id.second); for(size_t i = 0; i < copy_count; i++) { if((int) i != line_num) { pos_limit.insert(hash_table_dest[i][node_idx].second); if(hash_table_dest[i][node_idx].first == node_id.first) { return SAME_NODE; } //if (option_level < CONSIDER_BASE) { // if ( hashTable_dest[i][node_idx].second == node_id.second){ // return SAME_POS; // } //} } } if(build_stat_normal && line_num != 0 && pos_limit.size() < 2) return SAME_POS; return NODE_OK; }
int table_builder1::is_this_node_OK(server_id_type node_id, int line_num, size_t node_idx, hash_table_type & hash_table_dest, int option_level, bool node_in_use) { if(is_node_availble(node_id) == false) return INVALID_NODE; int turn = 0; if(node_in_use == true) turn = 1; if(line_num == 0) { if(mtokens_count_in_node[node_id] >= master_server_capable[node_id] + turn) { return TOOMANY_MASTER; } } else if(option_level == CONSIDER_ALL) { //line_num != 0 if(tokens_count_in_node[node_id] >= server_capable[node_id] + turn) { return TOOMANY_BUCKET; } } else { //line_num != 0 && option_level != CONSIDER_ALL if(option_level != CONSIDER_FORCE && tokens_count_in_node_now[node_id] >= tokens_per_node_min + turn && max_count_now >= tokens_per_node_max_count + turn) { return TOOMANY_BUCKET; } } if(line_num == 0 && option_level == CONSIDER_BASE) { return NODE_OK; } for(size_t i = 0; i < copy_count; i++) { if((int) i != line_num) { if(hash_table_dest[i][node_idx].first == node_id.first) { return SAME_NODE; } if(option_level < CONSIDER_BASE) { //CONSIDER_ALL if(hash_table_dest[i][node_idx].second == node_id.second) { return SAME_POS; } } } } return NODE_OK; }