Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvg committed Jan 10, 2022
1 parent d70aa28 commit 36af27e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ public Index getConcreteWriteIndex(IndexAbstraction ia, Metadata metadata) {
);
}

Index result = dataStream.selectWriteIndex(timestamp, metadata);
Index result = dataStream.selectTimeSeriesWriteIndex(timestamp, metadata);
if (result == null) {
String timestampAsString = DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.format(timestamp);
throw new IllegalArgumentException("no index available for a document with an @timestamp of [" + timestampAsString + "]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,13 @@ public Index getWriteIndex() {
return indices.get(indices.size() - 1);
}

public Index selectWriteIndex(Instant timestamp, Metadata metadata) {
/**
* @param timestamp The timestamp used to select a backing index based on its start and end time.
* @param metadata The metadata that is used to fetch the start and end times for backing indices of this data stream.
* @return a backing index with a start time that is greater or equal to the provided timestamp and
* an end time that is less than the provided timestamp. Otherwise <code>null</code> is returned.
*/
public Index selectTimeSeriesWriteIndex(Instant timestamp, Metadata metadata) {
for (int i = indices.size() - 1; i >= 0; i--) {
Index index = indices.get(i);
IndexMetadata im = metadata.index(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ public void testSnapshotWithAllBackingIndicesRemoved() {
);
}

public void testSelectWriteIndex() {
public void testSelectTimeSeriesWriteIndex() {
Instant currentTime = Instant.now();

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

DataStream dataStream = clusterState.getMetadata().dataStreams().get(dataStreamName);
Index result = dataStream.selectWriteIndex(currentTime, clusterState.getMetadata());
Index result = dataStream.selectTimeSeriesWriteIndex(currentTime, clusterState.getMetadata());
assertThat(result, equalTo(dataStream.getIndices().get(1)));
assertThat(result.getName(), equalTo(DataStream.getDefaultBackingIndexName(dataStreamName, 2, start2.toEpochMilli())));

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

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

result = dataStream.selectWriteIndex(currentTime.minus(6, ChronoUnit.HOURS), clusterState.getMetadata());
result = dataStream.selectTimeSeriesWriteIndex(currentTime.minus(6, ChronoUnit.HOURS), clusterState.getMetadata());
assertThat(result, equalTo(dataStream.getIndices().get(0)));
assertThat(result.getName(), equalTo(DataStream.getDefaultBackingIndexName(dataStreamName, 1, start1.toEpochMilli())));
}
Expand Down

0 comments on commit 36af27e

Please sign in to comment.