searchdconfig.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // Copyright (c) 2017-2026, Manticore Software LTD (https://manticoresearch.com)
  3. // All rights reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License. You should have
  7. // received a copy of the GPL license along with this program; if you
  8. // did not, you can find it at http://www.gnu.org/
  9. //
  10. #ifndef _searchdconfig_
  11. #define _searchdconfig_
  12. #include "sphinxutils.h"
  13. #include "indexsettings.h"
  14. enum class IndexType_e
  15. {
  16. PLAIN = 0,
  17. TEMPLATE,
  18. RT,
  19. PERCOLATE,
  20. DISTR,
  21. ERROR_, // simple "ERROR" doesn't work on win due to '#define ERROR 0' somewhere.
  22. };
  23. const char * szIndexType ( IndexType_e eType );
  24. struct ClusterOptions_t
  25. {
  26. SmallStringHash_T<CSphString> m_hOptions;
  27. void Parse ( const CSphString & sOptions );
  28. [[nodiscard]] CSphString AsStr () const;
  29. [[nodiscard]] bool IsEmpty() const noexcept;
  30. };
  31. // cluster data that gets stored and loaded
  32. struct ClusterDesc_t
  33. {
  34. CSphString m_sName; // cluster name
  35. CSphString m_sPath; // path relative to data_dir
  36. sph::StringSet m_hIndexes; // list of index name in cluster
  37. StrVec_t m_dClusterNodes; // string list of nodes (node - address:API_port)
  38. ClusterOptions_t m_tOptions; // options for Galera
  39. bool Parse ( const bson::Bson_c & tBson, const CSphString& sName, CSphString & sWarning );
  40. void Save ( JsonEscapedBuilder& tOut ) const;
  41. };
  42. struct AgentConfigDesc_t
  43. {
  44. CSphString m_sConfig;
  45. bool m_bPersistent = false;
  46. bool m_bBlackhole = false;
  47. };
  48. struct IndexDescDistr_t
  49. {
  50. StrVec_t m_dLocals;
  51. CSphVector<AgentConfigDesc_t> m_dAgents;
  52. int m_iAgentConnectTimeout = 0;
  53. int m_iAgentQueryTimeout = 0;
  54. int m_iAgentRetryCount = 0;
  55. bool m_bDivideRemoteRanges = false;
  56. CSphString m_sHaStrategy;
  57. bool Parse ( const bson::Bson_c & tBson, CSphString & sWarning );
  58. void Save ( JsonEscapedBuilder& tOut ) const;
  59. void Save ( CSphConfigSection & hIndex ) const;
  60. };
  61. struct IndexDesc_t
  62. {
  63. CSphString m_sName;
  64. CSphString m_sPath;
  65. IndexType_e m_eType = IndexType_e::ERROR_;
  66. IndexDescDistr_t m_tDistr;
  67. bool Parse ( const bson::Bson_c & tBson, const CSphString& sName, CSphString & sWarning );
  68. void Save ( JsonEscapedBuilder& tOut ) const;
  69. void Save ( CSphConfigSection & hIndex ) const;
  70. };
  71. // load data from internal config on daemon start
  72. bool LoadConfigInt ( const CSphConfig & hConf, const CSphString & sConfigFile, CSphString & sError );
  73. bool SaveConfigInt ( CSphString & sError );
  74. struct DistributedIndex_t;
  75. IndexDescDistr_t GetDistributedDesc ( const DistributedIndex_t & tDist );
  76. // load indexes got from internal config on daemon indexes preload (part of ConfigureAndPreload work done here)
  77. void ConfigureAndPreloadConfiglessIndexes ( int & iValidIndexes, int & iCounter );
  78. std::unique_ptr<FilenameBuilder_i> CreateFilenameBuilder ( const char * szIndex );
  79. void ModifyDaemonPaths ( CSphConfigSection & hSearchd, FixPathAbsolute_fn && fnPathFix = nullptr );
  80. CSphString GetDataDirInt();
  81. // create string by join global data_dir and given path
  82. CSphString GetDatadirPath ( const CSphString& sPath );
  83. bool IsConfigless();
  84. const CSphVector<ClusterDesc_t> & GetClustersInt();
  85. struct DistributedIndex_t;
  86. CSphString BuildCreateTableDistr ( const CSphString & sName, const DistributedIndex_t & tDistr );
  87. bool CreateNewIndexConfigless ( const CSphString & sIndex, const CreateTableSettings_t & tCreateTable, StrVec_t & dWarnings, CSphString & sError );
  88. bool AddExistingIndexConfigless ( const CSphString & sIndex, IndexType_e eType, StrVec_t & dWarnings, CSphString & sError );
  89. bool DropIndexInt ( const CSphString & sIndex, bool bIfExists, bool bForce, CSphString & sError, CSphString * pWarning=nullptr );
  90. bool CopyIndexFiles ( const CSphString & sIndex, const CSphString & sPathToIndex, bool & bPQ, StrVec_t & dWarnings, CSphString & sError );
  91. bool IsDistrTableHasSystem ( const DistributedIndex_t & tDistr, bool bForce );
  92. enum RunIdx_e : int {
  93. NOTSERVED = 0,
  94. LOCAL,
  95. DISTR,
  96. };
  97. RunIdx_e IndexIsServed ( const CSphString& sName );
  98. #endif // _searchdconfig_