|
20 | 20 | #include <aws/core/utils/logging/LogLevel.h> |
21 | 21 | #include <aws/core/utils/logging/LogSystemInterface.h> |
22 | 22 |
|
23 | | -#ifdef USE_AZURE |
24 | | -#include <azure/core/diagnostics/logger.hpp> |
25 | | -#endif |
26 | 23 | #include <memory> |
27 | 24 | #include <utility> |
28 | 25 |
|
29 | 26 | #include "common/config.h" |
30 | 27 | #include "common/logging.h" |
31 | 28 | #include "cpp/aws_logger.h" |
32 | 29 | #include "cpp/obj-client/auth/aws_credential_factory.h" |
| 30 | +#include "io/obj_storage/obj_client_ca.h" |
33 | 31 | #include "io/obj_storage/obj_storage_config.h" |
34 | | -#include "util/string_util.h" |
35 | 32 |
|
36 | 33 | namespace doris { |
37 | 34 |
|
38 | | -S3ClientFactory::S3ClientFactory() { |
| 35 | +AwsSdkManager::AwsSdkManager() { |
39 | 36 | _aws_options = Aws::SDKOptions {}; |
40 | 37 | auto logLevel = static_cast<Aws::Utils::Logging::LogLevel>(config::aws_log_level); |
41 | 38 | _aws_options.loggingOptions.logLevel = logLevel; |
42 | 39 | _aws_options.loggingOptions.logger_create_fn = [logLevel] { |
43 | 40 | return std::make_shared<DorisAWSLogger>(logLevel); |
44 | 41 | }; |
45 | 42 | Aws::InitAPI(_aws_options); |
46 | | - _get_ca_cert_file_path(); |
47 | | - |
48 | | -#ifdef USE_AZURE |
49 | | - auto azureLogLevel = |
50 | | - static_cast<Azure::Core::Diagnostics::Logger::Level>(config::azure_log_level); |
51 | | - Azure::Core::Diagnostics::Logger::SetLevel(azureLogLevel); |
52 | | - Azure::Core::Diagnostics::Logger::SetListener( |
53 | | - [&](Azure::Core::Diagnostics::Logger::Level level, const std::string& message) { |
54 | | - switch (level) { |
55 | | - case Azure::Core::Diagnostics::Logger::Level::Verbose: |
56 | | - LOG(INFO) << message; |
57 | | - break; |
58 | | - case Azure::Core::Diagnostics::Logger::Level::Informational: |
59 | | - LOG(INFO) << message; |
60 | | - break; |
61 | | - case Azure::Core::Diagnostics::Logger::Level::Warning: |
62 | | - LOG(WARNING) << message; |
63 | | - break; |
64 | | - case Azure::Core::Diagnostics::Logger::Level::Error: |
65 | | - LOG(ERROR) << message; |
66 | | - break; |
67 | | - default: |
68 | | - LOG(WARNING) << "Unknown level: " << static_cast<int>(level) |
69 | | - << ", message: " << message; |
70 | | - break; |
71 | | - } |
72 | | - }); |
73 | | -#endif |
| 43 | + io::obj_client_ca_cert_file_path(); |
74 | 44 | } |
75 | 45 |
|
76 | | -S3ClientFactory::~S3ClientFactory() { |
| 46 | +AwsSdkManager::~AwsSdkManager() { |
77 | 47 | Aws::ShutdownAPI(_aws_options); |
78 | 48 | } |
79 | 49 |
|
80 | | -S3ClientFactory& S3ClientFactory::instance() { |
81 | | - static S3ClientFactory ret; |
| 50 | +AwsSdkManager& AwsSdkManager::instance() { |
| 51 | + static AwsSdkManager ret; |
82 | 52 | return ret; |
83 | 53 | } |
84 | 54 |
|
85 | | -std::string S3ClientFactory::_get_ca_cert_file_path() { |
86 | | - std::lock_guard lock(_ca_cert_lock); |
87 | | - if (_ca_cert_file_path.empty()) { |
88 | | - _ca_cert_file_path = get_valid_ca_cert_path(doris::split(config::ca_cert_file_paths, ";")); |
89 | | - } |
90 | | - return _ca_cert_file_path; |
91 | | -} |
92 | | - |
93 | | -AwsCredentialResult S3ClientFactory::create_aws_credentials_provider(const io::S3AuthConfig& auth) { |
94 | | - auto sts_config = S3ClientFactory::getClientConfiguration(); |
95 | | - auto ca_cert_file_path = _get_ca_cert_file_path(); |
| 55 | +AwsCredentialResult AwsSdkManager::create_aws_credentials_provider(const io::S3AuthConfig& auth) { |
| 56 | + auto sts_config = AwsSdkManager::getClientConfiguration(); |
| 57 | + auto ca_cert_file_path = io::obj_client_ca_cert_file_path(); |
96 | 58 | if (!ca_cert_file_path.empty()) { |
97 | 59 | sts_config.caFile = ca_cert_file_path; |
98 | 60 | } |
|
0 commit comments