11// Copyright (c) 2016-present, Rockset, Inc. All rights reserved.
22//
33#pragma once
4- #include " rocksdb/cache.h"
5- #include " rocksdb/configurable.h"
6- #include " rocksdb/file_system.h"
7- #include " rocksdb/io_status.h"
8- #include " rocksdb/status.h"
94#include < chrono>
105#include < functional>
116#include < memory>
127#include < optional>
138#include < string>
149#include < unordered_map>
1510
11+ #include " rocksdb/cache.h"
12+ #include " rocksdb/configurable.h"
13+ #include " rocksdb/file_system.h"
14+ #include " rocksdb/io_status.h"
15+ #include " rocksdb/status.h"
16+
1617namespace Aws {
1718namespace Auth {
1819class AWSCredentialsProvider ;
@@ -90,10 +91,10 @@ class AwsCloudAccessCredentials {
9091 // functions to support AWS credentials
9192 //
9293 // Initialize AWS credentials using access_key_id and secret_key
93- void InitializeSimple (std::string const & aws_access_key_id,
94- std::string const & aws_secret_key);
94+ void InitializeSimple (const std::string& aws_access_key_id,
95+ const std::string& aws_secret_key);
9596 // Initialize AWS credentials using a config file
96- void InitializeConfig (std::string const & aws_config_file);
97+ void InitializeConfig (const std::string& aws_config_file);
9798
9899 // test if valid AWS credentials are present
99100 Status HasValid () const ;
@@ -104,7 +105,7 @@ class AwsCloudAccessCredentials {
104105
105106 private:
106107 AwsAccessType GetAccessType () const ;
107- Status CheckCredentials (AwsAccessType const & aws_type) const ;
108+ Status CheckCredentials (const AwsAccessType & aws_type) const ;
108109
109110 public:
110111 std::string access_key_id;
@@ -117,13 +118,13 @@ class AwsCloudAccessCredentials {
117118};
118119
119120using S3ClientFactory = std::function<std::shared_ptr<Aws::S3::S3Client>(
120- std::shared_ptr<Aws::Auth::AWSCredentialsProvider> const &,
121- Aws::Client::ClientConfiguration const &)>;
121+ const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>&,
122+ const Aws::Client::ClientConfiguration&)>;
122123
123124#ifdef USE_GCP
124125using GCSClientFactory =
125126 std::function<std::shared_ptr<google::cloud::storage::Client>(
126- google::cloud::Options const &)>;
127+ const google::cloud::Options&)>;
127128#endif
128129
129130// Defines parameters required to connect to Kafka
@@ -169,26 +170,21 @@ class BucketOptions {
169170 void SetBucketPrefix (std::string prefix);
170171 const std::string& GetBucketPrefix () const { return prefix_; }
171172 const std::string& GetBucketName (bool full = true ) const {
172- =======
173- void SetBucketName (std::string const & bucket, std::string const & prefix = " " );
174- std::string const & GetBucketPrefix () const { return prefix_; }
175- std::string const & GetBucketName (bool full = true ) const {
176- >>>>>>> c266119fc (Google cloud storage support)
177173 if (full) {
178174 return name_;
179175 } else {
180176 return bucket_;
181177 }
182178 }
183- std::string const & GetObjectPath () const { return object_; }
184- void SetObjectPath (std::string const & object) { object_ = object; }
185- std::string const & GetRegion () const { return region_; }
186- void SetRegion (std::string const & region) { region_ = region; }
179+ const std::string& GetObjectPath () const { return object_; }
180+ void SetObjectPath (const std::string& object) { object_ = object; }
181+ const std::string& GetRegion () const { return region_; }
182+ void SetRegion (const std::string& region) { region_ = region; }
187183
188184 // Initializes the bucket properties for test purposes
189- void TEST_Initialize (std::string const & name_prefix,
190- std::string const & object_path,
191- std::string const & region = " " );
185+ void TEST_Initialize (const std::string& name_prefix,
186+ const std::string& object_path,
187+ const std::string& region = " " );
192188 bool IsValid () const {
193189 if (object_.empty () || name_.empty ()) {
194190 return false ;
@@ -198,7 +194,7 @@ class BucketOptions {
198194 }
199195};
200196
201- inline bool operator ==(BucketOptions const & lhs, BucketOptions const & rhs) {
197+ inline bool operator ==(const BucketOptions & lhs, const BucketOptions & rhs) {
202198 if (lhs.IsValid () && rhs.IsValid ()) {
203199 return ((lhs.GetBucketName () == rhs.GetBucketName ()) &&
204200 (lhs.GetObjectPath () == rhs.GetObjectPath ()) &&
@@ -207,14 +203,14 @@ inline bool operator==(BucketOptions const& lhs, BucketOptions const& rhs) {
207203 return false ;
208204 }
209205}
210- inline bool operator !=(BucketOptions const & lhs, BucketOptions const & rhs) {
206+ inline bool operator !=(const BucketOptions & lhs, const BucketOptions & rhs) {
211207 return !(lhs == rhs);
212208}
213209
214210class AwsCloudOptions {
215211 public:
216212 static Status GetClientConfiguration (
217- CloudFileSystem* fs, std::string const & region,
213+ CloudFileSystem* fs, const std::string& region,
218214 Aws::Client::ClientConfiguration* config);
219215};
220216
@@ -225,7 +221,7 @@ class AwsCloudOptions {
225221class CloudFileSystemOptions {
226222 private:
227223 public:
228- static char const * kName () { return " CloudFileSystemOptions" ; }
224+ static const char * kName () { return " CloudFileSystemOptions" ; }
229225 BucketOptions src_bucket;
230226 BucketOptions dest_bucket;
231227 // Specify the type of cloud-service to use. Deprecated.
@@ -489,11 +485,11 @@ class CloudFileSystemOptions {
489485
490486 // Sets result based on the value of name or alt in the environment
491487 // Returns true if the name/alt exists in the environment, false otherwise
492- static bool GetNameFromEnvironment (char const * name, char const * alt,
488+ static bool GetNameFromEnvironment (const char * name, const char * alt,
493489 std::string* result);
494- void TEST_Initialize (std::string const & name_prefix,
495- std::string const & object_path,
496- std::string const & region = " " );
490+ void TEST_Initialize (const std::string& name_prefix,
491+ const std::string& object_path,
492+ const std::string& region = " " );
497493
498494 Status Configure (const ConfigOptions& config_options,
499495 const std::string& opts_str);
@@ -532,31 +528,31 @@ class CloudFileSystem : public FileSystem {
532528 virtual IOStatus PreloadCloudManifest (const std::string& local_dbname) = 0;
533529 // This method will migrate the database that is using pure RocksDB into
534530 // RocksDB-Cloud. Call this before opening the database with RocksDB-Cloud.
535- virtual IOStatus MigrateFromPureRocksDB (std::string const & local_dbname) = 0;
531+ virtual IOStatus MigrateFromPureRocksDB (const std::string& local_dbname) = 0;
536532
537533 // Reads a file from the cloud
538534 virtual IOStatus NewSequentialFileCloud (
539- std::string const & bucket_prefix, std::string const & fname,
540- FileOptions const & file_opts, std::unique_ptr<FSSequentialFile>* result,
535+ const std::string& bucket_prefix, const std::string& fname,
536+ const FileOptions & file_opts, std::unique_ptr<FSSequentialFile>* result,
541537 IODebugContext* dbg) = 0;
542538
543539 // Saves and retrieves the dbid->dirname mapping in cloud storage
544- virtual IOStatus SaveDbid (std::string const & bucket_name,
545- std::string const & dbid,
546- std::string const & dirname) = 0;
547- virtual IOStatus GetPathForDbid (std::string const & bucket_prefix,
548- std::string const & dbid,
540+ virtual IOStatus SaveDbid (const std::string& bucket_name,
541+ const std::string& dbid,
542+ const std::string& dirname) = 0;
543+ virtual IOStatus GetPathForDbid (const std::string& bucket_prefix,
544+ const std::string& dbid,
549545 std::string* dirname) = 0;
550- virtual IOStatus GetDbidList (std::string const & bucket_prefix,
546+ virtual IOStatus GetDbidList (const std::string& bucket_prefix,
551547 DbidList* dblist) = 0;
552- virtual IOStatus DeleteDbid (std::string const & bucket_prefix,
553- std::string const & dbid) = 0;
548+ virtual IOStatus DeleteDbid (const std::string& bucket_prefix,
549+ const std::string& dbid) = 0;
554550
555551 // Deletes file from a destination bucket.
556- virtual IOStatus DeleteCloudFileFromDest (std::string const & fname) = 0;
552+ virtual IOStatus DeleteCloudFileFromDest (const std::string& fname) = 0;
557553 // Copies a local file to a destination bucket.
558- virtual IOStatus CopyLocalFileToDest (std::string const & local_name,
559- std::string const & cloud_name) = 0;
554+ virtual IOStatus CopyLocalFileToDest (const std::string& local_name,
555+ const std::string& cloud_name) = 0;
560556
561557 // Returns CloudManifest file name for a given db.
562558 virtual std::string CloudManifestFile (const std::string& dbname) = 0;
@@ -584,14 +580,14 @@ class CloudFileSystem : public FileSystem {
584580 // For example, it will map 00010.sst to 00010.sst-[epoch] where [epoch] is
585581 // an epoch during which that file was created.
586582 // Files both in S3 and in the local directory have this [epoch] suffix.
587- virtual std::string RemapFilename (std::string const & logical_name) const = 0;
583+ virtual std::string RemapFilename (const std::string& logical_name) const = 0;
588584
589585 // Find the list of live files based on CloudManifest and Manifest in local db
590586 //
591587 // For the returned filepath in `live_sst_files` and `manifest_file`, we only
592588 // include the basename of the filepath but not the directory prefix to the
593589 // file
594- virtual IOStatus FindAllLiveFiles (std::string const & local_dbname,
590+ virtual IOStatus FindAllLiveFiles (const std::string& local_dbname,
595591 std::vector<std::string>* live_sst_files,
596592 std::string* manifest_file) = 0;
597593
@@ -610,7 +606,7 @@ class CloudFileSystem : public FileSystem {
610606 //
611607 // If delta has already been applied in cloud manifest, delta_applied would be
612608 // `false`
613- virtual IOStatus ApplyCloudManifestDelta (CloudManifestDelta const & delta,
609+ virtual IOStatus ApplyCloudManifestDelta (const CloudManifestDelta & delta,
614610 bool * delta_applied) = 0;
615611
616612 // This function does several things:
@@ -622,16 +618,17 @@ class CloudFileSystem : public FileSystem {
622618 //
623619 // Return InvalidArgument status if the delta has been applied in current
624620 // CloudManifest
625- virtual IOStatus RollNewCookie (std::string const & local_dbname,
626- std::string const & cookie,
627- CloudManifestDelta const & delta) const = 0;
621+ virtual IOStatus RollNewCookie (const std::string& local_dbname,
622+ const std::string& cookie,
623+ const CloudManifestDelta & delta) const = 0;
628624
629625 virtual IOStatus GetMaxFileNumberFromCurrentManifest (
630- std::string const & local_dbname, uint64_t * max_file_number) = 0;
626+ const std::string& local_dbname, uint64_t * max_file_number) = 0;
631627
632628 // Delete both local and cloud invisble files
633629 virtual IOStatus DeleteCloudInvisibleFiles (
634630 const std::vector<std::string>& active_cookies) = 0;
631+
635632 // Delete local invisible files. This could be helpful when there is one
636633 // single instance managing lifetime of files in cloud while the other
637634 // instances reference and download the files in cloud. The other instances
@@ -702,34 +699,34 @@ class CloudFileSystemEnv {
702699 // data from cloud storage.
703700 // If dest_bucket_name is empty, then the associated db does not write any
704701 // data to cloud storage.
705- static Status NewAwsFileSystem (std::shared_ptr<FileSystem> const & base_fs,
706- std::string const & src_bucket_name,
707- std::string const & src_object_prefix,
708- std::string const & src_bucket_region,
709- std::string const & dest_bucket_name,
710- std::string const & dest_object_prefix,
711- std::string const & dest_bucket_region,
712- CloudFileSystemOptions const & fs_options,
713- std::shared_ptr<Logger> const & logger,
702+ static Status NewAwsFileSystem (const std::shared_ptr<FileSystem>& base_fs,
703+ const std::string& src_bucket_name,
704+ const std::string& src_object_prefix,
705+ const std::string& src_bucket_region,
706+ const std::string& dest_bucket_name,
707+ const std::string& dest_object_prefix,
708+ const std::string& dest_bucket_region,
709+ const CloudFileSystemOptions & fs_options,
710+ const std::shared_ptr<Logger>& logger,
714711 CloudFileSystem** cfs);
715- static Status NewAwsFileSystem (std::shared_ptr<FileSystem> const & base_fs,
716- CloudFileSystemOptions const & fs_options,
717- std::shared_ptr<Logger> const & logger,
712+ static Status NewAwsFileSystem (const std::shared_ptr<FileSystem>& base_fs,
713+ const CloudFileSystemOptions & fs_options,
714+ const std::shared_ptr<Logger>& logger,
718715 CloudFileSystem** cfs);
719716
720- static Status NewGcpFileSystem (std::shared_ptr<FileSystem> const & base_fs,
721- std::string const & src_bucket_name,
722- std::string const & src_object_prefix,
723- std::string const & src_buck_region,
724- std::string const & dest_bucket_name,
725- std::string const & dest_bucket_prefix,
726- std::string const & dest_bucket_region,
727- CloudFileSystemOptions const & fs_options,
728- std::shared_ptr<Logger> const & logger,
717+ static Status NewGcpFileSystem (const std::shared_ptr<FileSystem>& base_fs,
718+ const std::string& src_bucket_name,
719+ const std::string& src_object_prefix,
720+ const std::string& src_buck_region,
721+ const std::string& dest_bucket_name,
722+ const std::string& dest_bucket_prefix,
723+ const std::string& dest_bucket_region,
724+ const CloudFileSystemOptions & fs_options,
725+ const std::shared_ptr<Logger>& logger,
729726 CloudFileSystem** cfs);
730- static Status NewGcpFileSystem (std::shared_ptr<FileSystem> const & base_fs,
731- CloudFileSystemOptions const & fs_options,
732- std::shared_ptr<Logger> const & logger,
727+ static Status NewGcpFileSystem (const std::shared_ptr<FileSystem>& base_fs,
728+ const CloudFileSystemOptions & fs_options,
729+ const std::shared_ptr<Logger>& logger,
733730 CloudFileSystem** cfs);
734731
735732 // Creates a new Env that delegates all thread/time related
0 commit comments