diff --git a/modules/ingest-common/src/internalClusterTest/java/org/elasticsearch/plugins/internal/DocumentSizeObserverWithPipelinesIT.java b/modules/ingest-common/src/internalClusterTest/java/org/elasticsearch/plugins/internal/DocumentSizeObserverWithPipelinesIT.java index ca27b4e7b8a82..a083fced44e7f 100644 --- a/modules/ingest-common/src/internalClusterTest/java/org/elasticsearch/plugins/internal/DocumentSizeObserverWithPipelinesIT.java +++ b/modules/ingest-common/src/internalClusterTest/java/org/elasticsearch/plugins/internal/DocumentSizeObserverWithPipelinesIT.java @@ -134,10 +134,15 @@ public Map map() throws IOException { } @Override - public long normalisedBytesParsed() { + public long raiNormalisedBytes() { return mapCounter; } + @Override + public long rasNormalisedBytes() { + return 0; + } + @Override public void setNormalisedBytesParsedOn(IndexRequest indexRequest) { indexRequest.setNormalisedBytesParsed(mapCounter); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/plugins/internal/DocumentSizeObserverIT.java b/server/src/internalClusterTest/java/org/elasticsearch/plugins/internal/DocumentSizeObserverIT.java index 3bab8d3e73958..fc11e0ba0fb62 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/plugins/internal/DocumentSizeObserverIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/plugins/internal/DocumentSizeObserverIT.java @@ -109,8 +109,7 @@ public IndexResult index(Index index) throws IOException { DocumentSizeAccumulator.EMPTY_INSTANCE ); ParsedDocument parsedDocument = index.parsedDoc(); - DocumentSizeObserver documentSizeObserver = parsedDocument.getDocumentSizeObserver(); - documentParsingReporter.onIndexingCompleted(documentSizeObserver); + documentParsingReporter.onIndexingCompleted(parsedDocument); return result; } @@ -151,8 +150,8 @@ public TestDocumentSizeReporter(String indexName) { } @Override - public void onIndexingCompleted(NormalisedBytesWrapper documentSizeObserver) { - COUNTER.addAndGet(documentSizeObserver.raiNormalisedBytes()); + public void onIndexingCompleted(ParsedDocument parsedDocument) { + COUNTER.addAndGet(parsedDocument.raiNormalisedBytes()); assertThat(indexName, equalTo(TEST_INDEX_NAME)); } } @@ -177,11 +176,6 @@ public Token nextToken() throws IOException { }; } - @Override - public long normalisedBytesParsed() { - return counter; - } - @Override public void setNormalisedBytesParsedOn(IndexRequest indexRequest) { indexRequest.setNormalisedBytesParsed(counter); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java b/server/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java index d500d42e45fae..8450d799ca89d 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java @@ -15,6 +15,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.index.mapper.MapperService.MergeReason; import org.elasticsearch.plugins.internal.DocumentSizeObserver; +import org.elasticsearch.plugins.internal.NormalisedBytesToReport; import org.elasticsearch.xcontent.XContentType; import java.util.Collections; @@ -179,7 +180,7 @@ public String documentDescription() { return "id"; } - public DocumentSizeObserver getDocumentSizeObserver() { + public NormalisedBytesToReport getDocumentSizeObserver() { return documentSizeObserver; } diff --git a/server/src/main/java/org/elasticsearch/plugins/internal/DocumentSizeObserver.java b/server/src/main/java/org/elasticsearch/plugins/internal/DocumentSizeObserver.java index 7ac56f8f0c0d4..8528057e8e97a 100644 --- a/server/src/main/java/org/elasticsearch/plugins/internal/DocumentSizeObserver.java +++ b/server/src/main/java/org/elasticsearch/plugins/internal/DocumentSizeObserver.java @@ -15,7 +15,7 @@ * An interface to allow wrapping an XContentParser and observe the events emitted while parsing * A default implementation returns a noop DocumentSizeObserver */ -public interface DocumentSizeObserver extends NormalisedBytesWrapper { +public interface DocumentSizeObserver extends NormalisedBytesToReport { /** * a default noop implementation */ diff --git a/server/src/main/java/org/elasticsearch/plugins/internal/DocumentSizeReporter.java b/server/src/main/java/org/elasticsearch/plugins/internal/DocumentSizeReporter.java index f792fc0af7ddc..3b9d0e75b7b1f 100644 --- a/server/src/main/java/org/elasticsearch/plugins/internal/DocumentSizeReporter.java +++ b/server/src/main/java/org/elasticsearch/plugins/internal/DocumentSizeReporter.java @@ -8,6 +8,8 @@ package org.elasticsearch.plugins.internal; +import org.elasticsearch.index.mapper.ParsedDocument; + /** * An interface to allow performing an action when parsing and indexing has been completed */ @@ -21,10 +23,10 @@ public interface DocumentSizeReporter { /** * An action to be performed upon finished indexing. */ - default void onParsingCompleted(NormalisedBytesWrapper documentSizeObserver) {} + default void onParsingCompleted(ParsedDocument parsedDocument) {} /** * An action to be performed upon finished indexing. */ - default void onIndexingCompleted(NormalisedBytesWrapper documentSizeObserver) {} + default void onIndexingCompleted(ParsedDocument parsedDocument) {} } diff --git a/server/src/main/java/org/elasticsearch/plugins/internal/NormalisedBytesWrapper.java b/server/src/main/java/org/elasticsearch/plugins/internal/NormalisedBytesToReport.java similarity index 93% rename from server/src/main/java/org/elasticsearch/plugins/internal/NormalisedBytesWrapper.java rename to server/src/main/java/org/elasticsearch/plugins/internal/NormalisedBytesToReport.java index a9636eece0f08..f32872395f9fa 100644 --- a/server/src/main/java/org/elasticsearch/plugins/internal/NormalisedBytesWrapper.java +++ b/server/src/main/java/org/elasticsearch/plugins/internal/NormalisedBytesToReport.java @@ -8,7 +8,7 @@ package org.elasticsearch.plugins.internal; -public interface NormalisedBytesWrapper { +public interface NormalisedBytesToReport { /** * Returns the state gathered during parsing diff --git a/server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java b/server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java index bd8ac7cfc946f..2b45ce53ef7dd 100644 --- a/server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java +++ b/server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java @@ -1193,7 +1193,6 @@ public XContentParser wrapParser(XContentParser xContentParser) { return xContentParser; } - @Override public void setNormalisedBytesParsedOn(IndexRequest indexRequest) { parsedValueWasUsed.incrementAndGet();