@@ -135,8 +135,6 @@ static Aws::Client::ClientConfiguration& GetDefaultClientConfig() {
135
135
absl::MutexLock l (&cfg_lock);
136
136
137
137
if (!init) {
138
- const char * endpoint = getenv (" S3_ENDPOINT" );
139
- if (endpoint) cfg.endpointOverride = Aws::String (endpoint);
140
138
const char * region = getenv (" AWS_REGION" );
141
139
// TODO (yongtang): `S3_REGION` should be deprecated after 2.0.
142
140
if (!region) region = getenv (" S3_REGION" );
@@ -168,20 +166,6 @@ static Aws::Client::ClientConfiguration& GetDefaultClientConfig() {
168
166
cfg.region = profiles[" default" ].GetRegion ();
169
167
}
170
168
}
171
- const char * use_https = getenv (" S3_USE_HTTPS" );
172
- if (use_https) {
173
- if (use_https[0 ] == ' 0' )
174
- cfg.scheme = Aws::Http::Scheme::HTTP;
175
- else
176
- cfg.scheme = Aws::Http::Scheme::HTTPS;
177
- }
178
- const char * verify_ssl = getenv (" S3_VERIFY_SSL" );
179
- if (verify_ssl) {
180
- if (verify_ssl[0 ] == ' 0' )
181
- cfg.verifySSL = false ;
182
- else
183
- cfg.verifySSL = true ;
184
- }
185
169
// if these timeouts are low, you may see an error when
186
170
// uploading/downloading large files: Unable to connect to endpoint
187
171
int64_t timeout;
@@ -241,6 +225,13 @@ static void GetS3Client(tf_s3_filesystem::S3File* s3_file) {
241
225
tf_s3_filesystem::AWSLogSystem::ShutdownAWSLogging ();
242
226
}
243
227
});
228
+
229
+ int temp_value;
230
+ if (absl::SimpleAtoi (getenv (" S3_DISABLE_MULTI_PART_DOWNLOAD" ), &temp_value))
231
+ s3_file->use_multi_part_download = (temp_value != 1 );
232
+
233
+ const char * endpoint = getenv (" S3_ENDPOINT" );
234
+ if (endpoint) s3_file->s3_client ->OverrideEndpoint (endpoint);
244
235
}
245
236
}
246
237
@@ -263,15 +254,26 @@ static void GetTransferManager(
263
254
264
255
absl::MutexLock l (&s3_file->initialization_lock );
265
256
266
- if (s3_file->transfer_managers [direction].get () == nullptr ) {
257
+ if (s3_file->transfer_managers .count (direction) == 0 ) {
258
+ uint64_t temp_value;
259
+ if (direction == Aws::Transfer::TransferDirection::UPLOAD) {
260
+ if (!absl::SimpleAtoi (getenv (" S3_MULTI_PART_UPLOAD_CHUNK_SIZE" ),
261
+ &temp_value))
262
+ temp_value = kS3MultiPartUploadChunkSize ;
263
+ } else if (direction == Aws::Transfer::TransferDirection::DOWNLOAD) {
264
+ if (!absl::SimpleAtoi (getenv (" S3_MULTI_PART_DOWNLOAD_CHUNK_SIZE" ),
265
+ &temp_value))
266
+ temp_value = kS3MultiPartDownloadChunkSize ;
267
+ }
268
+ s3_file->multi_part_chunk_sizes .emplace (direction, temp_value);
269
+
267
270
Aws::Transfer::TransferManagerConfiguration config (s3_file->executor .get ());
268
271
config.s3Client = s3_file->s3_client ;
269
- config.bufferSize = s3_file-> multi_part_chunk_sizes [direction] ;
272
+ config.bufferSize = temp_value ;
270
273
// must be larger than pool size * multi part chunk size
271
- config.transferBufferMaxHeapSize =
272
- (kExecutorPoolSize + 1 ) * s3_file->multi_part_chunk_sizes [direction];
273
- s3_file->transfer_managers [direction] =
274
- Aws::Transfer::TransferManager::Create (config);
274
+ config.transferBufferMaxHeapSize = (kExecutorPoolSize + 1 ) * temp_value;
275
+ s3_file->transfer_managers .emplace (
276
+ direction, Aws::Transfer::TransferManager::Create (config));
275
277
}
276
278
}
277
279
@@ -529,24 +531,7 @@ S3File::S3File()
529
531
transfer_managers(),
530
532
multi_part_chunk_sizes(),
531
533
use_multi_part_download(false ), // TODO: change to true after fix
532
- initialization_lock() {
533
- uint64_t temp_value;
534
- multi_part_chunk_sizes[Aws::Transfer::TransferDirection::UPLOAD] =
535
- absl::SimpleAtoi (getenv (" S3_MULTI_PART_UPLOAD_CHUNK_SIZE" ), &temp_value)
536
- ? temp_value
537
- : kS3MultiPartUploadChunkSize ;
538
- multi_part_chunk_sizes[Aws::Transfer::TransferDirection::DOWNLOAD] =
539
- absl::SimpleAtoi (getenv (" S3_MULTI_PART_DOWNLOAD_CHUNK_SIZE" ), &temp_value)
540
- ? temp_value
541
- : kS3MultiPartDownloadChunkSize ;
542
- use_multi_part_download =
543
- absl::SimpleAtoi (getenv (" S3_DISABLE_MULTI_PART_DOWNLOAD" ), &temp_value)
544
- ? (temp_value != 1 )
545
- : use_multi_part_download;
546
- transfer_managers.emplace (Aws::Transfer::TransferDirection::UPLOAD, nullptr );
547
- transfer_managers.emplace (Aws::Transfer::TransferDirection::DOWNLOAD,
548
- nullptr );
549
- }
534
+ initialization_lock() {}
550
535
void Init (TF_Filesystem* filesystem, TF_Status* status) {
551
536
filesystem->plugin_filesystem = new S3File ();
552
537
TF_SetStatus (status, TF_OK, " " );
0 commit comments