|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <ydb/core/base/blobstorage.h> |
| 4 | +#include <ydb/core/base/defs.h> |
| 5 | +#include <ydb/core/engine/minikql/flat_local_tx_factory.h> |
| 6 | +#include <ydb/core/protos/counters_backup.pb.h> |
| 7 | +#include <ydb/core/tablet_flat/flat_cxx_database.h> |
| 8 | +#include <ydb/core/tablet_flat/tablet_flat_executed.h> |
| 9 | +#include <ydb/core/tx/replication/service/service.h> |
| 10 | + |
| 11 | +#include <ydb/library/actors/core/interconnect.h> |
| 12 | +#include <ydb/library/yverify_stream/yverify_stream.h> |
| 13 | + |
| 14 | +namespace NKikimr::NBackup { |
| 15 | + |
| 16 | +struct TBackupControllerSchema : NIceDb::Schema { |
| 17 | + struct BackupCollections : Table<1> { |
| 18 | + struct ID : Column<1, NScheme::NTypeIds::Uint32> {}; |
| 19 | + |
| 20 | + using TKey = TableKey<ID>; |
| 21 | + using TColumns = TableColumns<ID>; |
| 22 | + }; |
| 23 | + |
| 24 | + using TTables = SchemaTables<BackupCollections>; |
| 25 | + using TSettings = SchemaSettings<ExecutorLogBatching<true>, ExecutorLogFlushPeriod<TDuration::MicroSeconds(512).GetValue()>>; |
| 26 | +}; |
| 27 | + |
| 28 | +class TBackupController |
| 29 | + : public TActor<TBackupController> |
| 30 | + , public NTabletFlatExecutor::TTabletExecutedFlat |
| 31 | +{ |
| 32 | +public: |
| 33 | + class TTxBase |
| 34 | + : public NTabletFlatExecutor::TTransactionBase<TBackupController> |
| 35 | + { |
| 36 | + public: |
| 37 | + TTxBase(const TString& name, TBackupController* self) |
| 38 | + : TTransactionBase(self) |
| 39 | + , LogPrefix(name) |
| 40 | + { |
| 41 | + } |
| 42 | + |
| 43 | + protected: |
| 44 | + const TString LogPrefix; |
| 45 | + }; |
| 46 | + using Schema = TBackupControllerSchema; |
| 47 | + |
| 48 | + // local transactions |
| 49 | + class TTxInitSchema; |
| 50 | + class TTxInit; |
| 51 | + |
| 52 | + // tx runners |
| 53 | + void RunTxInitSchema(const TActorContext& ctx); |
| 54 | + void RunTxInit(const TActorContext& ctx); |
| 55 | + |
| 56 | + static constexpr NKikimrServices::TActivity::EType ActorActivityType() { |
| 57 | + return NKikimrServices::TActivity::BACKUP_CONTROLLER_TABLET; |
| 58 | + } |
| 59 | + |
| 60 | + explicit TBackupController(const TActorId& tablet, TTabletStorageInfo* info); |
| 61 | + |
| 62 | + STFUNC(StateInit); |
| 63 | + |
| 64 | + STFUNC(StateWork); |
| 65 | + |
| 66 | + void OnDetach(const TActorContext& ctx) override; |
| 67 | + |
| 68 | + void OnTabletDead(TEvTablet::TEvTabletDead::TPtr& ev, const TActorContext& ctx) override; |
| 69 | + |
| 70 | + void OnActivateExecutor(const TActorContext& ctx) override; |
| 71 | + |
| 72 | + void DefaultSignalTabletActive(const TActorContext& ctx) override; |
| 73 | + |
| 74 | + void SwitchToWork(const TActorContext& ctx); |
| 75 | + |
| 76 | + void Reset(); |
| 77 | +}; |
| 78 | + |
| 79 | +} // namespace NKikimr::NBackup |
0 commit comments