src/api2/admin/datastore/backup.rs: improve debug logging
This commit is contained in:
parent
4ae6551c78
commit
39e60bd6fa
@ -303,22 +303,23 @@ fn dynamic_append (
|
||||
let digest_list = tools::required_array_param(¶m, "digest-list")?;
|
||||
let offset_list = tools::required_array_param(¶m, "offset-list")?;
|
||||
|
||||
println!("DIGEST LIST LEN {}", digest_list.len());
|
||||
|
||||
if offset_list.len() != digest_list.len() {
|
||||
bail!("offset list has wrong length ({} != {})", offset_list.len(), digest_list.len());
|
||||
}
|
||||
|
||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||
|
||||
env.debug(format!("dynamic_append {} chunks", digest_list.len()));
|
||||
|
||||
for (i, item) in digest_list.iter().enumerate() {
|
||||
let digest_str = item.as_str().unwrap();
|
||||
let digest = crate::tools::hex_to_digest(digest_str)?;
|
||||
let offset = offset_list[i].as_u64().unwrap();
|
||||
let size = env.lookup_chunk(&digest).ok_or_else(|| format_err!("no such chunk {}", digest_str))?;
|
||||
|
||||
env.dynamic_writer_append_chunk(wid, offset, size, &digest)?;
|
||||
|
||||
env.log(format!("sucessfully added chunk {} to dynamic index {}", digest_str, wid));
|
||||
env.debug(format!("sucessfully added chunk {} to dynamic index {} (offset {}, size {})", digest_str, wid, offset, size));
|
||||
}
|
||||
|
||||
Ok(Value::Null)
|
||||
@ -355,23 +356,23 @@ fn fixed_append (
|
||||
let digest_list = tools::required_array_param(¶m, "digest-list")?;
|
||||
let offset_list = tools::required_array_param(¶m, "offset-list")?;
|
||||
|
||||
println!("DIGEST LIST LEN {}", digest_list.len());
|
||||
|
||||
if offset_list.len() != digest_list.len() {
|
||||
bail!("offset list has wrong length ({} != {})", offset_list.len(), digest_list.len());
|
||||
}
|
||||
|
||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||
|
||||
env.debug(format!("fixed_append {} chunks", digest_list.len()));
|
||||
|
||||
for (i, item) in digest_list.iter().enumerate() {
|
||||
let digest_str = item.as_str().unwrap();
|
||||
let digest = crate::tools::hex_to_digest(digest_str)?;
|
||||
let offset = offset_list[i].as_u64().unwrap();
|
||||
let size = env.lookup_chunk(&digest).ok_or_else(|| format_err!("no such chunk {}", digest_str))?;
|
||||
println!("DEBUG {} {}", offset, size);
|
||||
|
||||
env.fixed_writer_append_chunk(wid, offset, size, &digest)?;
|
||||
|
||||
env.log(format!("sucessfully added chunk {} to fixed index {}", digest_str, wid));
|
||||
env.debug(format!("sucessfully added chunk {} to fixed index {} (offset {}, size {})", digest_str, wid, offset, size));
|
||||
}
|
||||
|
||||
Ok(Value::Null)
|
||||
@ -485,8 +486,6 @@ fn dynamic_chunk_index(
|
||||
|
||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||
|
||||
println!("TEST CHUNK DOWNLOAD");
|
||||
|
||||
let mut archive_name = tools::required_string_param(¶m, "archive-name")?.to_owned();
|
||||
|
||||
if !archive_name.ends_with(".pxar") {
|
||||
@ -517,6 +516,8 @@ fn dynamic_chunk_index(
|
||||
}
|
||||
};
|
||||
|
||||
env.log(format!("download last backup index for archive '{}'", archive_name));
|
||||
|
||||
let count = index.index_count();
|
||||
for pos in 0..count {
|
||||
let (start, end, digest) = index.chunk_info(pos)?;
|
||||
@ -588,6 +589,8 @@ fn fixed_chunk_index(
|
||||
}
|
||||
};
|
||||
|
||||
env.log(format!("download last backup index for archive '{}'", archive_name));
|
||||
|
||||
let count = index.index_count();
|
||||
for pos in 0..count {
|
||||
let digest = index.index_digest(pos).unwrap();
|
||||
|
@ -45,7 +45,7 @@ impl BackupService {
|
||||
Err(err) => return Box::new(future::err(http_err!(BAD_REQUEST, err.to_string()))),
|
||||
};
|
||||
|
||||
self.debug(format!("REQUEST: {} {}", method, path));
|
||||
self.debug(format!("{} {}", method, path));
|
||||
|
||||
let mut uri_param = HashMap::new();
|
||||
|
||||
|
@ -75,8 +75,6 @@ fn upload_chunk(
|
||||
|
||||
let size = tools::required_integer_param(¶m, "size")? as u32;
|
||||
|
||||
println!("upload_chunk: {} bytes", size);
|
||||
|
||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||
|
||||
let upload = UploadChunk::new(req_body, env.datastore.clone(), size);
|
||||
@ -85,10 +83,12 @@ fn upload_chunk(
|
||||
.then(move |result| {
|
||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||
|
||||
let result = result.and_then(|(digest, size)| {
|
||||
env.register_chunk(digest, size)?;
|
||||
Ok(json!(tools::digest_to_hex(&digest)))
|
||||
});
|
||||
let result = result.and_then(|(digest, size)| {
|
||||
env.register_chunk(digest, size)?;
|
||||
let digest_str = tools::digest_to_hex(&digest);
|
||||
env.debug(format!("upload_chunk done: {} bytes, {}", size, digest_str));
|
||||
Ok(json!(digest_str))
|
||||
});
|
||||
|
||||
Ok(env.format_response(result))
|
||||
});
|
||||
|
@ -445,7 +445,7 @@ fn create_backup(
|
||||
println!("Client name: {}", tools::nodename());
|
||||
println!("Start Time: {}", backup_time.to_rfc3339());
|
||||
|
||||
let client = client.start_backup(repo.store(), "host", &backup_id).wait()?;
|
||||
let client = client.start_backup(repo.store(), "host", &backup_id, verbose).wait()?;
|
||||
|
||||
for (filename, target) in upload_list {
|
||||
println!("Upload '{}' to '{:?}' as {}", filename, repo, target);
|
||||
|
@ -12,7 +12,7 @@ fn upload_speed() -> Result<usize, Error> {
|
||||
|
||||
let client = HttpClient::new(host, username)?;
|
||||
|
||||
let client = client.start_backup(datastore, "host", "speedtest").wait()?;
|
||||
let client = client.start_backup(datastore, "host", "speedtest", false).wait()?;
|
||||
|
||||
println!("start upload speed test");
|
||||
let res = client.upload_speedtest().wait()?;
|
||||
|
@ -255,10 +255,11 @@ impl HttpClient {
|
||||
datastore: &str,
|
||||
backup_type: &str,
|
||||
backup_id: &str,
|
||||
debug: bool,
|
||||
) -> impl Future<Item=BackupClient, Error=Error> {
|
||||
|
||||
let path = format!("/api2/json/admin/datastore/{}/backup", datastore);
|
||||
let param = json!({"backup-type": backup_type, "backup-id": backup_id});
|
||||
let param = json!({"backup-type": backup_type, "backup-id": backup_id, "debug": debug});
|
||||
let mut req = Self::request_builder(&self.server, "GET", &path, Some(param)).unwrap();
|
||||
|
||||
let login = self.auth.listen();
|
||||
|
Loading…
Reference in New Issue
Block a user