Skip to content

Commit 6972b21

Browse files
ivanmorozov333Gazizonoki
authored andcommitted
Moved "improve CS-resharding" commit from ydb repo
1 parent 9ed0db6 commit 6972b21

File tree

9 files changed

+90
-0
lines changed

9 files changed

+90
-0
lines changed

src/client/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ add_subdirectory(query)
3131
add_subdirectory(rate_limiter)
3232
add_subdirectory(result)
3333
add_subdirectory(scheme)
34+
add_subdirectory(ss_tasks)
3435
add_subdirectory(table)
3536
add_subdirectory(topic)
3637
add_subdirectory(types)

src/client/operation/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ target_link_libraries(cpp-client-ydb_operation PUBLIC
99
cpp-client-ydb_driver
1010
cpp-client-ydb_export
1111
cpp-client-ydb_import
12+
cpp-client-ss_tasks
1213
client-ydb_types-operation
1314
)
1415

src/client/operation/operation.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <ydb-cpp-sdk/client/query/query.h>
99
#include <ydb-cpp-sdk/client/export/export.h>
1010
#include <ydb-cpp-sdk/client/import/import.h>
11+
#include <src/client/ss_tasks/task.h>
1112
#include <ydb-cpp-sdk/client/table/table.h>
1213

1314
#include <src/api/grpc/ydb_operation_v1.grpc.pb.h>
@@ -168,6 +169,12 @@ TFuture<TOperationsList<TOp>> TOperationClient::List(const std::string& kind, ui
168169
}
169170

170171
// Instantiations
172+
template TFuture<NSchemeShard::TBackgroundProcessesResponse> TOperationClient::Get(const TOperation::TOperationId& id);
173+
template <>
174+
TFuture<TOperationsList<NSchemeShard::TBackgroundProcessesResponse>> TOperationClient::List(ui64 pageSize, const std::string& pageToken) {
175+
return List<NSchemeShard::TBackgroundProcessesResponse>("ss/backgrounds", pageSize, pageToken);
176+
}
177+
171178
template TFuture<NExport::TExportToYtResponse> TOperationClient::Get(const TOperation::TOperationId& id);
172179
template <>
173180
TFuture<TOperationsList<NExport::TExportToYtResponse>> TOperationClient::List(ui64 pageSize, const std::string& pageToken) {

src/client/ss_tasks/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
add_library(cpp-client-ss_tasks)
2+
3+
target_link_libraries(cpp-client-ss_tasks PUBLIC
4+
yutil
5+
api-grpc
6+
api-protos
7+
client-ydb_common_client-impl
8+
cpp-client-ydb_driver
9+
cpp-client-ydb_proto
10+
client-ydb_types-operation
11+
)
12+
13+
target_sources(cpp-client-ss_tasks PRIVATE
14+
task.cpp
15+
out.cpp
16+
)
17+
18+
generate_enum_serilization(cpp-client-ss_tasks
19+
${YDB_SDK_SOURCE_DIR}/src/client/ss_tasks/task.h
20+
INCLUDE_HEADERS
21+
src/client/ss_tasks/task.h
22+
)

src/client/ss_tasks/out.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "task.h"

src/client/ss_tasks/task.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "task.h"
2+
#include <src/api/grpc/ydb_discovery_v1.grpc.pb.h>
3+
#include <src/api/grpc/ydb_export_v1.grpc.pb.h>
4+
#include <src/api/protos/ydb_export.pb.h>
5+
#include <src/client/common_client/impl/client.h>
6+
#include <ydb-cpp-sdk/client/proto/accessor.h>
7+
8+
namespace NYdb {
9+
namespace NSchemeShard {
10+
11+
/// YT
12+
TBackgroundProcessesResponse::TBackgroundProcessesResponse(TStatus&& status, Ydb::Operations::Operation&& operation)
13+
: TOperation(std::move(status), std::move(operation))
14+
{
15+
Metadata_.Id = GetProto().DebugString();
16+
}
17+
18+
const TBackgroundProcessesResponse::TMetadata& TBackgroundProcessesResponse::Metadata() const {
19+
return Metadata_;
20+
}
21+
22+
} // namespace NExport
23+
} // namespace NYdb

src/client/ss_tasks/task.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#pragma once
2+
3+
#include <ydb-cpp-sdk/client/driver/driver.h>
4+
#include <ydb-cpp-sdk/client/types/operation/operation.h>
5+
6+
#include <ydb-cpp-sdk/client/types/s3_settings.h>
7+
8+
namespace NYdb {
9+
namespace NSchemeShard {
10+
11+
class TBackgroundProcessesResponse: public TOperation {
12+
private:
13+
using TBase = TOperation;
14+
public:
15+
struct TMetadata {
16+
std::string Id;
17+
};
18+
19+
public:
20+
using TOperation::TOperation;
21+
TBackgroundProcessesResponse(TStatus&& status, Ydb::Operations::Operation&& operation);
22+
23+
const TMetadata& Metadata() const;
24+
25+
private:
26+
TMetadata Metadata_;
27+
};
28+
29+
} // namespace NExport
30+
} // namespace NYdb

src/library/operation_id/operation_id.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ void AddOptionalValue(Ydb::TOperationId& proto, const std::string& key, const st
180180
}
181181

182182
Ydb::TOperationId::EKind ParseKind(const std::string_view value) {
183+
if (value.starts_with("ss/backgrounds")) {
184+
return Ydb::TOperationId::SS_BG_TASKS;
185+
}
186+
183187
if (value.starts_with("export")) {
184188
return Ydb::TOperationId::EXPORT;
185189
}

src/library/operation_id/protos/operation_id.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ message TOperationId {
1414
BUILD_INDEX = 7;
1515
IMPORT = 8;
1616
SCRIPT_EXECUTION = 9;
17+
SS_BG_TASKS = 10;
1718
}
1819

1920
message TData {

0 commit comments

Comments
 (0)