|
22 | 22 | import jakarta.inject.Inject; |
23 | 23 | import jakarta.inject.Singleton; |
24 | 24 | import jakarta.validation.constraints.NotNull; |
| 25 | +import jakarta.ws.rs.NotFoundException; |
25 | 26 | import org.graylog2.indexer.ElasticsearchException; |
26 | 27 | import org.graylog2.indexer.cluster.Cluster; |
27 | 28 | import org.graylog2.indexer.indexset.registry.IndexSetRegistry; |
@@ -67,7 +68,11 @@ public List<OutdatedIndex> getOutdatedIndices() { |
67 | 68 | } |
68 | 69 |
|
69 | 70 | public void reindex(String index, boolean withReplicas) { |
70 | | - HealthStatus sourceStatus = indicesAdapter.waitForRecovery(index, 2); |
| 71 | + OutdatedIndex outdatedIndex = getOutdatedIndices().stream() |
| 72 | + .filter(OutdatedIndex::isSystemIndex) |
| 73 | + .filter(i -> i.indexName().equals(index)) |
| 74 | + .findAny().orElseThrow(() -> new NotFoundException("Index " + index + " not found or is no system index")); |
| 75 | + HealthStatus sourceStatus = indicesAdapter.waitForRecovery(outdatedIndex.indexName(), 2); |
71 | 76 | if (sourceStatus != HealthStatus.Green) { |
72 | 77 | throw new IllegalStateException("Index " + index + " state is not healthy: " + sourceStatus); |
73 | 78 | } |
@@ -151,6 +156,10 @@ private Map<String, Object> cleanIndexSettings(Map<String, Object> settings, boo |
151 | 156 | } |
152 | 157 |
|
153 | 158 | public void delete(@NotNull String index) { |
154 | | - indicesAdapter.delete(index); |
| 159 | + OutdatedIndex outdatedIndex = getOutdatedIndices().stream() |
| 160 | + .filter(i -> !i.managedIndex()) |
| 161 | + .filter(i -> i.indexName().equals(index)) |
| 162 | + .findAny().orElseThrow(() -> new NotFoundException("Index " + index + " not found or is an index managed by Graylog")); |
| 163 | + indicesAdapter.delete(outdatedIndex.indexName()); |
155 | 164 | } |
156 | 165 | } |
0 commit comments