|
5 | 5 | #include "client_writer.h" |
6 | 6 | #include "file_reader.h" |
7 | 7 | #include "file_writer.h" |
| 8 | +#include "file_fragment_writer.h" |
8 | 9 | #include "format_hints.h" |
9 | 10 | #include "init.h" |
10 | 11 | #include "lock.h" |
@@ -401,6 +402,13 @@ IFileWriterPtr TClientBase::CreateFileWriter( |
401 | 402 | return new TFileWriter(realPath, RawClient_, ClientRetryPolicy_, GetTransactionPinger(), Context_, TransactionId_, options); |
402 | 403 | } |
403 | 404 |
|
| 405 | +IFileFragmentWriterPtr TClientBase::CreateFileFragmentWriter( |
| 406 | + const TDistributedWriteFileCookie& cookie, |
| 407 | + const TFileFragmentWriterOptions& options) |
| 408 | +{ |
| 409 | + return NDetail::CreateFileFragmentWriter(RawClient_, ClientRetryPolicy_->CreatePolicyForGenericRequest(), cookie, options); |
| 410 | +} |
| 411 | + |
404 | 412 | TTableWriterPtr<::google::protobuf::Message> TClientBase::CreateTableWriter( |
405 | 413 | const TRichYPath& path, const ::google::protobuf::Descriptor& descriptor, const TTableWriterOptions& options) |
406 | 414 | { |
@@ -978,6 +986,23 @@ ::TIntrusivePtr<IProtoWriterImpl> TClientBase::CreateProtoWriter( |
978 | 986 | } |
979 | 987 | } |
980 | 988 |
|
| 989 | +::TIntrusivePtr<ITableFragmentWriter<TNode>> TClientBase::CreateNodeFragmentWriter( |
| 990 | + const TDistributedWriteTableCookie& cookie, |
| 991 | + const TTableFragmentWriterOptions& options) |
| 992 | +{ |
| 993 | + auto format = TFormat::YsonBinary(); |
| 994 | + |
| 995 | + // TODO(achains): Make proper wrapper class with retries and auto ping. |
| 996 | + auto stream = NDetail::RequestWithRetry<std::unique_ptr<IOutputStreamWithResponse>>( |
| 997 | + ClientRetryPolicy_->CreatePolicyForGenericRequest(), |
| 998 | + [&] (TMutationId /*mutationId*/) { |
| 999 | + return RawClient_->WriteTableFragment(cookie, format, options); |
| 1000 | + } |
| 1001 | + ); |
| 1002 | + |
| 1003 | + return ::MakeIntrusive<TNodeTableFragmentWriter>(std::move(stream)); |
| 1004 | +} |
| 1005 | + |
981 | 1006 | TBatchRequestPtr TClientBase::CreateBatchRequest() |
982 | 1007 | { |
983 | 1008 | return MakeIntrusive<TBatchRequest>(TransactionId_, GetParentClientImpl()); |
@@ -1497,6 +1522,82 @@ void TClient::ResumeOperation( |
1497 | 1522 | }); |
1498 | 1523 | } |
1499 | 1524 |
|
| 1525 | +TDistributedWriteTableSessionWithCookies TClient::StartDistributedWriteTableSession( |
| 1526 | + const TRichYPath& richPath, |
| 1527 | + i64 cookieCount, |
| 1528 | + const TStartDistributedWriteTableOptions& options) |
| 1529 | +{ |
| 1530 | + CheckShutdown(); |
| 1531 | + return RequestWithRetry<TDistributedWriteTableSessionWithCookies>( |
| 1532 | + ClientRetryPolicy_->CreatePolicyForGenericRequest(), |
| 1533 | + [this, cookieCount, &richPath, &options] (TMutationId& mutationId) { |
| 1534 | + return RawClient_->StartDistributedWriteTableSession(mutationId, richPath, cookieCount, options); |
| 1535 | + }); |
| 1536 | +} |
| 1537 | + |
| 1538 | +void TClient::PingDistributedWriteTableSession( |
| 1539 | + const TDistributedWriteTableSession& session, |
| 1540 | + const TPingDistributedWriteTableOptions& options) |
| 1541 | +{ |
| 1542 | + CheckShutdown(); |
| 1543 | + RequestWithRetry<void>( |
| 1544 | + ClientRetryPolicy_->CreatePolicyForGenericRequest(), |
| 1545 | + [this, &session, &options] (TMutationId& /*mutationId*/) { |
| 1546 | + RawClient_->PingDistributedWriteTableSession(session, options); |
| 1547 | + }); |
| 1548 | +} |
| 1549 | + |
| 1550 | +void TClient::FinishDistributedWriteTableSession( |
| 1551 | + const TDistributedWriteTableSession& session, |
| 1552 | + const TVector<TWriteTableFragmentResult>& results, |
| 1553 | + const TFinishDistributedWriteTableOptions& options) |
| 1554 | +{ |
| 1555 | + CheckShutdown(); |
| 1556 | + RequestWithRetry<void>( |
| 1557 | + ClientRetryPolicy_->CreatePolicyForGenericRequest(), |
| 1558 | + [this, &session, &results, &options] (TMutationId& mutationId) { |
| 1559 | + RawClient_->FinishDistributedWriteTableSession(mutationId, session, results, options); |
| 1560 | + }); |
| 1561 | +} |
| 1562 | + |
| 1563 | +TDistributedWriteFileSessionWithCookies TClient::StartDistributedWriteFileSession( |
| 1564 | + const TRichYPath& richPath, |
| 1565 | + i64 cookieCount, |
| 1566 | + const TStartDistributedWriteFileOptions& options) |
| 1567 | +{ |
| 1568 | + CheckShutdown(); |
| 1569 | + return RequestWithRetry<TDistributedWriteFileSessionWithCookies>( |
| 1570 | + ClientRetryPolicy_->CreatePolicyForGenericRequest(), |
| 1571 | + [this, cookieCount, &richPath, &options] (TMutationId& mutationId) { |
| 1572 | + return RawClient_->StartDistributedWriteFileSession(mutationId, richPath, cookieCount, options); |
| 1573 | + }); |
| 1574 | +} |
| 1575 | + |
| 1576 | +void TClient::PingDistributedWriteFileSession( |
| 1577 | + const TDistributedWriteFileSession& session, |
| 1578 | + const TPingDistributedWriteFileOptions& options) |
| 1579 | +{ |
| 1580 | + CheckShutdown(); |
| 1581 | + RequestWithRetry<void>( |
| 1582 | + ClientRetryPolicy_->CreatePolicyForGenericRequest(), |
| 1583 | + [this, &session, &options] (TMutationId& /*mutationId*/) { |
| 1584 | + RawClient_->PingDistributedWriteFileSession(session, options); |
| 1585 | + }); |
| 1586 | +} |
| 1587 | + |
| 1588 | +void TClient::FinishDistributedWriteFileSession( |
| 1589 | + const TDistributedWriteFileSession& session, |
| 1590 | + const TVector<TWriteFileFragmentResult>& results, |
| 1591 | + const TFinishDistributedWriteFileOptions& options) |
| 1592 | +{ |
| 1593 | + CheckShutdown(); |
| 1594 | + RequestWithRetry<void>( |
| 1595 | + ClientRetryPolicy_->CreatePolicyForGenericRequest(), |
| 1596 | + [this, &session, &results, &options] (TMutationId& mutationId) { |
| 1597 | + RawClient_->FinishDistributedWriteFileSession(mutationId, session, results, options); |
| 1598 | + }); |
| 1599 | +} |
| 1600 | + |
1500 | 1601 | TYtPoller& TClient::GetYtPoller() |
1501 | 1602 | { |
1502 | 1603 | auto g = Guard(Lock_); |
|
0 commit comments