Skip to content

Commit

Permalink
Remove polling for blob/container propagation/deletion.
Browse files Browse the repository at this point in the history
  • Loading branch information
teo-tsirpanis committed Apr 4, 2023
1 parent c8397d2 commit aeb31e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 127 deletions.
91 changes: 6 additions & 85 deletions tiledb/sm/filesystem/azure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,46 +212,7 @@ Status Azure::create_container(const URI& uri) const {
"Create container failed on: " + uri.to_string() + error_message)));
}

return wait_for_container_to_propagate(container_name);
}

Status Azure::wait_for_container_to_propagate(
const std::string& container_name) const {
unsigned attempts = 0;
while (attempts++ < constants::azure_max_attempts) {
bool is_container;
RETURN_NOT_OK(this->is_container(container_name, &is_container));

if (is_container) {
return Status::Ok();
}

std::this_thread::sleep_for(
std::chrono::milliseconds(constants::azure_attempt_sleep_ms));
}

return LOG_STATUS(Status_AzureError(std::string(
"Timed out waiting on container to propogate: " + container_name)));
}

Status Azure::wait_for_container_to_be_deleted(
const std::string& container_name) const {
assert(client_);

unsigned attempts = 0;
while (attempts++ < constants::azure_max_attempts) {
bool is_container;
RETURN_NOT_OK(this->is_container(container_name, &is_container));
if (!is_container) {
return Status::Ok();
}

std::this_thread::sleep_for(
std::chrono::milliseconds(constants::azure_attempt_sleep_ms));
}

return LOG_STATUS(Status_AzureError(std::string(
"Timed out waiting on container to be deleted: " + container_name)));
return Status::Ok();
}

Status Azure::empty_container(const URI& container) const {
Expand Down Expand Up @@ -333,7 +294,7 @@ Status Azure::flush_blob(const URI& uri) {
"Flush blob failed on: " + uri.to_string() + "; " + e.Message));
}

return wait_for_blob_to_propagate(container_name, blob_path);
return Status::Ok();
}

void Azure::finish_block_list_upload(const URI& uri) {
Expand Down Expand Up @@ -383,7 +344,7 @@ Status Azure::flush_blob_direct(const URI& uri) {
write_cache_map_.erase(uri.to_string());
}

return wait_for_blob_to_propagate(container_name, blob_path);
return Status::Ok();
}

Status Azure::is_empty_container(const URI& uri, bool* is_empty) const {
Expand Down Expand Up @@ -628,47 +589,7 @@ Status Azure::copy_blob(const URI& old_uri, const URI& new_uri) {
"Copy blob failed on: " + old_uri.to_string() + "; " + e.Message));
}

return wait_for_blob_to_propagate(new_container_name, new_blob_path);
}

Status Azure::wait_for_blob_to_propagate(
const std::string& container_name, const std::string& blob_path) const {
assert(client_);

unsigned attempts = 0;
while (attempts++ < constants::azure_max_attempts) {
bool is_blob;
RETURN_NOT_OK(this->is_blob(container_name, blob_path, &is_blob));
if (is_blob) {
return Status::Ok();
}

std::this_thread::sleep_for(
std::chrono::milliseconds(constants::azure_attempt_sleep_ms));
}

return LOG_STATUS(Status_AzureError(
std::string("Timed out waiting on blob to propogate: " + blob_path)));
}

Status Azure::wait_for_blob_to_be_deleted(
const std::string& container_name, const std::string& blob_path) const {
assert(client_);

unsigned attempts = 0;
while (attempts++ < constants::azure_max_attempts) {
bool is_blob;
RETURN_NOT_OK(this->is_blob(container_name, blob_path, &is_blob));
if (!is_blob) {
return Status::Ok();
}

std::this_thread::sleep_for(
std::chrono::milliseconds(constants::azure_attempt_sleep_ms));
}

return LOG_STATUS(Status_AzureError(
std::string("Timed out waiting on blob to be deleted: " + blob_path)));
return Status::Ok();
}

Status Azure::move_dir(const URI& old_uri, const URI& new_uri) {
Expand Down Expand Up @@ -794,7 +715,7 @@ Status Azure::remove_container(const URI& uri) const {
"Remove container failed on: " + uri.to_string() + error_message)));
}

return wait_for_container_to_be_deleted(container_name);
return Status::Ok();
}

Status Azure::remove_blob(const URI& uri) const {
Expand All @@ -820,7 +741,7 @@ Status Azure::remove_blob(const URI& uri) const {
"Remove blob failed on: " + uri.to_string() + error_message)));
}

return wait_for_blob_to_be_deleted(container_name, blob_path);
return Status::Ok();
}

Status Azure::remove_dir(const URI& uri) const {
Expand Down
42 changes: 0 additions & 42 deletions tiledb/sm/filesystem/azure.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,48 +521,6 @@ class Azure {
*/
Status copy_blob(const URI& old_uri, const URI& new_uri);

/**
* Waits for a blob with `container_name` and `blob_path`
* to exist on Azure.
*
* @param container_name The blob's container name.
* @param blob_path The blob's path
* @return Status
*/
Status wait_for_blob_to_propagate(
const std::string& container_name, const std::string& blob_path) const;

/**
* Waits for a blob with `container_name` and `blob_path`
* to not exist on Azure.
*
* @param container_name The blob's container name.
* @param blob_path The blob's path
* @return Status
*/
Status wait_for_blob_to_be_deleted(
const std::string& container_name, const std::string& blob_path) const;

/**
* Waits for a container with `container_name`
* to exist on Azure.
*
* @param container_name The container's name.
* @return Status
*/
Status wait_for_container_to_propagate(
const std::string& container_name) const;

/**
* Waits for a container with `container_name`
* to not exist on Azure.
*
* @param container_name The container's name.
* @return Status
*/
Status wait_for_container_to_be_deleted(
const std::string& container_name) const;

/**
* Check if 'container_name' is a container on Azure.
*
Expand Down

0 comments on commit aeb31e0

Please sign in to comment.