///
/// Generate partitions on spus that have been assigned to racks
///
Generate partitions on spus that have been assigned to racks
Generate partitions on spus that have been assigned to racks
fn generate_partitions_with_rack_assignment(
    spus: &SpuLocalStore,
    param: &TopicReplicaParam,
    start_index: i32,
) -> ReplicaMap {
    let mut partition_map = BTreeMap::new();
    let rack_map = SpuLocalStore::live_spu_rack_map_sorted(&spus);
    let spu_list = SpuLocalStore::online_spus_in_rack(&rack_map);
    let spu_cnt = spus.online_spu_count();
    let s_idx = if start_index >= 0 {
        start_index
    } else {
        thread_rng().gen_range(0, spu_cnt)
    };
    for p_idx in 0..param.partitions {
        let mut replicas: Vec<i32> = vec![];
        for r_idx in 0..param.replication_factor {
            let spu_idx = ((s_idx + p_idx + r_idx) % spu_cnt) as usize;
            replicas.push(spu_list[spu_idx]);
        }
        partition_map.insert(p_idx, replicas);
    }
    partition_map
}
fn generate_partitions_with_rack_assignment ( spus : & SpuLocalStore , param : & TopicReplicaParam , start_index : i32 , ) -> ReplicaMap { let mut partition_map = BTreeMap :: new ( ) ; let rack_map = SpuLocalStore :: live_spu_rack_map_sorted ( & spus ) ; let spu_list = SpuLocalStore :: online_spus_in_rack ( & rack_map ) ; let spu_cnt = spus . online_spu_count ( ) ; let s_idx = if start_index >= 0 { start_index } else { thread_rng ( ) . gen_range ( 0 , spu_cnt ) } ; for p_idx in 0 .. param . partitions { let mut replicas : Vec < i32 > = vec ! [ ] ; for r_idx in 0 .. param . replication_factor { let spu_idx = ( ( s_idx + p_idx + r_idx ) % spu_cnt ) as usize ; replicas . push ( spu_list [ spu_idx ] ) ; } partition_map . insert ( p_idx , replicas ) ; } partition_map }
Generate partitions on spus that have been assigned to racks
Generate partitions on spus that have been assigned to racks
spus
&SpuLocalStore
param
&TopicReplicaParam
start_index
i32