summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorilnaz <[email protected]>2022-11-15 16:01:28 +0300
committerilnaz <[email protected]>2022-11-15 16:01:28 +0300
commitec904f035bf5d3663c00ba636c43416a99f7b387 (patch)
tree86bb9505676ba9b6ae056b7db8d2fd43c56634eb
parent7acb5a7e5fb57a2e60219f301523a0dde4476401 (diff)
(refactoring) Simplify suboperations
-rw-r--r--contrib/libs/libunwind/ut/libunwind_ut.cpp29
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp49
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_bsv.cpp48
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_cdc_stream.cpp86
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_extsubdomain.cpp49
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_fs.cpp56
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_index.cpp49
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_kesus.cpp52
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_olap_store.cpp49
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_olap_table.cpp49
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp51
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_solomon.cpp48
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_subdomain.cpp49
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_table.cpp50
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_backup_restore_common.h48
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_blob_depot.cpp47
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp51
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_bsv.cpp48
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp80
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_extsubdomain.cpp48
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_fs.cpp56
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp39
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_kesus.cpp49
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_lock.cpp34
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_olap_store.cpp47
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_olap_table.cpp53
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp48
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_replication.cpp46
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp48
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_sequence.cpp47
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_solomon.cpp47
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_subdomain.cpp48
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp64
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_bsv.cpp50
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp88
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_extsubdomain.cpp50
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp56
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_index.cpp53
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_indexed_table.cpp50
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_kesus.cpp50
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_lock.cpp49
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_olap_store.cpp62
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_olap_table.cpp62
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp51
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_replication.cpp45
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_sequence.cpp52
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_solomon.cpp50
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_subdomain.cpp51
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_table.cpp53
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_unsafe.cpp55
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_finalize_build_index.cpp51
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_initiate_build_index.cpp39
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_mkdir.cpp48
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_move_index.cpp49
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp52
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp49
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_part.h67
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_split_merge.cpp49
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_upgrade_subdomain.cpp102
59 files changed, 699 insertions, 2396 deletions
diff --git a/contrib/libs/libunwind/ut/libunwind_ut.cpp b/contrib/libs/libunwind/ut/libunwind_ut.cpp
deleted file mode 100644
index 93767c50c87..00000000000
--- a/contrib/libs/libunwind/ut/libunwind_ut.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/system/compiler.h>
-
-#include <exception>
-#include <vector>
-
-Y_NO_INLINE void Except(int arg, ...) {
- (void)arg;
- throw std::exception();
-}
-
-Y_UNIT_TEST_SUITE(LibunwindSuite) {
- static void Y_NO_INLINE DoTestVarargs() {
- std::vector<int> v;
- v.push_back(0);
- Except(0x11, 0x22, 0x33, 0x44, 0xAA, 0xBB, 0xCC, 0xDD);
- }
-
- Y_UNIT_TEST(TestVarargs) {
- try {
- DoTestVarargs();
- } catch (const std::exception& e) {
- return;
- }
-
- UNIT_FAIL("Should not be here");
- }
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp
index a198dbca7a2..b19de1dddd2 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp
@@ -13,16 +13,12 @@ using namespace NKikimr;
using namespace NSchemeShard;
class TAllocatePQ: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -33,11 +29,10 @@ class TAllocatePQ: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -52,28 +47,8 @@ class TAllocatePQ: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TAllocatePQ(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TAllocatePQ(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -496,9 +471,7 @@ public:
context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_STORAGE].Add(storage);
context.SS->TabletCounters->Simple()[COUNTER_STREAM_SHARDS_COUNT].Add(partitionsToCreate);
-
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -519,17 +492,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateAllocatePQ(TOperationId id, const TTxTransaction& tx) {
- return new TAllocatePQ(id, tx);
+ return MakeSubOperation<TAllocatePQ>(id, tx);
}
ISubOperationBase::TPtr CreateAllocatePQ(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TAllocatePQ(id, state);
+ return MakeSubOperation<TAllocatePQ>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_bsv.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_bsv.cpp
index 0699e71dffe..1de23e18645 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_bsv.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_bsv.cpp
@@ -12,16 +12,12 @@ using namespace NKikimr;
using namespace NSchemeShard;
class TAlterBlockStoreVolume: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -32,11 +28,10 @@ class TAlterBlockStoreVolume: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -51,28 +46,8 @@ class TAlterBlockStoreVolume: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TAlterBlockStoreVolume(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TAlterBlockStoreVolume(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
TTxState& PrepareChanges(
TOperationId operationId, TPathElement::TPtr item,
@@ -642,8 +617,7 @@ public:
path.Base()->IncShardsInside(shardsToCreate);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -664,17 +638,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateAlterBSV(TOperationId id, const TTxTransaction& tx) {
- return new TAlterBlockStoreVolume(id, tx);
+ return MakeSubOperation<TAlterBlockStoreVolume>(id, tx);
}
ISubOperationBase::TPtr CreateAlterBSV(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TAlterBlockStoreVolume(id, state);
+ return MakeSubOperation<TAlterBlockStoreVolume>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_cdc_stream.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_cdc_stream.cpp
index 7be83c22dd8..0c95d17d926 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_cdc_stream.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_cdc_stream.cpp
@@ -6,8 +6,7 @@
#define LOG_I(stream) LOG_INFO_S (context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
#define LOG_N(stream) LOG_NOTICE_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
namespace {
@@ -77,7 +76,7 @@ class TAlterCdcStream: public TSubOperation {
return TTxState::Propose;
}
- static TTxState::ETxState NextState(TTxState::ETxState state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
switch (state) {
case TTxState::Propose:
return TTxState::Done;
@@ -86,7 +85,7 @@ class TAlterCdcStream: public TSubOperation {
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
switch (state) {
case TTxState::Propose:
return THolder(new TPropose(OperationId));
@@ -97,29 +96,8 @@ class TAlterCdcStream: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- explicit TAlterCdcStream(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- , State(TTxState::Invalid)
- {
- }
-
- explicit TAlterCdcStream(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const auto& workingDir = Transaction.GetWorkingDir();
@@ -205,9 +183,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
-
+ SetState(NextState());
return result;
}
@@ -222,11 +198,6 @@ public:
context.OnComplete.DoneOperation(OperationId);
}
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State;
-
}; // TAlterCdcStream
class TConfigurePartsAtTable: public NCdcStreamState::TConfigurePartsAtTable {
@@ -274,7 +245,7 @@ class TAlterCdcStreamAtTable: public TSubOperation {
return TTxState::ConfigureParts;
}
- static TTxState::ETxState NextState(TTxState::ETxState state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
@@ -290,7 +261,7 @@ class TAlterCdcStreamAtTable: public TSubOperation {
return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
@@ -306,29 +277,8 @@ class TAlterCdcStreamAtTable: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- explicit TAlterCdcStreamAtTable(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- , State(TTxState::Invalid)
- {
- }
-
- explicit TAlterCdcStreamAtTable(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const auto& workingDir = Transaction.GetWorkingDir();
@@ -424,9 +374,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
-
+ SetState(NextState());
return result;
}
@@ -441,29 +389,24 @@ public:
context.OnComplete.DoneOperation(OperationId);
}
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State;
-
}; // TAlterCdcStreamAtTable
} // anonymous
ISubOperationBase::TPtr CreateAlterCdcStreamImpl(TOperationId id, const TTxTransaction& tx) {
- return new TAlterCdcStream(id, tx);
+ return MakeSubOperation<TAlterCdcStream>(id, tx);
}
ISubOperationBase::TPtr CreateAlterCdcStreamImpl(TOperationId id, TTxState::ETxState state) {
- return new TAlterCdcStream(id, state);
+ return MakeSubOperation<TAlterCdcStream>(id, state);
}
ISubOperationBase::TPtr CreateAlterCdcStreamAtTable(TOperationId id, const TTxTransaction& tx) {
- return new TAlterCdcStreamAtTable(id, tx);
+ return MakeSubOperation<TAlterCdcStreamAtTable>(id, tx);
}
ISubOperationBase::TPtr CreateAlterCdcStreamAtTable(TOperationId id, TTxState::ETxState state) {
- return new TAlterCdcStreamAtTable(id, state);
+ return MakeSubOperation<TAlterCdcStreamAtTable>(id, state);
}
TVector<ISubOperationBase::TPtr> CreateAlterCdcStream(TOperationId opId, const TTxTransaction& tx, TOperationContext& context) {
@@ -542,5 +485,4 @@ TVector<ISubOperationBase::TPtr> CreateAlterCdcStream(TOperationId opId, const T
return result;
}
-} // NSchemeShard
-} // NKikimr
+}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_extsubdomain.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_extsubdomain.cpp
index 7c8ac55ef1c..d2454cd6861 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_extsubdomain.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_extsubdomain.cpp
@@ -7,7 +7,6 @@
namespace {
-
using namespace NKikimr;
using namespace NSchemeShard;
@@ -37,16 +36,12 @@ void PersistShards(NIceDb::TNiceDb& db, TTxState& txState, ui64 shardsToCreate,
}
class TAlterExtSubDomain: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -57,11 +52,10 @@ class TAlterExtSubDomain: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -76,28 +70,8 @@ class TAlterExtSubDomain: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TAlterExtSubDomain(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TAlterExtSubDomain(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -435,8 +409,7 @@ public:
path.DomainInfo()->AddInternalShards(txState);
path.Base()->IncShardsInside(shardsToCreate);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -457,17 +430,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateAlterExtSubDomain(TOperationId id, const TTxTransaction& tx) {
- return new TAlterExtSubDomain(id, tx);
+ return MakeSubOperation<TAlterExtSubDomain>(id, tx);
}
ISubOperationBase::TPtr CreateAlterExtSubDomain(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TAlterExtSubDomain(id, state);
+ return MakeSubOperation<TAlterExtSubDomain>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_fs.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_fs.cpp
index f217a459fb9..fb16ada54cd 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_fs.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_fs.cpp
@@ -194,25 +194,8 @@ public:
////////////////////////////////////////////////////////////////////////////////
class TAlterFileStore: public TSubOperation {
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
-
- TTxState::ETxState State = TTxState::Invalid;
-
public:
- TAlterFileStore(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TAlterFileStore(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(
const TString& owner,
@@ -232,22 +215,13 @@ public:
context.OnComplete.DoneOperation(OperationId);
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
private:
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -256,11 +230,10 @@ private:
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return MakeHolder<TCreateParts>(OperationId);
@@ -409,8 +382,7 @@ THolder<TProposeResponse> TAlterFileStore::Propose(
context.SS->ClearDescribePathCaches(path.Base());
context.OnComplete.PublishToSchemeBoard(OperationId, path.Base()->PathId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -561,21 +533,17 @@ void TAlterFileStore::ApplyChannelBindings(
}
}
-} // namespace
+}
-namespace NKikimr {
-namespace NSchemeShard {
-
-////////////////////////////////////////////////////////////////////////////////
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateAlterFileStore(TOperationId id, const TTxTransaction& tx) {
- return new TAlterFileStore(id, tx);
+ return MakeSubOperation<TAlterFileStore>(id, tx);
}
ISubOperationBase::TPtr CreateAlterFileStore(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TAlterFileStore(id, state);
+ return MakeSubOperation<TAlterFileStore>(id, state);
}
-} // namespace NSchemeShard
-} // namespace NKikimr
+}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_index.cpp
index 01c96432933..5c28655303b 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_index.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_index.cpp
@@ -75,16 +75,12 @@ public:
};
class TAlterTableIndex: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Propose;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Propose:
return TTxState::Done;
default:
@@ -92,8 +88,8 @@ class TAlterTableIndex: public TSubOperation {
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Propose:
return THolder(new TPropose(OperationId));
case TTxState::Done:
@@ -103,28 +99,8 @@ class TAlterTableIndex: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TAlterTableIndex(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TAlterTableIndex(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -148,7 +124,6 @@ public:
return result;
}
-
if (!tableIndexAlter.HasName()) {
result->SetError(NKikimrScheme::StatusInvalidParameter, "Name is not present in AlterTableIndex");
return result;
@@ -233,8 +208,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -258,17 +232,14 @@ public:
}
-
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateAlterTableIndex(TOperationId id, const TTxTransaction& tx) {
- return new TAlterTableIndex(id, tx);
+ return MakeSubOperation<TAlterTableIndex>(id, tx);
}
ISubOperationBase::TPtr CreateAlterTableIndex(TOperationId id, TTxState::ETxState state) {
- return new TAlterTableIndex(id, state);
+ return MakeSubOperation<TAlterTableIndex>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_kesus.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_kesus.cpp
index 6cc17c37466..22ce9189ee2 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_kesus.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_kesus.cpp
@@ -1,4 +1,3 @@
-
#include "schemeshard__operation_part.h"
#include "schemeshard__operation_common.h"
#include "schemeshard_impl.h"
@@ -8,7 +7,6 @@
namespace {
-
using namespace NKikimr;
using namespace NSchemeShard;
@@ -145,7 +143,6 @@ public:
}
};
-
class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -213,29 +210,23 @@ public:
}
};
-
class TAlterKesus: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::ConfigureParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
return TTxState::Propose;
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
return THolder(new TConfigureParts(OperationId));
@@ -246,28 +237,8 @@ class TAlterKesus: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TAlterKesus(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TAlterKesus(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
const Ydb::Coordination::Config* ParseParams(
const NKikimrSchemeOp::TKesusDescription& alter,
@@ -372,8 +343,7 @@ public:
context.SS->ClearDescribePathCaches(path.Base());
context.OnComplete.PublishToSchemeBoard(OperationId, path.Base()->PathId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -394,17 +364,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateAlterKesus(TOperationId id, const TTxTransaction& tx) {
- return new TAlterKesus(id, tx);
+ return MakeSubOperation<TAlterKesus>(id, tx);
}
ISubOperationBase::TPtr CreateAlterKesus(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TAlterKesus(id, state);
+ return MakeSubOperation<TAlterKesus>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_olap_store.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_olap_store.cpp
index 0a5158708bb..95d48ea3633 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_olap_store.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_olap_store.cpp
@@ -537,17 +537,12 @@ public:
};
class TAlterOlapStore: public TSubOperation {
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::ConfigureParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::ConfigureParts:
return TTxState::Propose;
case TTxState::Propose:
@@ -557,11 +552,10 @@ private:
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::ConfigureParts:
return THolder(new TConfigureParts(OperationId));
case TTxState::Propose:
@@ -575,28 +569,8 @@ private:
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TAlterOlapStore(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TAlterOlapStore(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -693,8 +667,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -715,17 +688,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateAlterOlapStore(TOperationId id, const TTxTransaction& tx) {
- return new TAlterOlapStore(id, tx);
+ return MakeSubOperation<TAlterOlapStore>(id, tx);
}
ISubOperationBase::TPtr CreateAlterOlapStore(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TAlterOlapStore(id, state);
+ return MakeSubOperation<TAlterOlapStore>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_olap_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_olap_table.cpp
index c5f2364d8a5..1cd9e0cc3ed 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_olap_table.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_olap_table.cpp
@@ -347,17 +347,12 @@ public:
};
class TAlterColumnTable: public TSubOperation {
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::ConfigureParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::ConfigureParts:
return TTxState::Propose;
case TTxState::Propose:
@@ -367,11 +362,10 @@ private:
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::ConfigureParts:
return THolder(new TConfigureParts(OperationId));
case TTxState::Propose:
@@ -385,28 +379,8 @@ private:
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TAlterColumnTable(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TAlterColumnTable(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -538,8 +512,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -560,17 +533,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateAlterColumnTable(TOperationId id, const TTxTransaction& tx) {
- return new TAlterColumnTable(id, tx);
+ return MakeSubOperation<TAlterColumnTable>(id, tx);
}
ISubOperationBase::TPtr CreateAlterColumnTable(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TAlterColumnTable(id, state);
+ return MakeSubOperation<TAlterColumnTable>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp
index ebc311243fe..3e69b92df0a 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp
@@ -12,16 +12,12 @@ using namespace NKikimr;
using namespace NSchemeShard;
class TAlterPQ: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -32,11 +28,10 @@ class TAlterPQ: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -51,28 +46,8 @@ class TAlterPQ: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TAlterPQ(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TAlterPQ(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
TPersQueueGroupInfo::TPtr ParseParams(
TOperationContext& context,
@@ -628,7 +603,7 @@ public:
path.DomainInfo()->AddInternalShards(txState);
path.DomainInfo()->IncPQPartitionsInside(partitionsToCreate);
path.DomainInfo()->UpdatePQReservedStorage(oldStorage, storage);
-
+ path.Base()->IncShardsInside(shardsToCreate);
context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Add(throughput);
context.SS->TabletCounters->Simple()[COUNTER_STREAM_RESERVED_THROUGHPUT].Sub(oldThroughput);
@@ -638,9 +613,7 @@ public:
context.SS->TabletCounters->Simple()[COUNTER_STREAM_SHARDS_COUNT].Add(partitionsToCreate);
- path.Base()->IncShardsInside(shardsToCreate);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -661,17 +634,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateAlterPQ(TOperationId id, const TTxTransaction& tx) {
- return new TAlterPQ(id, tx);
+ return MakeSubOperation<TAlterPQ>(id, tx);
}
ISubOperationBase::TPtr CreateAlterPQ(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TAlterPQ(id, state);
+ return MakeSubOperation<TAlterPQ>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_solomon.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_solomon.cpp
index 8bfb5f3eec1..da9256256d1 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_solomon.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_solomon.cpp
@@ -134,16 +134,12 @@ public:
};
class TAlterSolomon: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -154,11 +150,10 @@ class TAlterSolomon: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return MakeHolder<TCreateParts>(OperationId);
@@ -173,28 +168,8 @@ class TAlterSolomon: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TAlterSolomon(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TAlterSolomon(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -355,8 +330,7 @@ public:
path.DomainInfo()->AddInternalShards(txState);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -377,17 +351,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateAlterSolomon(TOperationId id, const TTxTransaction& tx) {
- return new TAlterSolomon(id, tx);
+ return MakeSubOperation<TAlterSolomon>(id, tx);
}
ISubOperationBase::TPtr CreateAlterSolomon(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TAlterSolomon(id, state);
+ return MakeSubOperation<TAlterSolomon>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_subdomain.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_subdomain.cpp
index 23b703302b7..ca3154f67a7 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_subdomain.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_subdomain.cpp
@@ -7,7 +7,6 @@
namespace {
-
using namespace NKikimr;
using namespace NSchemeShard;
@@ -37,16 +36,12 @@ void PersistShards(NIceDb::TNiceDb& db, TTxState& txState, ui64 shardsToCreate,
}
class TAlterSubDomain: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -57,11 +52,10 @@ class TAlterSubDomain: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -76,28 +70,8 @@ class TAlterSubDomain: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TAlterSubDomain(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TAlterSubDomain(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -349,8 +323,7 @@ public:
path.DomainInfo()->AddInternalShards(txState);
path.Base()->IncShardsInside(shardsToCreate);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -371,17 +344,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateAlterSubDomain(TOperationId id, const TTxTransaction& tx) {
- return new TAlterSubDomain(id, tx);
+ return MakeSubOperation<TAlterSubDomain>(id, tx);
}
ISubOperationBase::TPtr CreateAlterSubDomain(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TAlterSubDomain(id, state);
+ return MakeSubOperation<TAlterSubDomain>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_table.cpp
index 69ee1da1796..346f84e5294 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_table.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_table.cpp
@@ -404,19 +404,14 @@ public:
};
class TAlterTable: public TSubOperation {
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
bool AllowShadowData = false;
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -429,11 +424,10 @@ private:
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -450,29 +444,8 @@ private:
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TAlterTable(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TAlterTable(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
-
+ using TSubOperation::TSubOperation;
void SetAllowShadowDataForBuildIndex() {
AllowShadowData = true;
@@ -605,8 +578,7 @@ public:
table->PrepareAlter(alterData);
PrepareChanges(OperationId, path.Base(), table, bindingChanges, context);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -627,16 +599,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateAlterTable(TOperationId id, const TTxTransaction& tx) {
- return new TAlterTable(id, tx);
+ return MakeSubOperation<TAlterTable>(id, tx);
}
ISubOperationBase::TPtr CreateAlterTable(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TAlterTable(id, state);
+ return MakeSubOperation<TAlterTable>(id, state);
}
ISubOperationBase::TPtr CreateFinalizeBuildIndexImplTable(TOperationId id, const TTxTransaction& tx) {
@@ -711,4 +682,3 @@ TVector<ISubOperationBase::TPtr> CreateConsistentAlterTable(TOperationId id, con
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_backup_restore_common.h b/ydb/core/tx/schemeshard/schemeshard__operation_backup_restore_common.h
index 673e1ceedac..576163b36da 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_backup_restore_common.h
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_backup_restore_common.h
@@ -9,8 +9,7 @@
#include <util/generic/utility.h>
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
template <typename TKind>
class TConfigurePart: public TSubOperationState {
@@ -448,26 +447,23 @@ class TBackupRestoreOperationBase: public TSubOperation {
const TTxState::ETxType TxType;
const TPathElement::EPathState Lock;
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state, TOperationContext& context) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState) const override {
+ Y_FAIL("unreachable");
+ }
+
+ TTxState::ETxState NextState(TTxState::ETxState state, TOperationContext& context) const {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
-
case TTxState::ConfigureParts:
return TTxState::Propose;
-
case TTxState::Propose:
return TTxState::ProposedWaitParts;
-
case TTxState::ProposedWaitParts: {
TTxState* txState = context.SS->FindTx(OperationId);
Y_VERIFY(txState);
@@ -485,15 +481,13 @@ class TBackupRestoreOperationBase: public TSubOperation {
}
case TTxState::Aborting:
return TTxState::Done;
-
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -513,10 +507,10 @@ class TBackupRestoreOperationBase: public TSubOperation {
}
void StateDone(TOperationContext& context) override {
- State = NextState(State, context);
+ auto state = NextState(GetState(), context);
+ SetState(state);
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
+ if (state != TTxState::Invalid) {
context.OnComplete.ActivateTx(OperationId);
}
}
@@ -525,22 +519,20 @@ public:
TBackupRestoreOperationBase(
TTxState::ETxType type, TPathElement::EPathState lock,
TOperationId id, const TTxTransaction& tx)
- : TxType(type)
+ : TSubOperation(id, tx)
+ , TxType(type)
, Lock(lock)
- , OperationId(id)
- , Transaction(tx)
{
}
TBackupRestoreOperationBase(
TTxState::ETxType type, TPathElement::EPathState lock,
TOperationId id, TTxState::ETxState state)
- : TxType(type)
+ : TSubOperation(id, state)
+ , TxType(type)
, Lock(lock)
- , OperationId(id)
- , State(state)
{
- SetState(SelectStateFunc(state));
+ SetState(state);
}
void PrepareChanges(TPathElement::TPtr path, TOperationContext& context) {
@@ -642,8 +634,7 @@ public:
PrepareChanges(path.Base(), context);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -663,4 +654,3 @@ public:
};
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_blob_depot.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_blob_depot.cpp
index dc2a3eb0e6e..abad0724895 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_blob_depot.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_blob_depot.cpp
@@ -14,9 +14,6 @@ namespace NKikimr::NSchemeShard {
class TBlobDepot : public TSubOperation {
const EAction Action;
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
public:
template<TTxState::ETxState ExpectedState>
@@ -139,18 +136,16 @@ namespace NKikimr::NSchemeShard {
public:
TBlobDepot(EAction action, TOperationId id, const TTxTransaction& tx)
- : Action(action)
- , OperationId(id)
- , Transaction(tx)
+ : TSubOperation(id, tx)
+ , Action(action)
{}
TBlobDepot(EAction action, TOperationId id, TTxState::ETxState state)
- : Action(action)
- , OperationId(id)
- , State(state)
+ : TSubOperation(id, state)
+ , Action(action)
{
- Y_VERIFY(State != TTxState::Invalid);
- SetState(PickStateFunc());
+ Y_VERIFY(state != TTxState::Invalid);
+ SetState(state);
}
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
@@ -199,20 +194,19 @@ namespace NKikimr::NSchemeShard {
{{EAction::Drop, TTxState::DeleteParts}, TTxState::Propose},
};
- const auto it = stateMachine.find({Action, State});
+ const auto it = stateMachine.find({Action, GetState()});
Y_VERIFY(it != stateMachine.end());
LOG_DEBUG_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "TBlobDepot::StateDone"
<< " OperationId# " << OperationId
<< " at schemeshard# " << context.SS->TabletID()
- << " State# " << TTxState::StateName(State)
+ << " State# " << TTxState::StateName(GetState())
<< " next State# " << TTxState::StateName(it->second));
- State = it->second;
- if (State != TTxState::Invalid) {
+ if (it->second != TTxState::Invalid) {
NIceDb::TNiceDb db(context.GetDB());
- context.SS->ChangeTxState(db, OperationId, State);
- SetState(PickStateFunc());
+ context.SS->ChangeTxState(db, OperationId, it->second);
+ SetState(it->second);
context.OnComplete.ActivateTx(OperationId);
}
}
@@ -382,8 +376,7 @@ namespace NKikimr::NSchemeShard {
dstPath->IncShardsInside();
parentPath->IncAliveChildren();
- State = TTxState::CreateParts;
- SetState(PickStateFunc());
+ SetState(TTxState::CreateParts);
auto resp = MakeHolder<TProposeResponse>(NKikimrScheme::StatusAccepted, txId, ssId);
resp->SetPathId(pathId.LocalPathId);
@@ -392,15 +385,13 @@ namespace NKikimr::NSchemeShard {
THolder<TProposeResponse> ProposeAlter(const TString& owner, TOperationContext& context) {
(void)owner, (void)context;
- State = TTxState::ConfigureParts;
- SetState(PickStateFunc());
+ SetState(TTxState::ConfigureParts);
return nullptr;
}
THolder<TProposeResponse> ProposeDrop(const TString& owner, TOperationContext& context) {
(void)owner, (void)context;
- State = TTxState::DeleteParts;
- SetState(PickStateFunc());
+ SetState(TTxState::DeleteParts);
return nullptr;
}
@@ -412,7 +403,11 @@ namespace NKikimr::NSchemeShard {
}
};
- TSubOperationState::TPtr PickStateFunc() const {
+ TTxState::ETxState NextState(TTxState::ETxState) const override {
+ Y_FAIL("unreachable");
+ }
+
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
using TFactory = std::function<TSubOperationState::TPtr(TOperationId)>;
static const std::unordered_map<std::pair<EAction, TTxState::ETxState>, TFactory> FactoryMap{
{{EAction::Create, TTxState::Waiting}, TFactoryImpl<TCreateParts>()},
@@ -422,8 +417,8 @@ namespace NKikimr::NSchemeShard {
{{EAction::Create, TTxState::Done}, TFactoryImpl<TDone>()},
};
- Y_VERIFY(State != TTxState::Invalid);
- const auto it = FactoryMap.find({Action, State});
+ Y_VERIFY(state != TTxState::Invalid);
+ const auto it = FactoryMap.find({Action, state});
Y_VERIFY(it != FactoryMap.end());
return it->second(OperationId);
}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp
index 661b900a596..0c637ecad8a 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp
@@ -136,7 +136,6 @@ public:
}
};
-
class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -242,18 +241,13 @@ public:
}
};
-
class TCopyTable: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -266,11 +260,10 @@ class TCopyTable: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -287,34 +280,13 @@ class TCopyTable: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCopyTable(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TCopyTable(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
bool IsShadowDataAllowed() const {
return AppData()->AllowShadowDataInSchemeShardForTests;
}
-
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -634,8 +606,7 @@ public:
dstPath.Base()->IncShardsInside(shardsToCreate);
parent.Base()->IncAliveChildren(1, isBackup);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -670,16 +641,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateCopyTable(TOperationId id, const TTxTransaction& tx) {
- return new TCopyTable(id, tx);
+ return MakeSubOperation<TCopyTable>(id, tx);
}
ISubOperationBase::TPtr CreateCopyTable(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCopyTable(id, state);
+ return MakeSubOperation<TCopyTable>(id, state);
}
TVector<ISubOperationBase::TPtr> CreateCopyTable(TOperationId nextId, const TTxTransaction& tx, TOperationContext& context) {
@@ -778,4 +748,3 @@ TVector<ISubOperationBase::TPtr> CreateCopyTable(TOperationId nextId, const TTxT
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_bsv.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_bsv.cpp
index d071e0a4b5e..146ec6dad01 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_bsv.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_bsv.cpp
@@ -146,16 +146,12 @@ TTxState& PrepareChanges(TOperationId operationId, TPathElement::TPtr parentDir,
class TCreateBlockStoreVolume: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -166,11 +162,10 @@ class TCreateBlockStoreVolume: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return MakeHolder<TCreateParts>(OperationId);
@@ -185,28 +180,8 @@ class TCreateBlockStoreVolume: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCreateBlockStoreVolume(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TCreateBlockStoreVolume(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -394,8 +369,7 @@ public:
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -416,17 +390,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateNewBSV(TOperationId id, const TTxTransaction& tx) {
- return new TCreateBlockStoreVolume(id, tx);
+ return MakeSubOperation<TCreateBlockStoreVolume>(id, tx);
}
ISubOperationBase::TPtr CreateNewBSV(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCreateBlockStoreVolume(id, state);
+ return MakeSubOperation<TCreateBlockStoreVolume>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp
index a89b46d39c5..cbbb22301f1 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp
@@ -10,8 +10,7 @@
#define LOG_I(stream) LOG_INFO_S (context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
#define LOG_N(stream) LOG_NOTICE_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
namespace {
@@ -83,7 +82,7 @@ class TNewCdcStream: public TSubOperation {
return TTxState::Propose;
}
- static TTxState::ETxState NextState(TTxState::ETxState state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
switch (state) {
case TTxState::Propose:
return TTxState::Done;
@@ -92,7 +91,7 @@ class TNewCdcStream: public TSubOperation {
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
switch (state) {
case TTxState::Propose:
return THolder(new TPropose(OperationId));
@@ -103,29 +102,8 @@ class TNewCdcStream: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- explicit TNewCdcStream(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- , State(TTxState::Invalid)
- {
- }
-
- explicit TNewCdcStream(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const auto& workingDir = Transaction.GetWorkingDir();
@@ -263,9 +241,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
-
+ SetState(NextState());
return result;
}
@@ -281,11 +257,6 @@ public:
context.OnComplete.DoneOperation(OperationId);
}
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State;
-
}; // TNewCdcStream
class TConfigurePartsAtTable: public NCdcStreamState::TConfigurePartsAtTable {
@@ -359,7 +330,7 @@ class TNewCdcStreamAtTable: public TSubOperation {
return TTxState::ConfigureParts;
}
- static TTxState::ETxState NextState(TTxState::ETxState state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
@@ -371,11 +342,9 @@ class TNewCdcStreamAtTable: public TSubOperation {
default:
return TTxState::Invalid;
}
-
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
@@ -395,30 +364,17 @@ class TNewCdcStreamAtTable: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
explicit TNewCdcStreamAtTable(TOperationId id, const TTxTransaction& tx, bool initialScan)
- : OperationId(id)
- , Transaction(tx)
+ : TSubOperation(id, tx)
, InitialScan(initialScan)
- , State(TTxState::Invalid)
{
}
explicit TNewCdcStreamAtTable(TOperationId id, TTxState::ETxState state, bool initialScan)
- : OperationId(id)
+ : TSubOperation(id, state)
, InitialScan(initialScan)
- , State(state)
{
- SetState(SelectStateFunc(state));
}
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
@@ -531,9 +487,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
-
+ SetState(NextState());
return result;
}
@@ -550,29 +504,26 @@ public:
}
private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
const bool InitialScan;
- TTxState::ETxState State;
}; // TNewCdcStreamAtTable
} // anonymous
ISubOperationBase::TPtr CreateNewCdcStreamImpl(TOperationId id, const TTxTransaction& tx) {
- return new TNewCdcStream(id, tx);
+ return MakeSubOperation<TNewCdcStream>(id, tx);
}
ISubOperationBase::TPtr CreateNewCdcStreamImpl(TOperationId id, TTxState::ETxState state) {
- return new TNewCdcStream(id, state);
+ return MakeSubOperation<TNewCdcStream>(id, state);
}
ISubOperationBase::TPtr CreateNewCdcStreamAtTable(TOperationId id, const TTxTransaction& tx, bool initialScan) {
- return new TNewCdcStreamAtTable(id, tx, initialScan);
+ return MakeSubOperation<TNewCdcStreamAtTable>(id, tx, initialScan);
}
ISubOperationBase::TPtr CreateNewCdcStreamAtTable(TOperationId id, TTxState::ETxState state, bool initialScan) {
- return new TNewCdcStreamAtTable(id, state, initialScan);
+ return MakeSubOperation<TNewCdcStreamAtTable>(id, state, initialScan);
}
TVector<ISubOperationBase::TPtr> CreateNewCdcStream(TOperationId opId, const TTxTransaction& tx, TOperationContext& context) {
@@ -789,5 +740,4 @@ TVector<ISubOperationBase::TPtr> CreateNewCdcStream(TOperationId opId, const TTx
return result;
}
-} // NSchemeShard
-} // NKikimr
+}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_extsubdomain.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_extsubdomain.cpp
index 0f1f338ac94..a6fa948751d 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_extsubdomain.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_extsubdomain.cpp
@@ -11,16 +11,12 @@ using namespace NKikimr;
using namespace NSchemeShard;
class TCreateExtSubDomain: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Propose;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
return TTxState::Propose;
case TTxState::Propose:
@@ -28,11 +24,10 @@ class TCreateExtSubDomain: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Propose:
return THolder(new NSubDomainState::TPropose(OperationId));
@@ -43,28 +38,8 @@ class TCreateExtSubDomain: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCreateExtSubDomain(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TCreateExtSubDomain(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -296,8 +271,7 @@ public:
parentPath.DomainInfo()->IncPathsInside();
parentPath.Base()->IncAliveChildren();
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -318,17 +292,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateExtSubDomain(TOperationId id, const TTxTransaction& tx) {
- return new TCreateExtSubDomain(id, tx);
+ return MakeSubOperation<TCreateExtSubDomain>(id, tx);
}
ISubOperationBase::TPtr CreateExtSubDomain(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCreateExtSubDomain(id, state);
+ return MakeSubOperation<TCreateExtSubDomain>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_fs.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_fs.cpp
index 5a4dbfe1fef..6c667d8e648 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_fs.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_fs.cpp
@@ -198,25 +198,8 @@ public:
////////////////////////////////////////////////////////////////////////////////
class TCreateFileStore: public TSubOperation {
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
-
- TTxState::ETxState State = TTxState::Invalid;
-
public:
- TCreateFileStore(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TCreateFileStore(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(
const TString& owner,
@@ -236,22 +219,13 @@ public:
context.OnComplete.DoneOperation(OperationId);
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
private:
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -262,11 +236,10 @@ private:
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return MakeHolder<TCreateParts>(OperationId);
@@ -451,8 +424,7 @@ THolder<TProposeResponse> TCreateFileStore::Propose(
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -539,21 +511,17 @@ TTxState& TCreateFileStore::PrepareChanges(
return txState;
}
-} // namespace
+}
-namespace NKikimr {
-namespace NSchemeShard {
-
-////////////////////////////////////////////////////////////////////////////////
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateNewFileStore(TOperationId id, const TTxTransaction& tx) {
- return new TCreateFileStore(id, tx);
+ return MakeSubOperation<TCreateFileStore>(id, tx);
}
ISubOperationBase::TPtr CreateNewFileStore(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCreateFileStore(id, state);
+ return MakeSubOperation<TCreateFileStore>(id, state);
}
-} // namespace NSchemeShard
-} // namespace NKikimr
+}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp
index 3b8ff6c377c..9b2ad0d2cbb 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp
@@ -73,15 +73,11 @@ public:
};
class TCreateTableIndex: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Propose;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
switch (state) {
case TTxState::Propose:
return TTxState::Done;
@@ -90,7 +86,7 @@ class TCreateTableIndex: public TSubOperation {
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
switch (state) {
case TTxState::Propose:
return THolder(new TPropose(OperationId));
@@ -101,28 +97,8 @@ class TCreateTableIndex: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCreateTableIndex(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TCreateTableIndex(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -270,8 +246,7 @@ public:
dstPath.DomainInfo()->IncPathsInside();
parentPath.Base()->IncAliveChildren();
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -298,11 +273,11 @@ public:
namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateNewTableIndex(TOperationId id, const TTxTransaction& tx) {
- return new TCreateTableIndex(id, tx);
+ return MakeSubOperation<TCreateTableIndex>(id, tx);
}
ISubOperationBase::TPtr CreateNewTableIndex(TOperationId id, TTxState::ETxState state) {
- return new TCreateTableIndex(id, state);
+ return MakeSubOperation<TCreateTableIndex>(id, state);
}
}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_kesus.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_kesus.cpp
index 0f0913372f8..aaf631ad958 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_kesus.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_kesus.cpp
@@ -1,4 +1,3 @@
-
#include "schemeshard__operation_part.h"
#include "schemeshard__operation_common.h"
#include "schemeshard_impl.h"
@@ -251,16 +250,12 @@ public:
class TCreateKesus: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -271,11 +266,10 @@ class TCreateKesus: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -290,28 +284,8 @@ class TCreateKesus: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCreateKesus(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TCreateKesus(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -435,8 +409,7 @@ public:
dstPath.Base()->IncShardsInside();
parentPath.Base()->IncAliveChildren();
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -457,17 +430,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateNewKesus(TOperationId id, const TTxTransaction& tx) {
- return new TCreateKesus(id, tx);
+ return MakeSubOperation<TCreateKesus>(id, tx);
}
ISubOperationBase::TPtr CreateNewKesus(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCreateKesus(id, state);
+ return MakeSubOperation<TCreateKesus>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_lock.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_lock.cpp
index 88e00286e60..f10df923839 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_lock.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_lock.cpp
@@ -55,12 +55,9 @@ private:
}; // TPropose
class TCreateLock: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
const bool ProposeToCoordinator;
- TTxState::ETxState State;
- TTxState::ETxState NextState() {
+ TTxState::ETxState NextState() const {
if (ProposeToCoordinator) {
return TTxState::Propose;
} else {
@@ -68,7 +65,7 @@ class TCreateLock: public TSubOperation {
}
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
switch (state) {
case TTxState::Waiting:
return NextState();
@@ -79,7 +76,7 @@ class TCreateLock: public TSubOperation {
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
switch (state) {
case TTxState::Propose:
return THolder(new TPropose(OperationId));
@@ -90,30 +87,17 @@ class TCreateLock: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
explicit TCreateLock(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
+ : TSubOperation(id, tx)
, ProposeToCoordinator(AppData()->FeatureFlags.GetEnableChangefeedInitialScan())
- , State(TTxState::Invalid)
{
}
explicit TCreateLock(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
+ : TSubOperation(id, state)
, ProposeToCoordinator(AppData()->FeatureFlags.GetEnableChangefeedInitialScan())
- , State(state)
{
- SetState(SelectStateFunc(state));
}
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
@@ -220,9 +204,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
-
+ SetState(NextState());
return result;
}
@@ -243,12 +225,12 @@ public:
} // anonymous namespace
ISubOperationBase::TPtr CreateLock(TOperationId id, const TTxTransaction& tx) {
- return new TCreateLock(id, tx);
+ return MakeSubOperation<TCreateLock>(id, tx);
}
ISubOperationBase::TPtr CreateLock(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCreateLock(id, state);
+ return MakeSubOperation<TCreateLock>(id, state);
}
}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_olap_store.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_olap_store.cpp
index 22e0f9e17fb..a8725f32bac 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_olap_store.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_olap_store.cpp
@@ -386,16 +386,12 @@ public:
};
class TCreateOlapStore: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -408,13 +404,12 @@ class TCreateOlapStore: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
using TPtr = TSubOperationState::TPtr;
- switch(state) {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TPtr(new TCreateParts(OperationId));
@@ -431,27 +426,8 @@ class TCreateOlapStore: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCreateOlapStore(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {}
-
- TCreateOlapStore(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -647,8 +623,7 @@ public:
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -669,17 +644,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateNewOlapStore(TOperationId id, const TTxTransaction& tx) {
- return new TCreateOlapStore(id, tx);
+ return MakeSubOperation<TCreateOlapStore>(id, tx);
}
ISubOperationBase::TPtr CreateNewOlapStore(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCreateOlapStore(id, state);
+ return MakeSubOperation<TCreateOlapStore>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_olap_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_olap_table.cpp
index 61fb1e4a533..7926bbb055a 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_olap_table.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_olap_table.cpp
@@ -8,8 +8,7 @@
#include <util/random/shuffle.h>
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
namespace {
@@ -655,19 +654,15 @@ public:
};
class TCreateColumnTable: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState(bool inStore) {
+ static TTxState::ETxState NextState(bool inStore) {
if (inStore) {
return TTxState::ConfigureParts;
}
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -680,13 +675,12 @@ class TCreateColumnTable: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
using TPtr = TSubOperationState::TPtr;
- switch(state) {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TPtr(new TCreateParts(OperationId));
@@ -703,27 +697,8 @@ class TCreateColumnTable: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCreateColumnTable(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {}
-
- TCreateColumnTable(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -1002,8 +977,7 @@ public:
}
parentPath.Base()->IncAliveChildren();
- State = NextState(!!storeInfo);
- SetState(SelectStateFunc(State));
+ SetState(NextState(!!storeInfo));
return result;
}
@@ -1022,18 +996,15 @@ public:
}
};
-
-} // namespace
+}
ISubOperationBase::TPtr CreateNewColumnTable(TOperationId id, const TTxTransaction& tx) {
- return new TCreateColumnTable(id, tx);
+ return MakeSubOperation<TCreateColumnTable>(id, tx);
}
ISubOperationBase::TPtr CreateNewColumnTable(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCreateColumnTable(id, state);
+ return MakeSubOperation<TCreateColumnTable>(id, state);
}
-
-} // namespace NSchemeShard
-} // namespace NKikimr
+}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp
index b693634e984..2441d6e008f 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp
@@ -219,16 +219,12 @@ void ApplySharding(TTxId txId,
class TCreatePQ: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -239,11 +235,10 @@ class TCreatePQ: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -258,28 +253,8 @@ class TCreatePQ: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCreatePQ(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TCreatePQ(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -552,8 +527,7 @@ public:
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -574,17 +548,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateNewPQ(TOperationId id, const TTxTransaction& tx) {
- return new TCreatePQ(id, tx);
+ return MakeSubOperation<TCreatePQ>(id, tx);
}
ISubOperationBase::TPtr CreateNewPQ(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCreatePQ(id, state);
+ return MakeSubOperation<TCreatePQ>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_replication.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_replication.cpp
index b253599ace9..d3fd3081702 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_replication.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_replication.cpp
@@ -9,8 +9,7 @@
#define LOG_N(stream) LOG_NOTICE_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
#define LOG_W(stream) LOG_WARN_S (context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
namespace {
@@ -202,7 +201,7 @@ class TCreateReplication: public TSubOperation {
return TTxState::CreateParts;
}
- static TTxState::ETxState NextState(TTxState::ETxState state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
@@ -216,7 +215,7 @@ class TCreateReplication: public TSubOperation {
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
@@ -232,29 +231,8 @@ class TCreateReplication: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- explicit TCreateReplication(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- , State(TTxState::Invalid)
- {
- }
-
- explicit TCreateReplication(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const auto& workingDir = Transaction.GetWorkingDir();
@@ -437,9 +415,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
-
+ SetState(NextState());
return result;
}
@@ -454,22 +430,16 @@ public:
context.OnComplete.DoneOperation(OperationId);
}
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State;
-
}; // TCreateReplication
} // anonymous
ISubOperationBase::TPtr CreateNewReplication(TOperationId id, const TTxTransaction& tx) {
- return new TCreateReplication(id, tx);
+ return MakeSubOperation<TCreateReplication>(id, tx);
}
ISubOperationBase::TPtr CreateNewReplication(TOperationId id, TTxState::ETxState state) {
- return new TCreateReplication(id, state);
+ return MakeSubOperation<TCreateReplication>(id, state);
}
-} // NSchemeShard
-} // NKikimr
+}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp
index 0b499a861a3..077b03b4026 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp
@@ -169,16 +169,12 @@ public:
};
class TCreateRTMR: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -189,11 +185,10 @@ class TCreateRTMR: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -208,28 +203,8 @@ class TCreateRTMR: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCreateRTMR(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TCreateRTMR(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const auto ssId = context.SS->SelfTabletId();
@@ -401,8 +376,7 @@ public:
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -423,17 +397,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateNewRTMR(TOperationId id, const TTxTransaction& tx) {
- return new TCreateRTMR(id, tx);
+ return MakeSubOperation<TCreateRTMR>(id, tx);
}
ISubOperationBase::TPtr CreateNewRTMR(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCreateRTMR(id, state);
+ return MakeSubOperation<TCreateRTMR>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_sequence.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_sequence.cpp
index 4280c0a451c..8bcd790dc4e 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_sequence.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_sequence.cpp
@@ -5,8 +5,7 @@
#include <ydb/core/tx/sequenceshard/public/events.h>
#include <ydb/core/mind/hive/hive.h>
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
namespace {
@@ -244,16 +243,12 @@ public:
};
class TCreateSequence : public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -267,10 +262,10 @@ class TCreateSequence : public TSubOperation {
return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
using TPtr = TSubOperationState::TPtr;
- switch(state) {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TPtr(new TCreateParts(OperationId));
@@ -285,27 +280,8 @@ class TCreateSequence : public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCreateSequence(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {}
-
- TCreateSequence(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -519,8 +495,7 @@ public:
domainInfo->IncPathsInside();
parentPath->IncAliveChildren();
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -541,14 +516,12 @@ public:
}
-
ISubOperationBase::TPtr CreateNewSequence(TOperationId id, const TTxTransaction& tx) {
- return new TCreateSequence(id ,tx);
+ return MakeSubOperation<TCreateSequence>(id ,tx);
}
ISubOperationBase::TPtr CreateNewSequence(TOperationId id, TTxState::ETxState state) {
- return new TCreateSequence(id, state);
+ return MakeSubOperation<TCreateSequence>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_solomon.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_solomon.cpp
index 419169d4143..5ae8a3c5206 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_solomon.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_solomon.cpp
@@ -197,16 +197,12 @@ public:
};
class TCreateSolomon: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -220,8 +216,8 @@ class TCreateSolomon: public TSubOperation {
return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -236,28 +232,8 @@ class TCreateSolomon: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCreateSolomon(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TCreateSolomon(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -442,8 +418,7 @@ public:
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -464,17 +439,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateNewSolomon(TOperationId id, const TTxTransaction& tx) {
- return new TCreateSolomon(id, tx);
+ return MakeSubOperation<TCreateSolomon>(id, tx);
}
ISubOperationBase::TPtr CreateNewSolomon(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCreateSolomon(id, state);
+ return MakeSubOperation<TCreateSolomon>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_subdomain.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_subdomain.cpp
index 76a97215bc7..b7f827bb4de 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_subdomain.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_subdomain.cpp
@@ -35,16 +35,12 @@ void PersistShards(NIceDb::TNiceDb& db, TTxState& txState, TSchemeShard* ss) {
class TCreateSubDomain: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -55,11 +51,10 @@ class TCreateSubDomain: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -74,28 +69,8 @@ class TCreateSubDomain: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCreateSubDomain(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TCreateSubDomain(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -363,8 +338,7 @@ public:
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -385,17 +359,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateSubDomain(TOperationId id, const TTxTransaction& tx) {
- return new TCreateSubDomain(id, tx);
+ return MakeSubOperation<TCreateSubDomain>(id, tx);
}
ISubOperationBase::TPtr CreateSubDomain(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCreateSubDomain(id, state);
+ return MakeSubOperation<TCreateSubDomain>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp
index ed259871a05..2600a71469f 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp
@@ -349,19 +349,15 @@ public:
};
class TCreateTable: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
bool AllowShadowData = false;
THashSet<TString> LocalSequences;
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -374,11 +370,10 @@ class TCreateTable: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
@@ -395,28 +390,8 @@ class TCreateTable: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TCreateTable(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TCreateTable(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
void SetAllowShadowDataForBuildIndex() {
AllowShadowData = true;
@@ -718,8 +693,7 @@ public:
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -740,32 +714,30 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateNewTable(TOperationId id, const TTxTransaction& tx, const THashSet<TString>& localSequences) {
- auto obj = MakeHolder<TCreateTable>(id, tx);
- obj->SetLocalSequences(localSequences);
- return obj.Release();
+ auto obj = MakeSubOperation<TCreateTable>(id, tx);
+ static_cast<TCreateTable*>(obj.Get())->SetLocalSequences(localSequences);
+ return obj;
}
ISubOperationBase::TPtr CreateNewTable(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TCreateTable(id, state);
+ return MakeSubOperation<TCreateTable>(id, state);
}
ISubOperationBase::TPtr CreateInitializeBuildIndexImplTable(TOperationId id, const TTxTransaction& tx) {
- auto obj = MakeHolder<TCreateTable>(id, tx);
- obj->SetAllowShadowDataForBuildIndex();
- return obj.Release();
+ auto obj = MakeSubOperation<TCreateTable>(id, tx);
+ static_cast<TCreateTable*>(obj.Get())->SetAllowShadowDataForBuildIndex();
+ return obj;
}
ISubOperationBase::TPtr CreateInitializeBuildIndexImplTable(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- auto obj = MakeHolder<TCreateTable>(id, state);
- obj->SetAllowShadowDataForBuildIndex();
- return obj.Release();
+ auto obj = MakeSubOperation<TCreateTable>(id, state);
+ static_cast<TCreateTable*>(obj.Get())->SetAllowShadowDataForBuildIndex();
+ return obj;
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_bsv.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_bsv.cpp
index e0f8d15e5a1..28863d00941 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_bsv.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_bsv.cpp
@@ -47,7 +47,6 @@ public:
}
};
-
class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -141,29 +140,23 @@ public:
}
};
-
class TDropBlockStoreVolume: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::DeleteParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::DeleteParts:
return TTxState::Propose;
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::DeleteParts:
return THolder(new TDeleteParts(OperationId));
@@ -174,28 +167,8 @@ class TDropBlockStoreVolume: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TDropBlockStoreVolume(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TDropBlockStoreVolume(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -296,8 +269,7 @@ public:
context.OnComplete.PublishToSchemeBoard(OperationId, path.Base()->PathId);
}
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -332,17 +304,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateDropBSV(TOperationId id, const TTxTransaction& tx) {
- return new TDropBlockStoreVolume(id, tx);
+ return MakeSubOperation<TDropBlockStoreVolume>(id, tx);
}
ISubOperationBase::TPtr CreateDropBSV(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropBlockStoreVolume(id, state);
+ return MakeSubOperation<TDropBlockStoreVolume>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp
index 4bdfc8b60b5..68af5cd99fe 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp
@@ -6,8 +6,7 @@
#define LOG_I(stream) LOG_INFO_S (context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
#define LOG_N(stream) LOG_NOTICE_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
namespace {
@@ -81,7 +80,7 @@ class TDropCdcStream: public TSubOperation {
return TTxState::Propose;
}
- static TTxState::ETxState NextState(TTxState::ETxState state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
switch (state) {
case TTxState::Propose:
return TTxState::Done;
@@ -90,7 +89,7 @@ class TDropCdcStream: public TSubOperation {
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
switch (state) {
case TTxState::Propose:
return THolder(new TPropose(OperationId));
@@ -101,29 +100,8 @@ class TDropCdcStream: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- explicit TDropCdcStream(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- , State(TTxState::Invalid)
- {
- }
-
- explicit TDropCdcStream(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const auto& workingDir = Transaction.GetWorkingDir();
@@ -199,9 +177,7 @@ public:
context.OnComplete.PublishToSchemeBoard(OperationId, streamPath.Base()->PathId);
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
-
+ SetState(NextState());
return result;
}
@@ -216,11 +192,6 @@ public:
context.OnComplete.DoneOperation(OperationId);
}
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State;
-
}; // TDropCdcStream
class TConfigurePartsAtTable: public NCdcStreamState::TConfigurePartsAtTable {
@@ -264,7 +235,7 @@ class TDropCdcStreamAtTable: public TSubOperation {
return TTxState::ConfigureParts;
}
- static TTxState::ETxState NextState(TTxState::ETxState state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
@@ -276,11 +247,9 @@ class TDropCdcStreamAtTable: public TSubOperation {
default:
return TTxState::Invalid;
}
-
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
@@ -296,29 +265,8 @@ class TDropCdcStreamAtTable: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- explicit TDropCdcStreamAtTable(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- , State(TTxState::Invalid)
- {
- }
-
- explicit TDropCdcStreamAtTable(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const auto& workingDir = Transaction.GetWorkingDir();
@@ -413,9 +361,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
-
+ SetState(NextState());
return result;
}
@@ -430,29 +376,24 @@ public:
context.OnComplete.DoneOperation(OperationId);
}
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State;
-
}; // TDropCdcStreamAtTable
} // anonymous
ISubOperationBase::TPtr CreateDropCdcStreamImpl(TOperationId id, const TTxTransaction& tx) {
- return new TDropCdcStream(id, tx);
+ return MakeSubOperation<TDropCdcStream>(id, tx);
}
ISubOperationBase::TPtr CreateDropCdcStreamImpl(TOperationId id, TTxState::ETxState state) {
- return new TDropCdcStream(id, state);
+ return MakeSubOperation<TDropCdcStream>(id, state);
}
ISubOperationBase::TPtr CreateDropCdcStreamAtTable(TOperationId id, const TTxTransaction& tx) {
- return new TDropCdcStreamAtTable(id, tx);
+ return MakeSubOperation<TDropCdcStreamAtTable>(id, tx);
}
ISubOperationBase::TPtr CreateDropCdcStreamAtTable(TOperationId id, TTxState::ETxState state) {
- return new TDropCdcStreamAtTable(id, state);
+ return MakeSubOperation<TDropCdcStreamAtTable>(id, state);
}
TVector<ISubOperationBase::TPtr> CreateDropCdcStream(TOperationId opId, const TTxTransaction& tx, TOperationContext& context) {
@@ -550,5 +491,4 @@ TVector<ISubOperationBase::TPtr> CreateDropCdcStream(TOperationId opId, const TT
return result;
}
-} // NSchemeShard
-} // NKikimr
+}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_extsubdomain.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_extsubdomain.cpp
index 893d8f84e20..ecbbb04d6ec 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_extsubdomain.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_extsubdomain.cpp
@@ -133,7 +133,6 @@ public:
}
};
-
class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -208,19 +207,13 @@ public:
}
};
-
class TDropExtSubdomain: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
-
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Propose;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Propose:
return TTxState::DeleteExternalShards;
case TTxState::DeleteExternalShards:
@@ -230,11 +223,10 @@ class TDropExtSubdomain: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Propose:
return THolder(new TPropose(OperationId));
@@ -249,27 +241,8 @@ class TDropExtSubdomain: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TDropExtSubdomain(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {}
-
- TDropExtSubdomain(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -375,8 +348,7 @@ public:
context.SS->ClearDescribePathCaches(path.Base());
context.OnComplete.PublishToSchemeBoard(OperationId, path.Base()->PathId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -411,17 +383,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateFroceDropExtSubDomain(TOperationId id, const TTxTransaction& tx) {
- return new TDropExtSubdomain(id, tx);
+ return MakeSubOperation<TDropExtSubdomain>(id, tx);
}
ISubOperationBase::TPtr CreateFroceDropExtSubDomain(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropExtSubdomain(id, state);
+ return MakeSubOperation<TDropExtSubdomain>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp
index 58ff34431c7..0d6e595b674 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp
@@ -148,25 +148,8 @@ public:
////////////////////////////////////////////////////////////////////////////////
class TDropFileStore: public TSubOperation {
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
-
- TTxState::ETxState State = TTxState::Invalid;
-
public:
- TDropFileStore(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TDropFileStore(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(
const TString& owner,
@@ -201,33 +184,23 @@ public:
context.OnComplete.DoneOperation(OperationId);
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
private:
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::DeleteParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::DeleteParts:
return TTxState::Propose;
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::DeleteParts:
return MakeHolder<TDeleteParts>(OperationId);
@@ -343,26 +316,21 @@ THolder<TProposeResponse> TDropFileStore::Propose(
context.OnComplete.PublishToSchemeBoard(OperationId, path.Base()->PathId);
}
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
-} // namespace
-
-namespace NKikimr {
-namespace NSchemeShard {
+}
-////////////////////////////////////////////////////////////////////////////////
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateDropFileStore(TOperationId id, const TTxTransaction& tx) {
- return new TDropFileStore(id, tx);
+ return MakeSubOperation<TDropFileStore>(id, tx);
}
ISubOperationBase::TPtr CreateDropFileStore(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropFileStore(id, state);
+ return MakeSubOperation<TDropFileStore>(id, state);
}
-} // namespace NSchemeShard
-} // namespace NKikimr
+}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_index.cpp
index fc4d82abfef..dcface87202 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_index.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_index.cpp
@@ -212,20 +212,13 @@ public:
}
};
-
-
class TDropIndexAtMainTable: public TSubOperation {
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::ConfigureParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
return TTxState::Propose;
@@ -236,11 +229,10 @@ private:
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
return THolder(new TConfigureParts(OperationId));
@@ -255,28 +247,8 @@ private:
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TDropIndexAtMainTable(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TDropIndexAtMainTable(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -395,8 +367,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -418,19 +389,16 @@ public:
}
};
-
-
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateDropTableIndexAtMainTable(TOperationId id, TTxState::ETxState state) {
- return new TDropIndexAtMainTable(id, state);
+ return MakeSubOperation<TDropIndexAtMainTable>(id, state);
}
ISubOperationBase::TPtr CreateDropTableIndexAtMainTable(TOperationId id, const TTxTransaction& tx) {
- return new TDropIndexAtMainTable(id, tx);
+ return MakeSubOperation<TDropIndexAtMainTable>(id, tx);
}
TVector<ISubOperationBase::TPtr> CreateDropIndex(TOperationId nextId, const TTxTransaction& tx, TOperationContext& context) {
@@ -535,4 +503,3 @@ TVector<ISubOperationBase::TPtr> CreateDropIndex(TOperationId nextId, const TTxT
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_indexed_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_indexed_table.cpp
index f42f785d0e1..a07b71e8139 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_indexed_table.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_indexed_table.cpp
@@ -239,34 +239,28 @@ public:
}
};
-
class TDropTableIndex: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
TTxState::ETxState AfterPropose = TTxState::Invalid;
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Propose;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Propose:
return AfterPropose;
-
case TTxState::WaitShadowPathPublication:
return TTxState::DeletePathBarrier;
case TTxState::DeletePathBarrier:
return TTxState::Done;
-
default:
return TTxState::Invalid;
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Propose:
return THolder(new TPropose(OperationId, AfterPropose));
case TTxState::WaitShadowPathPublication:
@@ -280,28 +274,8 @@ class TDropTableIndex: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TDropTableIndex(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TDropTableIndex(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -386,8 +360,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -411,18 +384,16 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateDropTableIndex(TOperationId id, const TTxTransaction& tx) {
- return new TDropTableIndex(id, tx);
+ return MakeSubOperation<TDropTableIndex>(id, tx);
}
ISubOperationBase::TPtr CreateDropTableIndex(TOperationId id, TTxState::ETxState state) {
- return new TDropTableIndex(id, state);
+ return MakeSubOperation<TDropTableIndex>(id, state);
}
-
TVector<ISubOperationBase::TPtr> CreateDropIndexedTable(TOperationId nextId, const TTxTransaction& tx, TOperationContext& context) {
Y_VERIFY(tx.GetOperationType() == NKikimrSchemeOp::EOperationType::ESchemeOpDropTable);
@@ -579,4 +550,3 @@ TVector<ISubOperationBase::TPtr> CreateDropIndexedTable(TOperationId nextId, con
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_kesus.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_kesus.cpp
index 5dfecc2dd26..a81e323fb8a 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_kesus.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_kesus.cpp
@@ -47,7 +47,6 @@ public:
}
};
-
class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -136,29 +135,23 @@ public:
}
};
-
class TDropKesus: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::DeleteParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::DeleteParts:
return TTxState::Propose;
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::DeleteParts:
return THolder(new TDeleteParts(OperationId));
@@ -169,28 +162,8 @@ class TDropKesus: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TDropKesus(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TDropKesus(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -284,8 +257,7 @@ public:
context.OnComplete.PublishToSchemeBoard(OperationId, path.Base()->PathId);
}
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -320,17 +292,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateDropKesus(TOperationId id, const TTxTransaction& tx) {
- return new TDropKesus(id, tx);
+ return MakeSubOperation<TDropKesus>(id, tx);
}
ISubOperationBase::TPtr CreateDropKesus(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropKesus(id, state);
+ return MakeSubOperation<TDropKesus>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_lock.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_lock.cpp
index bbbebf76c73..e6b1091e7c7 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_lock.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_lock.cpp
@@ -11,28 +11,22 @@ namespace {
using namespace NKikimr;
using namespace NSchemeShard;
-
class TDropLock: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Done;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
return TTxState::Done;
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Done:
return MakeHolder<TDone>(OperationId);
@@ -41,28 +35,8 @@ class TDropLock: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TDropLock(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TDropLock(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -177,8 +151,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -199,17 +172,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr DropLock(TOperationId id, const TTxTransaction& tx) {
- return new TDropLock(id, tx);
+ return MakeSubOperation<TDropLock>(id, tx);
}
ISubOperationBase::TPtr DropLock(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropLock(id, state);
+ return MakeSubOperation<TDropLock>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_olap_store.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_olap_store.cpp
index b6432ba1358..e5a34f2acd6 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_olap_store.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_olap_store.cpp
@@ -4,12 +4,11 @@
#include <ydb/core/base/subdomain.h>
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
namespace {
-class TDropParts : public TSubOperationState {
+class TDropParts: public TSubOperationState {
private:
TOperationId OperationId;
@@ -48,7 +47,7 @@ public:
}
};
-class TPropose : public TSubOperationState {
+class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -132,7 +131,7 @@ public:
}
};
-class TProposedWaitParts : public TSubOperationState {
+class TProposedWaitParts: public TSubOperationState {
private:
TOperationId OperationId;
@@ -207,7 +206,7 @@ public:
}
};
-class TProposedDeleteParts : public TSubOperationState {
+class TProposedDeleteParts: public TSubOperationState {
private:
TOperationId OperationId;
@@ -252,21 +251,10 @@ public:
}
};
-class TDropOlapStore : public TSubOperation {
+class TDropOlapStore: public TSubOperation {
public:
- TDropOlapStore(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {}
+ using TSubOperation::TSubOperation;
- TDropOlapStore(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
-
-public:
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -392,8 +380,7 @@ public:
context.OnComplete.PublishToSchemeBoard(OperationId, path.Base()->PathId);
}
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -424,12 +411,12 @@ public:
}
private:
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::DropParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::DropParts:
return TTxState::Propose;
case TTxState::Propose:
@@ -441,8 +428,8 @@ private:
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::DropParts:
return MakeHolder<TDropParts>(OperationId);
case TTxState::Propose:
@@ -455,32 +442,17 @@ private:
return nullptr;
}
}
-
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
-private:
- const TOperationId OperationId;
- TTxState::ETxState State = TTxState::Invalid;
- const NKikimrSchemeOp::TModifyScheme Transaction;
};
-} // namespace
+}
ISubOperationBase::TPtr CreateDropOlapStore(TOperationId id, const TTxTransaction& tx) {
- return new TDropOlapStore(id, tx);
+ return MakeSubOperation<TDropOlapStore>(id, tx);
}
ISubOperationBase::TPtr CreateDropOlapStore(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropOlapStore(id, state);
+ return MakeSubOperation<TDropOlapStore>(id, state);
}
-} // namespace NSchemeShard
-} // namespace NKikimr
+}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_olap_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_olap_table.cpp
index 7007d345228..8a76c76eb5a 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_olap_table.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_olap_table.cpp
@@ -5,12 +5,11 @@
#include <ydb/core/base/subdomain.h>
#include <ydb/core/tx/tiering/cleaner_task.h>
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
namespace {
-class TDropParts : public TSubOperationState {
+class TDropParts: public TSubOperationState {
private:
TOperationId OperationId;
@@ -88,7 +87,7 @@ public:
}
};
-class TPropose : public TSubOperationState {
+class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -177,7 +176,7 @@ public:
}
};
-class TProposedWaitParts : public TSubOperationState {
+class TProposedWaitParts: public TSubOperationState {
private:
TOperationId OperationId;
@@ -252,7 +251,7 @@ public:
}
};
-class TProposedDeleteParts : public TSubOperationState {
+class TProposedDeleteParts: public TSubOperationState {
private:
TOperationId OperationId;
@@ -328,21 +327,10 @@ public:
}
};
-class TDropColumnTable : public TSubOperation {
+class TDropColumnTable: public TSubOperation {
public:
- TDropColumnTable(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {}
+ using TSubOperation::TSubOperation;
- TDropColumnTable(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
-
-public:
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -498,8 +486,7 @@ public:
context.OnComplete.PublishToSchemeBoard(OperationId, path.Base()->PathId);
}
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -530,12 +517,12 @@ public:
}
private:
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::DropParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::DropParts:
return TTxState::Propose;
case TTxState::Propose:
@@ -547,8 +534,8 @@ private:
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::DropParts:
return MakeHolder<TDropParts>(OperationId);
case TTxState::Propose:
@@ -561,32 +548,17 @@ private:
return nullptr;
}
}
-
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
-private:
- const TOperationId OperationId;
- TTxState::ETxState State = TTxState::Invalid;
- const NKikimrSchemeOp::TModifyScheme Transaction;
};
-} // namespace
+}
ISubOperationBase::TPtr CreateDropColumnTable(TOperationId id, const TTxTransaction& tx) {
- return new TDropColumnTable(id, tx);
+ return MakeSubOperation<TDropColumnTable>(id, tx);
}
ISubOperationBase::TPtr CreateDropColumnTable(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropColumnTable(id, state);
+ return MakeSubOperation<TDropColumnTable>(id, state);
}
-} // namespace NSchemeShard
-} // namespace NKikimr
+}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp
index 9515509f7ae..09d3b048e6b 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp
@@ -118,7 +118,6 @@ public:
}
};
-
class TDeleteParts: public TSubOperationState {
private:
TOperationId OperationId;
@@ -158,7 +157,6 @@ public:
};
-
class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -273,18 +271,13 @@ public:
}
};
-
class TDropPQ: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::DropParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::DropParts:
return TTxState::DeleteParts;
@@ -295,11 +288,10 @@ class TDropPQ: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::DropParts:
return THolder(new TDropParts(OperationId));
@@ -314,28 +306,8 @@ class TDropPQ: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TDropPQ(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TDropPQ(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
void SetPQBalancer(TPersQueueGroupInfo::TPtr pqGroup, TTxState& txState, TOperationContext& context) {
auto shardId = pqGroup->BalancerShardIdx;
@@ -504,8 +476,7 @@ public:
context.OnComplete.PublishToSchemeBoard(OperationId, path.Base()->PathId);
}
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -540,17 +511,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateDropPQ(TOperationId id, const TTxTransaction& tx) {
- return new TDropPQ(id, tx);
+ return MakeSubOperation<TDropPQ>(id, tx);
}
ISubOperationBase::TPtr CreateDropPQ(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropPQ(id, state);
+ return MakeSubOperation<TDropPQ>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_replication.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_replication.cpp
index adf0077549e..bfedbcd7b9b 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_replication.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_replication.cpp
@@ -9,8 +9,7 @@
#define LOG_N(stream) LOG_NOTICE_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
#define LOG_W(stream) LOG_WARN_S (context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "[" << context.SS->TabletID() << "] " << stream)
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
namespace {
@@ -188,7 +187,7 @@ class TDropReplication: public TSubOperation {
return TTxState::DropParts;
}
- static TTxState::ETxState NextState(TTxState::ETxState state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
switch (state) {
case TTxState::DropParts:
return TTxState::Propose;
@@ -199,7 +198,7 @@ class TDropReplication: public TSubOperation {
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
switch (state) {
case TTxState::DropParts:
return MakeHolder<TDropParts>(OperationId);
@@ -212,28 +211,8 @@ class TDropReplication: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
public:
- explicit TDropReplication(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- , State(TTxState::Invalid)
- {
- }
-
- explicit TDropReplication(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const auto& workingDir = Transaction.GetWorkingDir();
@@ -337,9 +316,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
-
+ SetState(NextState());
return result;
}
@@ -354,22 +331,16 @@ public:
context.OnComplete.DoneOperation(OperationId);
}
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State;
-
}; // TDropReplication
} // anonymous
ISubOperationBase::TPtr CreateDropReplication(TOperationId id, const TTxTransaction& tx) {
- return new TDropReplication(id, tx);
+ return MakeSubOperation<TDropReplication>(id, tx);
}
ISubOperationBase::TPtr CreateDropReplication(TOperationId id, TTxState::ETxState state) {
- return new TDropReplication(id, state);
+ return MakeSubOperation<TDropReplication>(id, state);
}
-} // NSchemeShard
-} // NKikimr
+}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_sequence.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_sequence.cpp
index a7b31d80f3d..93285d5ae77 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_sequence.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_sequence.cpp
@@ -4,12 +4,11 @@
#include <ydb/core/tx/sequenceshard/public/events.h>
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
namespace {
-class TDropParts : public TSubOperationState {
+class TDropParts: public TSubOperationState {
private:
TOperationId OperationId;
@@ -125,7 +124,7 @@ public:
}
};
-class TPropose : public TSubOperationState {
+class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -209,17 +208,13 @@ public:
}
};
-class TDropSequence : public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+class TDropSequence: public TSubOperation {
+ static TTxState::ETxState NextState() {
return TTxState::DropParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::DropParts:
return TTxState::Propose;
case TTxState::Propose:
@@ -229,8 +224,8 @@ class TDropSequence : public TSubOperation {
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::DropParts:
return MakeHolder<TDropParts>(OperationId);
case TTxState::Propose:
@@ -242,27 +237,8 @@ class TDropSequence : public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TDropSequence(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {}
-
- TDropSequence(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -399,8 +375,7 @@ public:
context.OnComplete.PublishToSchemeBoard(OperationId, path->PathId);
}
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -434,12 +409,11 @@ public:
}
ISubOperationBase::TPtr CreateDropSequence(TOperationId id, const TTxTransaction& tx) {
- return new TDropSequence(id ,tx);
+ return MakeSubOperation<TDropSequence>(id ,tx);
}
ISubOperationBase::TPtr CreateDropSequence(TOperationId id, TTxState::ETxState state) {
- return new TDropSequence(id, state);
+ return MakeSubOperation<TDropSequence>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_solomon.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_solomon.cpp
index 9dd7444649b..ce683ddbb4c 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_solomon.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_solomon.cpp
@@ -45,7 +45,6 @@ public:
}
};
-
class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -120,29 +119,23 @@ public:
}
};
-
class TDropSolomon: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Propose;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Propose:
return TTxState::ProposedDeleteParts;
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Propose:
return THolder(new TPropose(OperationId));
@@ -153,28 +146,8 @@ class TDropSolomon: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TDropSolomon(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TDropSolomon(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -268,8 +241,7 @@ public:
context.OnComplete.PublishToSchemeBoard(OperationId, path.Base()->PathId);
}
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -304,17 +276,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateDropSolomon(TOperationId id, const TTxTransaction& tx) {
- return new TDropSolomon(id, tx);
+ return MakeSubOperation<TDropSolomon>(id, tx);
}
ISubOperationBase::TPtr CreateDropSolomon(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropSolomon(id, state);
+ return MakeSubOperation<TDropSolomon>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_subdomain.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_subdomain.cpp
index 3e6f4cb9b87..71dc2671077 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_subdomain.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_subdomain.cpp
@@ -45,7 +45,6 @@ public:
}
};
-
class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -113,29 +112,23 @@ public:
}
};
-
class TDropSubdomain: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Propose;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Propose:
return TTxState::ProposedDeleteParts;
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Propose:
return THolder(new TPropose(OperationId));
@@ -146,28 +139,8 @@ class TDropSubdomain: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TDropSubdomain(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TDropSubdomain(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -261,9 +234,7 @@ public:
context.SS->ClearDescribePathCaches(path.Base());
context.OnComplete.PublishToSchemeBoard(OperationId, path.Base()->PathId);
-
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -299,17 +270,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateDropSubdomain(TOperationId id, const TTxTransaction& tx) {
- return new TDropSubdomain(id, tx);
+ return MakeSubOperation<TDropSubdomain>(id, tx);
}
ISubOperationBase::TPtr CreateDropSubdomain(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropSubdomain(id, state);
+ return MakeSubOperation<TDropSubdomain>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_table.cpp
index 86cd86a0e4d..8f6efb5b544 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_table.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_table.cpp
@@ -312,7 +312,6 @@ public:
}
};
-
class TDeleteTableBarrier: public TSubOperationState {
private:
TOperationId OperationId;
@@ -380,7 +379,6 @@ public:
}
};
-
class TProposedDeletePart: public TSubOperationState {
private:
TOperationId OperationId;
@@ -436,40 +434,32 @@ public:
};
class TDropTable: public TSubOperation {
-private:
- const TOperationId OperationId;
- TTxState::ETxState State = TTxState::Invalid;
TTxState::ETxState AfterPropose = TTxState::Invalid;
- const NKikimrSchemeOp::TModifyScheme Transaction;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::DropParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::DropParts:
return TTxState::Propose;
case TTxState::Propose:
return AfterPropose;
-
case TTxState::WaitShadowPathPublication:
return TTxState::DeletePathBarrier;
case TTxState::DeletePathBarrier:
return TTxState::ProposedWaitParts;
-
case TTxState::ProposedWaitParts:
return TTxState::ProposedDeleteParts;
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::DropParts:
return MakeHolder<TDropParts>(OperationId);
@@ -489,27 +479,8 @@ private:
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TDropTable(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {}
-
- TDropTable(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -637,9 +608,9 @@ public:
context.OnComplete.Dependence(splitTx.GetTxId(), OperationId.GetTxId());
}
- State = NextState();
- SetState(SelectStateFunc(State));
context.OnComplete.ActivateTx(OperationId);
+
+ SetState(NextState());
return result;
}
@@ -677,17 +648,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateDropTable(TOperationId id, const TTxTransaction& tx) {
- return new TDropTable(id, tx);
+ return MakeSubOperation<TDropTable>(id, tx);
}
ISubOperationBase::TPtr CreateDropTable(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropTable(id, state);
+ return MakeSubOperation<TDropTable>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_unsafe.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_unsafe.cpp
index 86dbbc7bbe3..86c38cf3c0c 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_unsafe.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_unsafe.cpp
@@ -45,7 +45,6 @@ public:
}
};
-
class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -122,30 +121,24 @@ public:
}
};
-
class TDropForceUnsafe: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
-
- TTxState::ETxState State = TTxState::Invalid;
TPathElement::EPathType ExpectedType = TPathElement::EPathType::EPathTypeInvalid;
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Propose;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Propose:
return TTxState::ProposedDeleteParts;
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Propose:
return MakeHolder<TPropose>(OperationId);
@@ -156,27 +149,16 @@ class TDropForceUnsafe: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TDropForceUnsafe(TOperationId id, const TTxTransaction& tx, TPathElement::EPathType expectedType)
- : OperationId(id)
- , Transaction(tx)
+ explicit TDropForceUnsafe(const TOperationId& id, const TTxTransaction& tx, TPathElement::EPathType expectedType)
+ : TSubOperation(id, tx)
, ExpectedType(expectedType)
- {}
+ {
+ }
- TDropForceUnsafe(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
+ explicit TDropForceUnsafe(const TOperationId& id, TTxState::ETxState state)
+ : TSubOperation(id, state)
{
- SetState(SelectStateFunc(state));
}
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
@@ -311,8 +293,7 @@ public:
context.OnComplete.PublishToSchemeBoard(OperationId, path.Base()->PathId);
}
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -347,26 +328,24 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateFroceDropUnsafe(TOperationId id, const TTxTransaction& tx) {
- return new TDropForceUnsafe(id, tx, TPathElement::EPathType::EPathTypeInvalid);
+ return MakeSubOperation<TDropForceUnsafe>(id, tx, TPathElement::EPathType::EPathTypeInvalid);
}
ISubOperationBase::TPtr CreateFroceDropUnsafe(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropForceUnsafe(id, state);
+ return MakeSubOperation<TDropForceUnsafe>(id, state);
}
ISubOperationBase::TPtr CreateFroceDropSubDomain(TOperationId id, const TTxTransaction& tx) {
- return new TDropForceUnsafe(id, tx, TPathElement::EPathType::EPathTypeSubDomain);
+ return MakeSubOperation<TDropForceUnsafe>(id, tx, TPathElement::EPathType::EPathTypeSubDomain);
}
ISubOperationBase::TPtr CreateFroceDropSubDomain(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TDropForceUnsafe(id, state);
+ return MakeSubOperation<TDropForceUnsafe>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_finalize_build_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_finalize_build_index.cpp
index 20f8f7090b2..18c73a5c146 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_finalize_build_index.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_finalize_build_index.cpp
@@ -108,7 +108,6 @@ public:
}
};
-
class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
@@ -203,7 +202,6 @@ public:
}
};
-
class TCreateTxShards: public TSubOperationState {
private:
TOperationId OperationId;
@@ -249,18 +247,13 @@ public:
}
};
-
class TFinalizeBuildIndex: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return TTxState::ConfigureParts;
@@ -273,11 +266,10 @@ class TFinalizeBuildIndex: public TSubOperation {
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
return THolder(new TCreateTxShards(OperationId));
@@ -294,28 +286,8 @@ class TFinalizeBuildIndex: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TFinalizeBuildIndex(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TFinalizeBuildIndex(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -426,8 +398,7 @@ public:
context.SS->ChangeTxState(db, OperationId, TTxState::CreateParts);
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -448,17 +419,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateFinalizeBuildIndexMainTable(TOperationId id, const TTxTransaction& tx) {
- return new TFinalizeBuildIndex(id, tx);
+ return MakeSubOperation<TFinalizeBuildIndex>(id, tx);
}
ISubOperationBase::TPtr CreateFinalizeBuildIndexMainTable(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TFinalizeBuildIndex(id, state);
+ return MakeSubOperation<TFinalizeBuildIndex>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_initiate_build_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_initiate_build_index.cpp
index facc70a2c81..8b8f803cbdb 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_initiate_build_index.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_initiate_build_index.cpp
@@ -261,15 +261,11 @@ public:
};
class TInitializeBuildIndex: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
@@ -285,7 +281,7 @@ class TInitializeBuildIndex: public TSubOperation {
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
switch (state) {
case TTxState::Waiting:
case TTxState::CreateParts:
@@ -303,28 +299,8 @@ class TInitializeBuildIndex: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TInitializeBuildIndex(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TInitializeBuildIndex(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -427,8 +403,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -456,12 +431,12 @@ public:
namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateInitializeBuildIndexMainTable(TOperationId id, const TTxTransaction& tx) {
- return new TInitializeBuildIndex(id, tx);
+ return MakeSubOperation<TInitializeBuildIndex>(id, tx);
}
ISubOperationBase::TPtr CreateInitializeBuildIndexMainTable(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TInitializeBuildIndex(id, state);
+ return MakeSubOperation<TInitializeBuildIndex>(id, state);
}
}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_mkdir.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_mkdir.cpp
index 1dbd4f46863..764b925cb5d 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_mkdir.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_mkdir.cpp
@@ -71,27 +71,22 @@ public:
};
class TMkDir: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Propose;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Propose:
return TTxState::Done;
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Propose:
return THolder(new TPropose(OperationId));
@@ -102,28 +97,8 @@ class TMkDir: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TMkDir(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TMkDir(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
const auto ssId = context.SS->SelfTabletId();
@@ -260,8 +235,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -285,17 +259,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateMkDir(TOperationId id, const TTxTransaction& tx) {
- return new TMkDir(id, tx);
+ return MakeSubOperation<TMkDir>(id, tx);
}
ISubOperationBase::TPtr CreateMkDir(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TMkDir(id, state);
+ return MakeSubOperation<TMkDir>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_index.cpp
index 9b972d70252..e917443c3a4 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_move_index.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_index.cpp
@@ -315,16 +315,12 @@ public:
};
class TUpdateMainTableOnIndexMove: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::ConfigureParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
return TTxState::Propose;
@@ -332,17 +328,15 @@ class TUpdateMainTableOnIndexMove: public TSubOperation {
return TTxState::DeletePathBarrier;
case TTxState::DeletePathBarrier:
return TTxState::ProposedWaitParts;
-
case TTxState::ProposedWaitParts:
return TTxState::Done;
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
return MakeHolder<TConfigureParts>(OperationId);
@@ -359,28 +353,8 @@ class TUpdateMainTableOnIndexMove: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TUpdateMainTableOnIndexMove(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TUpdateMainTableOnIndexMove(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -465,8 +439,7 @@ public:
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -491,8 +464,7 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
TVector<ISubOperationBase::TPtr> CreateConsistentMoveIndex(TOperationId nextId, const TTxTransaction& tx, TOperationContext& context) {
Y_VERIFY(tx.GetOperationType() == NKikimrSchemeOp::EOperationType::ESchemeOpMoveIndex);
@@ -646,12 +618,11 @@ TVector<ISubOperationBase::TPtr> CreateConsistentMoveIndex(TOperationId nextId,
}
ISubOperationBase::TPtr CreateUpdateMainTableOnIndexMove(TOperationId id, const TTxTransaction& tx) {
- return new TUpdateMainTableOnIndexMove(id, tx);
+ return MakeSubOperation<TUpdateMainTableOnIndexMove>(id, tx);
}
ISubOperationBase::TPtr CreateUpdateMainTableOnIndexMove(TOperationId id, TTxState::ETxState state) {
- return new TUpdateMainTableOnIndexMove(id, state);
+ return MakeSubOperation<TUpdateMainTableOnIndexMove>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp
index 86618ee86c1..4602fcb9775 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp
@@ -358,7 +358,6 @@ public:
}
};
-
class TDeleteTableBarrier: public TSubOperationState {
private:
TOperationId OperationId;
@@ -427,7 +426,6 @@ public:
}
};
-
class TDone: public TSubOperationState {
private:
TOperationId OperationId;
@@ -490,40 +488,33 @@ public:
}
};
-
class TMoveTable: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
TTxState::ETxState AfterPropose = TTxState::Invalid;
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::ConfigureParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
return TTxState::Propose;
case TTxState::Propose:
return AfterPropose;
-
case TTxState::WaitShadowPathPublication:
return TTxState::DeletePathBarrier;
case TTxState::DeletePathBarrier:
return TTxState::ProposedWaitParts;
-
case TTxState::ProposedWaitParts:
return TTxState::Done;
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::ConfigureParts:
return MakeHolder<TConfigureParts>(OperationId);
@@ -542,28 +533,8 @@ class TMoveTable: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TMoveTable(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TMoveTable(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -743,9 +714,8 @@ public:
}
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -769,17 +739,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateMoveTable(TOperationId id, const TTxTransaction& tx) {
- return new TMoveTable(id, tx);
+ return MakeSubOperation<TMoveTable>(id, tx);
}
ISubOperationBase::TPtr CreateMoveTable(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TMoveTable(id, state);
+ return MakeSubOperation<TMoveTable>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp
index 8dc24dc4f3b..465f49a3ba9 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp
@@ -295,34 +295,28 @@ public:
};
class TMoveTableIndex: public TSubOperation {
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
TTxState::ETxState AfterPropose = TTxState::Invalid;
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Propose;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Propose:
return AfterPropose;
-
case TTxState::WaitShadowPathPublication:
return TTxState::DeletePathBarrier;
case TTxState::DeletePathBarrier:
return TTxState::Done;
-
default:
return TTxState::Invalid;
}
- return TTxState::Invalid;
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Propose:
return MakeHolder<TPropose>(OperationId, AfterPropose);
@@ -337,28 +331,8 @@ class TMoveTableIndex: public TSubOperation {
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TMoveTableIndex(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TMoveTableIndex(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -548,9 +522,8 @@ public:
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, srcPath, context.SS, context.OnComplete);
context.OnComplete.ActivateTx(OperationId);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -574,17 +547,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateMoveTableIndex(TOperationId id, const TTxTransaction& tx) {
- return new TMoveTableIndex(id, tx);
+ return MakeSubOperation<TMoveTableIndex>(id, tx);
}
ISubOperationBase::TPtr CreateMoveTableIndex(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TMoveTableIndex(id, state);
+ return MakeSubOperation<TMoveTableIndex>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_part.h b/ydb/core/tx/schemeshard/schemeshard__operation_part.h
index 593d68c8dcb..f5b12ede622 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_part.h
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_part.h
@@ -231,37 +231,82 @@ public:
};
class TSubOperation: public ISubOperationBase {
+protected:
+ const TOperationId OperationId;
+ const TTxTransaction Transaction;
+
private:
+ TTxState::ETxState State = TTxState::Invalid;
TSubOperationState::TPtr Base = nullptr;
+protected:
+ virtual TTxState::ETxState NextState(TTxState::ETxState state) const = 0;
+ virtual TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) = 0;
+
+ virtual void StateDone(TOperationContext& context) {
+ auto state = NextState(GetState());
+ SetState(state);
+
+ if (state != TTxState::Invalid) {
+ context.OnComplete.ActivateTx(OperationId);
+ }
+ }
+
public:
- virtual void StateDone(TOperationContext& context) = 0;
+ explicit TSubOperation(const TOperationId& id, const TTxTransaction& tx)
+ : OperationId(id)
+ , Transaction(tx)
+ {
+ }
- void SetState(TSubOperationState::TPtr state) {
- Base = std::move(state);
+ explicit TSubOperation(const TOperationId& id, TTxState::ETxState state)
+ : OperationId(id)
+ , State(state)
+ {
+ }
+
+ TTxState::ETxState GetState() const {
+ return State;
+ }
+
+ void SetState(TTxState::ETxState state) {
+ State = state;
+ Base = SelectStateFunc(state);
}
void ProgressState(TOperationContext& context) override {
Y_VERIFY(Base);
- bool isDone = Base->ProgressState(context);
+ const bool isDone = Base->ProgressState(context);
if (isDone) {
StateDone(context);
}
}
- #define DefaultHandleReply(TEvType, ...) \
- void HandleReply(TEvType::TPtr& ev, TOperationContext& context) override { \
- Y_VERIFY(Base); \
- bool isDone = Base->HandleReply(ev, context); \
- if (isDone) { \
- StateDone(context); \
- } \
+ #define DefaultHandleReply(TEvType, ...) \
+ void HandleReply(TEvType::TPtr& ev, TOperationContext& context) override { \
+ Y_VERIFY(Base); \
+ bool isDone = Base->HandleReply(ev, context); \
+ if (isDone) { \
+ StateDone(context); \
+ } \
}
SCHEMESHARD_INCOMING_EVENTS(DefaultHandleReply)
#undef DefaultHandleReply
};
+template <typename T, typename... Args>
+ISubOperationBase::TPtr MakeSubOperation(const TOperationId& id, const TTxTransaction& tx, Args&&... args) {
+ return new T(id, tx, std::forward<Args>(args)...);
+}
+
+template <typename T, typename... Args>
+ISubOperationBase::TPtr MakeSubOperation(const TOperationId& id, TTxState::ETxState state, Args&&... args) {
+ auto result = MakeHolder<T>(id, state, std::forward<Args>(args)...);
+ result->SetState(state);
+ return result.Release();
+}
+
ISubOperationBase::TPtr CreateReject(TOperationId id, THolder<TProposeResponse> response);
ISubOperationBase::TPtr CreateReject(TOperationId id, NKikimrScheme::EStatus status, const TString& message);
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_split_merge.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_split_merge.cpp
index 539c4604847..43e5608a55f 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_split_merge.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_split_merge.cpp
@@ -178,7 +178,6 @@ public:
}
};
-
class TTranserData: public TSubOperationState {
private:
TOperationId OperationId;
@@ -482,17 +481,12 @@ public:
};
class TSplitMerge: public TSubOperation {
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::CreateParts;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::CreateParts:
return TTxState::ConfigureParts;
case TTxState::ConfigureParts:
@@ -506,8 +500,8 @@ private:
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::CreateParts:
return THolder(new TCreateParts(OperationId));
case TTxState::ConfigureParts:
@@ -521,28 +515,8 @@ private:
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TSplitMerge(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TSplitMerge(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
bool AllocateDstForMerge(
const NKikimrSchemeOp::TSplitMergeTablePartitions& info,
@@ -999,8 +973,7 @@ public:
path.DomainInfo()->AddInternalShards(op); //allow over commit for merge
path->IncShardsInside(dstCount);
- State = NextState();
- SetState(SelectStateFunc(State));
+ SetState(NextState());
return result;
}
@@ -1034,17 +1007,15 @@ public:
}
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateSplitMerge(TOperationId id, const TTxTransaction& tx) {
- return new TSplitMerge(id, tx);
+ return MakeSubOperation<TSplitMerge>(id, tx);
}
ISubOperationBase::TPtr CreateSplitMerge(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TSplitMerge(id, state);
+ return MakeSubOperation<TSplitMerge>(id, state);
}
}
-}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_upgrade_subdomain.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_upgrade_subdomain.cpp
index 20f28587099..df7452c9416 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_upgrade_subdomain.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_upgrade_subdomain.cpp
@@ -887,7 +887,6 @@ public:
}
};
-
class TPublishTenant: public TSubOperationState {
private:
TOperationId OperationId;
@@ -1050,19 +1049,14 @@ public:
};
class TUpgradeSubDomain: public TSubOperation {
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
TTxState::ETxState UpgradeSubDomainDecision = TTxState::Invalid;
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Waiting;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
return TTxState::CreateParts;
case TTxState::CreateParts:
@@ -1073,22 +1067,19 @@ private:
return TTxState::PublishGlobal;
case TTxState::PublishGlobal:
return UpgradeSubDomainDecision;
-
case TTxState::RewriteOwners:
return TTxState::PublishTenant;
case TTxState::PublishTenant:
return TTxState::DoneMigrateTree;
-
case TTxState::DeleteTenantSS:
return TTxState::Invalid;
-
default:
return TTxState::Invalid;
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
return THolder(new TWait(OperationId));
case TTxState::CreateParts:
@@ -1099,44 +1090,21 @@ private:
return THolder(new TPublishTenantReadOnly(OperationId));
case TTxState::PublishGlobal:
return THolder(new TPublishGlobal(OperationId, UpgradeSubDomainDecision));
-
case TTxState::RewriteOwners:
return THolder(new TRewriteOwner(OperationId));
case TTxState::PublishTenant:
return THolder(new TPublishTenant(OperationId));
case TTxState::DoneMigrateTree:
return THolder(new TDoneMigrateTree(OperationId));
-
case TTxState::DeleteTenantSS:
return THolder(new TDeleteTenantSS(OperationId));
-
default:
return nullptr;
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TUpgradeSubDomain(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TUpgradeSubDomain(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -1286,9 +1254,9 @@ public:
path.DomainInfo()->AddInternalShards(txState);
path.Base()->IncShardsInside();
- State = NextState();
- SetState(SelectStateFunc(State));
context.OnComplete.ActivateTx(OperationId);
+
+ SetState(NextState());
return result;
}
@@ -1366,17 +1334,12 @@ public:
};
class TUpgradeSubDomainDecision: public TSubOperation {
-private:
- const TOperationId OperationId;
- const TTxTransaction Transaction;
- TTxState::ETxState State = TTxState::Invalid;
-
- TTxState::ETxState NextState() {
+ static TTxState::ETxState NextState() {
return TTxState::Done;
}
- TTxState::ETxState NextState(TTxState::ETxState state) {
- switch(state) {
+ TTxState::ETxState NextState(TTxState::ETxState state) const override {
+ switch (state) {
case TTxState::Waiting:
return TTxState::Done;
default:
@@ -1384,8 +1347,8 @@ private:
}
}
- TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) {
- switch(state) {
+ TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState state) override {
+ switch (state) {
case TTxState::Waiting:
case TTxState::Done:
return THolder(new TDecisionDone(OperationId));
@@ -1394,28 +1357,8 @@ private:
}
}
- void StateDone(TOperationContext& context) override {
- State = NextState(State);
-
- if (State != TTxState::Invalid) {
- SetState(SelectStateFunc(State));
- context.OnComplete.ActivateTx(OperationId);
- }
- }
-
public:
- TUpgradeSubDomainDecision(TOperationId id, const TTxTransaction& tx)
- : OperationId(id)
- , Transaction(tx)
- {
- }
-
- TUpgradeSubDomainDecision(TOperationId id, TTxState::ETxState state)
- : OperationId(id)
- , State(state)
- {
- SetState(SelectStateFunc(state));
- }
+ using TSubOperation::TSubOperation;
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TTabletId ssId = context.SS->SelfTabletId();
@@ -1520,11 +1463,9 @@ public:
LOG_ERROR_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, errMsg);
context.OnComplete.Dependence(txId, OperationId.GetTxId());
-
- State = NextState();
- SetState(SelectStateFunc(State));
context.OnComplete.ActivateTx(OperationId);
+ SetState(NextState());
return result;
}
@@ -1545,26 +1486,24 @@ public:
}
-
-namespace NKikimr {
-namespace NSchemeShard {
+namespace NKikimr::NSchemeShard {
ISubOperationBase::TPtr CreateUpgradeSubDomain(TOperationId id, const TTxTransaction& tx) {
- return new TUpgradeSubDomain(id, tx);
+ return MakeSubOperation<TUpgradeSubDomain>(id, tx);
}
ISubOperationBase::TPtr CreateUpgradeSubDomain(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TUpgradeSubDomain(id, state);
+ return MakeSubOperation<TUpgradeSubDomain>(id, state);
}
ISubOperationBase::TPtr CreateUpgradeSubDomainDecision(TOperationId id, const TTxTransaction& tx) {
- return new TUpgradeSubDomainDecision(id, tx);
+ return MakeSubOperation<TUpgradeSubDomainDecision>(id, tx);
}
ISubOperationBase::TPtr CreateUpgradeSubDomainDecision(TOperationId id, TTxState::ETxState state) {
Y_VERIFY(state != TTxState::Invalid);
- return new TUpgradeSubDomainDecision(id, state);
+ return MakeSubOperation<TUpgradeSubDomainDecision>(id, state);
}
ISubOperationBase::TPtr CreateCompatibleSubdomainDrop(TSchemeShard* ss, TOperationId id, const TTxTransaction& tx) {
@@ -1622,4 +1561,3 @@ ISubOperationBase::TPtr CreateCompatibleSubdomainAlter(TSchemeShard* ss, TOperat
}
}
-}