pub fn assign_rand_nodes_to_slot(&mut self, slot_index: usize) -> common_exception::Result<()> {
        let n = match self.replication {
            Replication::Mirror(x) => x,
        } as usize;

        let mut node_ids = self.nodes.keys().collect::<Vec<&NodeId>>();
        node_ids.sort();
        let total = node_ids.len();
        let node_indexes = rand_n_from_m(total, n)?;

        let mut slot = self
            .slots
            .get_mut(slot_index)
            .ok_or_else(|| ErrorCode::InvalidConfig(format!("slot not found: {}", slot_index)))?;

        slot.node_ids = node_indexes.iter().map(|i| *node_ids[*i]).collect();

        Ok(())
    }
/// Assign `n` random nodes to a slot thus the files associated to this slot are replicated to the corresponding nodes.
/// This func does not cnosider nodes load and should only be used when a Dfs cluster is initiated.
/// TODO(xp): add another func for load based assignment
Assign `n` random nodes to a slot thus the files associated to this slot are replicated to the corresponding nodes.
This func does not cnosider nodes load and should only be used when a Dfs cluster is initiated.
TODO(xp): add another func for load based assignment
Assign ` n ` random nodes to a slot thus the files associated to this slot are replicated to the corresponding nodes . This func does not cnosider nodes load and should only be used when a Dfs cluster is initiated . TODO ( xp ) : add another func for load based assignment
pub fn assign_rand_nodes_to_slot(&mut self, slot_index: usize) -> common_exception::Result<()> {
        let n = match self.replication {
            Replication::Mirror(x) => x,
        } as usize;
        let mut node_ids = self.nodes.keys().collect::<Vec<&NodeId>>();
        node_ids.sort();
        let total = node_ids.len();
        let node_indexes = rand_n_from_m(total, n)?;
        let mut slot = self
            .slots
            .get_mut(slot_index)
            .ok_or_else(|| ErrorCode::InvalidConfig(format!("slot not found: {}", slot_index)))?;
        slot.node_ids = node_indexes.iter().map(|i| *node_ids[*i]).collect();
        Ok(())
    }
pub fn assign_rand_nodes_to_slot ( & mut self , slot_index : usize ) -> common_exception :: Result < ( ) > { let n = match self . replication { Replication :: Mirror ( x ) => x , } as usize ; let mut node_ids = self . nodes . keys ( ) . collect :: < Vec < & NodeId > > ( ) ; node_ids . sort ( ) ; let total = node_ids . len ( ) ; let node_indexes = rand_n_from_m ( total , n ) ? ; let mut slot = self . slots . get_mut ( slot_index ) . ok_or_else ( | | ErrorCode :: InvalidConfig ( format ! ( " " slot_index ) ) ) ? ; slot . node_ids = node_indexes . iter ( ) . map ( | i | * node_ids [ * i ] ) . collect ( ) ; Ok ( ( ) ) }
Assign `n` random nodes to a slot thus the files associated to this slot are replicated to the corresponding nodes.
Assign ` n ` random nodes to a slot thus the files associated to this slot are replicated to the corresponding nodes .
&mut self
slot_index
usize
&mut self
slot_index
usize