config.cpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #include "config.h"
  2. #include <yt/yt/core/misc/config.h>
  3. namespace NYT::NApi {
  4. ////////////////////////////////////////////////////////////////////////////////
  5. void TTableMountCacheConfig::Register(TRegistrar registrar)
  6. {
  7. registrar.Parameter("on_error_retry_count", &TThis::OnErrorRetryCount)
  8. .GreaterThanOrEqual(0)
  9. .Default(5);
  10. registrar.Parameter("on_error_retry_slack_period", &TThis::OnErrorSlackPeriod)
  11. .GreaterThan(TDuration::Zero())
  12. .Default(TDuration::Seconds(1));
  13. }
  14. ////////////////////////////////////////////////////////////////////////////////
  15. void TConnectionConfig::Register(TRegistrar registrar)
  16. {
  17. registrar.Parameter("connection_type", &TThis::ConnectionType)
  18. .Default(EConnectionType::Native);
  19. registrar.Parameter("cluster_name", &TThis::ClusterName)
  20. .Default();
  21. registrar.Parameter("table_mount_cache", &TThis::TableMountCache)
  22. .DefaultNew();
  23. registrar.Parameter("replication_card_cache", &TThis::ReplicationCardCache)
  24. .Optional();
  25. }
  26. ////////////////////////////////////////////////////////////////////////////////
  27. void TConnectionDynamicConfig::Register(TRegistrar registrar)
  28. {
  29. registrar.Parameter("table_mount_cache", &TThis::TableMountCache)
  30. .DefaultNew();
  31. registrar.Parameter("tablet_write_backoff", &TThis::TabletWriteBackoff)
  32. .Default({
  33. .InvocationCount = 0,
  34. });
  35. }
  36. ////////////////////////////////////////////////////////////////////////////////
  37. void TPersistentQueuePollerConfig::Register(TRegistrar registrar)
  38. {
  39. registrar.Parameter("max_prefetch_row_count", &TThis::MaxPrefetchRowCount)
  40. .GreaterThan(0)
  41. .Default(1024);
  42. registrar.Parameter("max_prefetch_data_weight", &TThis::MaxPrefetchDataWeight)
  43. .GreaterThan(0)
  44. .Default((i64) 16 * 1024 * 1024);
  45. registrar.Parameter("max_rows_per_fetch", &TThis::MaxRowsPerFetch)
  46. .GreaterThan(0)
  47. .Default(512);
  48. registrar.Parameter("max_rows_per_poll", &TThis::MaxRowsPerPoll)
  49. .GreaterThan(0)
  50. .Default(1);
  51. registrar.Parameter("max_fetched_untrimmed_row_count", &TThis::MaxFetchedUntrimmedRowCount)
  52. .GreaterThan(0)
  53. .Default(40000);
  54. registrar.Parameter("untrimmed_data_rows_low", &TThis::UntrimmedDataRowsLow)
  55. .Default(0);
  56. registrar.Parameter("untrimmed_data_rows_high", &TThis::UntrimmedDataRowsHigh)
  57. .Default(std::numeric_limits<i64>::max());
  58. registrar.Parameter("data_poll_period", &TThis::DataPollPeriod)
  59. .Default(TDuration::Seconds(1));
  60. registrar.Parameter("state_trim_period", &TThis::StateTrimPeriod)
  61. .Default(TDuration::Seconds(15));
  62. registrar.Parameter("backoff_time", &TThis::BackoffTime)
  63. .Default(TDuration::Seconds(5));
  64. registrar.Postprocessor([] (TThis* config) {
  65. if (config->UntrimmedDataRowsLow > config->UntrimmedDataRowsHigh) {
  66. THROW_ERROR_EXCEPTION("\"untrimmed_data_rows_low\" must not exceed \"untrimmed_data_rows_high\"");
  67. }
  68. });
  69. }
  70. ////////////////////////////////////////////////////////////////////////////////
  71. void TJournalChunkWriterConfig::Register(TRegistrar registrar)
  72. {
  73. registrar.Parameter("max_batch_row_count", &TThis::MaxBatchRowCount)
  74. .Default(256);
  75. registrar.Parameter("max_batch_data_size", &TThis::MaxBatchDataSize)
  76. .Default(16_MB);
  77. registrar.Parameter("max_batch_delay", &TThis::MaxBatchDelay)
  78. .Default(TDuration::MilliSeconds(5));
  79. registrar.Parameter("max_flush_row_count", &TThis::MaxFlushRowCount)
  80. .Default(100'000);
  81. registrar.Parameter("max_flush_data_size", &TThis::MaxFlushDataSize)
  82. .Default(100_MB);
  83. registrar.Parameter("prefer_local_host", &TThis::PreferLocalHost)
  84. .Default(true);
  85. registrar.Parameter("node_rpc_timeout", &TThis::NodeRpcTimeout)
  86. .Default(TDuration::Seconds(15));
  87. registrar.Parameter("node_ping_period", &TThis::NodePingPeriod)
  88. .Default(TDuration::Seconds(15));
  89. registrar.Parameter("node_ban_timeout", &TThis::NodeBanTimeout)
  90. .Default(TDuration::Seconds(60));
  91. registrar.Parameter("node_channel", &TThis::NodeChannel)
  92. .DefaultNew();
  93. registrar.Parameter("replica_failure_probability", &TThis::ReplicaFailureProbability)
  94. .Default(0.0)
  95. .InRange(0.0, 1.0);
  96. registrar.Parameter("replica_row_limits", &TThis::ReplicaRowLimits)
  97. .Default();
  98. registrar.Parameter("replica_fake_timeout_delay", &TThis::ReplicaFakeTimeoutDelay)
  99. .Default();
  100. registrar.Postprocessor([] (TThis* config) {
  101. if (config->MaxBatchRowCount > config->MaxFlushRowCount) {
  102. THROW_ERROR_EXCEPTION("\"max_batch_row_count\" cannot be greater than \"max_flush_row_count\"")
  103. << TErrorAttribute("max_batch_row_count", config->MaxBatchRowCount)
  104. << TErrorAttribute("max_flush_row_count", config->MaxFlushRowCount);
  105. }
  106. if (config->MaxBatchDataSize > config->MaxFlushDataSize) {
  107. THROW_ERROR_EXCEPTION("\"max_batch_data_size\" cannot be greater than \"max_flush_data_size\"")
  108. << TErrorAttribute("max_batch_data_size", config->MaxBatchDataSize)
  109. << TErrorAttribute("max_flush_data_size", config->MaxFlushDataSize);
  110. }
  111. });
  112. }
  113. ////////////////////////////////////////////////////////////////////////////////
  114. void TJournalWriterConfig::Register(TRegistrar registrar)
  115. {
  116. registrar.Parameter("max_chunk_row_count", &TThis::MaxChunkRowCount)
  117. .GreaterThan(0)
  118. .Default(1'000'000);
  119. registrar.Parameter("max_chunk_data_size", &TThis::MaxChunkDataSize)
  120. .GreaterThan(0)
  121. .Default(10_GB);
  122. registrar.Parameter("max_chunk_session_duration", &TThis::MaxChunkSessionDuration)
  123. .Default(TDuration::Hours(60));
  124. registrar.Parameter("open_session_backoff_time", &TThis::OpenSessionBackoffTime)
  125. .Default(TDuration::Seconds(10));
  126. registrar.Parameter("open_session_retry_count", &TThis::OpenSessionRetryCount)
  127. .Default(5);
  128. registrar.Parameter("prerequisite_transaction_probe_period", &TThis::PrerequisiteTransactionProbePeriod)
  129. .Default(TDuration::Seconds(60));
  130. registrar.Parameter("dont_close", &TThis::DontClose)
  131. .Default(false);
  132. registrar.Parameter("dont_seal", &TThis::DontSeal)
  133. .Default(false);
  134. registrar.Parameter("dont_preallocate", &TThis::DontPreallocate)
  135. .Default(false);
  136. registrar.Parameter("open_delay", &TThis::OpenDelay)
  137. .Default();
  138. }
  139. ////////////////////////////////////////////////////////////////////////////////
  140. void TJournalChunkWriterOptions::Register(TRegistrar registrar)
  141. {
  142. registrar.Parameter("replication_factor", &TThis::ReplicationFactor)
  143. .Default(3);
  144. registrar.Parameter("erasure_codec", &TThis::ErasureCodec)
  145. .Default(NErasure::ECodec::None);
  146. registrar.Parameter("read_quorum", &TThis::ReadQuorum)
  147. .Default(2);
  148. registrar.Parameter("write_quorum", &TThis::WriteQuorum)
  149. .Default(2);
  150. registrar.Parameter("replica_lag_limit", &TThis::ReplicaLagLimit)
  151. .Default(NJournalClient::DefaultReplicaLagLimit);
  152. registrar.Parameter("enable_multiplexing", &TThis::EnableMultiplexing)
  153. .Default(false);
  154. }
  155. ////////////////////////////////////////////////////////////////////////////////
  156. } // namespace NYT::NApi