|
@@ -1957,9 +1957,9 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
// total
|
|
|
assertStats(ingestStats.totalStats(), 0, 0, 0);
|
|
|
// pipeline
|
|
|
- assertPipelineStats(ingestStats.pipelineStats(), "_id1", 0, 0, 0);
|
|
|
- assertPipelineStats(ingestStats.pipelineStats(), "_id2", 0, 0, 0);
|
|
|
- assertPipelineStats(ingestStats.pipelineStats(), "_id3", 0, 0, 0);
|
|
|
+ assertPipelineStats(ingestStats.pipelineStats(), "_id1", 0, 0, 0, 0, 0);
|
|
|
+ assertPipelineStats(ingestStats.pipelineStats(), "_id2", 0, 0, 0, 0, 0);
|
|
|
+ assertPipelineStats(ingestStats.pipelineStats(), "_id3", 0, 0, 0, 0, 0);
|
|
|
// processor
|
|
|
assertProcessorStats(0, ingestStats, "_id1", 0, 0, 0);
|
|
|
assertProcessorStats(0, ingestStats, "_id2", 0, 0, 0);
|
|
@@ -1970,6 +1970,7 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
final IndexRequest indexRequest = new IndexRequest("_index");
|
|
|
indexRequest.setPipeline("_id1").setFinalPipeline("_id2");
|
|
|
indexRequest.source(randomAlphaOfLength(10), randomAlphaOfLength(10));
|
|
|
+ var startSize = indexRequest.ramBytesUsed();
|
|
|
ingestService.executeBulkRequest(
|
|
|
1,
|
|
|
List.of(indexRequest),
|
|
@@ -1988,9 +1989,9 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
// total
|
|
|
assertStats(ingestStats.totalStats(), 1, 0, 0);
|
|
|
// pipeline
|
|
|
- assertPipelineStats(ingestStats.pipelineStats(), "_id1", 1, 0, 0);
|
|
|
- assertPipelineStats(ingestStats.pipelineStats(), "_id2", 1, 0, 0);
|
|
|
- assertPipelineStats(ingestStats.pipelineStats(), "_id3", 1, 0, 0);
|
|
|
+ assertPipelineStats(ingestStats.pipelineStats(), "_id1", 1, 0, 0, startSize, indexRequest.ramBytesUsed());
|
|
|
+ assertPipelineStats(ingestStats.pipelineStats(), "_id2", 1, 0, 0, 0, 0);
|
|
|
+ assertPipelineStats(ingestStats.pipelineStats(), "_id3", 1, 0, 0, 0, 0);
|
|
|
// processor
|
|
|
assertProcessorStats(0, ingestStats, "_id1", 1, 0, 0);
|
|
|
assertProcessorStats(0, ingestStats, "_id2", 1, 0, 0);
|
|
@@ -2022,6 +2023,7 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
Map<String, Processor.Factory> map = Maps.newMapWithExpectedSize(2);
|
|
|
map.put("mock", (factories, tag, description, config) -> processor);
|
|
|
map.put("failure-mock", (factories, tag, description, config) -> processorFailure);
|
|
|
+ map.put("drop", new DropProcessor.Factory());
|
|
|
IngestService ingestService = createWithProcessors(map);
|
|
|
|
|
|
final IngestStats initialStats = ingestService.stats();
|
|
@@ -2050,6 +2052,7 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
final IndexRequest indexRequest = new IndexRequest("_index");
|
|
|
indexRequest.setPipeline("_id1").setFinalPipeline("_none");
|
|
|
indexRequest.source(randomAlphaOfLength(10), randomAlphaOfLength(10));
|
|
|
+ var startSize1 = indexRequest.ramBytesUsed();
|
|
|
ingestService.executeBulkRequest(
|
|
|
1,
|
|
|
List.of(indexRequest),
|
|
@@ -2061,6 +2064,7 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
EsExecutors.DIRECT_EXECUTOR_SERVICE
|
|
|
);
|
|
|
final IngestStats afterFirstRequestStats = ingestService.stats();
|
|
|
+ var endSize1 = indexRequest.ramBytesUsed();
|
|
|
assertThat(afterFirstRequestStats.pipelineStats().size(), equalTo(2));
|
|
|
|
|
|
afterFirstRequestStats.processorStats().get("_id1").forEach(p -> assertEquals(p.name(), "mock:mockTag"));
|
|
@@ -2069,13 +2073,14 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
// total
|
|
|
assertStats(afterFirstRequestStats.totalStats(), 1, 0, 0);
|
|
|
// pipeline
|
|
|
- assertPipelineStats(afterFirstRequestStats.pipelineStats(), "_id1", 1, 0, 0);
|
|
|
- assertPipelineStats(afterFirstRequestStats.pipelineStats(), "_id2", 0, 0, 0);
|
|
|
+ assertPipelineStats(afterFirstRequestStats.pipelineStats(), "_id1", 1, 0, 0, startSize1, endSize1);
|
|
|
+ assertPipelineStats(afterFirstRequestStats.pipelineStats(), "_id2", 0, 0, 0, 0, 0);
|
|
|
// processor
|
|
|
assertProcessorStats(0, afterFirstRequestStats, "_id1", 1, 0, 0);
|
|
|
assertProcessorStats(0, afterFirstRequestStats, "_id2", 0, 0, 0);
|
|
|
|
|
|
indexRequest.setPipeline("_id2");
|
|
|
+ var startSize2 = indexRequest.ramBytesUsed();
|
|
|
ingestService.executeBulkRequest(
|
|
|
1,
|
|
|
List.of(indexRequest),
|
|
@@ -2087,12 +2092,13 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
EsExecutors.DIRECT_EXECUTOR_SERVICE
|
|
|
);
|
|
|
final IngestStats afterSecondRequestStats = ingestService.stats();
|
|
|
+ var endSize2 = indexRequest.ramBytesUsed();
|
|
|
assertThat(afterSecondRequestStats.pipelineStats().size(), equalTo(2));
|
|
|
// total
|
|
|
assertStats(afterSecondRequestStats.totalStats(), 2, 0, 0);
|
|
|
// pipeline
|
|
|
- assertPipelineStats(afterSecondRequestStats.pipelineStats(), "_id1", 1, 0, 0);
|
|
|
- assertPipelineStats(afterSecondRequestStats.pipelineStats(), "_id2", 1, 0, 0);
|
|
|
+ assertPipelineStats(afterSecondRequestStats.pipelineStats(), "_id1", 1, 0, 0, startSize1, endSize1);
|
|
|
+ assertPipelineStats(afterSecondRequestStats.pipelineStats(), "_id2", 1, 0, 0, startSize2, endSize2);
|
|
|
// processor
|
|
|
assertProcessorStats(0, afterSecondRequestStats, "_id1", 1, 0, 0);
|
|
|
assertProcessorStats(0, afterSecondRequestStats, "_id2", 1, 0, 0);
|
|
@@ -2107,6 +2113,7 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
clusterState = executePut(putRequest, clusterState);
|
|
|
ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState));
|
|
|
indexRequest.setPipeline("_id1");
|
|
|
+ startSize1 += indexRequest.ramBytesUsed();
|
|
|
ingestService.executeBulkRequest(
|
|
|
1,
|
|
|
List.of(indexRequest),
|
|
@@ -2118,12 +2125,13 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
EsExecutors.DIRECT_EXECUTOR_SERVICE
|
|
|
);
|
|
|
final IngestStats afterThirdRequestStats = ingestService.stats();
|
|
|
+ endSize1 += indexRequest.ramBytesUsed();
|
|
|
assertThat(afterThirdRequestStats.pipelineStats().size(), equalTo(2));
|
|
|
// total
|
|
|
assertStats(afterThirdRequestStats.totalStats(), 3, 0, 0);
|
|
|
// pipeline
|
|
|
- assertPipelineStats(afterThirdRequestStats.pipelineStats(), "_id1", 2, 0, 0);
|
|
|
- assertPipelineStats(afterThirdRequestStats.pipelineStats(), "_id2", 1, 0, 0);
|
|
|
+ assertPipelineStats(afterThirdRequestStats.pipelineStats(), "_id1", 2, 0, 0, startSize1, endSize1);
|
|
|
+ assertPipelineStats(afterThirdRequestStats.pipelineStats(), "_id2", 1, 0, 0, startSize2, endSize2);
|
|
|
// The number of processors for the "id1" pipeline changed, so the per-processor metrics are not carried forward. This is
|
|
|
// due to the parallel array's used to identify which metrics to carry forward. Without unique ids or semantic equals for each
|
|
|
// processor, parallel arrays are the best option for of carrying forward metrics between pipeline changes. However, in some cases,
|
|
@@ -2139,6 +2147,7 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
clusterState = executePut(putRequest, clusterState);
|
|
|
ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState));
|
|
|
indexRequest.setPipeline("_id1");
|
|
|
+ startSize1 += indexRequest.ramBytesUsed();
|
|
|
ingestService.executeBulkRequest(
|
|
|
1,
|
|
|
List.of(indexRequest),
|
|
@@ -2150,16 +2159,47 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
EsExecutors.DIRECT_EXECUTOR_SERVICE
|
|
|
);
|
|
|
final IngestStats afterForthRequestStats = ingestService.stats();
|
|
|
+ endSize1 += indexRequest.ramBytesUsed();
|
|
|
assertThat(afterForthRequestStats.pipelineStats().size(), equalTo(2));
|
|
|
// total
|
|
|
assertStats(afterForthRequestStats.totalStats(), 4, 0, 0);
|
|
|
// pipeline
|
|
|
- assertPipelineStats(afterForthRequestStats.pipelineStats(), "_id1", 3, 0, 0);
|
|
|
- assertPipelineStats(afterForthRequestStats.pipelineStats(), "_id2", 1, 0, 0);
|
|
|
+ assertPipelineStats(afterForthRequestStats.pipelineStats(), "_id1", 3, 0, 0, startSize1, endSize1);
|
|
|
+ assertPipelineStats(afterForthRequestStats.pipelineStats(), "_id2", 1, 0, 0, startSize2, endSize2);
|
|
|
// processor
|
|
|
assertProcessorStats(0, afterForthRequestStats, "_id1", 1, 1, 0); // not carried forward since type changed
|
|
|
assertProcessorStats(1, afterForthRequestStats, "_id1", 2, 0, 0); // carried forward and added from old stats
|
|
|
assertProcessorStats(0, afterForthRequestStats, "_id2", 1, 0, 0);
|
|
|
+
|
|
|
+ // test with drop processor
|
|
|
+ putRequest = new PutPipelineRequest("_id3", new BytesArray("{\"processors\": [{\"drop\" : {}}]}"), XContentType.JSON);
|
|
|
+ previousClusterState = clusterState;
|
|
|
+ clusterState = executePut(putRequest, clusterState);
|
|
|
+ ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState));
|
|
|
+ indexRequest.setPipeline("_id3");
|
|
|
+ long startSize3 = indexRequest.ramBytesUsed();
|
|
|
+ ingestService.executeBulkRequest(
|
|
|
+ 1,
|
|
|
+ List.of(indexRequest),
|
|
|
+ indexReq -> {},
|
|
|
+ (s) -> false,
|
|
|
+ (slot, targetIndex, e) -> fail("Should not be redirecting failures"),
|
|
|
+ failureHandler,
|
|
|
+ completionHandler,
|
|
|
+ EsExecutors.DIRECT_EXECUTOR_SERVICE
|
|
|
+ );
|
|
|
+ final IngestStats afterFifthRequestStats = ingestService.stats();
|
|
|
+ assertThat(afterFifthRequestStats.pipelineStats().size(), equalTo(3));
|
|
|
+ // total
|
|
|
+ assertStats(afterFifthRequestStats.totalStats(), 5, 0, 0);
|
|
|
+ // pipeline
|
|
|
+ assertPipelineStats(afterFifthRequestStats.pipelineStats(), "_id1", 3, 0, 0, startSize1, endSize1);
|
|
|
+ assertPipelineStats(afterFifthRequestStats.pipelineStats(), "_id2", 1, 0, 0, startSize2, endSize2);
|
|
|
+ assertPipelineStats(afterFifthRequestStats.pipelineStats(), "_id3", 1, 0, 0, startSize3, 0);
|
|
|
+ // processor
|
|
|
+ assertProcessorStats(0, afterFifthRequestStats, "_id1", 1, 1, 0);
|
|
|
+ assertProcessorStats(1, afterFifthRequestStats, "_id1", 2, 0, 0);
|
|
|
+ assertProcessorStats(0, afterFifthRequestStats, "_id2", 1, 0, 0);
|
|
|
}
|
|
|
|
|
|
public void testStatName() {
|
|
@@ -2979,8 +3019,18 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
assertStats(stats.processorStats().get(pipelineId).get(processor).stats(), count, failed, time);
|
|
|
}
|
|
|
|
|
|
- private void assertPipelineStats(List<IngestStats.PipelineStat> pipelineStats, String pipelineId, long count, long failed, long time) {
|
|
|
- assertStats(getPipelineStats(pipelineStats, pipelineId), count, failed, time);
|
|
|
+ private void assertPipelineStats(
|
|
|
+ List<IngestStats.PipelineStat> pipelineStats,
|
|
|
+ String pipelineId,
|
|
|
+ long count,
|
|
|
+ long failed,
|
|
|
+ long time,
|
|
|
+ long ingested,
|
|
|
+ long produced
|
|
|
+ ) {
|
|
|
+ var pipeline = getPipeline(pipelineStats, pipelineId);
|
|
|
+ assertStats(pipeline.stats(), count, failed, time);
|
|
|
+ assertByteStats(pipeline.byteStats(), ingested, produced);
|
|
|
}
|
|
|
|
|
|
private void assertStats(IngestStats.Stats stats, long count, long failed, long time) {
|
|
@@ -2990,8 +3040,13 @@ public class IngestServiceTests extends ESTestCase {
|
|
|
assertThat(stats.ingestTimeInMillis(), greaterThanOrEqualTo(time));
|
|
|
}
|
|
|
|
|
|
- private IngestStats.Stats getPipelineStats(List<IngestStats.PipelineStat> pipelineStats, String id) {
|
|
|
- return pipelineStats.stream().filter(p1 -> p1.pipelineId().equals(id)).findFirst().map(p2 -> p2.stats()).orElse(null);
|
|
|
+ private void assertByteStats(IngestStats.ByteStats byteStats, long ingested, long produced) {
|
|
|
+ assertThat(byteStats.bytesIngested(), equalTo(ingested));
|
|
|
+ assertThat(byteStats.bytesProduced(), equalTo(produced));
|
|
|
+ }
|
|
|
+
|
|
|
+ private IngestStats.PipelineStat getPipeline(List<IngestStats.PipelineStat> pipelineStats, String id) {
|
|
|
+ return pipelineStats.stream().filter(p1 -> p1.pipelineId().equals(id)).findFirst().orElse(null);
|
|
|
}
|
|
|
|
|
|
private static List<IngestService.PipelineClusterStateUpdateTask> oneTask(DeletePipelineRequest request) {
|