Fix walk_ring_from
This commit is contained in:
parent
40c48e6a59
commit
ace07da7c1
2 changed files with 11 additions and 9 deletions
|
@ -86,7 +86,7 @@ impl BlockManager {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Not found but maybe we should have had it ??
|
// Not found but maybe we should have had it ??
|
||||||
self.put_to_resync(hash, DEFAULT_TIMEOUT.as_millis() as u64)?;
|
self.put_to_resync(hash, 0)?;
|
||||||
return Err(Into::into(e));
|
return Err(Into::into(e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -158,21 +158,23 @@ impl Ring {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_ring_from_pos(&self, start: usize, n: usize) -> Vec<UUID> {
|
pub fn walk_ring_from_pos(&self, start: usize, n: usize) -> Vec<UUID> {
|
||||||
|
if n >= self.config.members.len() {
|
||||||
|
return self.config.members.keys().cloned().collect::<Vec<_>>();
|
||||||
|
}
|
||||||
|
|
||||||
let mut ret = vec![];
|
let mut ret = vec![];
|
||||||
let mut datacenters = vec![];
|
let mut datacenters = vec![];
|
||||||
|
|
||||||
for delta in 0..self.ring.len() {
|
let mut delta = 0;
|
||||||
if ret.len() == n {
|
while ret.len() < n {
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
let i = (start + delta) % self.ring.len();
|
let i = (start + delta) % self.ring.len();
|
||||||
|
delta += 1;
|
||||||
|
|
||||||
if datacenters.len() == self.n_datacenters && !ret.contains(&self.ring[i].node) {
|
if !datacenters.contains(&self.ring[i].datacenter) {
|
||||||
ret.push(self.ring[i].node.clone());
|
|
||||||
} else if !datacenters.contains(&self.ring[i].datacenter) {
|
|
||||||
ret.push(self.ring[i].node.clone());
|
ret.push(self.ring[i].node.clone());
|
||||||
datacenters.push(self.ring[i].datacenter);
|
datacenters.push(self.ring[i].datacenter);
|
||||||
|
} else if datacenters.len() == self.n_datacenters && !ret.contains(&self.ring[i].node) {
|
||||||
|
ret.push(self.ring[i].node.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue