[7.x] Get index includes parent data stream for backing indices (#56238)

This commit is contained in:
Dan Hermann 2020-05-05 15:43:42 -05:00 committed by GitHub
parent dac4ed282e
commit 6674f14fb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 234 additions and 58 deletions

View File

@ -47,13 +47,15 @@ public class GetIndexResponse {
private Map<String, List<AliasMetadata>> aliases;
private Map<String, Settings> settings;
private Map<String, Settings> defaultSettings;
private Map<String, String> dataStreams;
private String[] indices;
GetIndexResponse(String[] indices,
Map<String, MappingMetadata> mappings,
Map<String, List<AliasMetadata>> aliases,
Map<String, Settings> settings,
Map<String, Settings> defaultSettings) {
Map<String, Settings> defaultSettings,
Map<String, String> dataStreams) {
this.indices = indices;
// to have deterministic order
Arrays.sort(indices);
@ -69,6 +71,9 @@ public class GetIndexResponse {
if (defaultSettings != null) {
this.defaultSettings = defaultSettings;
}
if (dataStreams != null) {
this.dataStreams = dataStreams;
}
}
public String[] getIndices() {
@ -99,6 +104,10 @@ public class GetIndexResponse {
return settings;
}
public Map<String, String> getDataStreams() {
return dataStreams;
}
/**
* Returns the string value for the specified index and setting. If the includeDefaults flag was not set or set to
* false on the {@link GetIndexRequest}, this method will only return a value where the setting was explicitly set
@ -142,6 +151,7 @@ public class GetIndexResponse {
MappingMetadata indexMappings = null;
Settings indexSettings = null;
Settings indexDefaultSettings = null;
String dataStream = null;
// We start at START_OBJECT since fromXContent ensures that
while (parser.nextToken() != Token.END_OBJECT) {
ensureExpectedToken(Token.FIELD_NAME, parser.currentToken(), parser::getTokenLocation);
@ -163,11 +173,16 @@ public class GetIndexResponse {
default:
parser.skipChildren();
}
} else if (parser.currentToken() == Token.VALUE_STRING) {
if (parser.currentName().equals("data_stream")) {
dataStream = parser.text();
}
parser.skipChildren();
} else if (parser.currentToken() == Token.START_ARRAY) {
parser.skipChildren();
}
}
return new IndexEntry(indexAliases, indexMappings, indexSettings, indexDefaultSettings);
return new IndexEntry(indexAliases, indexMappings, indexSettings, indexDefaultSettings, dataStream);
}
// This is just an internal container to make stuff easier for returning
@ -176,11 +191,14 @@ public class GetIndexResponse {
MappingMetadata indexMappings;
Settings indexSettings = Settings.EMPTY;
Settings indexDefaultSettings = Settings.EMPTY;
IndexEntry(List<AliasMetadata> indexAliases, MappingMetadata indexMappings, Settings indexSettings, Settings indexDefaultSettings) {
String dataStream;
IndexEntry(List<AliasMetadata> indexAliases, MappingMetadata indexMappings, Settings indexSettings, Settings indexDefaultSettings,
String dataStream) {
if (indexAliases != null) this.indexAliases = indexAliases;
if (indexMappings != null) this.indexMappings = indexMappings;
if (indexSettings != null) this.indexSettings = indexSettings;
if (indexDefaultSettings != null) this.indexDefaultSettings = indexDefaultSettings;
if (dataStream != null) this.dataStream = dataStream;
}
}
@ -189,6 +207,7 @@ public class GetIndexResponse {
Map<String, MappingMetadata> mappings = new HashMap<>();
Map<String, Settings> settings = new HashMap<>();
Map<String, Settings> defaultSettings = new HashMap<>();
Map<String, String> dataStreams = new HashMap<>();
List<String> indices = new ArrayList<>();
if (parser.currentToken() == null) {
@ -211,12 +230,15 @@ public class GetIndexResponse {
if (indexEntry.indexDefaultSettings.isEmpty() == false) {
defaultSettings.put(indexName, indexEntry.indexDefaultSettings);
}
if (indexEntry.dataStream != null) {
dataStreams.put(indexName, indexEntry.dataStream);
}
} else if (parser.currentToken() == Token.START_ARRAY) {
parser.skipChildren();
} else {
parser.nextToken();
}
}
return new GetIndexResponse(indices.toArray(new String[0]), mappings, aliases, settings, defaultSettings);
return new GetIndexResponse(indices.toArray(new String[0]), mappings, aliases, settings, defaultSettings, dataStreams);
}
}

View File

@ -40,6 +40,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
@ -76,6 +77,7 @@ public class GetIndexResponseTests extends ESTestCase {
Map<String, List<AliasMetadata>> aliases = new HashMap<>();
Map<String, Settings> settings = new HashMap<>();
Map<String, Settings> defaultSettings = new HashMap<>();
Map<String, String> dataStreams = new HashMap<>();
IndexScopedSettings indexScopedSettings = IndexScopedSettings.DEFAULT_SCOPED_SETTINGS;
boolean includeDefaults = randomBoolean();
for (String index: indices) {
@ -96,8 +98,12 @@ public class GetIndexResponseTests extends ESTestCase {
if (includeDefaults) {
defaultSettings.put(index, indexScopedSettings.diff(settings.get(index), Settings.EMPTY));
}
if (randomBoolean()) {
dataStreams.put(index, randomAlphaOfLength(5).toLowerCase(Locale.ROOT));
}
}
return new GetIndexResponse(indices, mappings, aliases, settings, defaultSettings);
return new GetIndexResponse(indices, mappings, aliases, settings, defaultSettings, dataStreams);
}
private static MappingMetadata createMappingsForIndex() {
@ -186,7 +192,9 @@ public class GetIndexResponseTests extends ESTestCase {
allMappings.build(),
aliases.build(),
settings.build(),
defaultSettings.build());
defaultSettings.build(),
ImmutableOpenMap.<String, String>builder().build()
);
// then we can call its toXContent method, forcing no output of types
Params params = new ToXContent.MapParams(Collections.singletonMap(BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER, "false"));

View File

@ -0,0 +1,35 @@
---
"Get backing indices for data stream":
- skip:
version: " - 7.99.99"
reason: "enable in 7.8+ after backporting"
- do:
indices.create_data_stream:
name: data-stream1
body:
timestamp_field: "@timestamp"
- is_true: acknowledged
- do:
indices.create:
index: test_index
body:
settings:
number_of_shards: 1
number_of_replicas: 1
- do:
indices.get:
index: ['data-stream1-000001', 'test_index']
- is_true: data-stream1-000001.settings
- is_true: data-stream1-000001.data_stream
- match: { data-stream1-000001.data_stream: data-stream1 }
- is_true: test_index.settings
- is_false: test_index.data_stream
- do:
indices.delete_data_stream:
name: data-stream1
- is_true: acknowledged

View File

@ -58,13 +58,15 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
private ImmutableOpenMap<String, List<AliasMetadata>> aliases = ImmutableOpenMap.of();
private ImmutableOpenMap<String, Settings> settings = ImmutableOpenMap.of();
private ImmutableOpenMap<String, Settings> defaultSettings = ImmutableOpenMap.of();
private ImmutableOpenMap<String, String> dataStreams = ImmutableOpenMap.of();
private String[] indices;
public GetIndexResponse(String[] indices,
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetadata>> mappings,
ImmutableOpenMap<String, List<AliasMetadata>> aliases,
ImmutableOpenMap<String, Settings> settings,
ImmutableOpenMap<String, Settings> defaultSettings) {
ImmutableOpenMap<String, Settings> defaultSettings,
ImmutableOpenMap<String, String> dataStreams) {
this.indices = indices;
// to have deterministic order
Arrays.sort(indices);
@ -80,6 +82,9 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
if (defaultSettings != null) {
this.defaultSettings = defaultSettings;
}
if (dataStreams != null) {
this.dataStreams = dataStreams;
}
}
GetIndexResponse(StreamInput in) throws IOException {
@ -128,6 +133,15 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
}
}
defaultSettings = defaultSettingsMapBuilder.build();
if (in.getVersion().onOrAfter(Version.V_7_8_0)) {
ImmutableOpenMap.Builder<String, String> dataStreamsMapBuilder = ImmutableOpenMap.builder();
int dataStreamsSize = in.readVInt();
for (int i = 0; i < dataStreamsSize; i++) {
dataStreamsMapBuilder.put(in.readString(), in.readOptionalString());
}
dataStreams = dataStreamsMapBuilder.build();
}
}
public String[] indices() {
@ -158,6 +172,14 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
return settings;
}
public ImmutableOpenMap<String, String> dataStreams() {
return dataStreams;
}
public ImmutableOpenMap<String, String> getDataStreams() {
return dataStreams();
}
/**
* If the originating {@link GetIndexRequest} object was configured to include
* defaults, this will contain a mapping of index name to {@link Settings} objects.
@ -230,6 +252,13 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
Settings.writeSettingsToStream(indexEntry.value, out);
}
}
if (out.getVersion().onOrAfter(Version.V_7_8_0)) {
out.writeVInt(dataStreams.size());
for (ObjectObjectCursor<String, String> indexEntry : dataStreams) {
out.writeString(indexEntry.key);
out.writeOptionalString(indexEntry.value);
}
}
}
@Override
@ -289,6 +318,11 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
defaultIndexSettings.toXContent(builder, params);
builder.endObject();
}
String dataStream = dataStreams.get(index);
if (dataStream != null) {
builder.field("data_stream", dataStream);
}
}
builder.endObject();
}
@ -328,6 +362,7 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
ImmutableOpenMap<String, MappingMetadata> indexMappings = null;
Settings indexSettings = null;
Settings indexDefaultSettings = null;
String dataStream = null;
// We start at START_OBJECT since fromXContent ensures that
while (parser.nextToken() != Token.END_OBJECT) {
ensureExpectedToken(Token.FIELD_NAME, parser.currentToken(), parser::getTokenLocation);
@ -349,11 +384,16 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
default:
parser.skipChildren();
}
} else if (parser.currentToken() == Token.VALUE_STRING) {
if (parser.currentName().equals("data_stream")) {
dataStream = parser.text();
}
parser.skipChildren();
} else if (parser.currentToken() == Token.START_ARRAY) {
parser.skipChildren();
}
}
return new IndexEntry(indexAliases, indexMappings, indexSettings, indexDefaultSettings);
return new IndexEntry(indexAliases, indexMappings, indexSettings, indexDefaultSettings, dataStream);
}
// This is just an internal container to make stuff easier for returning
@ -362,12 +402,14 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
ImmutableOpenMap<String, MappingMetadata> indexMappings = ImmutableOpenMap.of();
Settings indexSettings = Settings.EMPTY;
Settings indexDefaultSettings = Settings.EMPTY;
String dataStream;
IndexEntry(List<AliasMetadata> indexAliases, ImmutableOpenMap<String, MappingMetadata> indexMappings,
Settings indexSettings, Settings indexDefaultSettings) {
Settings indexSettings, Settings indexDefaultSettings, String dataStream) {
if (indexAliases != null) this.indexAliases = indexAliases;
if (indexMappings != null) this.indexMappings = indexMappings;
if (indexSettings != null) this.indexSettings = indexSettings;
if (indexDefaultSettings != null) this.indexDefaultSettings = indexDefaultSettings;
if (dataStream != null) this.dataStream = dataStream;
}
}
@ -376,6 +418,7 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
ImmutableOpenMap.Builder<String, ImmutableOpenMap<String, MappingMetadata>> mappings = ImmutableOpenMap.builder();
ImmutableOpenMap.Builder<String, Settings> settings = ImmutableOpenMap.builder();
ImmutableOpenMap.Builder<String, Settings> defaultSettings = ImmutableOpenMap.builder();
ImmutableOpenMap.Builder<String, String> dataStreams = ImmutableOpenMap.builder();
List<String> indices = new ArrayList<>();
if (parser.currentToken() == null) {
@ -398,6 +441,9 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
if (indexEntry.indexDefaultSettings.isEmpty() == false) {
defaultSettings.put(indexName, indexEntry.indexDefaultSettings);
}
if (indexEntry.dataStream != null) {
dataStreams.put(indexName, indexEntry.dataStream);
}
} else if (parser.currentToken() == Token.START_ARRAY) {
parser.skipChildren();
} else {
@ -407,7 +453,7 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
return
new GetIndexResponse(
indices.toArray(new String[0]), mappings.build(), aliases.build(),
settings.build(), defaultSettings.build()
settings.build(), defaultSettings.build(), dataStreams.build()
);
}
@ -425,7 +471,8 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
Objects.equals(aliases, that.aliases) &&
Objects.equals(mappings, that.mappings) &&
Objects.equals(settings, that.settings) &&
Objects.equals(defaultSettings, that.defaultSettings);
Objects.equals(defaultSettings, that.defaultSettings) &&
Objects.equals(dataStreams, that.dataStreams);
}
@Override
@ -436,7 +483,8 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
aliases,
mappings,
settings,
defaultSettings
defaultSettings,
dataStreams
);
}
}

View File

@ -44,6 +44,8 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
/**
* Get index action.
@ -90,6 +92,9 @@ public class TransportGetIndexAction extends TransportClusterInfoAction<GetIndex
ImmutableOpenMap<String, List<AliasMetadata>> aliasesResult = ImmutableOpenMap.of();
ImmutableOpenMap<String, Settings> settings = ImmutableOpenMap.of();
ImmutableOpenMap<String, Settings> defaultSettings = ImmutableOpenMap.of();
ImmutableOpenMap<String, String> dataStreams = ImmutableOpenMap.<String, String>builder()
.putAll(StreamSupport.stream(state.metadata().findDataStreams(concreteIndices).spliterator(), false)
.collect(Collectors.toMap(k -> k.key, v -> v.value.getName()))).build();
Feature[] features = request.features();
boolean doneAliases = false;
boolean doneMappings = false;
@ -141,7 +146,7 @@ public class TransportGetIndexAction extends TransportClusterInfoAction<GetIndex
}
}
listener.onResponse(
new GetIndexResponse(concreteIndices, mappingsResult, aliasesResult, settings, defaultSettings)
new GetIndexResponse(concreteIndices, mappingsResult, aliasesResult, settings, defaultSettings, dataStreams)
);
}
}

View File

@ -451,6 +451,24 @@ public class Metadata implements Iterable<IndexMetadata>, Diffable<Metadata>, To
return indexMapBuilder.build();
}
/**
* Finds the parent data streams, if any, for the specified concrete indices.
*/
public ImmutableOpenMap<String, IndexAbstraction.DataStream> findDataStreams(String[] concreteIndices) {
assert concreteIndices != null;
final ImmutableOpenMap.Builder<String, IndexAbstraction.DataStream> builder = ImmutableOpenMap.builder();
final SortedMap<String, IndexAbstraction> lookup = getIndicesLookup();
for (String indexName : concreteIndices) {
IndexAbstraction index = lookup.get(indexName);
assert index != null;
assert index.getType() == IndexAbstraction.Type.CONCRETE_INDEX;
if (index.getParentDataStream() != null) {
builder.put(indexName, index.getParentDataStream());
}
}
return builder.build();
}
private static ImmutableOpenMap<String, MappingMetadata> filterFields(ImmutableOpenMap<String, MappingMetadata> mappings,
Predicate<String> fieldPredicate) throws IOException {
if (fieldPredicate == MapperPlugin.NOOP_FIELD_PREDICATE) {

View File

@ -47,6 +47,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.function.Predicate;
import java.util.Locale;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
@ -80,6 +81,7 @@ public class GetIndexResponseTests extends AbstractSerializingTestCase<GetIndexR
ImmutableOpenMap.Builder<String, List<AliasMetadata>> aliases = ImmutableOpenMap.builder();
ImmutableOpenMap.Builder<String, Settings> settings = ImmutableOpenMap.builder();
ImmutableOpenMap.Builder<String, Settings> defaultSettings = ImmutableOpenMap.builder();
ImmutableOpenMap.Builder<String, String> dataStreams = ImmutableOpenMap.builder();
IndexScopedSettings indexScopedSettings = IndexScopedSettings.DEFAULT_SCOPED_SETTINGS;
boolean includeDefaults = randomBoolean();
for (String index: indices) {
@ -102,9 +104,13 @@ public class GetIndexResponseTests extends AbstractSerializingTestCase<GetIndexR
if (includeDefaults) {
defaultSettings.put(index, indexScopedSettings.diff(settings.get(index), Settings.EMPTY));
}
if (randomBoolean()) {
dataStreams.put(index, randomAlphaOfLength(5).toLowerCase(Locale.ROOT));
}
}
return new GetIndexResponse(
indices, mappings.build(), aliases.build(), settings.build(), defaultSettings.build()
indices, mappings.build(), aliases.build(), settings.build(), defaultSettings.build(), dataStreams.build()
);
}
@ -159,7 +165,7 @@ public class GetIndexResponseTests extends AbstractSerializingTestCase<GetIndexR
return
new GetIndexResponse(
indices, getTestMappings(indexName), getTestAliases(indexName), getTestSettings(indexName),
ImmutableOpenMap.of()
ImmutableOpenMap.of(), ImmutableOpenMap.of()
);
}
@ -173,7 +179,7 @@ public class GetIndexResponseTests extends AbstractSerializingTestCase<GetIndexR
return
new GetIndexResponse(
indices, getTestMappings(indexName), getTestAliases(indexName), getTestSettings(indexName),
defaultSettings.build()
defaultSettings.build(), ImmutableOpenMap.of()
);
}

View File

@ -52,6 +52,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.stream.Collectors;
import static org.elasticsearch.cluster.DataStreamTestHelper.createBackingIndex;
import static org.elasticsearch.cluster.DataStreamTestHelper.createFirstBackingIndex;
@ -137,6 +138,23 @@ public class MetadataTests extends ESTestCase {
assertThat(aliases.get(0).alias(), equalTo("alias2"));
}
public void testFindDataStreams() {
final int numIndices = randomIntBetween(2, 5);
final int numBackingIndices = randomIntBetween(2, 5);
final String dataStreamName = "my-data-stream";
CreateIndexResult result = createIndices(numIndices, numBackingIndices, dataStreamName);
List<Index> allIndices = new ArrayList<>(result.indices);
allIndices.addAll(result.backingIndices);
String[] concreteIndices = allIndices.stream().map(Index::getName).collect(Collectors.toList()).toArray(new String[]{});
ImmutableOpenMap<String, IndexAbstraction.DataStream> dataStreams = result.metadata.findDataStreams(concreteIndices);
assertThat(dataStreams.size(), equalTo(numBackingIndices));
for (Index backingIndex : result.backingIndices) {
assertThat(dataStreams.containsKey(backingIndex.getName()), is(true));
assertThat(dataStreams.get(backingIndex.getName()).getName(), equalTo(dataStreamName));
}
}
public void testFindAliasWithExclusionAndOverride() {
Metadata metadata = Metadata.builder().put(
IndexMetadata.builder("index")
@ -1066,47 +1084,18 @@ public class MetadataTests extends ESTestCase {
}
public void testIndicesLookupRecordsDataStreamForBackingIndices() {
// create some indices that do not back a data stream
final List<Index> indices = new ArrayList<>();
final int numIndices = randomIntBetween(2, 5);
int lastIndexNum = randomIntBetween(9, 50);
Metadata.Builder b = Metadata.builder();
for (int k = 1; k <= numIndices; k++) {
IndexMetadata im = IndexMetadata.builder(DataStream.getBackingIndexName("index", lastIndexNum))
.settings(settings(Version.CURRENT))
.numberOfShards(1)
.numberOfReplicas(1)
.build();
b.put(im, false);
indices.add(im.getIndex());
lastIndexNum = randomIntBetween(lastIndexNum + 1, lastIndexNum + 50);
}
// create some backing indices for a data stream
final String dataStreamName = "my-data-stream";
final List<Index> backingIndices = new ArrayList<>();
final int numBackingIndices = randomIntBetween(2, 5);
int lastBackingIndexNum = 0;
for (int k = 1; k <= numBackingIndices; k++) {
lastBackingIndexNum = randomIntBetween(lastBackingIndexNum + 1, lastBackingIndexNum + 50);
IndexMetadata im = IndexMetadata.builder(DataStream.getBackingIndexName(dataStreamName, lastBackingIndexNum))
.settings(settings(Version.CURRENT))
.numberOfShards(1)
.numberOfReplicas(1)
.build();
b.put(im, false);
backingIndices.add(im.getIndex());
}
b.put(new DataStream(dataStreamName, "ts", backingIndices, lastBackingIndexNum));
Metadata metadata = b.build();
final String dataStreamName = "my-data-stream";
CreateIndexResult result = createIndices(numIndices, numBackingIndices, dataStreamName);
SortedMap<String, IndexAbstraction> indicesLookup = metadata.getIndicesLookup();
assertThat(indicesLookup.size(), equalTo(indices.size() + backingIndices.size() + 1));
for (Index index : indices) {
SortedMap<String, IndexAbstraction> indicesLookup = result.metadata.getIndicesLookup();
assertThat(indicesLookup.size(), equalTo(result.indices.size() + result.backingIndices.size() + 1));
for (Index index : result.indices) {
assertTrue(indicesLookup.containsKey(index.getName()));
assertNull(indicesLookup.get(index.getName()).getParentDataStream());
}
for (Index index : backingIndices) {
for (Index index : result.backingIndices) {
assertTrue(indicesLookup.containsKey(index.getName()));
assertNotNull(indicesLookup.get(index.getName()).getParentDataStream());
assertThat(indicesLookup.get(index.getName()).getParentDataStream().getName(), equalTo(dataStreamName));
@ -1153,4 +1142,49 @@ public class MetadataTests extends ESTestCase {
return md.build();
}
private static CreateIndexResult createIndices(int numIndices, int numBackingIndices, String dataStreamName) {
// create some indices that do not back a data stream
final List<Index> indices = new ArrayList<>();
int lastIndexNum = randomIntBetween(9, 50);
Metadata.Builder b = Metadata.builder();
for (int k = 1; k <= numIndices; k++) {
IndexMetadata im = IndexMetadata.builder(DataStream.getBackingIndexName("index", lastIndexNum))
.settings(settings(Version.CURRENT))
.numberOfShards(1)
.numberOfReplicas(1)
.build();
b.put(im, false);
indices.add(im.getIndex());
lastIndexNum = randomIntBetween(lastIndexNum + 1, lastIndexNum + 50);
}
// create some backing indices for a data stream
final List<Index> backingIndices = new ArrayList<>();
int lastBackingIndexNum = 0;
for (int k = 1; k <= numBackingIndices; k++) {
lastBackingIndexNum = randomIntBetween(lastBackingIndexNum + 1, lastBackingIndexNum + 50);
IndexMetadata im = IndexMetadata.builder(DataStream.getBackingIndexName(dataStreamName, lastBackingIndexNum))
.settings(settings(Version.CURRENT))
.numberOfShards(1)
.numberOfReplicas(1)
.build();
b.put(im, false);
backingIndices.add(im.getIndex());
}
b.put(new DataStream(dataStreamName, "ts", backingIndices, lastBackingIndexNum));
return new CreateIndexResult(indices, backingIndices, b.build());
}
private static class CreateIndexResult {
final List<Index> indices;
final List<Index> backingIndices;
final Metadata metadata;
CreateIndexResult(List<Index> indices, List<Index> backingIndices, Metadata metadata) {
this.indices = indices;
this.backingIndices = backingIndices;
this.metadata = metadata;
}
}
}

View File

@ -282,8 +282,8 @@ public class DestinationIndexTests extends ESTestCase {
ImmutableOpenMap.Builder<String, ImmutableOpenMap<String, MappingMetadata>> mappings = ImmutableOpenMap.builder();
mappings.put(DEST_INDEX, indexMappingsMap.build());
GetIndexResponse getIndexResponse =
new GetIndexResponse(
new String[] { DEST_INDEX }, mappings.build(), ImmutableOpenMap.of(), ImmutableOpenMap.of(), ImmutableOpenMap.of());
new GetIndexResponse(new String[] { DEST_INDEX }, mappings.build(), ImmutableOpenMap.of(), ImmutableOpenMap.of(),
ImmutableOpenMap.of(), ImmutableOpenMap.of());
ArgumentCaptor<PutMappingRequest> putMappingRequestCaptor = ArgumentCaptor.forClass(PutMappingRequest.class);
@ -356,8 +356,8 @@ public class DestinationIndexTests extends ESTestCase {
ImmutableOpenMap.Builder<String, ImmutableOpenMap<String, MappingMetadata>> mappings = ImmutableOpenMap.builder();
mappings.put(DEST_INDEX, indexMappingsMap.build());
GetIndexResponse getIndexResponse =
new GetIndexResponse(
new String[] { DEST_INDEX }, mappings.build(), ImmutableOpenMap.of(), ImmutableOpenMap.of(), ImmutableOpenMap.of());
new GetIndexResponse(new String[] { DEST_INDEX }, mappings.build(), ImmutableOpenMap.of(), ImmutableOpenMap.of(),
ImmutableOpenMap.of(), ImmutableOpenMap.of());
ElasticsearchStatusException e =
expectThrows(

View File

@ -116,7 +116,7 @@ public class EmptyStateIndexRemoverTests extends ESTestCase {
doReturn(indexStatsMap).when(indicesStatsResponse).getIndices();
doAnswer(withResponse(indicesStatsResponse)).when(client).execute(eq(IndicesStatsAction.INSTANCE), any(), any());
GetIndexResponse getIndexResponse = new GetIndexResponse(new String[] { ".ml-state-e" }, null, null, null, null);
GetIndexResponse getIndexResponse = new GetIndexResponse(new String[] { ".ml-state-e" }, null, null, null, null, null);
doAnswer(withResponse(getIndexResponse)).when(client).execute(eq(GetIndexAction.INSTANCE), any(), any());
AcknowledgedResponse deleteIndexResponse = new AcknowledgedResponse(acknowledged);
@ -147,7 +147,7 @@ public class EmptyStateIndexRemoverTests extends ESTestCase {
doReturn(Collections.singletonMap(".ml-state-a", indexStats(".ml-state-a", 0))).when(indicesStatsResponse).getIndices();
doAnswer(withResponse(indicesStatsResponse)).when(client).execute(eq(IndicesStatsAction.INSTANCE), any(), any());
GetIndexResponse getIndexResponse = new GetIndexResponse(new String[] { ".ml-state-a" }, null, null, null, null);
GetIndexResponse getIndexResponse = new GetIndexResponse(new String[] { ".ml-state-a" }, null, null, null, null, null);
doAnswer(withResponse(getIndexResponse)).when(client).execute(eq(GetIndexAction.INSTANCE), any(), any());
remover.remove(listener, () -> false);

View File

@ -111,7 +111,7 @@ public class TransformCheckpointServiceNodeTests extends TransformSingleNodeTest
if (request instanceof GetIndexRequest) {
// for this test we only need the indices
assert (indices != null);
final GetIndexResponse indexResponse = new GetIndexResponse(indices, null, null, null, null);
final GetIndexResponse indexResponse = new GetIndexResponse(indices, null, null, null, null, null);
listener.onResponse((Response) indexResponse);
return;