Rename n_tokens into capacity
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
7cda917b6b
commit
6a3dcf3974
3 changed files with 16 additions and 16 deletions
|
@ -18,6 +18,6 @@ garage status \
|
||||||
| grep UNCONFIGURED \
|
| grep UNCONFIGURED \
|
||||||
| grep -Po '^[0-9a-f]+' \
|
| grep -Po '^[0-9a-f]+' \
|
||||||
| while read id; do
|
| while read id; do
|
||||||
garage node configure -d dc1 -n 1 $id
|
garage node configure -d dc1 -c 1 $id
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -98,9 +98,9 @@ pub struct ConfigureNodeOpt {
|
||||||
#[structopt(short = "d", long = "datacenter")]
|
#[structopt(short = "d", long = "datacenter")]
|
||||||
datacenter: Option<String>,
|
datacenter: Option<String>,
|
||||||
|
|
||||||
/// Number of tokens
|
/// Capacity (in relative terms, use 1 to represent your smallest server)
|
||||||
#[structopt(short = "n", long = "n-tokens")]
|
#[structopt(short = "c", long = "capacity")]
|
||||||
n_tokens: Option<u32>,
|
capacity: Option<u32>,
|
||||||
|
|
||||||
/// Optionnal node tag
|
/// Optionnal node tag
|
||||||
#[structopt(short = "t", long = "tag")]
|
#[structopt(short = "t", long = "tag")]
|
||||||
|
@ -360,7 +360,7 @@ async fn cmd_status(rpc_cli: RpcAddrClient<Message>, rpc_host: SocketAddr) -> Re
|
||||||
if let Some(cfg) = config.members.get(&adv.id) {
|
if let Some(cfg) = config.members.get(&adv.id) {
|
||||||
println!(
|
println!(
|
||||||
"{:?}\t{}\t{}\t[{}]\t{}\t{}",
|
"{:?}\t{}\t{}\t[{}]\t{}\t{}",
|
||||||
adv.id, adv.state_info.hostname, adv.addr, cfg.tag, cfg.datacenter, cfg.n_tokens
|
adv.id, adv.state_info.hostname, adv.addr, cfg.tag, cfg.datacenter, cfg.capacity
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
println!(
|
println!(
|
||||||
|
@ -387,7 +387,7 @@ async fn cmd_status(rpc_cli: RpcAddrClient<Message>, rpc_host: SocketAddr) -> Re
|
||||||
adv.addr,
|
adv.addr,
|
||||||
cfg.tag,
|
cfg.tag,
|
||||||
cfg.datacenter,
|
cfg.datacenter,
|
||||||
cfg.n_tokens,
|
cfg.capacity,
|
||||||
(now_msec() - adv.last_seen) / 1000,
|
(now_msec() - adv.last_seen) / 1000,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -396,7 +396,7 @@ async fn cmd_status(rpc_cli: RpcAddrClient<Message>, rpc_host: SocketAddr) -> Re
|
||||||
if !status.iter().any(|x| x.id == *id) {
|
if !status.iter().any(|x| x.id == *id) {
|
||||||
println!(
|
println!(
|
||||||
"{:?}\t{}\t{}\t{}\tnever seen",
|
"{:?}\t{}\t{}\t{}\tnever seen",
|
||||||
id, cfg.tag, cfg.datacenter, cfg.n_tokens
|
id, cfg.tag, cfg.datacenter, cfg.capacity
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,14 +444,14 @@ async fn cmd_configure(
|
||||||
datacenter: args
|
datacenter: args
|
||||||
.datacenter
|
.datacenter
|
||||||
.expect("Please specifiy a datacenter with the -d flag"),
|
.expect("Please specifiy a datacenter with the -d flag"),
|
||||||
n_tokens: args
|
capacity: args
|
||||||
.n_tokens
|
.capacity
|
||||||
.expect("Please specifiy a number of tokens with the -n flag"),
|
.expect("Please specifiy a capacity with the -c flag"),
|
||||||
tag: args.tag.unwrap_or("".to_string()),
|
tag: args.tag.unwrap_or("".to_string()),
|
||||||
},
|
},
|
||||||
Some(old) => NetworkConfigEntry {
|
Some(old) => NetworkConfigEntry {
|
||||||
datacenter: args.datacenter.unwrap_or(old.datacenter.to_string()),
|
datacenter: args.datacenter.unwrap_or(old.datacenter.to_string()),
|
||||||
n_tokens: args.n_tokens.unwrap_or(old.n_tokens),
|
capacity: args.capacity.unwrap_or(old.capacity),
|
||||||
tag: args.tag.unwrap_or(old.tag.to_string()),
|
tag: args.tag.unwrap_or(old.tag.to_string()),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl NetworkConfig {
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct NetworkConfigEntry {
|
pub struct NetworkConfigEntry {
|
||||||
pub datacenter: String,
|
pub datacenter: String,
|
||||||
pub n_tokens: u32,
|
pub capacity: u32,
|
||||||
pub tag: String,
|
pub tag: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,10 +88,10 @@ impl Ring {
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let max_toktok = config
|
let max_capacity = config
|
||||||
.members
|
.members
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_, node_info)| node_info.n_tokens)
|
.map(|(_, node_info)| node_info.capacity)
|
||||||
.fold(0, std::cmp::max);
|
.fold(0, std::cmp::max);
|
||||||
|
|
||||||
// Fill up ring
|
// Fill up ring
|
||||||
|
@ -108,9 +108,9 @@ impl Ring {
|
||||||
let mut remaining = partitions_idx.len();
|
let mut remaining = partitions_idx.len();
|
||||||
while remaining > 0 {
|
while remaining > 0 {
|
||||||
let remaining0 = remaining;
|
let remaining0 = remaining;
|
||||||
for toktok in 0..max_toktok {
|
for i_round in 0..max_capacity {
|
||||||
for (node_id, node_info, q, pos) in queues.iter_mut() {
|
for (node_id, node_info, q, pos) in queues.iter_mut() {
|
||||||
if toktok >= node_info.n_tokens {
|
if i_round >= node_info.capacity {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for pos2 in *pos..q.len() {
|
for pos2 in *pos..q.len() {
|
||||||
|
|
Loading…
Reference in a new issue