|
82 | 82 | import org.opensearch.common.xcontent.XContentHelper;
|
83 | 83 | import org.opensearch.core.action.ActionListener;
|
84 | 84 | import org.opensearch.core.common.Strings;
|
| 85 | +import org.opensearch.core.common.unit.ByteSizeValue; |
85 | 86 | import org.opensearch.core.index.Index;
|
86 | 87 | import org.opensearch.core.xcontent.NamedXContentRegistry;
|
87 | 88 | import org.opensearch.env.Environment;
|
88 | 89 | import org.opensearch.index.IndexModule;
|
89 | 90 | import org.opensearch.index.IndexNotFoundException;
|
90 | 91 | import org.opensearch.index.IndexService;
|
91 | 92 | import org.opensearch.index.IndexSettings;
|
| 93 | +import org.opensearch.index.compositeindex.CompositeIndexSettings; |
92 | 94 | import org.opensearch.index.compositeindex.CompositeIndexValidator;
|
| 95 | +import org.opensearch.index.compositeindex.datacube.startree.StarTreeIndexSettings; |
93 | 96 | import org.opensearch.index.mapper.DocumentMapper;
|
94 | 97 | import org.opensearch.index.mapper.MapperService;
|
95 | 98 | import org.opensearch.index.mapper.MapperService.MergeReason;
|
|
154 | 157 | import static org.opensearch.cluster.metadata.Metadata.DEFAULT_REPLICA_COUNT_SETTING;
|
155 | 158 | import static org.opensearch.cluster.metadata.MetadataIndexTemplateService.findContextTemplateName;
|
156 | 159 | import static org.opensearch.index.IndexModule.INDEX_STORE_TYPE_SETTING;
|
| 160 | +import static org.opensearch.index.IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING; |
157 | 161 | import static org.opensearch.indices.IndicesService.CLUSTER_REPLICATION_TYPE_SETTING;
|
158 | 162 | import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.isRemoteDataAttributePresent;
|
159 | 163 | import static org.opensearch.node.remotestore.RemoteStoreNodeService.REMOTE_STORE_COMPATIBILITY_MODE_SETTING;
|
@@ -1079,6 +1083,7 @@ static Settings aggregateIndexSettings(
|
1079 | 1083 | validateTranslogRetentionSettings(indexSettings);
|
1080 | 1084 | validateStoreTypeSettings(indexSettings);
|
1081 | 1085 | validateRefreshIntervalSettings(request.settings(), clusterSettings);
|
| 1086 | + validateTranslogFlushIntervalSettingsForCompositeIndex(request.settings(), clusterSettings); |
1082 | 1087 | validateTranslogDurabilitySettings(request.settings(), clusterSettings, settings);
|
1083 | 1088 | return indexSettings;
|
1084 | 1089 | }
|
@@ -1766,6 +1771,71 @@ public static void validateTranslogRetentionSettings(Settings indexSettings) {
|
1766 | 1771 | }
|
1767 | 1772 | }
|
1768 | 1773 |
|
| 1774 | + /** |
| 1775 | + * Validates {@code index.translog.flush_threshold_size} is equal or below the {@code indices.composite_index.translog.max_flush_threshold_size} |
| 1776 | + * for composite indices based on {{@code index.composite_index}} |
| 1777 | + * |
| 1778 | + * @param requestSettings settings passed in during index create/update request |
| 1779 | + * @param clusterSettings cluster setting |
| 1780 | + */ |
| 1781 | + public static void validateTranslogFlushIntervalSettingsForCompositeIndex(Settings requestSettings, ClusterSettings clusterSettings) { |
| 1782 | + if (StarTreeIndexSettings.IS_COMPOSITE_INDEX_SETTING.exists(requestSettings) == false |
| 1783 | + || requestSettings.get(StarTreeIndexSettings.IS_COMPOSITE_INDEX_SETTING.getKey()) == null) { |
| 1784 | + return; |
| 1785 | + } |
| 1786 | + ByteSizeValue translogFlushSize = INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.get(requestSettings); |
| 1787 | + ByteSizeValue compositeIndexMaxFlushSize = clusterSettings.get( |
| 1788 | + CompositeIndexSettings.COMPOSITE_INDEX_MAX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING |
| 1789 | + ); |
| 1790 | + if (translogFlushSize.compareTo(compositeIndexMaxFlushSize) > 0) { |
| 1791 | + throw new IllegalArgumentException( |
| 1792 | + String.format( |
| 1793 | + Locale.ROOT, |
| 1794 | + "You can configure '%s' with upto '%s' for composite index", |
| 1795 | + INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), |
| 1796 | + compositeIndexMaxFlushSize |
| 1797 | + ) |
| 1798 | + ); |
| 1799 | + } |
| 1800 | + } |
| 1801 | + |
| 1802 | + /** |
| 1803 | + * Validates {@code index.translog.flush_threshold_size} is equal or below the {@code indices.composite_index.translog.max_flush_threshold_size} |
| 1804 | + * for composite indices based on {{@code index.composite_index}} |
| 1805 | + * This is used during update index settings flow |
| 1806 | + * |
| 1807 | + * @param requestSettings settings passed in during index update request |
| 1808 | + * @param clusterSettings cluster setting |
| 1809 | + * @param indexSettings index settings |
| 1810 | + */ |
| 1811 | + public static Optional<String> validateTranslogFlushIntervalSettingsForCompositeIndex( |
| 1812 | + Settings requestSettings, |
| 1813 | + ClusterSettings clusterSettings, |
| 1814 | + Settings indexSettings |
| 1815 | + ) { |
| 1816 | + if (INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.exists(requestSettings) == false |
| 1817 | + || requestSettings.get(INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey()) == null |
| 1818 | + || StarTreeIndexSettings.IS_COMPOSITE_INDEX_SETTING.exists(indexSettings) == false |
| 1819 | + || indexSettings.get(StarTreeIndexSettings.IS_COMPOSITE_INDEX_SETTING.getKey()) == null) { |
| 1820 | + return Optional.empty(); |
| 1821 | + } |
| 1822 | + ByteSizeValue translogFlushSize = INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.get(requestSettings); |
| 1823 | + ByteSizeValue compositeIndexMaxFlushSize = clusterSettings.get( |
| 1824 | + CompositeIndexSettings.COMPOSITE_INDEX_MAX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING |
| 1825 | + ); |
| 1826 | + if (translogFlushSize.compareTo(compositeIndexMaxFlushSize) > 0) { |
| 1827 | + return Optional.of( |
| 1828 | + String.format( |
| 1829 | + Locale.ROOT, |
| 1830 | + "You can configure '%s' with upto '%s' for composite index", |
| 1831 | + INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), |
| 1832 | + compositeIndexMaxFlushSize |
| 1833 | + ) |
| 1834 | + ); |
| 1835 | + } |
| 1836 | + return Optional.empty(); |
| 1837 | + } |
| 1838 | + |
1769 | 1839 | /**
|
1770 | 1840 | * Validates {@code index.refresh_interval} is equal or below the {@code cluster.minimum.index.refresh_interval}.
|
1771 | 1841 | *
|
|
0 commit comments