diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2022-01-21 09:35:10 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2022-01-21 09:35:10 +0100 |
commit | f96bff8dcc27eec3c7b957157701321319a004dd (patch) | |
tree | 5187cd80e250e2b33f297828f7f725a80cbab694 /container-search | |
parent | d59648c5901d26cf9e8c472b094a4349ad7b20b2 (diff) |
Manually handle interrupts in CompiledQueryProfileRegistry ctor
Diffstat (limited to 'container-search')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistry.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistry.java b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistry.java index fb1552e549b..8d2c847dc3a 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistry.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistry.java @@ -10,6 +10,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.search.query.profile.config.QueryProfileConfigurer; import com.yahoo.search.query.profile.config.QueryProfilesConfig; import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry; +import com.yahoo.yolean.UncheckedInterruptedException; /** * A set of compiled query profiles. @@ -28,10 +29,18 @@ public class CompiledQueryProfileRegistry extends ComponentRegistry<CompiledQuer QueryProfileRegistry registry = QueryProfileConfigurer.createFromConfig(config); typeRegistry = registry.getTypeRegistry(); for (QueryProfile inputProfile : registry.allComponents()) { + abortIfInterrupted(); register(QueryProfileCompiler.compile(inputProfile, this)); } } + // Query profile construction is very expensive and triggers no operations that automatically throws on interrupt + // We need to manually check the interrupt flag in case the container reconfigurer should shut down + private void abortIfInterrupted() { + if (Thread.interrupted()) + throw new UncheckedInterruptedException("Interrupted while building query profile registry", true); + } + /** Creates a compiled query profile registry with no types */ public CompiledQueryProfileRegistry() { this(QueryProfileTypeRegistry.emptyFrozen()); |