#include "batch_request_impl.h" #include "lock.h" #include #include #include #include #include #include #include #include #include #include #include #include #include namespace NYT { namespace NDetail { using namespace NRawClient; using ::NThreading::TFuture; using ::NThreading::TPromise; using ::NThreading::NewPromise; //////////////////////////////////////////////////////////////////// TBatchRequest::TBatchRequest(const TTransactionId& defaultTransaction, ::TIntrusivePtr client) : DefaultTransaction_(defaultTransaction) , Impl_(MakeIntrusive(client->GetContext().Config)) , Client_(client) { } TBatchRequest::TBatchRequest(TRawBatchRequest* impl, ::TIntrusivePtr client) : Impl_(impl) , Client_(std::move(client)) { } TBatchRequest::~TBatchRequest() = default; IBatchRequestBase& TBatchRequest::WithTransaction(const TTransactionId& transactionId) { if (!TmpWithTransaction_) { TmpWithTransaction_.Reset(new TBatchRequest(Impl_.Get(), Client_)); } TmpWithTransaction_->DefaultTransaction_ = transactionId; return *TmpWithTransaction_; } TFuture TBatchRequest::Get( const TYPath& path, const TGetOptions& options) { return Impl_->Get(DefaultTransaction_, path, options); } TFuture TBatchRequest::Set(const TYPath& path, const TNode& node, const TSetOptions& options) { return Impl_->Set(DefaultTransaction_, path, node, options); } TFuture TBatchRequest::List(const TYPath& path, const TListOptions& options) { return Impl_->List(DefaultTransaction_, path, options); } TFuture TBatchRequest::Exists(const TYPath& path, const TExistsOptions& options) { return Impl_->Exists(DefaultTransaction_, path, options); } TFuture TBatchRequest::Lock( const TYPath& path, ELockMode mode, const TLockOptions& options) { auto convert = [waitable=options.Waitable_, client=Client_] (TFuture nodeIdFuture) -> ILockPtr { return ::MakeIntrusive(nodeIdFuture.GetValue(), client, waitable); }; return Impl_->Lock(DefaultTransaction_, path, mode, options).Apply(convert); } ::NThreading::TFuture TBatchRequest::Unlock( const TYPath& path, const TUnlockOptions& options = TUnlockOptions()) { return Impl_->Unlock(DefaultTransaction_, path, options); } TFuture TBatchRequest::Create( const TYPath& path, ENodeType type, const TCreateOptions& options) { return Impl_->Create(DefaultTransaction_, path, type, options); } TFuture TBatchRequest::Remove( const TYPath& path, const TRemoveOptions& options) { return Impl_->Remove(DefaultTransaction_, path, options); } TFuture TBatchRequest::Move( const TYPath& sourcePath, const TYPath& destinationPath, const TMoveOptions& options) { return Impl_->Move(DefaultTransaction_, sourcePath, destinationPath, options); } TFuture TBatchRequest::Copy( const TYPath& sourcePath, const TYPath& destinationPath, const TCopyOptions& options) { return Impl_->Copy(DefaultTransaction_, sourcePath, destinationPath, options); } TFuture TBatchRequest::Link( const TYPath& targetPath, const TYPath& linkPath, const TLinkOptions& options) { return Impl_->Link(DefaultTransaction_, targetPath, linkPath, options); } TFuture TBatchRequest::AbortOperation(const NYT::TOperationId& operationId) { return Impl_->AbortOperation(operationId); } TFuture TBatchRequest::CompleteOperation(const NYT::TOperationId& operationId) { return Impl_->CompleteOperation(operationId); } TFuture TBatchRequest::SuspendOperation( const TOperationId& operationId, const TSuspendOperationOptions& options) { return Impl_->SuspendOperation(operationId, options); } TFuture TBatchRequest::ResumeOperation( const TOperationId& operationId, const TResumeOperationOptions& options) { return Impl_->ResumeOperation(operationId, options); } TFuture TBatchRequest::UpdateOperationParameters( const NYT::TOperationId& operationId, const NYT::TUpdateOperationParametersOptions& options) { return Impl_->UpdateOperationParameters(operationId, options); } TFuture TBatchRequest::CanonizeYPath(const TRichYPath& path) { return Impl_->CanonizeYPath(path); } TFuture> TBatchRequest::GetTableColumnarStatistics( const TVector& paths, const NYT::TGetTableColumnarStatisticsOptions& options) { return Impl_->GetTableColumnarStatistics(DefaultTransaction_, paths, options); } TFuture TBatchRequest::CheckPermission( const TString& user, EPermission permission, const TYPath& path, const TCheckPermissionOptions& options) { return Impl_->CheckPermission(user, permission, path, options); } void TBatchRequest::ExecuteBatch(const TExecuteBatchOptions& options) { NYT::NDetail::ExecuteBatch(Client_->GetRetryPolicy()->CreatePolicyForGenericRequest(), Client_->GetContext(), *Impl_, options); } //////////////////////////////////////////////////////////////////////////////// } // namespace NDetail } // namespace NYT