diff options
| author | max42 <[email protected]> | 2023-06-30 11:13:34 +0300 |
|---|---|---|
| committer | max42 <[email protected]> | 2023-06-30 11:13:34 +0300 |
| commit | 3e1899838408bbad47622007aa382bc8a2b01f87 (patch) | |
| tree | 0f21c1e6add187ddb6c3ccc048a7d640ce03fb87 /yt/cpp/mapreduce/client/lock.cpp | |
| parent | 5463eb3f5e72a86f858a3d27c886470a724ede34 (diff) | |
Revert "YT-19324: move YT provider to ydb/library/yql"
This reverts commit ca272f12fdd0e8d5c3e957fc87939148f1caaf72, reversing
changes made to 49f8acfc8b0b5c0071b804423bcf53fda26c7c12.
Diffstat (limited to 'yt/cpp/mapreduce/client/lock.cpp')
| -rw-r--r-- | yt/cpp/mapreduce/client/lock.cpp | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/yt/cpp/mapreduce/client/lock.cpp b/yt/cpp/mapreduce/client/lock.cpp deleted file mode 100644 index 88110f9266e..00000000000 --- a/yt/cpp/mapreduce/client/lock.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "lock.h" - -#include "yt_poller.h" - -#include <yt/cpp/mapreduce/http/retry_request.h> - -#include <yt/cpp/mapreduce/common/retry_lib.h> - -#include <yt/cpp/mapreduce/raw_client/raw_batch_request.h> - -#include <util/string/builder.h> - -namespace NYT { -namespace NDetail { - -using namespace NRawClient; - -//////////////////////////////////////////////////////////////////////////////// - -class TLockPollerItem - : public IYtPollerItem -{ -public: - TLockPollerItem(const TLockId& lockId, ::NThreading::TPromise<void> acquired) - : LockStateYPath_("#" + GetGuidAsString(lockId) + "/@state") - , Acquired_(acquired) - { } - - void PrepareRequest(TRawBatchRequest* batchRequest) override - { - LockState_ = batchRequest->Get(TTransactionId(), LockStateYPath_, TGetOptions()); - } - - EStatus OnRequestExecuted() override - { - try { - const auto& state = LockState_.GetValue().AsString(); - if (state == "acquired") { - Acquired_.SetValue(); - return PollBreak; - } - } catch (const TErrorResponse& e) { - if (!IsRetriable(e)) { - Acquired_.SetException(std::current_exception()); - return PollBreak; - } - } catch (const std::exception& e) { - if (!IsRetriable(e)) { - Acquired_.SetException(std::current_exception()); - return PollBreak; - } - } - return PollContinue; - } - - void OnItemDiscarded() override - { - Acquired_.SetException(std::make_exception_ptr(yexception() << "Operation cancelled")); - } - -private: - const TString LockStateYPath_; - ::NThreading::TPromise<void> Acquired_; - - ::NThreading::TFuture<TNode> LockState_; -}; - -//////////////////////////////////////////////////////////////////////////////// - -TLock::TLock(const TLockId& lockId, TClientPtr client, bool waitable) - : LockId_(lockId) - , Client_(std::move(client)) -{ - if (!waitable) { - Acquired_ = ::NThreading::MakeFuture(); - } -} - -const TLockId& TLock::GetId() const -{ - return LockId_; -} - -TNodeId TLock::GetLockedNodeId() const -{ - auto nodeIdNode = Client_->Get( - ::TStringBuilder() << '#' << GetGuidAsString(LockId_) << "/@node_id", - TGetOptions()); - return GetGuid(nodeIdNode.AsString()); -} - -const ::NThreading::TFuture<void>& TLock::GetAcquiredFuture() const -{ - if (!Acquired_) { - auto promise = ::NThreading::NewPromise<void>(); - Client_->GetYtPoller().Watch(::MakeIntrusive<TLockPollerItem>(LockId_, promise)); - Acquired_ = promise.GetFuture(); - } - return *Acquired_; -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NDetail -} // namespace NYT |
