|
19 | 19 | import org.elasticsearch.action.support.PlainActionFuture; |
20 | 20 | import org.elasticsearch.client.internal.Client; |
21 | 21 | import org.elasticsearch.cluster.block.ClusterBlockLevel; |
| 22 | +import org.elasticsearch.cluster.metadata.ProjectId; |
22 | 23 | import org.elasticsearch.cluster.service.ClusterService; |
23 | 24 | import org.elasticsearch.common.CheckedSupplier; |
24 | 25 | import org.elasticsearch.common.Strings; |
25 | 26 | import org.elasticsearch.common.hash.MessageDigests; |
| 27 | +import org.elasticsearch.core.NotMultiProjectCapable; |
26 | 28 | import org.elasticsearch.core.TimeValue; |
27 | 29 | import org.elasticsearch.core.Tuple; |
28 | 30 | import org.elasticsearch.index.query.BoolQueryBuilder; |
|
67 | 69 | * Downloads are verified against MD5 checksum provided by the server |
68 | 70 | * Current state of all stored databases is stored in cluster state in persistent task state |
69 | 71 | */ |
| 72 | +@NotMultiProjectCapable( |
| 73 | + description = "Enterprise GeoIP not available in serverless, we should review this class for MP again after serverless is enabled" |
| 74 | +) |
70 | 75 | public class EnterpriseGeoIpDownloader extends AllocatedPersistentTask { |
71 | 76 |
|
72 | 77 | private static final Logger logger = LogManager.getLogger(EnterpriseGeoIpDownloader.class); |
@@ -142,22 +147,27 @@ void setState(EnterpriseGeoIpTaskState state) { |
142 | 147 |
|
143 | 148 | // visible for testing |
144 | 149 | void updateDatabases() throws IOException { |
| 150 | + @NotMultiProjectCapable(description = "Enterprise GeoIP not available in serverless") |
| 151 | + ProjectId projectId = ProjectId.DEFAULT; |
145 | 152 | var clusterState = clusterService.state(); |
146 | | - var geoipIndex = clusterState.getMetadata().getProject().getIndicesLookup().get(EnterpriseGeoIpDownloader.DATABASES_INDEX); |
| 153 | + var geoipIndex = clusterState.getMetadata().getProject(projectId).getIndicesLookup().get(EnterpriseGeoIpDownloader.DATABASES_INDEX); |
147 | 154 | if (geoipIndex != null) { |
148 | 155 | logger.trace("the geoip index [{}] exists", EnterpriseGeoIpDownloader.DATABASES_INDEX); |
149 | | - if (clusterState.getRoutingTable().index(geoipIndex.getWriteIndex()).allPrimaryShardsActive() == false) { |
| 156 | + if (clusterState.routingTable(projectId).index(geoipIndex.getWriteIndex()).allPrimaryShardsActive() == false) { |
150 | 157 | logger.debug("not updating databases because not all primary shards of [{}] index are active yet", DATABASES_INDEX); |
151 | 158 | return; |
152 | 159 | } |
153 | | - var blockException = clusterState.blocks().indexBlockedException(ClusterBlockLevel.WRITE, geoipIndex.getWriteIndex().getName()); |
| 160 | + var blockException = clusterState.blocks() |
| 161 | + .indexBlockedException(projectId, ClusterBlockLevel.WRITE, geoipIndex.getWriteIndex().getName()); |
154 | 162 | if (blockException != null) { |
155 | 163 | throw blockException; |
156 | 164 | } |
157 | 165 | } |
158 | 166 |
|
159 | 167 | logger.trace("Updating databases"); |
160 | | - IngestGeoIpMetadata geoIpMeta = clusterState.metadata().getProject().custom(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY); |
| 168 | + IngestGeoIpMetadata geoIpMeta = clusterState.metadata() |
| 169 | + .getProject(projectId) |
| 170 | + .custom(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY); |
161 | 171 |
|
162 | 172 | // if there are entries in the cs that aren't in the persistent task state, |
163 | 173 | // then download those (only) |
|
0 commit comments