Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 61 additions & 21 deletions dsc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ enum Action {
#[clap(long, default_value = "15", action)]
extent_count: u32,

/// Registration address of an Oximeter collector. When set, each
/// downstairs is started with `--oximeter <addr>` and publishes
/// metrics to that collector.
#[clap(long, action)]
oximeter: Option<SocketAddr>,

/// Downstairs will all be started read only (default: false)
#[clap(long, action, default_value = "false")]
read_only: bool,
Expand Down Expand Up @@ -234,6 +240,9 @@ struct DownstairsInfo {
output_file: PathBuf,
client_id: usize,
read_only: bool,
/// Registration address of an Oximeter collector. When set, the spawned
/// downstairs is told to register and publish metrics (`--oximeter`).
oximeter: Option<SocketAddr>,
}

impl DownstairsInfo {
Expand All @@ -247,6 +256,7 @@ impl DownstairsInfo {
output_file: PathBuf,
client_id: usize,
read_only: bool,
oximeter: Option<SocketAddr>,
) -> DownstairsInfo {
DownstairsInfo {
ds_bin,
Expand All @@ -257,6 +267,7 @@ impl DownstairsInfo {
output_file,
client_id,
read_only,
oximeter,
}
}

Expand All @@ -275,16 +286,21 @@ impl DownstairsInfo {
};

let region_dir = self.region_dir.clone();
let mut args = vec![
"run".to_string(),
"-p".to_string(),
port_value,
"-d".to_string(),
region_dir.clone(),
"--mode".to_string(),
mode,
];
if let Some(oximeter) = self.oximeter {
args.push("--oximeter".to_string());
args.push(oximeter.to_string());
}
let cmd = Command::new(self.ds_bin.clone())
.args([
"run",
"-p",
&port_value,
"-d",
&region_dir,
"--mode",
&mode,
])
.args(&args)
.stdout(Stdio::from(outputs))
.stderr(Stdio::from(errors))
.spawn()
Expand Down Expand Up @@ -324,6 +340,8 @@ pub struct DscInfo {
work: Mutex<DscWork>,
/// If the downstairs are started read only
read_only: bool,
/// Oximeter collector registration address passed to each downstairs
oximeter: Option<SocketAddr>,
}

impl DscInfo {
Expand All @@ -337,6 +355,7 @@ impl DscInfo {
port_base: u32,
region_count: usize,
read_only: bool,
oximeter: Option<SocketAddr>,
) -> Result<Arc<Self>> {
// Verify the downstairs binary exists as is a file
if !Path::new(&downstairs_bin).exists() {
Expand Down Expand Up @@ -453,6 +472,7 @@ impl DscInfo {
rs: mrs,
work,
read_only,
oximeter,
}))
}

Expand Down Expand Up @@ -598,6 +618,7 @@ impl DscInfo {
output_path,
ds_id,
self.read_only,
self.oximeter,
);
rs.ds.push(Arc::new(dsi));

Expand Down Expand Up @@ -693,6 +714,7 @@ impl DscInfo {
output_path,
ds_id,
self.read_only,
self.oximeter,
);
rs.ds.push(Arc::new(dsi));
port += rs.port_step;
Expand Down Expand Up @@ -1569,6 +1591,7 @@ fn main() -> Result<()> {
port_base,
region_count,
false,
None,
)?;

runtime.block_on(dsci.create_regions(
Expand All @@ -1587,7 +1610,8 @@ fn main() -> Result<()> {
region_dir,
} => {
let dsci = DscInfo::new(
ds_bin, output_dir, region_dir, notify_tx, true, 8810, 3, false,
ds_bin, output_dir, region_dir, notify_tx, true, 8810, 3,
false, None,
)?;
runtime.block_on(region_create_test(&dsci, long, csv_out))
}
Expand All @@ -1600,6 +1624,7 @@ fn main() -> Result<()> {
encrypted,
extent_size,
extent_count,
oximeter,
output_dir,
port_base,
read_only,
Expand Down Expand Up @@ -1628,6 +1653,7 @@ fn main() -> Result<()> {
port_base,
region_count,
read_only,
oximeter,
)?;

if create {
Expand Down Expand Up @@ -1683,6 +1709,7 @@ mod test {
8810,
3,
false,
None,
);
assert!(res.is_ok());
assert!(Path::new(&dir).exists());
Expand All @@ -1708,6 +1735,7 @@ mod test {
8810,
3,
false,
None,
);
assert!(res.is_ok());
assert!(Path::new(&dir).exists());
Expand All @@ -1727,8 +1755,9 @@ mod test {
let r2 = tempdir().unwrap().as_ref().to_path_buf();
let region_vec = vec![r1, r2];
let (tx, _) = watch::channel(0);
let res =
DscInfo::new(ds_bin, dir, region_vec, tx, true, 8810, 3, false);
let res = DscInfo::new(
ds_bin, dir, region_vec, tx, true, 8810, 3, false, None,
);
assert!(res.is_err());
}

Expand All @@ -1744,8 +1773,9 @@ mod test {
let r3 = tempdir().unwrap().as_ref().to_path_buf();
let region_vec = vec![r1, r2, r3];
let (tx, _) = watch::channel(0);
let res =
DscInfo::new(ds_bin, dir, region_vec, tx, true, 8810, 2, false);
let res = DscInfo::new(
ds_bin, dir, region_vec, tx, true, 8810, 2, false, None,
);
assert!(res.is_err());
}

Expand All @@ -1770,6 +1800,7 @@ mod test {
8810,
4,
false,
None,
);
assert!(res.is_ok());
assert!(Path::new(&dir).exists());
Expand All @@ -1795,6 +1826,7 @@ mod test {
8810,
3,
false,
None,
);

assert!(res.is_err());
Expand All @@ -1820,13 +1852,14 @@ mod test {
8810,
3,
false,
None,
)
.unwrap();

// Now, create them again and expect an error.
let (tx, _) = watch::channel(0);
let res = DscInfo::new(
ds_bin, output_dir, region_vec, tx, true, 8810, 3, false,
ds_bin, output_dir, region_vec, tx, true, 8810, 3, false, None,
);
assert!(res.is_err());
}
Expand All @@ -1839,9 +1872,10 @@ mod test {
let dir = tempdir().unwrap().as_ref().to_path_buf();
let region_vec = vec![dir.clone()];
let (tx, _) = watch::channel(0);
let dsci =
DscInfo::new(ds_bin, dir, region_vec, tx, true, 8810, 3, false)
.unwrap();
let dsci = DscInfo::new(
ds_bin, dir, region_vec, tx, true, 8810, 3, false, None,
)
.unwrap();

let res = dsci.delete_ds_region(0).await;
println!("res is {:?}", res);
Expand All @@ -1859,9 +1893,10 @@ mod test {
let r3 = tempdir().unwrap().as_ref().to_path_buf();
let region_vec = vec![r1.clone(), r2, r3];
let (tx, _) = watch::channel(0);
let dsci =
DscInfo::new(ds_bin, dir, region_vec, tx, true, 8810, 3, false)
.unwrap();
let dsci = DscInfo::new(
ds_bin, dir, region_vec, tx, true, 8810, 3, false, None,
)
.unwrap();

// Manually create the first region directory.
let ds_region_dir =
Expand Down Expand Up @@ -1895,6 +1930,7 @@ mod test {
8810,
3,
false,
None,
)
.unwrap();

Expand Down Expand Up @@ -1927,6 +1963,7 @@ mod test {
8810,
3,
false,
None,
)
.unwrap();
assert!(Path::new(&dir).exists());
Expand Down Expand Up @@ -1969,6 +2006,7 @@ mod test {
8810,
4,
false,
None,
)
.unwrap();
assert!(Path::new(&dir).exists());
Expand Down Expand Up @@ -2012,6 +2050,7 @@ mod test {
8810,
3,
false,
None,
)
.unwrap();
assert!(Path::new(&dir).exists());
Expand Down Expand Up @@ -2050,6 +2089,7 @@ mod test {
8810,
4,
false,
None,
)
.unwrap();
assert!(Path::new(&dir).exists());
Expand Down