Rename datacenters into zones (doc not yet updated)
This commit is contained in:
parent
b490ebc7f6
commit
ddb2b29bfd
@ -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 -c 1 $id
|
garage node configure -z dc1 -c 1 $id
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -72,9 +72,9 @@ pub struct ConfigureNodeOpt {
|
|||||||
/// Node to configure (prefix of hexadecimal node id)
|
/// Node to configure (prefix of hexadecimal node id)
|
||||||
node_id: String,
|
node_id: String,
|
||||||
|
|
||||||
/// Location (datacenter) of the node
|
/// Location (zone or datacenter) of the node
|
||||||
#[structopt(short = "d", long = "datacenter")]
|
#[structopt(short = "z", long = "zone")]
|
||||||
datacenter: Option<String>,
|
zone: Option<String>,
|
||||||
|
|
||||||
/// Capacity (in relative terms, use 1 to represent your smallest server)
|
/// Capacity (in relative terms, use 1 to represent your smallest server)
|
||||||
#[structopt(short = "c", long = "capacity")]
|
#[structopt(short = "c", long = "capacity")]
|
||||||
@ -347,7 +347,7 @@ pub async fn cmd_status(
|
|||||||
adv.state_info.hostname,
|
adv.state_info.hostname,
|
||||||
adv.addr,
|
adv.addr,
|
||||||
cfg.tag,
|
cfg.tag,
|
||||||
cfg.datacenter,
|
cfg.zone,
|
||||||
cfg.capacity_string()
|
cfg.capacity_string()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -374,7 +374,7 @@ pub async fn cmd_status(
|
|||||||
adv.state_info.hostname,
|
adv.state_info.hostname,
|
||||||
adv.addr,
|
adv.addr,
|
||||||
cfg.tag,
|
cfg.tag,
|
||||||
cfg.datacenter,
|
cfg.zone,
|
||||||
cfg.capacity_string(),
|
cfg.capacity_string(),
|
||||||
(now_msec() - adv.last_seen) / 1000,
|
(now_msec() - adv.last_seen) / 1000,
|
||||||
);
|
);
|
||||||
@ -386,7 +386,7 @@ pub async fn cmd_status(
|
|||||||
"{:?}\t{}\t{}\t{}\tnever seen",
|
"{:?}\t{}\t{}\t{}\tnever seen",
|
||||||
id,
|
id,
|
||||||
cfg.tag,
|
cfg.tag,
|
||||||
cfg.datacenter,
|
cfg.zone,
|
||||||
cfg.capacity_string(),
|
cfg.capacity_string(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -467,9 +467,9 @@ pub async fn cmd_configure(
|
|||||||
"Please specify a capacity with the -c flag, or set node explicitly as gateway with -g".into())),
|
"Please specify a capacity with the -c flag, or set node explicitly as gateway with -g".into())),
|
||||||
};
|
};
|
||||||
NetworkConfigEntry {
|
NetworkConfigEntry {
|
||||||
datacenter: args
|
zone: args
|
||||||
.datacenter
|
.zone
|
||||||
.expect("Please specifiy a datacenter with the -d flag"),
|
.expect("Please specifiy a zone with the -z flag"),
|
||||||
capacity,
|
capacity,
|
||||||
tag: args.tag.unwrap_or_default(),
|
tag: args.tag.unwrap_or_default(),
|
||||||
}
|
}
|
||||||
@ -481,9 +481,9 @@ pub async fn cmd_configure(
|
|||||||
_ => old.capacity,
|
_ => old.capacity,
|
||||||
};
|
};
|
||||||
NetworkConfigEntry {
|
NetworkConfigEntry {
|
||||||
datacenter: args
|
zone: args
|
||||||
.datacenter
|
.zone
|
||||||
.unwrap_or_else(|| old.datacenter.to_string()),
|
.unwrap_or_else(|| old.zone.to_string()),
|
||||||
capacity,
|
capacity,
|
||||||
tag: args.tag.unwrap_or_else(|| old.tag.to_string()),
|
tag: args.tag.unwrap_or_else(|| old.tag.to_string()),
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ impl NetworkConfig {
|
|||||||
pub struct NetworkConfigEntry {
|
pub struct NetworkConfigEntry {
|
||||||
/// Datacenter at which this entry belong. This infromation might be used to perform a better
|
/// Datacenter at which this entry belong. This infromation might be used to perform a better
|
||||||
/// geodistribution
|
/// geodistribution
|
||||||
pub datacenter: String,
|
pub zone: String,
|
||||||
/// The (relative) capacity of the node
|
/// The (relative) capacity of the node
|
||||||
/// If this is set to None, the node does not participate in storing data for the system
|
/// If this is set to None, the node does not participate in storing data for the system
|
||||||
/// and is only active as an API gateway to other nodes
|
/// and is only active as an API gateway to other nodes
|
||||||
@ -109,13 +109,13 @@ impl Ring {
|
|||||||
// Create a vector of partition indices (0 to 2**PARTITION_BITS-1)
|
// Create a vector of partition indices (0 to 2**PARTITION_BITS-1)
|
||||||
let partitions_idx = (0usize..(1usize << PARTITION_BITS)).collect::<Vec<_>>();
|
let partitions_idx = (0usize..(1usize << PARTITION_BITS)).collect::<Vec<_>>();
|
||||||
|
|
||||||
let datacenters = config
|
let zones = config
|
||||||
.members
|
.members
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_id, info)| info.capacity.is_some())
|
.filter(|(_id, info)| info.capacity.is_some())
|
||||||
.map(|(_id, info)| info.datacenter.as_str())
|
.map(|(_id, info)| info.zone.as_str())
|
||||||
.collect::<HashSet<&str>>();
|
.collect::<HashSet<&str>>();
|
||||||
let n_datacenters = datacenters.len();
|
let n_zones = zones.len();
|
||||||
|
|
||||||
// Prepare ring
|
// Prepare ring
|
||||||
let mut partitions: Vec<Vec<(&Uuid, &NetworkConfigEntry)>> = partitions_idx
|
let mut partitions: Vec<Vec<(&Uuid, &NetworkConfigEntry)>> = partitions_idx
|
||||||
@ -174,13 +174,13 @@ impl Ring {
|
|||||||
if partitions[qv].len() != rep {
|
if partitions[qv].len() != rep {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let p_dcs = partitions[qv]
|
let p_zns = partitions[qv]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_id, info)| info.datacenter.as_str())
|
.map(|(_id, info)| info.zone.as_str())
|
||||||
.collect::<HashSet<&str>>();
|
.collect::<HashSet<&str>>();
|
||||||
if (p_dcs.len() < n_datacenters
|
if (p_zns.len() < n_zones
|
||||||
&& !p_dcs.contains(&node_info.datacenter.as_str()))
|
&& !p_zns.contains(&node_info.zone.as_str()))
|
||||||
|| (p_dcs.len() == n_datacenters
|
|| (p_zns.len() == n_zones
|
||||||
&& !partitions[qv].iter().any(|(id, _i)| id == node_id))
|
&& !partitions[qv].iter().any(|(id, _i)| id == node_id))
|
||||||
{
|
{
|
||||||
partitions[qv].push((node_id, node_info));
|
partitions[qv].push((node_id, node_info));
|
||||||
|
Loading…
Reference in New Issue
Block a user