Skip to content

Commit 664dae0

Browse files
authored
Merge 220122b into 389847d
2 parents 389847d + 220122b commit 664dae0

File tree

5 files changed

+110
-64
lines changed

5 files changed

+110
-64
lines changed

ydb/core/grpc_services/rpc_keyvalue.cpp

Lines changed: 93 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -432,58 +432,6 @@ class TDropVolumeRequest : public TRpcSchemeRequestActor<TDropVolumeRequest, TEv
432432
}
433433
};
434434

435-
class TAlterVolumeRequest : public TRpcSchemeRequestActor<TAlterVolumeRequest, TEvAlterVolumeKeyValueRequest> {
436-
public:
437-
using TBase = TRpcSchemeRequestActor<TAlterVolumeRequest, TEvAlterVolumeKeyValueRequest>;
438-
using TBase::TBase;
439-
440-
void Bootstrap(const TActorContext& ctx) {
441-
TBase::Bootstrap(ctx);
442-
Become(&TAlterVolumeRequest::StateFunc);
443-
SendProposeRequest(ctx);
444-
}
445-
446-
void SendProposeRequest(const TActorContext &ctx) {
447-
const auto req = this->GetProtoRequest();
448-
449-
std::pair<TString, TString> pathPair;
450-
try {
451-
pathPair = SplitPath(req->path());
452-
} catch (const std::exception& ex) {
453-
Request_->RaiseIssue(NYql::ExceptionToIssue(ex));
454-
return Reply(StatusIds::BAD_REQUEST, ctx);
455-
}
456-
const auto& workingDir = pathPair.first;
457-
const auto& name = pathPair.second;
458-
459-
std::unique_ptr<TEvTxUserProxy::TEvProposeTransaction> proposeRequest = this->CreateProposeTransaction();
460-
NKikimrTxUserProxy::TEvProposeTransaction& record = proposeRequest->Record;
461-
NKikimrSchemeOp::TModifyScheme* modifyScheme = record.MutableTransaction()->MutableModifyScheme();
462-
modifyScheme->SetWorkingDir(workingDir);
463-
NKikimrSchemeOp::TAlterSolomonVolume* tableDesc = nullptr;
464-
465-
modifyScheme->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpAlterSolomonVolume);
466-
tableDesc = modifyScheme->MutableAlterSolomonVolume();
467-
tableDesc->SetName(name);
468-
tableDesc->SetPartitionCount(req->alter_partition_count());
469-
470-
if (GetProtoRequest()->has_storage_config()) {
471-
tableDesc->SetUpdateChannelsBinding(true);
472-
auto &storageConfig = GetProtoRequest()->storage_config();
473-
auto *internalStorageConfig = tableDesc->MutableStorageConfig();
474-
AssignPoolKinds(storageConfig, internalStorageConfig);
475-
} else {
476-
tableDesc->SetUpdateChannelsBinding(false);
477-
tableDesc->SetChannelProfileId(0);
478-
}
479-
480-
ctx.Send(MakeTxProxyID(), proposeRequest.release());
481-
}
482-
483-
STFUNC(StateFunc) {
484-
return TBase::StateWork(ev);
485-
}
486-
};
487435

488436
template <typename TDerived>
489437
class TBaseKeyValueRequest {
@@ -621,12 +569,10 @@ class TDescribeVolumeRequest
621569
Ydb::KeyValue::DescribeVolumeResult result;
622570
result.set_path(this->GetProtoRequest()->path());
623571
result.set_partition_count(desc.PartitionsSize());
624-
if (desc.PartitionsSize() > 0) {
625-
auto *storageConfig = result.mutable_storage_config();
626-
for (auto &channel : desc.GetPartitions(0).GetBoundChannels()) {
627-
auto *channelBind = storageConfig->add_channel();
628-
channelBind->set_media(channel.GetStoragePoolName());
629-
}
572+
auto *storageConfig = result.mutable_storage_config();
573+
for (auto &channel : desc.GetBoundChannels()) {
574+
auto *channelBind = storageConfig->add_channel();
575+
channelBind->set_media(channel.GetStoragePoolName());
630576
}
631577
this->ReplyWithResult(Ydb::StatusIds::SUCCESS, result, TActivationContext::AsActorContext());
632578
}
@@ -640,6 +586,95 @@ class TDescribeVolumeRequest
640586
};
641587

642588

589+
class TAlterVolumeRequest
590+
: public TRpcSchemeRequestActor<TAlterVolumeRequest, TEvAlterVolumeKeyValueRequest>
591+
, public TBaseKeyValueRequest<TAlterVolumeRequest>
592+
{
593+
public:
594+
using TBase = TRpcSchemeRequestActor<TAlterVolumeRequest, TEvAlterVolumeKeyValueRequest>;
595+
using TBase::TBase;
596+
using TBaseKeyValueRequest::TBaseKeyValueRequest;
597+
friend class TBaseKeyValueRequest<TAlterVolumeRequest>;
598+
599+
void Bootstrap(const TActorContext& ctx) {
600+
TBase::Bootstrap(ctx);
601+
Become(&TAlterVolumeRequest::StateWork);
602+
if (GetProtoRequest()->has_storage_config()) {
603+
StorageConfig = GetProtoRequest()->storage_config();
604+
SendProposeRequest(ctx);
605+
} else {
606+
OnBootstrap();
607+
}
608+
}
609+
610+
bool ValidateRequest(Ydb::StatusIds::StatusCode& /*status*/, NYql::TIssues& /*issues*/) {
611+
return true;
612+
}
613+
614+
void SendProposeRequest(const TActorContext &ctx) {
615+
const auto req = this->GetProtoRequest();
616+
617+
std::pair<TString, TString> pathPair;
618+
try {
619+
pathPair = SplitPath(req->path());
620+
} catch (const std::exception& ex) {
621+
Request_->RaiseIssue(NYql::ExceptionToIssue(ex));
622+
return Reply(StatusIds::BAD_REQUEST, ctx);
623+
}
624+
const auto& workingDir = pathPair.first;
625+
const auto& name = pathPair.second;
626+
627+
std::unique_ptr<TEvTxUserProxy::TEvProposeTransaction> proposeRequest = this->CreateProposeTransaction();
628+
NKikimrTxUserProxy::TEvProposeTransaction& record = proposeRequest->Record;
629+
NKikimrSchemeOp::TModifyScheme* modifyScheme = record.MutableTransaction()->MutableModifyScheme();
630+
modifyScheme->SetWorkingDir(workingDir);
631+
NKikimrSchemeOp::TAlterSolomonVolume* tableDesc = nullptr;
632+
633+
modifyScheme->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpAlterSolomonVolume);
634+
tableDesc = modifyScheme->MutableAlterSolomonVolume();
635+
tableDesc->SetName(name);
636+
tableDesc->SetPartitionCount(req->alter_partition_count());
637+
638+
if (GetProtoRequest()->has_storage_config()) {
639+
tableDesc->SetUpdateChannelsBinding(true);
640+
}
641+
auto *internalStorageConfig = tableDesc->MutableStorageConfig();
642+
AssignPoolKinds(StorageConfig, internalStorageConfig);
643+
644+
ctx.Send(MakeTxProxyID(), proposeRequest.release());
645+
}
646+
647+
STFUNC(StateWork) {
648+
Cerr << "TAlterVolumeRequest::StateWork; received event: " << ev->GetTypeName() << Endl;
649+
switch (ev->GetTypeRewrite()) {
650+
hFunc(TEvTxProxySchemeCache::TEvNavigateKeySetResult, Handle);
651+
default:
652+
return TBase::StateWork(ev);
653+
}
654+
}
655+
656+
void Handle(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr &ev) {
657+
TEvTxProxySchemeCache::TEvNavigateKeySetResult* res = ev->Get();
658+
NSchemeCache::TSchemeCacheNavigate *request = res->Request.Get();
659+
660+
if (!OnNavigateKeySetResult(ev, NACLib::DescribeSchema)) {
661+
return;
662+
}
663+
664+
const NKikimrSchemeOp::TSolomonVolumeDescription &desc = request->ResultSet[0].SolomonVolumeInfo->Description;
665+
for (auto &channel : desc.GetBoundChannels()) {
666+
auto *channelBind = StorageConfig.add_channel();
667+
channelBind->set_media(channel.GetStoragePoolName());
668+
}
669+
SendProposeRequest(TActivationContext::AsActorContext());
670+
}
671+
672+
private:
673+
TIntrusiveConstPtr<NACLib::TUserToken> UserToken;
674+
Ydb::KeyValue::StorageConfig StorageConfig;
675+
};
676+
677+
643678
class TListLocalPartitionsRequest
644679
: public TRpcOperationRequestActor<TListLocalPartitionsRequest, TEvListLocalPartitionsKeyValueRequest>
645680
, public TBaseKeyValueRequest<TListLocalPartitionsRequest>

ydb/core/protos/flat_scheme_op.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,7 @@ message TSolomonVolumeDescription {
13621362
optional uint64 PathId = 2;
13631363
optional uint64 PartitionCount = 3;
13641364
repeated TPartition Partitions = 4;
1365+
repeated NKikimrStoragePool.TChannelBind BoundChannels = 5;
13651366
}
13661367

13671368
message TCreateSolomonVolume {

ydb/core/tx/schemeshard/schemeshard__operation_alter_solomon.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,17 +254,16 @@ class TAlterSolomon: public TSubOperation {
254254
return result;
255255
}
256256

257-
if (!alter.HasChannelProfileId()) {
258-
result->SetError(TEvSchemeShard::EStatus::StatusInvalidParameter, "set channel profile id, please");
259-
return result;
260-
}
261-
262257
TChannelsBindings channelsBinding;
263258
bool isResolved = false;
264259
if (alter.HasStorageConfig()) {
265260
isResolved = context.SS->ResolveSolomonChannels(alter.GetStorageConfig(), path.GetPathIdForDomain(), channelsBinding);
266261
} else {
267-
isResolved = context.SS->ResolveSolomonChannels(channelProfileId, path.GetPathIdForDomain(), channelsBinding);
262+
if (!alter.HasChannelProfileId()) {
263+
result->SetError(TEvSchemeShard::EStatus::StatusInvalidParameter, "set channel profile id, please");
264+
return result;
265+
}
266+
isResolved = context.SS->ResolveSolomonChannels(alter.GetChannelProfileId(), path.GetPathIdForDomain(), channelsBinding);
268267
}
269268
if (!isResolved) {
270269
result->SetError(NKikimrScheme::StatusInvalidParameter, "Unable to construct channel binding with the storage pool");

ydb/core/tx/schemeshard/schemeshard_path_describer.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,15 @@ void TPathDescriber::DescribeSolomonVolume(TPathId pathId, TPathElement::TPtr pa
810810
}
811811
}
812812

813+
if (solomonVolumeInfo->Partitions.size() > 0) {
814+
auto shardId = solomonVolumeInfo->Partitions.begin()->first;
815+
auto shardInfo = Self->ShardInfos.FindPtr(shardId);
816+
Y_ABORT_UNLESS(shardInfo);
817+
for (const auto& channel : shardInfo->BindedChannels) {
818+
entry->AddBoundChannels()->CopyFrom(channel);
819+
}
820+
}
821+
813822
Sort(entry->MutablePartitions()->begin(),
814823
entry->MutablePartitions()->end(),
815824
[] (auto& part1, auto& part2) {

ydb/services/keyvalue/grpc_service_ut.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ Y_UNIT_TEST_SUITE(KeyValueGRPCService) {
813813
auto describeVolumeResult = DescribeVolume(channel, tablePath);
814814
UNIT_ASSERT_VALUES_EQUAL(1, describeVolumeResult.partition_count());
815815
UNIT_ASSERT(describeVolumeResult.has_storage_config());
816+
UNIT_ASSERT_VALUES_EQUAL(describeVolumeResult.storage_config().channel_size(), 3);
816817
for (const auto& channel : describeVolumeResult.storage_config().channel()) {
817818
UNIT_ASSERT_VALUES_EQUAL(channel.media(), "ssd");
818819
}
@@ -825,6 +826,7 @@ Y_UNIT_TEST_SUITE(KeyValueGRPCService) {
825826
describeVolumeResult = DescribeVolume(channel, tablePath);
826827
UNIT_ASSERT_VALUES_EQUAL(2, describeVolumeResult.partition_count());
827828
UNIT_ASSERT(describeVolumeResult.has_storage_config());
829+
UNIT_ASSERT_VALUES_EQUAL(describeVolumeResult.storage_config().channel_size(), 3);
828830
for (const auto& channel : describeVolumeResult.storage_config().channel()) {
829831
UNIT_ASSERT_VALUES_EQUAL(channel.media(), "ssd");
830832
}

0 commit comments

Comments
 (0)