aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/RetryStrategy.cpp
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:45:01 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:01 +0300
commit2d37894b1b037cf24231090eda8589bbb44fb6fc (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/RetryStrategy.cpp
parent718c552901d703c502ccbefdfc3c9028d608b947 (diff)
downloadydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/RetryStrategy.cpp')
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/RetryStrategy.cpp204
1 files changed, 102 insertions, 102 deletions
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/RetryStrategy.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/RetryStrategy.cpp
index f66070220d..b439b7ca99 100644
--- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/RetryStrategy.cpp
+++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/RetryStrategy.cpp
@@ -1,102 +1,102 @@
-/**
- * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
- * SPDX-License-Identifier: Apache-2.0.
- */
-
-#include <aws/core/client/RetryStrategy.h>
-
-#include <aws/core/client/AWSError.h>
-#include <aws/core/client/CoreErrors.h>
-#include <aws/core/utils/Outcome.h>
-
-using namespace Aws::Utils::Threading;
-
-namespace Aws
-{
- namespace Client
- {
- static const int INITIAL_RETRY_TOKENS = 500;
- static const int RETRY_COST = 5;
- static const int NO_RETRY_INCREMENT = 1;
- static const int TIMEOUT_RETRY_COST = 10;
-
- StandardRetryStrategy::StandardRetryStrategy(long maxAttempts) :
- m_retryQuotaContainer(Aws::MakeShared<DefaultRetryQuotaContainer>("StandardRetryStrategy")),
- m_maxAttempts(maxAttempts)
- {}
-
- StandardRetryStrategy::StandardRetryStrategy(std::shared_ptr<RetryQuotaContainer> retryQuotaContainer, long maxAttempts) :
- m_retryQuotaContainer(retryQuotaContainer),
- m_maxAttempts(maxAttempts)
- {}
-
- void StandardRetryStrategy::RequestBookkeeping(const HttpResponseOutcome& httpResponseOutcome)
- {
- if (httpResponseOutcome.IsSuccess())
- {
- m_retryQuotaContainer->ReleaseRetryQuota(NO_RETRY_INCREMENT);
- }
- }
-
- void StandardRetryStrategy::RequestBookkeeping(const HttpResponseOutcome& httpResponseOutcome, const AWSError<CoreErrors>& lastError)
- {
- if (httpResponseOutcome.IsSuccess())
- {
- m_retryQuotaContainer->ReleaseRetryQuota(lastError);
- }
- }
-
- bool StandardRetryStrategy::ShouldRetry(const AWSError<CoreErrors>& error, long attemptedRetries) const
- {
- if (!error.ShouldRetry())
- return false;
-
- if (attemptedRetries + 1 >= m_maxAttempts)
- return false;
-
- return m_retryQuotaContainer->AcquireRetryQuota(error);
- }
-
- long StandardRetryStrategy::CalculateDelayBeforeNextRetry(const AWSError<CoreErrors>& error, long attemptedRetries) const
- {
- AWS_UNREFERENCED_PARAM(error);
- return (std::min)(rand() % 1000 * (1 << attemptedRetries), 20000);
- }
-
- DefaultRetryQuotaContainer::DefaultRetryQuotaContainer() : m_retryQuota(INITIAL_RETRY_TOKENS)
- {}
-
- bool DefaultRetryQuotaContainer::AcquireRetryQuota(int capacityAmount)
- {
- WriterLockGuard guard(m_retryQuotaLock);
-
- if (capacityAmount > m_retryQuota)
- {
- return false;
- }
- else
- {
- m_retryQuota -= capacityAmount;
- return true;
- }
- }
-
- bool DefaultRetryQuotaContainer::AcquireRetryQuota(const AWSError<CoreErrors>& error)
- {
- int capacityAmount = error.GetErrorType() == CoreErrors::REQUEST_TIMEOUT ? TIMEOUT_RETRY_COST : RETRY_COST;
- return AcquireRetryQuota(capacityAmount);
- }
-
- void DefaultRetryQuotaContainer::ReleaseRetryQuota(int capacityAmount)
- {
- WriterLockGuard guard(m_retryQuotaLock);
- m_retryQuota = (std::min)(m_retryQuota + capacityAmount, INITIAL_RETRY_TOKENS);
- }
-
- void DefaultRetryQuotaContainer::ReleaseRetryQuota(const AWSError<CoreErrors>& error)
- {
- int capacityAmount = error.GetErrorType() == CoreErrors::REQUEST_TIMEOUT ? TIMEOUT_RETRY_COST : RETRY_COST;
- ReleaseRetryQuota(capacityAmount);
- }
- }
-} \ No newline at end of file
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include <aws/core/client/RetryStrategy.h>
+
+#include <aws/core/client/AWSError.h>
+#include <aws/core/client/CoreErrors.h>
+#include <aws/core/utils/Outcome.h>
+
+using namespace Aws::Utils::Threading;
+
+namespace Aws
+{
+ namespace Client
+ {
+ static const int INITIAL_RETRY_TOKENS = 500;
+ static const int RETRY_COST = 5;
+ static const int NO_RETRY_INCREMENT = 1;
+ static const int TIMEOUT_RETRY_COST = 10;
+
+ StandardRetryStrategy::StandardRetryStrategy(long maxAttempts) :
+ m_retryQuotaContainer(Aws::MakeShared<DefaultRetryQuotaContainer>("StandardRetryStrategy")),
+ m_maxAttempts(maxAttempts)
+ {}
+
+ StandardRetryStrategy::StandardRetryStrategy(std::shared_ptr<RetryQuotaContainer> retryQuotaContainer, long maxAttempts) :
+ m_retryQuotaContainer(retryQuotaContainer),
+ m_maxAttempts(maxAttempts)
+ {}
+
+ void StandardRetryStrategy::RequestBookkeeping(const HttpResponseOutcome& httpResponseOutcome)
+ {
+ if (httpResponseOutcome.IsSuccess())
+ {
+ m_retryQuotaContainer->ReleaseRetryQuota(NO_RETRY_INCREMENT);
+ }
+ }
+
+ void StandardRetryStrategy::RequestBookkeeping(const HttpResponseOutcome& httpResponseOutcome, const AWSError<CoreErrors>& lastError)
+ {
+ if (httpResponseOutcome.IsSuccess())
+ {
+ m_retryQuotaContainer->ReleaseRetryQuota(lastError);
+ }
+ }
+
+ bool StandardRetryStrategy::ShouldRetry(const AWSError<CoreErrors>& error, long attemptedRetries) const
+ {
+ if (!error.ShouldRetry())
+ return false;
+
+ if (attemptedRetries + 1 >= m_maxAttempts)
+ return false;
+
+ return m_retryQuotaContainer->AcquireRetryQuota(error);
+ }
+
+ long StandardRetryStrategy::CalculateDelayBeforeNextRetry(const AWSError<CoreErrors>& error, long attemptedRetries) const
+ {
+ AWS_UNREFERENCED_PARAM(error);
+ return (std::min)(rand() % 1000 * (1 << attemptedRetries), 20000);
+ }
+
+ DefaultRetryQuotaContainer::DefaultRetryQuotaContainer() : m_retryQuota(INITIAL_RETRY_TOKENS)
+ {}
+
+ bool DefaultRetryQuotaContainer::AcquireRetryQuota(int capacityAmount)
+ {
+ WriterLockGuard guard(m_retryQuotaLock);
+
+ if (capacityAmount > m_retryQuota)
+ {
+ return false;
+ }
+ else
+ {
+ m_retryQuota -= capacityAmount;
+ return true;
+ }
+ }
+
+ bool DefaultRetryQuotaContainer::AcquireRetryQuota(const AWSError<CoreErrors>& error)
+ {
+ int capacityAmount = error.GetErrorType() == CoreErrors::REQUEST_TIMEOUT ? TIMEOUT_RETRY_COST : RETRY_COST;
+ return AcquireRetryQuota(capacityAmount);
+ }
+
+ void DefaultRetryQuotaContainer::ReleaseRetryQuota(int capacityAmount)
+ {
+ WriterLockGuard guard(m_retryQuotaLock);
+ m_retryQuota = (std::min)(m_retryQuota + capacityAmount, INITIAL_RETRY_TOKENS);
+ }
+
+ void DefaultRetryQuotaContainer::ReleaseRetryQuota(const AWSError<CoreErrors>& error)
+ {
+ int capacityAmount = error.GetErrorType() == CoreErrors::REQUEST_TIMEOUT ? TIMEOUT_RETRY_COST : RETRY_COST;
+ ReleaseRetryQuota(capacityAmount);
+ }
+ }
+} \ No newline at end of file