浏览代码

Add AutoscalingMissedIndicesUpdateException (#102817)

Add an exception for the case where we can't update autoscaling index metric stats due to a missed index.
Artem Prigoda 1 年之前
父节点
当前提交
8d4677e011

+ 7 - 0
server/src/main/java/org/elasticsearch/ElasticsearchException.java

@@ -28,6 +28,7 @@ import org.elasticsearch.health.node.action.HealthNodeNotDiscoveredException;
 import org.elasticsearch.index.Index;
 import org.elasticsearch.index.mapper.DocumentParsingException;
 import org.elasticsearch.index.shard.ShardId;
+import org.elasticsearch.indices.AutoscalingMissedIndicesUpdateException;
 import org.elasticsearch.indices.recovery.RecoveryCommitTooNewException;
 import org.elasticsearch.rest.ApiNotAvailableException;
 import org.elasticsearch.rest.RestStatus;
@@ -1863,6 +1864,12 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
             AggregationExecutionException.InvalidPath::new,
             174,
             TransportVersions.INVALID_BUCKET_PATH_EXCEPTION_INTRODUCED
+        ),
+        MISSED_INDICES_UPDATE_EXCEPTION(
+            AutoscalingMissedIndicesUpdateException.class,
+            AutoscalingMissedIndicesUpdateException::new,
+            175,
+            TransportVersions.MISSED_INDICES_UPDATE_EXCEPTION_ADDED
         );
 
         final Class<? extends ElasticsearchException> exceptionClass;

+ 1 - 0
server/src/main/java/org/elasticsearch/TransportVersions.java

@@ -188,6 +188,7 @@ public class TransportVersions {
     public static final TransportVersion UPGRADE_TO_LUCENE_9_9 = def(8_555_00_0);
     public static final TransportVersion HEALTH_INFO_ENRICHED_WITH_DSL_STATUS = def(8_556_00_0);
     public static final TransportVersion SOURCE_IN_SINGLE_VALUE_QUERY_ADDED = def(8_557_00_0);
+    public static final TransportVersion MISSED_INDICES_UPDATE_EXCEPTION_ADDED = def(8_558_00_0);
 
     /*
      * STOP! READ THIS FIRST! No, really,

+ 24 - 0
server/src/main/java/org/elasticsearch/indices/AutoscalingMissedIndicesUpdateException.java

@@ -0,0 +1,24 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+package org.elasticsearch.indices;
+
+import org.elasticsearch.ElasticsearchException;
+import org.elasticsearch.common.io.stream.StreamInput;
+
+import java.io.IOException;
+
+public class AutoscalingMissedIndicesUpdateException extends ElasticsearchException {
+
+    public AutoscalingMissedIndicesUpdateException(String message) {
+        super(message);
+    }
+
+    public AutoscalingMissedIndicesUpdateException(StreamInput in) throws IOException {
+        super(in);
+    }
+}

+ 2 - 0
server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java

@@ -59,6 +59,7 @@ import org.elasticsearch.index.shard.IllegalIndexShardStateException;
 import org.elasticsearch.index.shard.IndexShardState;
 import org.elasticsearch.index.shard.ShardId;
 import org.elasticsearch.index.shard.ShardNotInPrimaryModeException;
+import org.elasticsearch.indices.AutoscalingMissedIndicesUpdateException;
 import org.elasticsearch.indices.IndexTemplateMissingException;
 import org.elasticsearch.indices.InvalidIndexTemplateException;
 import org.elasticsearch.indices.recovery.PeerRecoveryNotFound;
@@ -825,6 +826,7 @@ public class ExceptionSerializationTests extends ESTestCase {
         ids.put(172, RecoveryCommitTooNewException.class);
         ids.put(173, TooManyScrollContextsException.class);
         ids.put(174, AggregationExecutionException.InvalidPath.class);
+        ids.put(175, AutoscalingMissedIndicesUpdateException.class);
 
         Map<Class<? extends ElasticsearchException>, Integer> reverse = new HashMap<>();
         for (Map.Entry<Integer, Class<? extends ElasticsearchException>> entry : ids.entrySet()) {