diff options
author | hiddenpath <hiddenpath@yandex-team.com> | 2024-12-13 21:31:44 +0300 |
---|---|---|
committer | hiddenpath <hiddenpath@yandex-team.com> | 2024-12-13 22:02:15 +0300 |
commit | d26f8c56ad3cce8d0b0d7486273d097c0b55d563 (patch) | |
tree | 4291ed68169f768b50bee9b4a6d2dfcb5d34894c | |
parent | 45adb506ceac868501980c617df1f1a5cc62bb9a (diff) | |
download | ydb-d26f8c56ad3cce8d0b0d7486273d097c0b55d563.tar.gz |
yt/cpp/mapreduce: move Copy methods to THttpRawClient
commit_hash:c0f835454764181a7258ab7358022f8a80d71873
-rw-r--r-- | yt/cpp/mapreduce/client/client.cpp | 9 | ||||
-rw-r--r-- | yt/cpp/mapreduce/interface/raw_client.h | 14 | ||||
-rw-r--r-- | yt/cpp/mapreduce/raw_client/raw_client.cpp | 31 | ||||
-rw-r--r-- | yt/cpp/mapreduce/raw_client/raw_client.h | 14 | ||||
-rw-r--r-- | yt/cpp/mapreduce/raw_client/raw_requests.cpp | 32 | ||||
-rw-r--r-- | yt/cpp/mapreduce/raw_client/raw_requests.h | 15 |
6 files changed, 66 insertions, 49 deletions
diff --git a/yt/cpp/mapreduce/client/client.cpp b/yt/cpp/mapreduce/client/client.cpp index 45a5bf1d47..477809dc7b 100644 --- a/yt/cpp/mapreduce/client/client.cpp +++ b/yt/cpp/mapreduce/client/client.cpp @@ -185,13 +185,18 @@ TNodeId TClientBase::Copy( const TCopyOptions& options) { try { - return NRawClient::CopyInsideMasterCell(ClientRetryPolicy_->CreatePolicyForGenericRequest(), Context_, TransactionId_, sourcePath, destinationPath, options); + return RequestWithRetry<TNodeId>( + ClientRetryPolicy_->CreatePolicyForGenericRequest(), + [this, &sourcePath, &destinationPath, &options] (TMutationId& mutationId) { + return RawClient_->CopyInsideMasterCell(mutationId, TransactionId_, sourcePath, destinationPath, options); + }); } catch (const TErrorResponse& e) { if (e.GetError().ContainsErrorCode(NClusterErrorCodes::NObjectClient::CrossCellAdditionalPath)) { // Do transaction for cross cell copying. std::function<TNodeId(ITransactionPtr)> lambda = [this, &sourcePath, &destinationPath, &options](ITransactionPtr transaction) { - return NRawClient::CopyWithoutRetries(Context_, transaction->GetId(), sourcePath, destinationPath, options); + TMutationId mutationId; + return RawClient_->CopyWithoutRetries(mutationId, transaction->GetId(), sourcePath, destinationPath, options); }; return RetryTransactionWithPolicy<TNodeId>( this, diff --git a/yt/cpp/mapreduce/interface/raw_client.h b/yt/cpp/mapreduce/interface/raw_client.h index e5c672929c..f9531289b4 100644 --- a/yt/cpp/mapreduce/interface/raw_client.h +++ b/yt/cpp/mapreduce/interface/raw_client.h @@ -50,6 +50,20 @@ public: const TYPath& path, const ENodeType& type, const TCreateOptions& options = {}) = 0; + + virtual TNodeId CopyWithoutRetries( + TMutationId& mutationId, + const TTransactionId& transactionId, + const TYPath& sourcePath, + const TYPath& destinationPath, + const TCopyOptions& options = {}) = 0; + + virtual TNodeId CopyInsideMasterCell( + TMutationId& mutationId, + const TTransactionId& transactionId, + const TYPath& sourcePath, + const TYPath& destinationPath, + const TCopyOptions& options = {}) = 0; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/cpp/mapreduce/raw_client/raw_client.cpp b/yt/cpp/mapreduce/raw_client/raw_client.cpp index 034dff7f33..85d253c510 100644 --- a/yt/cpp/mapreduce/raw_client/raw_client.cpp +++ b/yt/cpp/mapreduce/raw_client/raw_client.cpp @@ -94,6 +94,37 @@ TNodeId THttpRawClient::Create( return ParseGuidFromResponse(RequestWithoutRetry(Context_, mutationId, header).Response); } + +TNodeId THttpRawClient::CopyWithoutRetries( + TMutationId& mutationId, + const TTransactionId& transactionId, + const TYPath& sourcePath, + const TYPath& destinationPath, + const TCopyOptions& options) +{ + THttpHeader header("POST", "copy"); + header.AddMutationId(); + header.MergeParameters(NRawClient::SerializeParamsForCopy(transactionId, Context_.Config->Prefix, sourcePath, destinationPath, options)); + return ParseGuidFromResponse(RequestWithoutRetry(Context_, mutationId, header).Response); +} + +TNodeId THttpRawClient::CopyInsideMasterCell( + TMutationId& mutationId, + const TTransactionId& transactionId, + const TYPath& sourcePath, + const TYPath& destinationPath, + const TCopyOptions& options) +{ + THttpHeader header("POST", "copy"); + header.AddMutationId(); + auto params = NRawClient::SerializeParamsForCopy(transactionId, Context_.Config->Prefix, sourcePath, destinationPath, options); + + // Make cross cell copying disable. + params["enable_cross_cell_copying"] = false; + header.MergeParameters(params); + return ParseGuidFromResponse(RequestWithoutRetry(Context_, mutationId, header).Response); +} + //////////////////////////////////////////////////////////////////////////////// } // namespace NYT::NDetail diff --git a/yt/cpp/mapreduce/raw_client/raw_client.h b/yt/cpp/mapreduce/raw_client/raw_client.h index 0908794168..63fb9a5a21 100644 --- a/yt/cpp/mapreduce/raw_client/raw_client.h +++ b/yt/cpp/mapreduce/raw_client/raw_client.h @@ -56,6 +56,20 @@ public: const ENodeType& type, const TCreateOptions& options = {}) override; + TNodeId CopyWithoutRetries( + TMutationId& mutationId, + const TTransactionId& transactionId, + const TYPath& sourcePath, + const TYPath& destinationPath, + const TCopyOptions& options = {}) override; + + TNodeId CopyInsideMasterCell( + TMutationId& mutationId, + const TTransactionId& transactionId, + const TYPath& sourcePath, + const TYPath& destinationPath, + const TCopyOptions& options = {}) override; + private: const TClientContext Context_; }; diff --git a/yt/cpp/mapreduce/raw_client/raw_requests.cpp b/yt/cpp/mapreduce/raw_client/raw_requests.cpp index 9d643afc91..b7014863d7 100644 --- a/yt/cpp/mapreduce/raw_client/raw_requests.cpp +++ b/yt/cpp/mapreduce/raw_client/raw_requests.cpp @@ -79,38 +79,6 @@ void ExecuteBatch( } } -TNodeId CopyWithoutRetries( - const TClientContext& context, - const TTransactionId& transactionId, - const TYPath& sourcePath, - const TYPath& destinationPath, - const TCopyOptions& options) -{ - THttpHeader header("POST", "copy"); - TMutationId mutationId; - header.AddMutationId(); - header.MergeParameters(SerializeParamsForCopy(transactionId, context.Config->Prefix, sourcePath, destinationPath, options)); - return ParseGuidFromResponse(RequestWithoutRetry(context, mutationId, header).Response); -} - -TNodeId CopyInsideMasterCell( - const IRequestRetryPolicyPtr& retryPolicy, - const TClientContext& context, - const TTransactionId& transactionId, - const TYPath& sourcePath, - const TYPath& destinationPath, - const TCopyOptions& options) -{ - THttpHeader header("POST", "copy"); - header.AddMutationId(); - auto params = SerializeParamsForCopy(transactionId, context.Config->Prefix, sourcePath, destinationPath, options); - - // Make cross cell copying disable. - params["enable_cross_cell_copying"] = false; - header.MergeParameters(params); - return ParseGuidFromResponse(RetryRequestWithPolicy(retryPolicy, context, header).Response); -} - TNodeId MoveWithoutRetries( const TClientContext& context, const TTransactionId& transactionId, diff --git a/yt/cpp/mapreduce/raw_client/raw_requests.h b/yt/cpp/mapreduce/raw_client/raw_requests.h index 9a02e34951..0c787df8e3 100644 --- a/yt/cpp/mapreduce/raw_client/raw_requests.h +++ b/yt/cpp/mapreduce/raw_client/raw_requests.h @@ -39,21 +39,6 @@ void ExecuteBatch( // Cypress // -TNodeId CopyWithoutRetries( - const TClientContext& context, - const TTransactionId& transactionId, - const TYPath& sourcePath, - const TYPath& destinationPath, - const TCopyOptions& options = TCopyOptions()); - -TNodeId CopyInsideMasterCell( - const IRequestRetryPolicyPtr& retryPolicy, - const TClientContext& context, - const TTransactionId& transactionId, - const TYPath& sourcePath, - const TYPath& destinationPath, - const TCopyOptions& options = TCopyOptions()); - TNodeId MoveWithoutRetries( const TClientContext& context, const TTransactionId& transactionId, |