Skip to content

Commit a7a441a

Browse files
authored
Merge pull request #86 from edouarda/master
Win32 fixes + US-EAST-1 fix
2 parents f518e3d + 4ee5673 commit a7a441a

File tree

5 files changed

+43
-9
lines changed

5 files changed

+43
-9
lines changed

cloud/aws/aws_env.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
//
33
#include "cloud/aws/aws_env.h"
44

5-
#include <unistd.h>
6-
75
#include <chrono>
86
#include <cinttypes>
97
#include <fstream>
@@ -15,7 +13,7 @@
1513
#include "cloud/cloud_scheduler.h"
1614
#include "cloud/cloud_storage_provider_impl.h"
1715
#include "cloud/filename.h"
18-
#include "port/port_posix.h"
16+
#include "port/port.h"
1917
#include "rocksdb/cloud/cloud_log_controller.h"
2018
#include "rocksdb/cloud/cloud_storage_provider.h"
2119
#include "rocksdb/env.h"
@@ -120,8 +118,8 @@ Status AwsCloudAccessCredentials::GetCredentialsProvider(
120118
AwsAccessType aws_type = GetAccessType();
121119
Status status = CheckCredentials(aws_type);
122120
if (status.ok()) {
123-
switch (aws_type) {
124121
#ifdef USE_AWS
122+
switch (aws_type) {
125123
case AwsAccessType::kSimple: {
126124
const char* access_key =
127125
(access_key_id.empty() ? getenv("AWS_ACCESS_KEY_ID")
@@ -155,11 +153,13 @@ Status AwsCloudAccessCredentials::GetCredentialsProvider(
155153
// Use AWS SDK's default credential chain
156154
result->reset();
157155
break;
158-
#endif
159156
default:
160157
status = Status::NotSupported("AWS credentials type not supported");
161158
break; // not supported
162159
}
160+
#else
161+
status = Status::NotSupported("AWS credentials type not supported");
162+
#endif
163163
}
164164
return status;
165165
}

cloud/aws/aws_env.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#ifdef USE_AWS
1616

17+
#include <string.h>
18+
1719
#include <chrono>
1820
#include <list>
1921
#include <unordered_map>

cloud/aws/aws_s3.cc

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@
4444
#include "cloud/aws/aws_file.h"
4545
#include "cloud/cloud_storage_provider_impl.h"
4646
#include "cloud/filename.h"
47-
#include "port/port_posix.h"
47+
#include "port/port.h"
4848
#include "rocksdb/cloud/cloud_env_options.h"
4949
#include "rocksdb/cloud/cloud_storage_provider.h"
5050
#include "rocksdb/options.h"
5151
#include "util/stderr_logger.h"
5252
#include "util/string_util.h"
5353

54+
#ifdef _WIN32_WINNT
55+
#undef GetMessage
56+
#endif
57+
5458
namespace ROCKSDB_NAMESPACE {
5559
#ifdef USE_AWS
5660
class CloudRequestCallbackGuard {
@@ -477,8 +481,20 @@ Status S3StorageProvider::CreateBucket(const std::string& bucket) {
477481
Aws::S3::Model::BucketLocationConstraint bucket_location = Aws::S3::Model::
478482
BucketLocationConstraintMapper::GetBucketLocationConstraintForName(
479483
ToAwsString(env_->GetCloudEnvOptions().dest_bucket.GetRegion()));
480-
if (bucket_location != Aws::S3::Model::BucketLocationConstraint::NOT_SET) {
481-
// only set the location constraint if it's not not set
484+
//
485+
// If you create a bucket in US-EAST-1, no location constraint should be
486+
// specified
487+
//
488+
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html
489+
//
490+
// By default, the bucket is created in the US East (N. Virginia) Region.
491+
// You can optionally specify a Region in the request body. You might choose
492+
// a Region to optimize latency, minimize costs, or address regulatory
493+
// requirements.
494+
//
495+
if ((bucket_location != Aws::S3::Model::BucketLocationConstraint::NOT_SET) &&
496+
(bucket_location !=
497+
Aws::S3::Model::BucketLocationConstraint::us_east_1)) {
482498
conf.SetLocationConstraint(bucket_location);
483499
}
484500

cloud/cloud_env.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// Copyright (c) 2017 Rockset.
22
#ifndef ROCKSDB_LITE
33

4+
#ifndef _WIN32_WINNT
45
#include <unistd.h>
6+
#else
7+
#include <windows.h>
8+
#endif
59

610
#include "cloud/aws/aws_env.h"
711
#include "cloud/cloud_env_impl.h"
@@ -66,7 +70,19 @@ void BucketOptions::TEST_Initialize(const std::string& bucket,
6670
if (!CloudEnvOptions::GetNameFromEnvironment("ROCKSDB_CLOUD_TEST_BUCKET_NAME",
6771
"ROCKSDB_CLOUD_BUCKET_NAME",
6872
&bucket_)) {
73+
#ifdef _WIN32_WINNT
74+
char user_name[257]; // UNLEN + 1
75+
DWORD dwsize = sizeof(user_name);
76+
if (!::GetUserName(user_name, &dwsize)) {
77+
bucket_ = bucket_ + "unknown";
78+
} else {
79+
bucket_ =
80+
bucket_ +
81+
std::string(user_name, static_cast<std::string::size_type>(dwsize));
82+
}
83+
#else
6984
bucket_ = bucket + std::to_string(geteuid());
85+
#endif
7086
}
7187
if (CloudEnvOptions::GetNameFromEnvironment(
7288
"ROCKSDB_CLOUD_TEST_BUCKET_PREFIX", "ROCKSDB_CLOUD_BUCKET_PREFIX",

include/rocksdb/cloud/cloud_env_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class CloudEnvOptions {
313313
bool _skip_dbid_verification = false,
314314
bool _use_aws_transfer_manager = false,
315315
int _number_objects_listed_in_one_iteration = 5000,
316-
bool _constant_sst_file_size_in_sst_file_manager = -1,
316+
int _constant_sst_file_size_in_sst_file_manager = -1,
317317
bool _skip_cloud_files_in_getchildren = false)
318318
: cloud_type(_cloud_type),
319319
log_type(_log_type),

0 commit comments

Comments
 (0)