Skip to content

Commit 36af27e

Browse files
committed
rename
1 parent d70aa28 commit 36af27e

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

server/src/main/java/org/elasticsearch/action/index/IndexRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ public Index getConcreteWriteIndex(IndexAbstraction ia, Metadata metadata) {
776776
);
777777
}
778778

779-
Index result = dataStream.selectWriteIndex(timestamp, metadata);
779+
Index result = dataStream.selectTimeSeriesWriteIndex(timestamp, metadata);
780780
if (result == null) {
781781
String timestampAsString = DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.format(timestamp);
782782
throw new IllegalArgumentException("no index available for a document with an @timestamp of [" + timestampAsString + "]");

server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ public Index getWriteIndex() {
175175
return indices.get(indices.size() - 1);
176176
}
177177

178-
public Index selectWriteIndex(Instant timestamp, Metadata metadata) {
178+
/**
179+
* @param timestamp The timestamp used to select a backing index based on its start and end time.
180+
* @param metadata The metadata that is used to fetch the start and end times for backing indices of this data stream.
181+
* @return a backing index with a start time that is greater or equal to the provided timestamp and
182+
* an end time that is less than the provided timestamp. Otherwise <code>null</code> is returned.
183+
*/
184+
public Index selectTimeSeriesWriteIndex(Instant timestamp, Metadata metadata) {
179185
for (int i = indices.size() - 1; i >= 0; i--) {
180186
Index index = indices.get(i);
181187
IndexMetadata im = metadata.index(index);

server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ public void testSnapshotWithAllBackingIndicesRemoved() {
484484
);
485485
}
486486

487-
public void testSelectWriteIndex() {
487+
public void testSelectTimeSeriesWriteIndex() {
488488
Instant currentTime = Instant.now();
489489

490490
Instant start1 = currentTime.minus(6, ChronoUnit.HOURS);
@@ -499,19 +499,19 @@ public void testSelectWriteIndex() {
499499
);
500500

501501
DataStream dataStream = clusterState.getMetadata().dataStreams().get(dataStreamName);
502-
Index result = dataStream.selectWriteIndex(currentTime, clusterState.getMetadata());
502+
Index result = dataStream.selectTimeSeriesWriteIndex(currentTime, clusterState.getMetadata());
503503
assertThat(result, equalTo(dataStream.getIndices().get(1)));
504504
assertThat(result.getName(), equalTo(DataStream.getDefaultBackingIndexName(dataStreamName, 2, start2.toEpochMilli())));
505505

506-
result = dataStream.selectWriteIndex(currentTime.minus(2, ChronoUnit.HOURS), clusterState.getMetadata());
506+
result = dataStream.selectTimeSeriesWriteIndex(currentTime.minus(2, ChronoUnit.HOURS), clusterState.getMetadata());
507507
assertThat(result, equalTo(dataStream.getIndices().get(1)));
508508
assertThat(result.getName(), equalTo(DataStream.getDefaultBackingIndexName(dataStreamName, 2, start2.toEpochMilli())));
509509

510-
result = dataStream.selectWriteIndex(currentTime.minus(3, ChronoUnit.HOURS), clusterState.getMetadata());
510+
result = dataStream.selectTimeSeriesWriteIndex(currentTime.minus(3, ChronoUnit.HOURS), clusterState.getMetadata());
511511
assertThat(result, equalTo(dataStream.getIndices().get(0)));
512512
assertThat(result.getName(), equalTo(DataStream.getDefaultBackingIndexName(dataStreamName, 1, start1.toEpochMilli())));
513513

514-
result = dataStream.selectWriteIndex(currentTime.minus(6, ChronoUnit.HOURS), clusterState.getMetadata());
514+
result = dataStream.selectTimeSeriesWriteIndex(currentTime.minus(6, ChronoUnit.HOURS), clusterState.getMetadata());
515515
assertThat(result, equalTo(dataStream.getIndices().get(0)));
516516
assertThat(result.getName(), equalTo(DataStream.getDefaultBackingIndexName(dataStreamName, 1, start1.toEpochMilli())));
517517
}

0 commit comments

Comments
 (0)