-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
#include "dsproxy.h" | ||
#include "dsproxy_mon.h" | ||
#include "dsproxy_quorum_tracker.h" | ||
#include <ydb/core/blobstorage/base/blobstorage_events.h> | ||
#include <ydb/core/blobstorage/vdisk/common/vdisk_events.h> | ||
|
||
namespace NKikimr { | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// GET BLOCK request | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
class TBlobStorageGroupGetBlockRequest : public TBlobStorageGroupRequestActor { | ||
const ui64 TabletId; | ||
ui64 Generation; | ||
const TInstant Deadline; | ||
ui64 Requests; | ||
ui64 Responses; | ||
TGroupQuorumTracker QuorumTracker; | ||
|
||
void Handle(TEvBlobStorage::TEvVGetBlockResult::TPtr &ev) { | ||
ProcessReplyFromQueue(ev->Get()); | ||
const NKikimrBlobStorage::TEvVGetBlockResult &record = ev->Get()->Record; | ||
Y_ABORT_UNLESS(record.HasStatus()); | ||
const NKikimrProto::EReplyStatus status = record.GetStatus(); | ||
Y_ABORT_UNLESS(record.HasVDiskID()); | ||
const TVDiskID vdisk = VDiskIDFromVDiskID(record.GetVDiskID()); | ||
|
||
DSP_LOG_LOG_S(PriorityForStatusInbound(status), "DSPGB01", "Handle TEvVGetBlockResult" | ||
<< " status# " << NKikimrProto::EReplyStatus_Name(status).data() | ||
<< " From# " << vdisk.ToString() | ||
<< " NodeId# " << Info->GetActorId(vdisk).NodeId()); | ||
|
||
if (record.HasGeneration()) { | ||
Generation = max(Generation, record.GetGeneration()); | ||
} | ||
++Responses; | ||
|
||
switch (const NKikimrProto::EReplyStatus overallStatus = QuorumTracker.ProcessReply(vdisk, status)) { | ||
case NKikimrProto::OK: | ||
if (Responses == Requests) { | ||
ReplyAndDie(NKikimrProto::OK); | ||
} | ||
break; | ||
|
||
case NKikimrProto::ERROR: | ||
ReplyAndDie(NKikimrProto::ERROR); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
void ReplyAndDie(NKikimrProto::EReplyStatus status) { | ||
auto result = std::make_unique<TEvBlobStorage::TEvGetBlockResult>(status); | ||
result->Generation = Generation; | ||
result->ErrorReason = ErrorReason; | ||
DSP_LOG_DEBUG_S("DSPGB02", "ReplyAndDie Result# " << result->Print(false)); | ||
SendResponseAndDie(std::move(result)); | ||
} | ||
|
||
void SendGetBlockRequest(const TVDiskID& vdiskId) { | ||
const ui64 cookie = TVDiskIdShort(vdiskId).GetRaw(); | ||
|
||
DSP_LOG_DEBUG_S("DSPB03", "Sending TEvVBlock Tablet# " << TabletId | ||
<< " Generation# " << Generation | ||
<< " vdiskId# " << vdiskId | ||
<< " node# " << Info->GetActorId(vdiskId).NodeId()); | ||
|
||
auto msg = std::make_unique<TEvBlobStorage::TEvVGetBlock>(TabletId, vdiskId, Deadline); | ||
SendToQueue(std::move(msg), cookie); | ||
} | ||
|
||
std::unique_ptr<IEventBase> RestartQuery(ui32 counter) override { | ||
++*Mon->NodeMon->RestartGetBlock; | ||
auto ev = std::make_unique<TEvBlobStorage::TEvVGetBlock>(Deadline); | ||
ev->RestartCounter = counter; | ||
return ev; | ||
} | ||
public: | ||
::NMonitoring::TDynamicCounters::TCounterPtr& GetActiveCounter() const override { | ||
return Mon->ActiveGetBlock; | ||
} | ||
|
||
ERequestType GetRequestType() const override { | ||
return ERequestType::GetBlock; | ||
} | ||
|
||
TBlobStorageGroupGetBlockRequest(TBlobStorageGroupGetBlockParameters& params) | ||
: TBlobStorageGroupRequestActor(params) | ||
, TabletId(params.Common.Event->TabletId) | ||
, Deadline(params.Common.Event->Deadline) | ||
, Requests(0) | ||
, Responses(0) | ||
, QuorumTracker(Info.Get()) | ||
{} | ||
|
||
void Bootstrap() override { | ||
DSP_LOG_INFO_S("DSPGB04", "bootstrap" | ||
<< " ActorId# " << SelfId() | ||
<< " Group# " << Info->GroupID | ||
<< " Deadline# " << Deadline | ||
<< " RestartCounter# " << RestartCounter); | ||
|
||
for (const auto& vdisk : Info->GetVDisks()) { | ||
const ui64 cookie = TVDiskIdShort(Info->GetVDiskId(vdisk.OrderNumber)).GetRaw(); | ||
|
||
auto vd = Info->GetVDiskId(vdisk.OrderNumber); | ||
DSP_LOG_DEBUG_S("DSGB05", "Sending TEvVGetBlock" | ||
<< " vDiskId# " << vd | ||
<< " node# " << Info->GetActorId(vd).NodeId()); | ||
|
||
auto msg = std::make_unique<TEvBlobStorage::TEvVGetBlock>(TabletId, vd, Deadline); | ||
SendToQueue(std::move(msg), cookie); | ||
++Requests; | ||
} | ||
|
||
Become(&TBlobStorageGroupGetBlockRequest::StateWait); | ||
|
||
if (Requests == 0) { | ||
ReplyAndDie(NKikimrProto::OK); | ||
} | ||
} | ||
|
||
STATEFN(StateWait) { | ||
if (ProcessEvent(ev)) { | ||
return; | ||
} | ||
switch (ev->GetTypeRewrite()) { | ||
hFunc(TEvBlobStorage::TEvVGetBlockResult, Handle); | ||
} | ||
} | ||
}; | ||
|
||
IActor* CreateBlobStorageGroupGetBlockRequest(TBlobStorageGroupGetBlockParameters params) { | ||
return new TBlobStorageGroupGetBlockRequest(params); | ||
} | ||
|
||
} // NKikimr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters