6
6
#ifndef KIKIMR_DISABLE_S3_OPS
7
7
namespace NKikimr ::NWrappers::NExternalStorage {
8
8
9
+ class TS3ThreadsPoolByEndpoint {
10
+ private:
11
+ class TPool {
12
+ public:
13
+ std::shared_ptr<Aws::Utils::Threading::PooledThreadExecutor> Executor;
14
+ ui32 ThreadsCount = 0 ;
15
+
16
+ TPool (const std::shared_ptr<Aws::Utils::Threading::PooledThreadExecutor>& executor, const ui32 threadsCount)
17
+ : Executor(executor)
18
+ , ThreadsCount(threadsCount)
19
+ {
20
+ }
21
+ };
22
+
23
+ THashMap<TString, TPool> Pools;
24
+ TMutex Mutex;
25
+
26
+ std::shared_ptr<Aws::Utils::Threading::PooledThreadExecutor> GetPoolImpl (const TString& endpoint, const ui32 threadsCount) {
27
+ TGuard<TMutex> g (Mutex);
28
+ auto it = Pools.find (endpoint);
29
+ if (it == Pools.end ()) {
30
+ TPool pool (std::make_shared<Aws::Utils::Threading::PooledThreadExecutor>(threadsCount), threadsCount);
31
+ it = Pools.emplace (endpoint, std::move (pool)).first ;
32
+ } else if (it->second .ThreadsCount < threadsCount) {
33
+ TPool pool (std::make_shared<Aws::Utils::Threading::PooledThreadExecutor>(threadsCount), threadsCount);
34
+ it->second = std::move (pool);
35
+ }
36
+ return it->second .Executor ;
37
+ }
38
+
39
+ public:
40
+ static std::shared_ptr<Aws::Utils::Threading::PooledThreadExecutor> GetPool (const TString& endpoint, const ui32 threadsCount) {
41
+ return Singleton<TS3ThreadsPoolByEndpoint>()->GetPoolImpl (endpoint, threadsCount);
42
+ }
43
+ };
44
+
9
45
namespace {
10
46
11
47
namespace NPrivate {
@@ -18,7 +54,8 @@ Aws::Client::ClientConfiguration ConfigFromSettings(const TSettings& settings) {
18
54
auto threadsCount = NKikimrSchemeOp::TS3Settings::default_instance ().GetExecutorThreadsCount ();
19
55
20
56
config.endpointOverride = settings.endpoint ();
21
- config.executor = std::make_shared<Aws::Utils::Threading::PooledThreadExecutor>(threadsCount);
57
+ config.executor = TS3ThreadsPoolByEndpoint::GetPool (settings.endpoint (), threadsCount);
58
+ config.enableTcpKeepAlive = true ;
22
59
config.verifySSL = false ;
23
60
config.connectTimeoutMs = 10000 ;
24
61
config.maxConnections = threadsCount;
@@ -46,42 +83,6 @@ Aws::Auth::AWSCredentials CredentialsFromSettings(const TSettings& settings) {
46
83
47
84
} // anonymous
48
85
49
- class TS3ThreadsPoolByEndpoint {
50
- private:
51
- class TPool {
52
- public:
53
- std::shared_ptr<Aws::Utils::Threading::PooledThreadExecutor> Executor;
54
- ui32 ThreadsCount = 0 ;
55
-
56
- TPool (const std::shared_ptr<Aws::Utils::Threading::PooledThreadExecutor>& executor, const ui32 threadsCount)
57
- : Executor(executor)
58
- , ThreadsCount(threadsCount)
59
- {
60
- }
61
- };
62
-
63
- THashMap<TString, TPool> Pools;
64
- TMutex Mutex;
65
-
66
- std::shared_ptr<Aws::Utils::Threading::PooledThreadExecutor> GetPoolImpl (const TString& endpoint, const ui32 threadsCount) {
67
- TGuard<TMutex> g (Mutex);
68
- auto it = Pools.find (endpoint);
69
- if (it == Pools.end ()) {
70
- TPool pool (std::make_shared<Aws::Utils::Threading::PooledThreadExecutor>(threadsCount), threadsCount);
71
- it = Pools.emplace (endpoint, std::move (pool)).first ;
72
- } else if (it->second .ThreadsCount < threadsCount) {
73
- TPool pool (std::make_shared<Aws::Utils::Threading::PooledThreadExecutor>(threadsCount), threadsCount);
74
- it->second = std::move (pool);
75
- }
76
- return it->second .Executor ;
77
- }
78
-
79
- public:
80
- static std::shared_ptr<Aws::Utils::Threading::PooledThreadExecutor> GetPool (const TString& endpoint, const ui32 threadsCount) {
81
- return Singleton<TS3ThreadsPoolByEndpoint>()->GetPoolImpl (endpoint, threadsCount);
82
- }
83
- };
84
-
85
86
Aws::Client::ClientConfiguration TS3ExternalStorageConfig::ConfigFromSettings (const NKikimrSchemeOp::TS3Settings& settings) {
86
87
Aws::Client::ClientConfiguration config;
87
88
0 commit comments