Skip to content

Commit

Permalink
Merge pull request facebook#3 from pikiwidb/feature/user_define_uploa…
Browse files Browse the repository at this point in the history
…d_function

add parameter to specify user defined cloudmanifest upload function
  • Loading branch information
baixin01 authored Mar 25, 2024
2 parents 422341f + 2983f21 commit 5f152f0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cloud/cloud_file_system_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,18 @@ IOStatus CloudFileSystemImpl::UploadCloudManifest(
if (!cloud_fs_options.is_master) {
return IOStatus::OK();
}

if (cloud_fs_options.upload_meta_func) {
bool success = cloud_fs_options.upload_meta_func(MakeCloudManifestFile(local_dbname, cookie),
GetDestBucketName(), MakeCloudManifestFile(GetDestObjectPath(), cookie));
if (!success) {
Log(InfoLogLevel::WARN_LEVEL, info_log_,
"[%s] UploadCloudManifest, user-defined upload failed", Name());
return IOStatus::IOError("user defined upload failed");
}
return IOStatus::OK();
}

// upload the cloud manifest file corresponds to cookie (i.e.,
// CLOUDMANIFEST-cookie)
auto st = GetStorageProvider()->PutCloudObject(
Expand Down
6 changes: 6 additions & 0 deletions include/rocksdb/cloud/cloud_file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ class CloudFileSystemOptions {
// if rocksdb works in master process
bool is_master;

// user defined meta upload function
// used to garantee only one server to update remote meta
std::function<bool(const std::string& local_path,
const std::string& bucket_name,
const std::string& object_path)> upload_meta_func;

// Experimental option!
// This option only affects how resync_on_open works. If resync_on_open is true,
// and resync_manifest_on_open is true, besides fetching CLOUDMANFIEST from s3,
Expand Down

0 comments on commit 5f152f0

Please sign in to comment.