diff --git a/CMakeLists.txt b/CMakeLists.txt index e088e94fdc8f..1957d2766526 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1648,6 +1648,25 @@ if(WITH_EXAMPLES) add_subdirectory(examples) endif() +option(WITH_CLOUD_EXAMPLES "build with cloud examples" OFF) +if(WITH_CLOUD_EXAMPLES) + set(EXAMPLES + cloud/examples/clone_example.cc + cloud/examples/cloud_dump.cc + cloud/examples/cloud_durable_example.cc + ) + foreach(sourcefile ${EXAMPLES}) + message(${sourcefile}) + get_filename_component(exename ${sourcefile} NAME_WE) + add_executable(${exename}${ARTIFACT_SUFFIX} ${sourcefile}) + target_link_libraries(${exename}${ARTIFACT_SUFFIX} + PRIVATE + ${ROCKSDB_LIB} + ${THIRDPARTY_LIBS} + ) + endforeach() +endif() + option(WITH_BENCHMARK "build benchmark tests" OFF) if(WITH_BENCHMARK) add_subdirectory(${PROJECT_SOURCE_DIR}/microbench/) diff --git a/cloud/examples/clone_example.cc b/cloud/examples/clone_example.cc index b1c489219dbc..9eede402c95d 100644 --- a/cloud/examples/clone_example.cc +++ b/cloud/examples/clone_example.cc @@ -1,4 +1,6 @@ // Copyright (c) 2017-present, Rockset, Inc. All rights reserved. +#include + #include #include #include @@ -43,7 +45,7 @@ Status CloneDB(const std::string& clone_name, const std::string& src_bucket, // Create new AWS env CloudFileSystem* cfs; - Status st = CloudFileSystem::NewAwsFileSystem( + Status st = CloudFileSystemEnv::NewAwsFileSystem( FileSystem::Default(), src_bucket, src_object_path, kRegion, dest_bucket, dest_object_path, kRegion, cloud_fs_options, nullptr, &cfs); if (!st.ok()) { @@ -79,6 +81,8 @@ Status CloneDB(const std::string& clone_name, const std::string& src_bucket, } int main() { + Aws::InitAPI(Aws::SDKOptions()); + // cloud environment config options here CloudFileSystemOptions cloud_fs_options; @@ -108,7 +112,7 @@ int main() { // Create a new AWS cloud env Status CloudFileSystem* cfs; - Status s = CloudFileSystem::NewAwsFileSystem( + Status s = CloudFileSystemEnv::NewAwsFileSystem( FileSystem::Default(), kBucketSuffix, kDBPath, kRegion, kBucketSuffix, kDBPath, kRegion, cloud_fs_options, nullptr, &cfs); if (!s.ok()) { @@ -185,5 +189,6 @@ int main() { fprintf(stdout, "Successfully used db at %s and clone at %s in bucket %s.\n", kDBPath.c_str(), kClonePath.c_str(), bucketName.c_str()); + Aws::ShutdownAPI(Aws::SDKOptions()); return 0; } diff --git a/cloud/examples/cloud_dump.cc b/cloud/examples/cloud_dump.cc index 36f25c54acf4..67be65d59970 100644 --- a/cloud/examples/cloud_dump.cc +++ b/cloud/examples/cloud_dump.cc @@ -1,4 +1,6 @@ // Copyright (c) 2017-present, Rockset, Inc. All rights reserved. +#include + #include #include #include @@ -20,6 +22,8 @@ std::string kBucketSuffix = "cloud.durable.example."; std::string kRegion = "us-west-2"; int main() { + Aws::InitAPI(Aws::SDKOptions()); + // cloud environment config options here CloudFileSystemOptions cloud_fs_options; @@ -53,7 +57,7 @@ int main() { // Create a new AWS cloud env Status CloudFileSystem* cfs; - Status s = CloudFileSystem::NewAwsFileSystem( + Status s = CloudFileSystemEnv::NewAwsFileSystem( FileSystem::Default(), kBucketSuffix, kDBPath, kRegion, kBucketSuffix, kDBPath, kRegion, cloud_fs_options, nullptr, &cfs); if (!s.ok()) { @@ -102,5 +106,6 @@ int main() { fprintf(stdout, "Successfully read db at path %s in bucket %s.\n", kDBPath.c_str(), bucketName.c_str()); + Aws::ShutdownAPI(Aws::SDKOptions()); return 0; } diff --git a/cloud/examples/cloud_durable_example.cc b/cloud/examples/cloud_durable_example.cc index 642226305cef..e8f07204fd66 100644 --- a/cloud/examples/cloud_durable_example.cc +++ b/cloud/examples/cloud_durable_example.cc @@ -1,4 +1,6 @@ // Copyright (c) 2017-present, Rockset, Inc. All rights reserved. +#include + #include #include #include @@ -23,6 +25,8 @@ static const bool flushAtEnd = true; static const bool disableWAL = false; int main() { + Aws::InitAPI(Aws::SDKOptions()); + // cloud environment config options here CloudFileSystemOptions cloud_fs_options; @@ -56,7 +60,7 @@ int main() { // Create a new AWS cloud env Status CloudFileSystem* cfs; - Status s = CloudFileSystem::NewAwsFileSystem( + Status s = CloudFileSystemEnv::NewAwsFileSystem( FileSystem::Default(), kBucketSuffix, kDBPath, kRegion, kBucketSuffix, kDBPath, kRegion, cloud_fs_options, nullptr, &cfs); if (!s.ok()) { @@ -128,5 +132,6 @@ int main() { fprintf(stdout, "Successfully used db at path %s in bucket %s.\n", kDBPath.c_str(), bucketName.c_str()); + Aws::ShutdownAPI(Aws::SDKOptions()); return 0; }