Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(search): refactor NUM_RETRIES in esindexbuilder to be configurable #3870

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public class ESIndexBuilder {
private final RestHighLevelClient searchClient;
private final int numShards;
private final int numReplicas;
private final int numRetries;

private static final int NUM_RETRIES = 3;
private static final List<String> SETTINGS_TO_COMPARE = ImmutableList.of("number_of_shards", "number_of_replicas");

public void buildIndex(String indexName, Map<String, Object> mappings, Map<String, Object> settings)
Expand Down Expand Up @@ -128,7 +128,7 @@ public void buildIndex(String indexName, Map<String, Object> mappings, Map<Strin
// There can be some delay between the reindex finishing and count being fully up to date, so try multiple times
long originalCount = 0;
long reindexedCount = 0;
for (int i = 0; i < NUM_RETRIES; i++) {
for (int i = 0; i < this.numRetries; i++) {
// Check if reindex succeeded by comparing document counts
originalCount = getCount(indexName);
reindexedCount = getCount(tempIndexName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static BulkProcessor getBulkProcessor(RestHighLevelClient searchClient) {
}

public static ESIndexBuilder getIndexBuilder(RestHighLevelClient searchClient) {
return new ESIndexBuilder(searchClient, 1, 1);
return new ESIndexBuilder(searchClient, 1, 1, 3);
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ public class ElasticSearchIndexBuilderFactory {
@Value("${elasticsearch.index.numReplicas}")
private Integer numReplicas;

@Value("${elasticsearch.index.numRetries}")
private Integer numRetries;

@Bean(name = "elasticSearchIndexBuilder")
@Nonnull
protected ESIndexBuilder getInstance() {
return new ESIndexBuilder(searchClient, numShards, numReplicas);
return new ESIndexBuilder(searchClient, numShards, numReplicas, numRetries);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ elasticsearch:
prefix: ${INDEX_PREFIX:}
numShards: ${ELASTICSEARCH_NUM_SHARDS_PER_INDEX:1}
numReplicas: ${ELASTICSEARCH_NUM_REPLICAS_PER_INDEX:1}
numRetries: ${ELASTICSEARCH_INDEX_BUILDER_NUM_RETRIES :3}
maxArrayLength: ${SEARCH_DOCUMENT_MAX_ARRAY_LENGTH:1000}

# TODO: Kafka topic convention
Expand Down