-
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
14 changed files
with
169 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "defs.h" | ||
|
||
#include <ydb/core/base/blobstorage.h> | ||
#include <ydb/core/protos/blobstorage.pb.h> | ||
|
||
namespace NKikimr { | ||
|
||
struct TEvBlobStorage::TEvControllerShredRequest : TEventPB<TEvControllerShredRequest, | ||
NKikimrBlobStorage::TEvControllerShredRequest, TEvBlobStorage::EvControllerShredRequest> { | ||
TEvControllerShredRequest() = default; | ||
|
||
TEvControllerShredRequest(ui64 generation) { | ||
Record.SetGeneration(generation); | ||
} | ||
}; | ||
|
||
struct TEvBlobStorage::TEvControllerShredResponse : TEventPB<TEvControllerShredResponse, | ||
NKikimrBlobStorage::TEvControllerShredResponse, TEvBlobStorage::EvControllerShredResponse> { | ||
TEvControllerShredResponse() = default; | ||
}; | ||
|
||
} |
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,40 @@ | ||
#include <ydb/core/blobstorage/ut_blobstorage/lib/env.h> | ||
#include <library/cpp/testing/unittest/registar.h> | ||
|
||
Y_UNIT_TEST_SUITE(Shred) { | ||
|
||
Y_UNIT_TEST(Basic) { | ||
TEnvironmentSetup env{{}}; | ||
env.CreateBoxAndPool(1, 1); | ||
env.Sim(TDuration::Seconds(5)); | ||
|
||
{ | ||
const TActorId self = env.Runtime->AllocateEdgeActor(env.Settings.ControllerNodeId, __FILE__, __LINE__); | ||
auto ev = std::make_unique<TEvBlobStorage::TEvControllerShredRequest>(); | ||
env.Runtime->SendToPipe(env.TabletId, self, ev.release(), 0, TTestActorSystem::GetPipeConfigWithRetries()); | ||
auto r = env.WaitForEdgeActorEvent<TEvBlobStorage::TEvControllerShredResponse>(self); | ||
UNIT_ASSERT(!r->Get()->Record.HasCurrentGeneration()); | ||
} | ||
|
||
{ | ||
const TActorId self = env.Runtime->AllocateEdgeActor(env.Settings.ControllerNodeId, __FILE__, __LINE__); | ||
auto ev = std::make_unique<TEvBlobStorage::TEvControllerShredRequest>(1); | ||
env.Runtime->SendToPipe(env.TabletId, self, ev.release(), 0, TTestActorSystem::GetPipeConfigWithRetries()); | ||
auto r = env.WaitForEdgeActorEvent<TEvBlobStorage::TEvControllerShredResponse>(self); | ||
UNIT_ASSERT_VALUES_EQUAL(r->Get()->Record.GetCurrentGeneration(), 1); | ||
UNIT_ASSERT_VALUES_EQUAL(r->Get()->Record.GetCompleted(), false); | ||
UNIT_ASSERT_VALUES_EQUAL(r->Get()->Record.GetProgress10k(), 0); | ||
} | ||
|
||
{ | ||
const TActorId self = env.Runtime->AllocateEdgeActor(env.Settings.ControllerNodeId, __FILE__, __LINE__); | ||
auto ev = std::make_unique<TEvBlobStorage::TEvControllerShredRequest>(0); | ||
env.Runtime->SendToPipe(env.TabletId, self, ev.release(), 0, TTestActorSystem::GetPipeConfigWithRetries()); | ||
auto r = env.WaitForEdgeActorEvent<TEvBlobStorage::TEvControllerShredResponse>(self); | ||
UNIT_ASSERT_VALUES_EQUAL(r->Get()->Record.GetCurrentGeneration(), 1); | ||
UNIT_ASSERT_VALUES_EQUAL(r->Get()->Record.GetCompleted(), false); | ||
UNIT_ASSERT_VALUES_EQUAL(r->Get()->Record.GetProgress10k(), 0); | ||
} | ||
} | ||
|
||
} |
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
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,63 @@ | ||
#include "impl.h" | ||
|
||
namespace NKikimr::NBsController { | ||
|
||
class TBlobStorageController::TTxUpdateShred : public TTransactionBase<TBlobStorageController> { | ||
const NKikimrBlobStorage::TEvControllerShredRequest Request; | ||
const TActorId Sender; | ||
const ui64 Cookie; | ||
const TActorId InterconnectSession; | ||
|
||
public: | ||
TTxUpdateShred(TBlobStorageController *controller, TEvBlobStorage::TEvControllerShredRequest::TPtr ev) | ||
: TTransactionBase(controller) | ||
, Request(std::move(ev->Get()->Record)) | ||
, Sender(ev->Sender) | ||
, Cookie(ev->Cookie) | ||
, InterconnectSession(ev->InterconnectSession) | ||
{} | ||
|
||
TTxType GetTxType() const override { return NBlobStorageController::TXTYPE_UPDATE_SHRED; } | ||
|
||
bool Execute(TTransactionContext& txc, const TActorContext&) override { | ||
auto& current = Self->ShredState; | ||
if (Request.HasGeneration() && (!current.HasGeneration() || current.GetGeneration() < Request.GetGeneration())) { | ||
// reset shred state to initial one with newly provided generation | ||
current.SetGeneration(Request.GetGeneration()); | ||
current.SetCompleted(false); | ||
current.SetProgress10k(0); | ||
|
||
// serialize it to string and update database | ||
TString buffer; | ||
const bool success = current.SerializeToString(&buffer); | ||
Y_ABORT_UNLESS(success); | ||
NIceDb::TNiceDb db(txc.DB); | ||
db.Table<Schema::State>().Key(true).Update<Schema::State::ShredState>(buffer); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void Complete(const TActorContext&) override { | ||
auto ev = std::make_unique<TEvBlobStorage::TEvControllerShredResponse>(); | ||
auto& r = ev->Record; | ||
const auto& current = Self->ShredState; | ||
if (current.HasGeneration()) { | ||
r.SetCurrentGeneration(current.GetGeneration()); | ||
r.SetCompleted(current.GetCompleted()); | ||
r.SetProgress10k(current.GetProgress10k()); | ||
} | ||
|
||
auto h = std::make_unique<IEventHandle>(Sender, Self->SelfId(), ev.release(), 0, Cookie); | ||
if (InterconnectSession) { | ||
h->Rewrite(TEvInterconnect::EvForward, InterconnectSession); | ||
} | ||
TActivationContext::Send(h.release()); | ||
} | ||
}; | ||
|
||
void TBlobStorageController::Handle(TEvBlobStorage::TEvControllerShredRequest::TPtr ev) { | ||
Execute(new TTxUpdateShred(this, ev)); | ||
} | ||
|
||
} // NKikimr::NBsController |
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 |
---|---|---|
|
@@ -45,6 +45,7 @@ SRCS( | |
resources.h | ||
scheme.h | ||
scrub.cpp | ||
shred.cpp | ||
select_groups.cpp | ||
select_groups.h | ||
self_heal.cpp | ||
|
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