Skip to content

Commit 2f67e0b

Browse files
committed
Straighten BSC <-> NW interoperation protocol
1 parent 80754f0 commit 2f67e0b

File tree

10 files changed

+214
-221
lines changed

10 files changed

+214
-221
lines changed

ydb/core/base/blobstorage.h

Lines changed: 29 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -786,64 +786,35 @@ struct TEvBlobStorage {
786786
EvBunchOfEvents,
787787

788788
// blobstorage controller interface
789-
// EvControllerReadSchemeString = EvPut + 11 * 512,
790-
// EvControllerReadDataString,
791-
EvControllerRegisterNode = EvPut + 11 * 512 + 2,
792-
EvControllerCreatePDisk,
793-
EvControllerCreateVDiskSlots,
794-
EvControllerCreateGroup,
795-
EvControllerSelectGroups,
796-
EvControllerGetGroup,
797-
EvControllerUpdateDiskStatus,
798-
EvControllerUpdateGroupsUsage, // Not used.
799-
EvControllerConfigRequest,
800-
EvControllerConfigResponse,
801-
EvControllerProposeRequest,
802-
EvControllerProposeResponse,
803-
EvControllerVDiskStatusSubscribeRequest,
804-
EvControllerVDiskStatusReport,
805-
EvControllerGroupStatusRequest,
806-
EvControllerGroupStatusResponse,
807-
EvControllerUpdateGroup,
808-
EvControllerUpdateFaultyDisks,
809-
EvControllerProposeGroupKey,
810-
EvControllerUpdateGroupLatencies, // Not used.
811-
EvControllerUpdateGroupStat,
812-
EvControllerNotifyGroupChange,
813-
EvControllerCommitGroupLatencies,
814-
EvControllerUpdateSelfHealInfo,
815-
EvControllerScrubQueryStartQuantum,
816-
EvControllerScrubQuantumFinished,
817-
EvControllerScrubReportQuantumInProgress,
818-
EvControllerUpdateNodeDrives,
819-
EvControllerGroupDecommittedNotify,
820-
EvControllerGroupDecommittedResponse,
821-
EvControllerGroupMetricsExchange,
822-
823-
// EvControllerReadSchemeStringResult = EvPut + 12 * 512,
824-
// EvControllerReadDataStringResult,
825-
EvControllerNodeServiceSetUpdate = EvPut + 12 * 512 + 2,
826-
EvControllerCreatePDiskResult,
827-
EvControllerCreateVDiskSlotsResult,
828-
EvControllerCreateGroupResult,
829-
EvControllerSelectGroupsResult,
830-
EvRequestControllerInfo,
831-
EvResponseControllerInfo,
832-
EvControllerGroupReconfigureReplace, // Not used.
833-
EvControllerGroupReconfigureReplaceResult, // Not used.
834-
EvControllerGroupReconfigureWipe,
835-
EvControllerGroupReconfigureWipeResult,
836-
EvControllerNodeReport,
837-
EvControllerScrubStartQuantum,
838-
839-
EvControllerMigrationPause,
840-
EvControllerMigrationContinue,
841-
EvControllerMigrationFinished,
842-
EvControllerMigrationBatch,
843-
EvControllerMigrationBatchRequest,
844-
EvControllerMigrationDone,
845-
846-
EvControllerUpdateSystemViews,
789+
EvControllerRegisterNode = 0x10031602,
790+
EvControllerSelectGroups = 0x10031606,
791+
EvControllerGetGroup = 0x10031607,
792+
EvControllerUpdateDiskStatus = 0x10031608,
793+
EvControllerConfigRequest = 0x1003160a,
794+
EvControllerConfigResponse = 0x1003160b,
795+
EvControllerProposeGroupKey = 0x10031614,
796+
EvControllerUpdateGroupStat = 0x10031616,
797+
EvControllerNotifyGroupChange = 0x10031617,
798+
EvControllerCommitGroupLatencies = 0x10031618,
799+
EvControllerUpdateSelfHealInfo = 0x10031619,
800+
EvControllerScrubQueryStartQuantum = 0x1003161a,
801+
EvControllerScrubQuantumFinished = 0x1003161b,
802+
EvControllerScrubReportQuantumInProgress = 0x1003161c,
803+
EvControllerUpdateNodeDrives = 0x1003161d,
804+
EvControllerGroupDecommittedNotify = 0x1003161e,
805+
EvControllerGroupDecommittedResponse = 0x1003161f,
806+
EvControllerGroupMetricsExchange = 0x10031620,
807+
808+
// BSC interface result section
809+
EvControllerNodeServiceSetUpdate = 0x10031802,
810+
EvControllerSelectGroupsResult = 0x10031806,
811+
EvRequestControllerInfo = 0x10031807,
812+
EvResponseControllerInfo = 0x10031808,
813+
EvControllerGroupReconfigureWipe = 0x1003180b,
814+
EvControllerGroupReconfigureWipeResult = 0x1003180c,
815+
EvControllerNodeReport = 0x1003180d,
816+
EvControllerScrubStartQuantum = 0x1003180e,
817+
EvControllerUpdateSystemViews = 0x10031815,
847818

848819
// proxy - node controller interface
849820
EvConfigureProxy = EvPut + 13 * 512,

ydb/core/blobstorage/vdisk/common/blobstorage_event_filter.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ namespace NKikimr {
5454
TEvBlobStorage::EvControllerUpdateDiskStatus,
5555
TEvBlobStorage::EvControllerConfigRequest,
5656
TEvBlobStorage::EvControllerConfigResponse,
57-
TEvBlobStorage::EvControllerVDiskStatusSubscribeRequest,
58-
TEvBlobStorage::EvControllerVDiskStatusReport,
59-
TEvBlobStorage::EvControllerGroupStatusRequest,
60-
TEvBlobStorage::EvControllerGroupStatusResponse,
61-
TEvBlobStorage::EvControllerUpdateGroup,
62-
TEvBlobStorage::EvControllerUpdateFaultyDisks,
6357
TEvBlobStorage::EvControllerUpdateGroupStat,
6458

6559
TEvBlobStorage::EvControllerSelectGroupsResult,

ydb/core/mind/bscontroller/config.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,21 @@ namespace NKikimr::NBsController {
1717
, State(state)
1818
{}
1919

20-
void Execute(std::deque<std::unique_ptr<IEventHandle>>& outbox) {
20+
void Execute() {
2121
ApplyUpdates();
2222

2323
for (auto &pair : Services) {
2424
const TNodeId &nodeId = pair.first;
2525

26-
if (TNodeInfo *node = Self->FindNode(nodeId); node && node->ConnectedCount) {
27-
auto event = MakeHolder<TEvBlobStorage::TEvControllerNodeServiceSetUpdate>();
26+
if (TNodeInfo *node = Self->FindNode(nodeId); node && node->ConnectedServerId) {
27+
auto event = std::make_unique<TEvBlobStorage::TEvControllerNodeServiceSetUpdate>();
2828
auto& record = event->Record;
2929
pair.second.Swap(&record);
3030
record.SetStatus(NKikimrProto::OK);
3131
record.SetNodeID(nodeId);
3232
record.SetInstanceId(Self->InstanceId);
3333
record.SetAvailDomain(AppData()->DomainsInfo->GetDomain()->DomainUid);
34-
outbox.push_back(std::make_unique<IEventHandle>(MakeBlobStorageNodeWardenID(nodeId),
35-
Self->SelfId(), event.Release()));
34+
State.Outbox.emplace_back(nodeId, std::move(event), 0);
3635
}
3736
}
3837
}
@@ -448,7 +447,7 @@ namespace NKikimr::NBsController {
448447
}
449448
}
450449

451-
TNodeWardenUpdateNotifier(this, state).Execute(state.Outbox);
450+
TNodeWardenUpdateNotifier(this, state).Execute();
452451

453452
state.CheckConsistency();
454453
state.Commit();
@@ -460,7 +459,7 @@ namespace NKikimr::NBsController {
460459
}
461460

462461
void TBlobStorageController::CommitSelfHealUpdates(TConfigState& state) {
463-
auto ev = MakeHolder<TEvControllerNotifyGroupChange>();
462+
auto ev = std::make_unique<TEvControllerNotifyGroupChange>();
464463
auto sh = MakeHolder<TEvControllerUpdateSelfHealInfo>();
465464

466465
for (auto&& [base, overlay] : state.Groups.Diff()) {
@@ -500,7 +499,7 @@ namespace NKikimr::NBsController {
500499
}
501500

502501
if (ev->Created || ev->Deleted) {
503-
state.Outbox.push_back(std::make_unique<IEventHandle>(StatProcessorActorId, SelfId(), ev.Release()));
502+
state.StatProcessorOutbox.push_back(std::move(ev));
504503
}
505504
if (sh->GroupsToUpdate) {
506505
FillInSelfHealGroups(*sh, &state);
@@ -590,8 +589,11 @@ namespace NKikimr::NBsController {
590589
}
591590

592591
ui64 TBlobStorageController::TConfigState::ApplyConfigUpdates() {
593-
for (auto& msg : Outbox) {
594-
TActivationContext::Send(msg.release());
592+
for (auto& [nodeId, ev, cookie] : Outbox) {
593+
Self.SendToWarden(nodeId, std::move(ev), cookie);
594+
}
595+
for (auto& ev : StatProcessorOutbox) {
596+
Self.SelfId().Send(Self.StatProcessorActorId, ev.release());
595597
}
596598

597599
if (UpdateSelfHealInfoMsg) {

ydb/core/mind/bscontroller/config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ namespace NKikimr {
9191
THashSet<TPDiskId> PDisksToRemove;
9292

9393
// outgoing messages
94-
std::deque<std::unique_ptr<IEventHandle>> Outbox;
94+
std::deque<std::tuple<TNodeId, std::unique_ptr<IEventBase>, ui64>> Outbox;
95+
std::deque<std::unique_ptr<IEventBase>> StatProcessorOutbox;
9596
THolder<TEvControllerUpdateSelfHealInfo> UpdateSelfHealInfoMsg;
9697

9798
// deferred callbacks

ydb/core/mind/bscontroller/get_group.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ namespace NKikimr::NBsController {
44

55
class TBlobStorageController::TTxGetGroup : public TTransactionBase<TBlobStorageController> {
66
TEvBlobStorage::TEvControllerGetGroup::TPtr Request;
7-
std::unique_ptr<IEventHandle> Response;
7+
std::unique_ptr<TEvBlobStorage::TEvControllerNodeServiceSetUpdate> Response;
8+
TNodeId NodeId = {};
89

910
public:
1011
TTxGetGroup(TEvBlobStorage::TEvControllerGetGroup::TPtr& ev, TBlobStorageController *controller)
@@ -20,27 +21,34 @@ class TBlobStorageController::TTxGetGroup : public TTransactionBase<TBlobStorage
2021

2122
STLOG(PRI_DEBUG, BS_CONTROLLER, BSCTXGG01, "Handle TEvControllerGetGroup", (Request, Request->Get()->Record));
2223

24+
NodeId = Request->Get()->Record.GetNodeID();
25+
26+
if (!Self->ValidateIncomingNodeWardenEvent(*Request)) {
27+
Response = std::make_unique<TEvBlobStorage::TEvControllerNodeServiceSetUpdate>(NKikimrProto::ERROR, NodeId);
28+
return true;
29+
}
30+
2331
const auto& v = Request->Get()->Record.GetGroupIDs();
2432
TSet<ui32> groupIDsToRead(v.begin(), v.end());
2533

26-
const TNodeId nodeId = Request->Get()->Record.GetNodeID();
27-
auto res = std::make_unique<TEvBlobStorage::TEvControllerNodeServiceSetUpdate>(NKikimrProto::OK, nodeId);
28-
Self->ReadGroups(groupIDsToRead, true, res.get(), nodeId);
34+
Response = std::make_unique<TEvBlobStorage::TEvControllerNodeServiceSetUpdate>(NKikimrProto::OK, NodeId);
35+
Self->ReadGroups(groupIDsToRead, true, Response.get(), NodeId);
2936

30-
auto& node = Self->GetNode(nodeId);
37+
auto& node = Self->GetNode(NodeId);
3138
for (TGroupId groupId : v) {
3239
node.GroupsRequested.insert(groupId);
33-
Self->GroupToNode.emplace(groupId, nodeId);
40+
Self->GroupToNode.emplace(groupId, NodeId);
3441
}
3542

36-
Response = std::make_unique<IEventHandle>(nodeId ? MakeBlobStorageNodeWardenID(nodeId) : Request->Sender,
37-
Self->SelfId(), res.release());
38-
3943
return true;
4044
}
4145

4246
void Complete(const TActorContext&) override {
43-
TActivationContext::Send(Response.release());
47+
if (NodeId) {
48+
Self->SendToWarden(NodeId, std::move(Response), Request->Cookie);
49+
} else {
50+
Self->SendInReply(*Request, std::move(Response));
51+
}
4452
}
4553
};
4654

Lines changed: 3 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,10 @@
11
#include "impl.h"
22

3-
namespace NKikimr {
4-
namespace NBsController {
5-
6-
class TBlobStorageController::TTxGroupReconfigureWipe : public TTransactionBase<TBlobStorageController> {
7-
protected:
8-
TEvBlobStorage::TEvControllerGroupReconfigureWipe::TPtr Event;
9-
NKikimrProto::EReplyStatus Status;
10-
TString ErrorReason;
11-
typedef TMap<TNodeId, THolder<TEvBlobStorage::TEvControllerNodeServiceSetUpdate>> TResultForNode;
12-
TResultForNode ResultForNode;
13-
14-
public:
15-
TTxGroupReconfigureWipe(TEvBlobStorage::TEvControllerGroupReconfigureWipe::TPtr &ev,
16-
TBlobStorageController *controller)
17-
: TBase(controller)
18-
, Event(ev)
19-
, Status(NKikimrProto::OK)
20-
{}
21-
22-
TTxType GetTxType() const override { return NBlobStorageController::TXTYPE_GROUP_RECONFIGURE_WIPE; }
23-
24-
bool Execute(TTransactionContext &txc, const TActorContext&) override {
25-
STLOG(PRI_DEBUG, BS_CONTROLLER, BSCTXGRW01, "TTxGroupReconfigureWipe execute");
26-
NIceDb::TNiceDb db(txc.DB);
27-
28-
Status = NKikimrProto::ERROR;
29-
ResultForNode.clear();
30-
31-
auto& record = Event->Get()->Record;
32-
const TVSlotId id(record.GetVSlotId());
33-
34-
if (TVSlotInfo *info = Self->FindVSlot(id); !info) {
35-
STLOG(PRI_ERROR, BS_CONTROLLER, BSCTXGRW02, "VSlot does not exist", (VSlotId, id));
36-
ErrorReason = TStringBuilder() << "VSlotId# " << id << " does not exist";
37-
} else if (info->Mood != TMood::Normal) { // Reply ERROR if From VSlot is improper mood
38-
STLOG(PRI_ERROR, BS_CONTROLLER, BSCTXGRW03, "VSlot is not in the 'Normal' mood", (VSlotId, id),
39-
(Mood, TMood::Name(TMood::EValue(info->Mood))));
40-
ErrorReason = TStringBuilder() << "VSlotId# " << id << " is in Mood# " << TMood::Name(TMood::EValue(info->Mood));
41-
} else {
42-
// TODO(cthulhu): Prohibit more than Max simultaneous reconfigurations on one group
43-
44-
// Mark VSlot for wipe
45-
info->Mood = TMood::Wipe;
46-
db.Table<Schema::VSlot>().Key(id.GetKey()).Update<Schema::VSlot::Mood>(info->Mood);
47-
48-
// Prepare results for nodes
49-
if (TNodeInfo *node = Self->FindNode(id.NodeId); node && node->ConnectedCount) {
50-
auto& msg = ResultForNode[id.NodeId];
51-
msg = MakeHolder<TEvBlobStorage::TEvControllerNodeServiceSetUpdate>(NKikimrProto::OK, id.NodeId);
52-
Self->ReadVSlot(*info, msg.Get());
53-
TSet<ui32> groupIDsToRead;
54-
groupIDsToRead.insert(info->GroupId);
55-
Self->ReadGroups(groupIDsToRead, false, msg.Get(), id.NodeId);
56-
for (const TGroupId groupId : groupIDsToRead) {
57-
STLOG(PRI_ERROR, BS_CONTROLLER, BSCTXGRW05, "No configuration for group", (GroupId, groupId));
58-
}
59-
}
60-
61-
Status = NKikimrProto::OK;
62-
}
63-
64-
return true;
65-
}
66-
67-
void Complete(const TActorContext&) override {
68-
// Send results to nodes
69-
if (Status == NKikimrProto::OK) {
70-
for (auto& [nodeId, msg] : ResultForNode) {
71-
// TODO(cthulhu): Availability Domain !!!
72-
const auto& node = nodeId;
73-
const auto& record = msg->Record;
74-
STLOG(PRI_DEBUG, BS_CONTROLLER, BSCTXGRW07, "Sending update", (NodeId, node), (Message, record));
75-
TActivationContext::Send(new IEventHandle(MakeBlobStorageNodeWardenID(nodeId), Self->SelfId(), msg.Release()));
76-
}
77-
}
78-
79-
// Respond
80-
auto response = MakeHolder<TEvBlobStorage::TEvControllerGroupReconfigureWipeResult>(Status, ErrorReason);
81-
auto& record = Event->Get()->Record;
82-
STLOG(Status == NKikimrProto::OK ? PRI_DEBUG : PRI_ERROR, BS_CONTROLLER, BSCTXGRW06, "TTxGroupReconfigureWipe complete",
83-
(Status, Status), (Request, record), (Response, response->Record));
84-
TActivationContext::Send(new IEventHandle(Event->Sender, Self->SelfId(), response.Release(), 0, Event->Cookie));
85-
}
86-
};
3+
namespace NKikimr::NBsController {
874

885
void TBlobStorageController::Handle(TEvBlobStorage::TEvControllerGroupReconfigureWipe::TPtr& ev) {
89-
Execute(new TTxGroupReconfigureWipe(ev, this));
6+
SendInReply(*ev, std::make_unique<TEvBlobStorage::TEvControllerGroupReconfigureWipeResult>(NKikimrProto::ERROR,
7+
"unsupported operation"));
908
}
919

9210
}
93-
}

0 commit comments

Comments
 (0)