Skip to content

Commit

Permalink
codemod --extensions rs get_snapshot_tar_path get_snapshot_archive_path
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Jan 23, 2020
1 parent ce23160 commit b045f9a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 15 deletions.
3 changes: 2 additions & 1 deletion core/src/snapshot_packager_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ mod tests {
}

// Create a packageable snapshot
let output_tar_path = snapshot_utils::get_snapshot_tar_path(&snapshot_package_output_path);
let output_tar_path =
snapshot_utils::get_snapshot_archive_path(&snapshot_package_output_path);
let snapshot_package = SnapshotPackage::new(
5,
vec![],
Expand Down
6 changes: 4 additions & 2 deletions core/tests/bank_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ mod tests {
.as_ref()
.unwrap()
.snapshot_path,
snapshot_utils::get_snapshot_tar_path(snapshot_package_output_path),
snapshot_utils::get_snapshot_archive_path(snapshot_package_output_path),
)
.unwrap();

Expand Down Expand Up @@ -135,7 +135,9 @@ mod tests {
slot_snapshot_paths
.last()
.expect("no snapshots found in path"),
snapshot_utils::get_snapshot_tar_path(&snapshot_config.snapshot_package_output_path),
snapshot_utils::get_snapshot_archive_path(
&snapshot_config.snapshot_package_output_path,
),
&snapshot_config.snapshot_path,
&last_bank.src.roots(),
)
Expand Down
2 changes: 1 addition & 1 deletion ledger/src/bank_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl BankForks {
root,
&root_bank.src.roots(),
snapshot_package_sender.as_ref().unwrap(),
snapshot_utils::get_snapshot_tar_path(&config.snapshot_package_output_path),
snapshot_utils::get_snapshot_archive_path(&config.snapshot_package_output_path),
);
if r.is_err() {
warn!("Error generating snapshot for bank: {}, err: {:?}", root, r);
Expand Down
5 changes: 3 additions & 2 deletions ledger/src/bank_forks_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ pub fn load(
fs::create_dir_all(&snapshot_config.snapshot_path)
.expect("Couldn't create snapshot directory");

let tar =
snapshot_utils::get_snapshot_tar_path(&snapshot_config.snapshot_package_output_path);
let tar = snapshot_utils::get_snapshot_archive_path(
&snapshot_config.snapshot_package_output_path,
);
if tar.exists() {
info!("Loading snapshot package: {:?}", tar);
// Fail hard here if snapshot fails to load, don't silently continue
Expand Down
2 changes: 1 addition & 1 deletion ledger/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ pub fn bank_from_archive<P: AsRef<Path>>(
Ok(bank)
}

pub fn get_snapshot_tar_path<P: AsRef<Path>>(snapshot_output_dir: P) -> PathBuf {
pub fn get_snapshot_archive_path<P: AsRef<Path>>(snapshot_output_dir: P) -> PathBuf {
snapshot_output_dir.as_ref().join("snapshot.tar.bz2")
}

Expand Down
16 changes: 9 additions & 7 deletions local-cluster/tests/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,13 @@ fn test_snapshot_restart_tower() {
.as_ref()
.unwrap()
.snapshot_package_output_path;
let tar = snapshot_utils::get_snapshot_tar_path(&snapshot_package_output_path);
let tar = snapshot_utils::get_snapshot_archive_path(&snapshot_package_output_path);
wait_for_next_snapshot(&cluster, &tar);

// Copy tar to validator's snapshot output directory
let validator_tar_path =
snapshot_utils::get_snapshot_tar_path(&validator_snapshot_test_config.snapshot_output_path);
let validator_tar_path = snapshot_utils::get_snapshot_archive_path(
&validator_snapshot_test_config.snapshot_output_path,
);
fs::hard_link(tar, &validator_tar_path).unwrap();

// Restart validator from snapshot, the validator's tower state in this snapshot
Expand Down Expand Up @@ -702,7 +703,7 @@ fn test_snapshots_blockstore_floor() {

trace!("Waiting for snapshot tar to be generated with slot",);

let tar = snapshot_utils::get_snapshot_tar_path(&snapshot_package_output_path);
let tar = snapshot_utils::get_snapshot_archive_path(&snapshot_package_output_path);
loop {
if tar.exists() {
trace!("snapshot tar exists");
Expand All @@ -712,8 +713,9 @@ fn test_snapshots_blockstore_floor() {
}

// Copy tar to validator's snapshot output directory
let validator_tar_path =
snapshot_utils::get_snapshot_tar_path(&validator_snapshot_test_config.snapshot_output_path);
let validator_tar_path = snapshot_utils::get_snapshot_archive_path(
&validator_snapshot_test_config.snapshot_output_path,
);
fs::hard_link(tar, &validator_tar_path).unwrap();
let slot_floor = snapshot_utils::bank_slot_from_archive(&validator_tar_path).unwrap();

Expand Down Expand Up @@ -803,7 +805,7 @@ fn test_snapshots_restart_validity() {

expected_balances.extend(new_balances);

let tar = snapshot_utils::get_snapshot_tar_path(&snapshot_package_output_path);
let tar = snapshot_utils::get_snapshot_archive_path(&snapshot_package_output_path);
wait_for_next_snapshot(&cluster, &tar);

// Create new account paths since validator exit is not guaranteed to cleanup RPC threads,
Expand Down
3 changes: 2 additions & 1 deletion validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ fn download_ledger(
download_tar_bz2(rpc_addr, "genesis.tar.bz2", ledger_path, false)?;

if !no_snapshot_fetch {
let snapshot_package = solana_ledger::snapshot_utils::get_snapshot_tar_path(ledger_path);
let snapshot_package =
solana_ledger::snapshot_utils::get_snapshot_archive_path(ledger_path);
if snapshot_package.exists() {
fs::remove_file(&snapshot_package)
.map_err(|err| format!("error removing {:?}: {}", snapshot_package, err))?;
Expand Down

0 comments on commit b045f9a

Please sign in to comment.