aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzalyalov <zalyalov@yandex-team.com>2023-07-12 10:35:59 +0300
committerzalyalov <zalyalov@yandex-team.com>2023-07-12 10:35:59 +0300
commitf15a5a2053e3c943171d08dc844a6117b1716c2d (patch)
treee81a4511d740225a1ca178e5580bd1e635b5329f
parente0c38703f7da8da4dde84d8893587a5791406e81 (diff)
downloadydb-f15a5a2053e3c943171d08dc844a6117b1716c2d.tar.gz
get tablet availability from config KIKIMR-18505
add availability to config
-rw-r--r--ydb/core/driver_lib/run/kikimr_services_initializers.cpp64
-rw-r--r--ydb/core/mind/hive/node_info.cpp6
-rw-r--r--ydb/core/mind/hive/node_info.h1
-rw-r--r--ydb/core/mind/local.cpp4
-rw-r--r--ydb/core/mind/local.h2
-rw-r--r--ydb/core/protos/config.proto4
-rw-r--r--ydb/core/protos/local.proto2
7 files changed, 46 insertions, 37 deletions
diff --git a/ydb/core/driver_lib/run/kikimr_services_initializers.cpp b/ydb/core/driver_lib/run/kikimr_services_initializers.cpp
index 3b406b11af..3b26d05d55 100644
--- a/ydb/core/driver_lib/run/kikimr_services_initializers.cpp
+++ b/ydb/core/driver_lib/run/kikimr_services_initializers.cpp
@@ -1050,36 +1050,40 @@ void TLocalServiceInitializer::InitializeServices(
// setup local
TLocalConfig::TPtr localConfig(new TLocalConfig());
- localConfig->TabletClassInfo[TTabletTypes::SchemeShard] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&CreateFlatTxSchemeShard, TMailboxType::ReadAsFilled, appData->UserPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::DataShard] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&CreateDataShard, TMailboxType::ReadAsFilled, appData->UserPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::KeyValue] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&CreateKeyValueFlat, TMailboxType::ReadAsFilled, appData->UserPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::PersQueue] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&CreatePersQueue, TMailboxType::ReadAsFilled, appData->UserPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::PersQueueReadBalancer] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&CreatePersQueueReadBalancer, TMailboxType::ReadAsFilled, appData->UserPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::Coordinator] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&CreateFlatTxCoordinator, TMailboxType::Revolving, importantPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::Mediator] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&CreateTxMediator, TMailboxType::Revolving, importantPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::Kesus] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&NKesus::CreateKesusTablet, TMailboxType::ReadAsFilled, appData->UserPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::Hive] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&CreateDefaultHive, TMailboxType::ReadAsFilled, importantPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::SysViewProcessor] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&NSysView::CreateSysViewProcessor, TMailboxType::ReadAsFilled, appData->UserPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::TestShard] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&NTestShard::CreateTestShard, TMailboxType::ReadAsFilled, appData->UserPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::ColumnShard] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&CreateColumnShard, TMailboxType::ReadAsFilled, appData->UserPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::SequenceShard] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&NSequenceShard::CreateSequenceShard, TMailboxType::ReadAsFilled, appData->UserPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::ReplicationController] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&NReplication::CreateController, TMailboxType::ReadAsFilled, appData->UserPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
- localConfig->TabletClassInfo[TTabletTypes::BlobDepot] = TLocalConfig::TTabletClassInfo(
- new TTabletSetupInfo(&NBlobDepot::CreateBlobDepot, TMailboxType::ReadAsFilled, appData->UserPoolId, TMailboxType::ReadAsFilled, appData->SystemPoolId));
+
+ std::unordered_map<TTabletTypes::EType, NKikimrLocal::TTabletAvailability> tabletAvailabilities;
+ for (const auto& availability : Config.GetDynamicNodeConfig().GetTabletAvailability()) {
+ tabletAvailabilities.emplace(availability.GetType(), availability);
+ }
+
+ auto addToLocalConfig = [&localConfig, &tabletAvailabilities, tabletPool = appData->SystemPoolId](TTabletTypes::EType tabletType,
+ TTabletSetupInfo::TTabletCreationFunc op,
+ NActors::TMailboxType::EType mailboxType,
+ ui32 poolId) {
+ auto availIt = tabletAvailabilities.find(tabletType);
+ auto localIt = localConfig->TabletClassInfo.emplace(tabletType, new TTabletSetupInfo(op, mailboxType, poolId, TMailboxType::ReadAsFilled, tabletPool)).first;
+ if (availIt != tabletAvailabilities.end()) {
+ localIt->second.MaxCount = availIt->second.GetMaxCount();
+ localIt->second.Priority = availIt->second.GetPriority();
+ }
+ };
+
+ addToLocalConfig(TTabletTypes::SchemeShard, &CreateFlatTxSchemeShard, TMailboxType::ReadAsFilled, appData->UserPoolId);
+ addToLocalConfig(TTabletTypes::DataShard, &CreateDataShard, TMailboxType::ReadAsFilled, appData->UserPoolId);
+ addToLocalConfig(TTabletTypes::KeyValue, &CreateKeyValueFlat, TMailboxType::ReadAsFilled, appData->UserPoolId);
+ addToLocalConfig(TTabletTypes::PersQueue, &CreatePersQueue, TMailboxType::ReadAsFilled, appData->UserPoolId);
+ addToLocalConfig(TTabletTypes::PersQueueReadBalancer, &CreatePersQueueReadBalancer, TMailboxType::ReadAsFilled, appData->UserPoolId);
+ addToLocalConfig(TTabletTypes::Coordinator, &CreateFlatTxCoordinator, TMailboxType::Revolving, importantPoolId);
+ addToLocalConfig(TTabletTypes::Mediator, &CreateTxMediator, TMailboxType::Revolving, importantPoolId);
+ addToLocalConfig(TTabletTypes::Kesus, &NKesus::CreateKesusTablet, TMailboxType::ReadAsFilled, appData->UserPoolId);
+ addToLocalConfig(TTabletTypes::Hive, &CreateDefaultHive, TMailboxType::ReadAsFilled, importantPoolId);
+ addToLocalConfig(TTabletTypes::SysViewProcessor, &NSysView::CreateSysViewProcessor, TMailboxType::ReadAsFilled, appData->UserPoolId);
+ addToLocalConfig(TTabletTypes::TestShard, &NTestShard::CreateTestShard, TMailboxType::ReadAsFilled, appData->UserPoolId);
+ addToLocalConfig(TTabletTypes::ColumnShard, &CreateColumnShard, TMailboxType::ReadAsFilled, appData->UserPoolId);
+ addToLocalConfig(TTabletTypes::SequenceShard, &NSequenceShard::CreateSequenceShard, TMailboxType::ReadAsFilled, appData->UserPoolId);
+ addToLocalConfig(TTabletTypes::ReplicationController, &NReplication::CreateController, TMailboxType::ReadAsFilled, appData->UserPoolId);
+ addToLocalConfig(TTabletTypes::BlobDepot, &NBlobDepot::CreateBlobDepot, TMailboxType::ReadAsFilled, appData->UserPoolId);
+
TTenantPoolConfig::TPtr tenantPoolConfig = new TTenantPoolConfig(Config.GetTenantPoolConfig(), localConfig);
if (!tenantPoolConfig->IsEnabled && !tenantPoolConfig->StaticSlots.empty())
diff --git a/ydb/core/mind/hive/node_info.cpp b/ydb/core/mind/hive/node_info.cpp
index bd5c0368f4..104e0a2705 100644
--- a/ydb/core/mind/hive/node_info.cpp
+++ b/ydb/core/mind/hive/node_info.cpp
@@ -4,6 +4,8 @@
namespace NKikimr {
namespace NHive {
+const ui64 TNodeInfo::MAX_TABLET_COUNT_DEFAULT_VALUE = NKikimrLocal::TTabletAvailability().GetMaxCount();
+
TNodeInfo::TNodeInfo(TNodeId nodeId, THive& hive)
: VolatileState(EVolatileState::Unknown)
, Hive(hive)
@@ -244,14 +246,14 @@ bool TNodeInfo::IsAbleToRunTablet(const TTabletInfo& tablet, TTabletDebugState*
maxCount = itTabletAvailability->second.GetMaxCount();
}
}
- if (maxCount == 0) {
+ if (maxCount == MAX_TABLET_COUNT_DEFAULT_VALUE) {
const std::unordered_map<TTabletTypes::EType, NKikimrConfig::THiveTabletLimit>& tabletLimit = Hive.GetTabletLimit();
auto itTabletLimit = tabletLimit.find(tabletType);
if (itTabletLimit != tabletLimit.end()) {
maxCount = itTabletLimit->second.GetMaxCount();
}
}
- if (maxCount != 0) {
+ if (maxCount != MAX_TABLET_COUNT_DEFAULT_VALUE) {
ui64 currentCount = GetTabletsRunningByType(tabletType);
if (currentCount >= maxCount) {
if (debugState) {
diff --git a/ydb/core/mind/hive/node_info.h b/ydb/core/mind/hive/node_info.h
index d615b44209..c6633df8c0 100644
--- a/ydb/core/mind/hive/node_info.h
+++ b/ydb/core/mind/hive/node_info.h
@@ -30,6 +30,7 @@ struct TNodeInfo {
protected:
EVolatileState VolatileState;
+ static const ui64 MAX_TABLET_COUNT_DEFAULT_VALUE;
public:
THive& Hive;
diff --git a/ydb/core/mind/local.cpp b/ydb/core/mind/local.cpp
index 961d73701a..8879efe3fa 100644
--- a/ydb/core/mind/local.cpp
+++ b/ydb/core/mind/local.cpp
@@ -193,8 +193,8 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> {
for (const auto& [tabletType, tabletInfo] : Config->TabletClassInfo) {
NKikimrLocal::TTabletAvailability* tabletAvailability = request->Record.AddTabletAvailability();
tabletAvailability->SetType(tabletType);
- if (tabletInfo.MaxCount != 0) {
- tabletAvailability->SetMaxCount(tabletInfo.MaxCount);
+ if (tabletInfo.MaxCount) {
+ tabletAvailability->SetMaxCount(*tabletInfo.MaxCount);
}
tabletAvailability->SetPriority(tabletInfo.Priority);
}
diff --git a/ydb/core/mind/local.h b/ydb/core/mind/local.h
index 466e88dd33..5b198a8f90 100644
--- a/ydb/core/mind/local.h
+++ b/ydb/core/mind/local.h
@@ -355,7 +355,7 @@ struct TLocalConfig : public TThrRefBase {
struct TTabletClassInfo {
TTabletSetupInfo::TPtr SetupInfo;
- ui64 MaxCount = 0; // maximum allowed number of running tablets, 0 means unlimited
+ std::optional<ui64> MaxCount; // maximum allowed number of running tablets, nullopt means unlimited
i32 Priority = 0;
TTabletClassInfo()
diff --git a/ydb/core/protos/config.proto b/ydb/core/protos/config.proto
index 8c10d52ef8..eac8cbfed3 100644
--- a/ydb/core/protos/config.proto
+++ b/ydb/core/protos/config.proto
@@ -12,6 +12,7 @@ import "ydb/core/protos/flat_scheme_op.proto";
import "ydb/core/protos/http_config.proto";
import "ydb/core/protos/hive.proto";
import "ydb/core/protos/kqp.proto";
+import "ydb/core/protos/local.proto";
import "ydb/core/protos/netclassifier.proto";
import "ydb/core/protos/node_broker.proto";
import "ydb/core/protos/pqconfig.proto";
@@ -700,6 +701,7 @@ message TDynamicNodeConfig {
optional NKikimrNodeBroker.TNodeInfo NodeInfo = 4;
optional string NodeAddress = 5; //DEPRECATED
optional string NodeHost = 6; //DEPRECATED
+ repeated NKikimrLocal.TTabletAvailability TabletAvailability = 7;
}
message TFeatureFlags {
@@ -1561,7 +1563,7 @@ message TAuditConfig {
message THiveTabletLimit {
optional NKikimrTabletBase.TTabletTypes.EType Type = 1;
- optional uint64 MaxCount = 2;
+ optional uint64 MaxCount = 2 [default = 1000000]; // Default value here should match the one in NkikimrLocal.TTabletAvailability
}
message THiveTabletPreference {
diff --git a/ydb/core/protos/local.proto b/ydb/core/protos/local.proto
index 3ba2f5b24b..012da6c0ea 100644
--- a/ydb/core/protos/local.proto
+++ b/ydb/core/protos/local.proto
@@ -10,7 +10,7 @@ option java_package = "ru.yandex.kikimr.proto";
message TTabletAvailability {
optional NKikimrTabletBase.TTabletTypes.EType Type = 1;
- optional uint64 MaxCount = 2;
+ optional uint64 MaxCount = 2 [default = 1000000];
optional int32 Priority = 3;
}