-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better names and types for ingest stats (#93533)
- Loading branch information
Showing
7 changed files
with
114 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 93533 | ||
summary: Better names and types for ingest stats | ||
area: Ingest Node | ||
type: bug | ||
issues: | ||
- 80763 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
server/src/main/java/org/elasticsearch/ingest/OnFailureProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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.ingest; | ||
|
||
import org.elasticsearch.core.Tuple; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* A wrapping processor that adds failure handling logic around the wrapped processor. | ||
*/ | ||
public class OnFailureProcessor extends CompoundProcessor implements WrappingProcessor { | ||
|
||
static final String TYPE = "on_failure"; | ||
|
||
public OnFailureProcessor(boolean ignoreFailure, Processor processor, List<Processor> onFailureProcessors) { | ||
super(ignoreFailure, List.of(processor), onFailureProcessors); | ||
} | ||
|
||
@Override | ||
public Processor getInnerProcessor() { | ||
List<Processor> processors = this.getProcessors(); | ||
assert processors.size() == 1; | ||
return processors.get(0); | ||
} | ||
|
||
IngestMetric getInnerMetric() { | ||
List<Tuple<Processor, IngestMetric>> processorsAndMetrics = this.getProcessorsWithMetrics(); | ||
assert processorsAndMetrics.size() == 1; | ||
return processorsAndMetrics.get(0).v2(); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return TYPE; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
server/src/test/java/org/elasticsearch/ingest/OnFailureProcessorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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.ingest; | ||
|
||
import org.elasticsearch.test.ESTestCase; | ||
|
||
import java.util.List; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.sameInstance; | ||
|
||
public class OnFailureProcessorTests extends ESTestCase { | ||
|
||
public void testOnFailureProcessor() { | ||
TestProcessor processor = new TestProcessor(new RuntimeException("error")); | ||
OnFailureProcessor onFailureProcessor = new OnFailureProcessor(false, processor, List.of()); | ||
|
||
assertThat(onFailureProcessor.isIgnoreFailure(), is(false)); | ||
|
||
assertThat(onFailureProcessor.getProcessors().size(), equalTo(1)); | ||
assertThat(onFailureProcessor.getProcessors().get(0), sameInstance(processor)); | ||
assertThat(onFailureProcessor.getInnerProcessor(), sameInstance(processor)); | ||
|
||
assertThat(onFailureProcessor.getOnFailureProcessors().isEmpty(), is(true)); | ||
|
||
assertThat(onFailureProcessor.getInnerMetric(), sameInstance(onFailureProcessor.getProcessorsWithMetrics().get(0).v2())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters