|
23 | 23 | import org.apache.logging.log4j.util.Supplier;
|
24 | 24 | import org.apache.lucene.util.BytesRef;
|
25 | 25 | import org.elasticsearch.ElasticsearchException;
|
| 26 | +import org.elasticsearch.ExceptionsHelper; |
26 | 27 | import org.elasticsearch.cluster.ClusterChangedEvent;
|
27 | 28 | import org.elasticsearch.cluster.ClusterState;
|
28 | 29 | import org.elasticsearch.cluster.ClusterStateListener;
|
@@ -165,7 +166,20 @@ public TribeService(Settings settings, Environment environment, NodeEnvironment
|
165 | 166 | nodesSettings.remove("on_conflict"); // remove prefix settings that don't indicate a client
|
166 | 167 | for (Map.Entry<String, Settings> entry : nodesSettings.entrySet()) {
|
167 | 168 | Settings clientSettings = buildClientSettings(entry.getKey(), nodeEnvironment.nodeId(), settings, entry.getValue());
|
168 |
| - nodes.add(clientNodeBuilder.newNode(clientSettings, environment.configFile())); |
| 169 | + try { |
| 170 | + nodes.add(clientNodeBuilder.newNode(clientSettings, environment.configFile())); |
| 171 | + } catch (Exception e) { |
| 172 | + // calling close is safe for non started nodes, we can just iterate over all |
| 173 | + for (Node otherNode : nodes) { |
| 174 | + try { |
| 175 | + otherNode.close(); |
| 176 | + } catch (Exception inner) { |
| 177 | + inner.addSuppressed(e); |
| 178 | + logger.warn((Supplier<?>) () -> new ParameterizedMessage("failed to close node {} on failed start", otherNode), inner); |
| 179 | + } |
| 180 | + } |
| 181 | + throw ExceptionsHelper.convertToRuntime(e); |
| 182 | + } |
169 | 183 | }
|
170 | 184 |
|
171 | 185 | this.blockIndicesMetadata = BLOCKS_METADATA_INDICES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY);
|
@@ -237,10 +251,7 @@ public void startNodes() {
|
237 | 251 | logger.warn((Supplier<?>) () -> new ParameterizedMessage("failed to close node {} on failed start", otherNode), inner);
|
238 | 252 | }
|
239 | 253 | }
|
240 |
| - if (e instanceof RuntimeException) { |
241 |
| - throw (RuntimeException) e; |
242 |
| - } |
243 |
| - throw new ElasticsearchException(e); |
| 254 | + throw ExceptionsHelper.convertToRuntime(e); |
244 | 255 | }
|
245 | 256 | }
|
246 | 257 | }
|
|
0 commit comments