Skip to content

Commit b4e59f5

Browse files
authored
Merge pull request #62 from rockset/CloudEnvOptions
Make CloudEnvOptions a member variable of CloudEnv
2 parents b26a8a0 + 3485183 commit b4e59f5

File tree

7 files changed

+29
-48
lines changed

7 files changed

+29
-48
lines changed

cloud/aws/aws_env.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,9 @@ Aws::S3::Model::HeadObjectOutcome AwsS3ClientWrapper::HeadObject(
261261
AwsEnv::AwsEnv(Env* underlying_env,
262262
const CloudEnvOptions& _cloud_env_options,
263263
const std::shared_ptr<Logger> & info_log)
264-
: CloudEnvImpl(_cloud_env_options.cloud_type, _cloud_env_options.log_type,
264+
: CloudEnvImpl(_cloud_env_options,
265265
underlying_env),
266266
info_log_(info_log),
267-
cloud_env_options(_cloud_env_options),
268267
running_(true),
269268
has_src_bucket_(false),
270269
has_dest_bucket_(false),

cloud/aws/aws_env.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -241,24 +241,8 @@ class AwsEnv : public CloudEnvImpl {
241241

242242
bool IsRunning() const { return running_; }
243243

244-
const std::string& GetSrcBucketName() const override {
245-
return cloud_env_options.src_bucket.GetBucketName();
246-
}
247-
const std::string& GetSrcObjectPath() const override {
248-
return cloud_env_options.src_bucket.GetObjectPath();
249-
}
250244

251-
const std::string& GetDestBucketName() const override {
252-
return cloud_env_options.dest_bucket.GetBucketName();
253-
}
254-
const std::string& GetDestObjectPath() const override {
255-
return cloud_env_options.dest_bucket.GetObjectPath();
256-
}
257245

258-
const CloudEnvOptions& GetCloudEnvOptions() override {
259-
return cloud_env_options;
260-
}
261-
262246
std::string GetWALCacheDir();
263247

264248
std::shared_ptr<Logger> info_log_; // informational messages
@@ -269,9 +253,6 @@ class AwsEnv : public CloudEnvImpl {
269253
// AWS's utility to help out with uploading and downloading S3 file
270254
std::shared_ptr<Aws::Transfer::TransferManager> awsTransferManager_;
271255

272-
// Configurations for this cloud environent
273-
CloudEnvOptions cloud_env_options;
274-
275256
//
276257
// Get credentials for running unit tests
277258
//

cloud/aws/aws_s3.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ Status S3WritableFile::Close() {
302302
}
303303

304304
// delete local file
305-
if (!env_->cloud_env_options.keep_local_sst_files) {
305+
if (!env_->GetCloudEnvOptions().keep_local_sst_files) {
306306
status_ = env_->GetPosixEnv()->DeleteFile(fname_);
307307
if (!status_.ok()) {
308308
Log(InfoLogLevel::ERROR_LEVEL, env_->info_log_,

cloud/cloud_env.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ CloudEnv::~CloudEnv() {}
8888

8989
CloudEnvWrapper::~CloudEnvWrapper() {}
9090

91-
CloudEnvImpl::CloudEnvImpl(
92-
CloudType cloud_type, LogType log_type, Env* base_env)
93-
: cloud_type_(cloud_type), log_type_(log_type),
91+
CloudEnvImpl::CloudEnvImpl(const CloudEnvOptions& opts, Env* base_env)
92+
: CloudEnv(opts),
9493
base_env_(base_env), purger_is_running_(true) {}
9594

9695
CloudEnvImpl::~CloudEnvImpl() { StopPurger(); }
@@ -242,7 +241,7 @@ Status CloudEnv::NewAwsEnv(Env* base_env,
242241
// If the src bucket is not specified, then this is a pass-through cloud env.
243242
if (! options.dest_bucket.IsValid() &&
244243
! options.src_bucket.IsValid()) {
245-
*cenv = new CloudEnvWrapper(base_env);
244+
*cenv = new CloudEnvWrapper(options, base_env);
246245
return Status::OK();
247246
}
248247

cloud/cloud_env_impl.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ class CloudEnvImpl : public CloudEnv {
2020

2121
public:
2222
// Constructor
23-
CloudEnvImpl(CloudType cloud_type, LogType log_type, Env* base_env);
23+
CloudEnvImpl(const CloudEnvOptions & options, Env* base_env);
2424

2525
virtual ~CloudEnvImpl();
2626

27-
const CloudType& GetCloudType() const { return cloud_type_; }
28-
const LogType& GetLogType() const { return log_type_; }
27+
const CloudType& GetCloudType() const { return cloud_env_options.cloud_type; }
2928

3029
// Returns the underlying env
3130
Env* GetBaseEnv() override { return base_env_; }
@@ -98,11 +97,6 @@ class CloudEnvImpl : public CloudEnv {
9897
}
9998

10099
protected:
101-
// The type of cloud service e.g. AWS, Azure, Google, etc.
102-
const CloudType cloud_type_;
103-
104-
// The type of cloud service used for WAL e.g. Kinesis, Kafka, etc.
105-
const LogType log_type_;
106100

107101
// The dbid of the source database that is cloned
108102
std::string src_dbid_;

cloud/cloud_env_wrapper.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ namespace rocksdb {
1919
class CloudEnvWrapper : public CloudEnvImpl {
2020
public:
2121
// Initialize an EnvWrapper that delegates all calls to *t
22-
explicit CloudEnvWrapper(Env* t) : CloudEnvImpl(
23-
CloudType::kCloudNone, LogType::kLogNone, t) {
22+
explicit CloudEnvWrapper(const CloudEnvOptions& options, Env* t) : CloudEnvImpl(options, t) {
23+
cloud_env_options.log_type = LogType::kLogNone;
24+
cloud_env_options.cloud_type = CloudType::kCloudNone;
2425
notsup_ = Status::NotSupported();
2526
}
2627

@@ -54,11 +55,6 @@ class CloudEnvWrapper : public CloudEnvImpl {
5455
return notsup_;
5556
}
5657

57-
virtual const std::string& GetSrcBucketName() const override { return empty_; }
58-
virtual const std::string& GetSrcObjectPath() const override { return empty_; }
59-
virtual const std::string& GetDestBucketName() const override { return empty_; }
60-
virtual const std::string& GetDestObjectPath() const override { return empty_; }
61-
6258
// Ability to read a file directly from cloud storage
6359
virtual Status NewSequentialFileCloud(const std::string& fname,
6460
unique_ptr<SequentialFile>* result,
@@ -208,7 +204,6 @@ class CloudEnvWrapper : public CloudEnvImpl {
208204

209205
uint64_t GetThreadID() const override { return base_env_->GetThreadID(); }
210206

211-
const CloudEnvOptions& GetCloudEnvOptions() override { return options_; }
212207

213208
Status ListObjects(const std::string& bucket_name_prefix,
214209
const std::string& bucket_object_prefix,
@@ -251,7 +246,6 @@ class CloudEnvWrapper : public CloudEnvImpl {
251246
private:
252247
Status notsup_;
253248
std::string empty_;
254-
const CloudEnvOptions options_;
255249
};
256250

257251
#pragma GCC diagnostic pop

include/rocksdb/cloud/cloud_env_options.h

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ typedef std::map<std::string, std::string> DbidList;
247247
// The Cloud environment
248248
//
249249
class CloudEnv : public Env {
250+
protected:
251+
CloudEnvOptions cloud_env_options;
252+
CloudEnv(const CloudEnvOptions& options) : cloud_env_options(options) { }
250253
public:
251254
// Returns the underlying env
252255
virtual Env* GetBaseEnv() = 0;
@@ -277,17 +280,28 @@ class CloudEnv : public Env {
277280
// GetSrcObjectPath specifies the path inside that bucket
278281
// where data files reside. The specified bucket is used in
279282
// a readonly mode by the associated DBCloud instance.
280-
virtual const std::string& GetSrcBucketName() const = 0;
281-
virtual const std::string& GetSrcObjectPath() const = 0;
283+
const std::string& GetSrcBucketName() const {
284+
return cloud_env_options.src_bucket.GetBucketName();
285+
}
286+
const std::string& GetSrcObjectPath() const {
287+
return cloud_env_options.src_bucket.GetObjectPath();
288+
}
282289

283290
// The DestBucketName identifies the cloud storage bucket and
284291
// GetDestObjectPath specifies the path inside that bucket
285292
// where data files reside. The associated DBCloud instance
286293
// writes newly created files to this bucket.
287-
virtual const std::string& GetDestBucketName() const = 0;
288-
virtual const std::string& GetDestObjectPath() const = 0;
294+
const std::string& GetDestBucketName() const {
295+
return cloud_env_options.dest_bucket.GetBucketName();
296+
}
297+
const std::string& GetDestObjectPath() const {
298+
return cloud_env_options.dest_bucket.GetObjectPath();
299+
}
300+
289301
// returns the options used to create this env
290-
virtual const CloudEnvOptions& GetCloudEnvOptions() = 0;
302+
const CloudEnvOptions& GetCloudEnvOptions() const {
303+
return cloud_env_options;
304+
}
291305

292306
// returns all the objects that have the specified path prefix and
293307
// are stored in a cloud bucket

0 commit comments

Comments
 (0)