Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 tier profile [DOn't Merge] #3242

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr<
response->SetClientErrorMessage(ss.str());
AWS_LOGSTREAM_ERROR(CURL_HTTP_CLIENT_TAG, ss.str());
}
std::cout<<"curl transmission time="<<(DateTime::Now() - startTransmissionTime).count()<<std::endl;
request->AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::RequestLatency), (DateTime::Now() - startTransmissionTime).count());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2580,4 +2580,63 @@ namespace
AWS_EXPECT_SUCCESS(headOutcome);
EXPECT_EQ(headOutcome.GetResult().GetContentEncoding(), "gzip");
}


void DownloadFile(const Aws::String& bucket_name, const Aws::String& object_key, const Aws::String& destination_file)
{
auto Limiter = Aws::MakeShared<Aws::Utils::RateLimits::DefaultRateLimiter<>>(ALLOCATION_TAG, 50000000);

ClientConfiguration config;
config.region = Aws::Region::US_WEST_2;
config.scheme = Scheme::HTTPS;
config.connectTimeoutMs = 30000;
config.requestTimeoutMs = 30000;
config.readRateLimiter = Limiter;
config.writeRateLimiter = Limiter;
config.executor = Aws::MakeShared<Aws::Utils::Threading::PooledThreadExecutor>(ALLOCATION_TAG, 4);
config.enableHttpClientTrace = true;

Aws::S3::S3Client s3_client(config);


// Open the destination file for writing
std::ofstream output_file(destination_file.c_str(), std::ios::binary);

if (!output_file) {
std::cerr << "Failed to open destination file." << std::endl;
return;
}

// Create a GetObjectRequest with the byte range
Aws::S3::Model::GetObjectRequest get_object_request;
get_object_request.SetBucket(bucket_name);
get_object_request.SetKey(object_key);
auto start = std::chrono::high_resolution_clock::now();
auto get_object_outcome = s3_client.GetObject(get_object_request);
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);

if (get_object_outcome.IsSuccess()) {
// Write the part to the destination file
auto& retrieved_file = get_object_outcome.GetResultWithOwnership().GetBody();
std::ofstream output_file(destination_file, std::ios::binary);
output_file << retrieved_file.rdbuf(); // Write the stream content to the file
std::cout << "File downloaded to " << destination_file << std::endl;

} else {
std::cerr << "Failed to download file: " << get_object_outcome.GetError().GetMessage() << std::endl;
}

std::cout<<"took "<<duration.count()<<" microseconds"<<std::endl;
}
TEST_F(BucketAndObjectOperationTest, MeasureTier)
{
for(int i = 0; i < 20; i++)
{
DownloadFile("cpp-sdk-bucket-intelligent-tier", "sample_test_file.txt", "sample_test_file_intelligent.txt");

DownloadFile("cpp-sdk-bucket-standard-tier", "sample_test_file.txt", "sample_test_file_standard.txt");
}

}
}
Loading