/graylog2-server/src/main/java/org/graylog2/configuration/ElasticsearchConfiguration.java

https://github.com/Graylog2/graylog2-server · Java · 194 lines · 136 code · 42 blank · 16 comment · 0 complexity · 46d2acf6e1d8598f54d602a2db21da3e MD5 · raw file

  1. /*
  2. * Copyright (C) 2020 Graylog, Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the Server Side Public License, version 1,
  6. * as published by MongoDB, Inc.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * Server Side Public License for more details.
  12. *
  13. * You should have received a copy of the Server Side Public License
  14. * along with this program. If not, see
  15. * <http://www.mongodb.com/licensing/server-side-public-license>.
  16. */
  17. package org.graylog2.configuration;
  18. import com.github.joschi.jadconfig.Parameter;
  19. import com.github.joschi.jadconfig.util.Duration;
  20. import com.github.joschi.jadconfig.validators.PositiveDurationValidator;
  21. import com.github.joschi.jadconfig.validators.PositiveIntegerValidator;
  22. import com.github.joschi.jadconfig.validators.PositiveLongValidator;
  23. import com.github.joschi.jadconfig.validators.StringNotBlankValidator;
  24. import org.joda.time.Period;
  25. import java.util.Locale;
  26. public class ElasticsearchConfiguration {
  27. public static final String DEFAULT_EVENTS_INDEX_PREFIX = "default_events_index_prefix";
  28. public static final String DEFAULT_SYSTEM_EVENTS_INDEX_PREFIX = "default_system_events_index_prefix";
  29. @Parameter(value = "elasticsearch_disable_version_check")
  30. private boolean disableVersionCheck = false;
  31. @Deprecated // Should be removed in Graylog 3.0
  32. @Parameter(value = "elasticsearch_index_prefix", required = true)
  33. private String indexPrefix = "graylog";
  34. @Deprecated // Should be removed in Graylog 3.0
  35. @Parameter(value = "elasticsearch_max_number_of_indices", required = true, validator = PositiveIntegerValidator.class)
  36. private int maxNumberOfIndices = 20;
  37. @Deprecated // Should be removed in Graylog 3.0
  38. @Parameter(value = "elasticsearch_max_docs_per_index", validator = PositiveIntegerValidator.class, required = true)
  39. private int maxDocsPerIndex = 20000000;
  40. @Deprecated // Should be removed in Graylog 3.0
  41. @Parameter(value = "elasticsearch_max_size_per_index", validator = PositiveLongValidator.class, required = true)
  42. private long maxSizePerIndex = 1L * 1024 * 1024 * 1024; // 1GB
  43. @Deprecated // Should be removed in Graylog 3.0
  44. @Parameter(value = "elasticsearch_max_time_per_index", required = true)
  45. private Period maxTimePerIndex = Period.days(1);
  46. @Deprecated // Should be removed in Graylog 3.0
  47. @Parameter(value = "elasticsearch_shards", validator = PositiveIntegerValidator.class, required = true)
  48. private int shards = 4;
  49. @Deprecated // Should be removed in Graylog 3.0
  50. @Parameter(value = "elasticsearch_replicas", validator = PositiveIntegerValidator.class, required = true)
  51. private int replicas = 0;
  52. @Deprecated // Should be removed in Graylog 3.0
  53. @Parameter(value = "elasticsearch_analyzer", required = true)
  54. private String analyzer = "standard";
  55. @Deprecated // Should be removed in Graylog 3.0
  56. @Parameter(value = "elasticsearch_template_name")
  57. private String templateName = "graylog-internal";
  58. @Parameter(value = "no_retention")
  59. private boolean noRetention = false;
  60. @Deprecated // Should be removed in Graylog 3.0
  61. @Parameter(value = "retention_strategy", required = true)
  62. private String retentionStrategy = "delete";
  63. @Deprecated // Should be removed in Graylog 3.0
  64. @Parameter(value = "rotation_strategy")
  65. private String rotationStrategy = "count";
  66. @Deprecated // Should be removed in Graylog 3.0
  67. @Parameter(value = "disable_index_optimization")
  68. private boolean disableIndexOptimization = false;
  69. @Deprecated // Should be removed in Graylog 3.0
  70. @Parameter(value = "index_optimization_max_num_segments", validator = PositiveIntegerValidator.class)
  71. private int indexOptimizationMaxNumSegments = 1;
  72. @Parameter(value = "elasticsearch_index_optimization_timeout", validator = DurationCastedToIntegerValidator.class)
  73. private Duration indexOptimizationTimeout = Duration.hours(1L);
  74. @Parameter(value = "elasticsearch_index_optimization_jobs", validator = PositiveIntegerValidator.class)
  75. private int indexOptimizationJobs = 20;
  76. @Parameter(value = "index_field_type_periodical_full_refresh_interval", validators = {PositiveDurationValidator.class})
  77. private Duration indexFieldTypePeriodicalFullRefreshInterval = Duration.minutes(5);
  78. @Parameter(value = DEFAULT_EVENTS_INDEX_PREFIX, validators = StringNotBlankValidator.class)
  79. private String defaultEventsIndexPrefix = "gl-events";
  80. @Parameter(value = DEFAULT_SYSTEM_EVENTS_INDEX_PREFIX, validators = StringNotBlankValidator.class)
  81. private String defaultSystemEventsIndexPrefix = "gl-system-events";
  82. public boolean isDisableVersionCheck() {
  83. return disableVersionCheck;
  84. }
  85. @Deprecated // Should be removed in Graylog 3.0
  86. public String getIndexPrefix() {
  87. return indexPrefix.toLowerCase(Locale.ENGLISH);
  88. }
  89. @Deprecated // Should be removed in Graylog 3.0
  90. public int getMaxNumberOfIndices() {
  91. return maxNumberOfIndices;
  92. }
  93. @Deprecated // Should be removed in Graylog 3.0
  94. public int getMaxDocsPerIndex() {
  95. return maxDocsPerIndex;
  96. }
  97. @Deprecated // Should be removed in Graylog 3.0
  98. public long getMaxSizePerIndex() {
  99. return maxSizePerIndex;
  100. }
  101. @Deprecated // Should be removed in Graylog 3.0
  102. public Period getMaxTimePerIndex() {
  103. return maxTimePerIndex;
  104. }
  105. @Deprecated // Should be removed in Graylog 3.0
  106. public int getShards() {
  107. return shards;
  108. }
  109. @Deprecated // Should be removed in Graylog 3.0
  110. public int getReplicas() {
  111. return replicas;
  112. }
  113. @Deprecated // Should be removed in Graylog 3.0
  114. public String getAnalyzer() {
  115. return analyzer;
  116. }
  117. @Deprecated // Should be removed in Graylog 3.0
  118. public String getTemplateName() {
  119. return templateName;
  120. }
  121. @Deprecated // Should be removed in Graylog 3.0
  122. public String getRotationStrategy() {
  123. return rotationStrategy;
  124. }
  125. public boolean performRetention() {
  126. return !noRetention;
  127. }
  128. @Deprecated // Should be removed in Graylog 3.0
  129. public String getRetentionStrategy() {
  130. return retentionStrategy;
  131. }
  132. @Deprecated // Should be removed in Graylog 3.0
  133. public int getIndexOptimizationMaxNumSegments() {
  134. return indexOptimizationMaxNumSegments;
  135. }
  136. @Deprecated // Should be removed in Graylog 3.0
  137. public boolean isDisableIndexOptimization() {
  138. return disableIndexOptimization;
  139. }
  140. public Duration getIndexOptimizationTimeout() {
  141. return indexOptimizationTimeout;
  142. }
  143. public int getIndexOptimizationJobs() {
  144. return indexOptimizationJobs;
  145. }
  146. public String getDefaultEventsIndexPrefix() {
  147. return defaultEventsIndexPrefix;
  148. }
  149. public String getDefaultSystemEventsIndexPrefix() {
  150. return defaultSystemEventsIndexPrefix;
  151. }
  152. }