Skip to content

Commit 1a00847

Browse files
author
Hendrik Muhs
authored
temporary merge PR 32743 (#32776)
This is a temporary (squashed) commit of #32743 till ed4feb6, to be reverted and replaced by the final version of this PR
1 parent fd708ed commit 1a00847

File tree

24 files changed

+729
-425
lines changed

24 files changed

+729
-425
lines changed

x-pack/docs/en/rest-api/rollup/get-job.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Which will yield the following response:
9999
"stats" : {
100100
"pages_processed" : 0,
101101
"documents_processed" : 0,
102-
"rollups_indexed" : 0,
102+
"documents_indexed" : 0,
103103
"trigger_count" : 0
104104
}
105105
}
@@ -219,7 +219,7 @@ Which will yield the following response:
219219
"stats" : {
220220
"pages_processed" : 0,
221221
"documents_processed" : 0,
222-
"rollups_indexed" : 0,
222+
"documents_indexed" : 0,
223223
"trigger_count" : 0
224224
}
225225
},
@@ -268,7 +268,7 @@ Which will yield the following response:
268268
"stats" : {
269269
"pages_processed" : 0,
270270
"documents_processed" : 0,
271-
"rollups_indexed" : 0,
271+
"documents_indexed" : 0,
272272
"trigger_count" : 0
273273
}
274274
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJobStats.java renamed to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexing/IndexerJobStats.java

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
package org.elasticsearch.xpack.core.rollup.job;
6+
package org.elasticsearch.xpack.core.indexing;
77

88
import org.elasticsearch.common.ParseField;
99
import org.elasticsearch.common.io.stream.StreamInput;
@@ -13,7 +13,6 @@
1313
import org.elasticsearch.common.xcontent.ToXContentObject;
1414
import org.elasticsearch.common.xcontent.XContentBuilder;
1515
import org.elasticsearch.common.xcontent.XContentParser;
16-
1716
import java.io.IOException;
1817
import java.util.Objects;
1918

@@ -24,45 +23,46 @@
2423
* and are only for external monitoring/reference. Statistics are not persisted with the job, so if the
2524
* allocated task is shutdown/restarted on a different node all the stats will reset.
2625
*/
27-
public class RollupJobStats implements ToXContentObject, Writeable {
26+
public class IndexerJobStats implements ToXContentObject, Writeable {
2827

2928
public static final ParseField NAME = new ParseField("job_stats");
3029

3130
private static ParseField NUM_PAGES = new ParseField("pages_processed");
32-
private static ParseField NUM_DOCUMENTS = new ParseField("documents_processed");
33-
private static ParseField NUM_ROLLUPS = new ParseField("rollups_indexed");
31+
private static ParseField NUM_INPUT_DOCUMENTS = new ParseField("documents_processed");
32+
// BWC for RollupJobStats
33+
private static ParseField NUM_OUTPUT_DOCUMENTS = new ParseField("documents_indexed").withDeprecation("rollups_indexed");
3434
private static ParseField NUM_INVOCATIONS = new ParseField("trigger_count");
3535

3636
private long numPages = 0;
37-
private long numDocuments = 0;
38-
private long numRollups = 0;
37+
private long numInputDocuments = 0;
38+
private long numOuputDocuments = 0;
3939
private long numInvocations = 0;
4040

41-
public static final ConstructingObjectParser<RollupJobStats, Void> PARSER =
41+
public static final ConstructingObjectParser<IndexerJobStats, Void> PARSER =
4242
new ConstructingObjectParser<>(NAME.getPreferredName(),
43-
args -> new RollupJobStats((long) args[0], (long) args[1], (long) args[2], (long) args[3]));
43+
args -> new IndexerJobStats((long) args[0], (long) args[1], (long) args[2], (long) args[3]));
4444

4545
static {
4646
PARSER.declareLong(constructorArg(), NUM_PAGES);
47-
PARSER.declareLong(constructorArg(), NUM_DOCUMENTS);
48-
PARSER.declareLong(constructorArg(), NUM_ROLLUPS);
47+
PARSER.declareLong(constructorArg(), NUM_INPUT_DOCUMENTS);
48+
PARSER.declareLong(constructorArg(), NUM_OUTPUT_DOCUMENTS);
4949
PARSER.declareLong(constructorArg(), NUM_INVOCATIONS);
5050
}
5151

52-
public RollupJobStats() {
52+
public IndexerJobStats() {
5353
}
5454

55-
public RollupJobStats(long numPages, long numDocuments, long numRollups, long numInvocations) {
55+
public IndexerJobStats(long numPages, long numDocuments, long numOuputDocuments, long numInvocations) {
5656
this.numPages = numPages;
57-
this.numDocuments = numDocuments;
58-
this.numRollups = numRollups;
57+
this.numInputDocuments = numDocuments;
58+
this.numOuputDocuments = numOuputDocuments;
5959
this.numInvocations = numInvocations;
6060
}
6161

62-
public RollupJobStats(StreamInput in) throws IOException {
62+
public IndexerJobStats(StreamInput in) throws IOException {
6363
this.numPages = in.readVLong();
64-
this.numDocuments = in.readVLong();
65-
this.numRollups = in.readVLong();
64+
this.numInputDocuments = in.readVLong();
65+
this.numOuputDocuments = in.readVLong();
6666
this.numInvocations = in.readVLong();
6767
}
6868

@@ -71,15 +71,15 @@ public long getNumPages() {
7171
}
7272

7373
public long getNumDocuments() {
74-
return numDocuments;
74+
return numInputDocuments;
7575
}
7676

7777
public long getNumInvocations() {
7878
return numInvocations;
7979
}
8080

81-
public long getNumRollups() {
82-
return numRollups;
81+
public long getOutputDocuments() {
82+
return numOuputDocuments;
8383
}
8484

8585
public void incrementNumPages(long n) {
@@ -89,28 +89,28 @@ public void incrementNumPages(long n) {
8989

9090
public void incrementNumDocuments(long n) {
9191
assert(n >= 0);
92-
numDocuments += n;
92+
numInputDocuments += n;
9393
}
9494

9595
public void incrementNumInvocations(long n) {
9696
assert(n >= 0);
9797
numInvocations += n;
9898
}
9999

100-
public void incrementNumRollups(long n) {
100+
public void incrementNumOutputDocuments(long n) {
101101
assert(n >= 0);
102-
numRollups += n;
102+
numOuputDocuments += n;
103103
}
104104

105105
@Override
106106
public void writeTo(StreamOutput out) throws IOException {
107107
out.writeVLong(numPages);
108-
out.writeVLong(numDocuments);
109-
out.writeVLong(numRollups);
108+
out.writeVLong(numInputDocuments);
109+
out.writeVLong(numOuputDocuments);
110110
out.writeVLong(numInvocations);
111111
}
112112

113-
public static RollupJobStats fromXContent(XContentParser parser) {
113+
public static IndexerJobStats fromXContent(XContentParser parser) {
114114
try {
115115
return PARSER.parse(parser, null);
116116
} catch (IOException e) {
@@ -122,8 +122,8 @@ public static RollupJobStats fromXContent(XContentParser parser) {
122122
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
123123
builder.startObject();
124124
builder.field(NUM_PAGES.getPreferredName(), numPages);
125-
builder.field(NUM_DOCUMENTS.getPreferredName(), numDocuments);
126-
builder.field(NUM_ROLLUPS.getPreferredName(), numRollups);
125+
builder.field(NUM_INPUT_DOCUMENTS.getPreferredName(), numInputDocuments);
126+
builder.field(NUM_OUTPUT_DOCUMENTS.getPreferredName(), numOuputDocuments);
127127
builder.field(NUM_INVOCATIONS.getPreferredName(), numInvocations);
128128
builder.endObject();
129129
return builder;
@@ -139,18 +139,16 @@ public boolean equals(Object other) {
139139
return false;
140140
}
141141

142-
RollupJobStats that = (RollupJobStats) other;
142+
IndexerJobStats that = (IndexerJobStats) other;
143143

144144
return Objects.equals(this.numPages, that.numPages)
145-
&& Objects.equals(this.numDocuments, that.numDocuments)
146-
&& Objects.equals(this.numRollups, that.numRollups)
145+
&& Objects.equals(this.numInputDocuments, that.numInputDocuments)
146+
&& Objects.equals(this.numOuputDocuments, that.numOuputDocuments)
147147
&& Objects.equals(this.numInvocations, that.numInvocations);
148148
}
149149

150150
@Override
151151
public int hashCode() {
152-
return Objects.hash(numPages, numDocuments, numRollups, numInvocations);
152+
return Objects.hash(numPages, numInputDocuments, numOuputDocuments, numInvocations);
153153
}
154-
155154
}
156-

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/IndexerState.java renamed to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexing/IndexerState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
package org.elasticsearch.xpack.core.rollup.job;
6+
package org.elasticsearch.xpack.core.indexing;
77

88
import org.elasticsearch.common.ParseField;
99
import org.elasticsearch.common.io.stream.StreamInput;
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
package org.elasticsearch.xpack.core.indexing;
8+
9+
import org.elasticsearch.action.index.IndexRequest;
10+
11+
import java.util.List;
12+
13+
/**
14+
* Result object to hold the result of 1 iteration of iterative indexing.
15+
* Acts as an interface between the implementation and the generic indexer.
16+
*/
17+
public class Iteration<JobPosition> {
18+
19+
private final boolean isDone;
20+
private final JobPosition position;
21+
private final List<IndexRequest> toIndex;
22+
23+
/**
24+
* Constructor for the result of 1 iteration.
25+
*
26+
* @param toIndex the list of requests to be indexed
27+
* @param position the extracted, persistable position of the job required for the search phase
28+
* @param isDone true if source is exhausted and job should go to sleep
29+
*
30+
* Note: toIndex.empty() != isDone due to possible filtering in the specific implementation
31+
*/
32+
public Iteration(List<IndexRequest> toIndex, JobPosition position, boolean isDone) {
33+
this.toIndex = toIndex;
34+
this.position = position;
35+
this.isDone = isDone;
36+
}
37+
38+
/**
39+
* Returns true if this indexing iteration is done and job should go into sleep mode.
40+
*/
41+
public boolean isDone() {
42+
return isDone;
43+
}
44+
45+
/**
46+
* Return the position of the job, a generic to be passed to the next query construction.
47+
*
48+
* @return the position
49+
*/
50+
public JobPosition getPosition() {
51+
return position;
52+
}
53+
54+
/**
55+
* List of requests to be passed to bulk indexing.
56+
*
57+
* @return List of index requests.
58+
*/
59+
public List<IndexRequest> getToIndex() {
60+
return toIndex;
61+
}
62+
}

0 commit comments

Comments
 (0)