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 the download_database_on_pipeline_creation checks #115421

Merged
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 @@ -309,14 +309,14 @@ private static boolean hasAtLeastOneGeoipProcessor(Map<String, Object> processor
{
final Map<String, Object> processorConfig = (Map<String, Object>) processor.get(GEOIP_TYPE);
if (processorConfig != null) {
return downloadDatabaseOnPipelineCreation(GEOIP_TYPE, processorConfig, null) == downloadDatabaseOnPipelineCreation;
return downloadDatabaseOnPipelineCreation(processorConfig) == downloadDatabaseOnPipelineCreation;
}
}

{
final Map<String, Object> processorConfig = (Map<String, Object>) processor.get(IP_LOCATION_TYPE);
if (processorConfig != null) {
return downloadDatabaseOnPipelineCreation(IP_LOCATION_TYPE, processorConfig, null) == downloadDatabaseOnPipelineCreation;
return downloadDatabaseOnPipelineCreation(processorConfig) == downloadDatabaseOnPipelineCreation;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,8 @@ public Processor create(
boolean ignoreMissing = readBooleanProperty(type, processorTag, config, "ignore_missing", false);
boolean firstOnly = readBooleanProperty(type, processorTag, config, "first_only", true);

// Validating the download_database_on_pipeline_creation even if the result
// is not used directly by the factory.
downloadDatabaseOnPipelineCreation(type, config, processorTag);
// validate (and consume) the download_database_on_pipeline_creation property even though the result is not used by the factory
readBooleanProperty(type, processorTag, config, "download_database_on_pipeline_creation", true);

// noop, should be removed in 9.0
Object value = config.remove("fallback_to_default_databases");
Expand Down Expand Up @@ -319,8 +318,15 @@ public Processor create(
);
}

public static boolean downloadDatabaseOnPipelineCreation(String type, Map<String, Object> config, String processorTag) {
return readBooleanProperty(type, processorTag, config, "download_database_on_pipeline_creation", true);
/**
* Get the value of the "download_database_on_pipeline_creation" property from a processor's config map.
* <p>
* As with the actual property definition, the default value of the property is 'true'. Unlike the actual
* property definition, this method doesn't consume (that is, <code>config.remove</code>) the property from
* the config map.
*/
public static boolean downloadDatabaseOnPipelineCreation(Map<String, Object> config) {
return (boolean) config.getOrDefault("download_database_on_pipeline_creation", true);
}
}

Expand Down