diff options
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query/properties/RequestContextProperties.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/query/properties/RequestContextProperties.java | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/RequestContextProperties.java b/container-search/src/main/java/com/yahoo/search/query/properties/RequestContextProperties.java index 46aafcb11e3..06d827faf68 100644 --- a/container-search/src/main/java/com/yahoo/search/query/properties/RequestContextProperties.java +++ b/container-search/src/main/java/com/yahoo/search/query/properties/RequestContextProperties.java @@ -1,17 +1,13 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.query.properties; -import ai.vespa.cloud.ZoneInfo; import com.yahoo.processing.request.CompoundName; import com.yahoo.search.query.Properties; -import java.util.Collections; -import java.util.HashMap; import java.util.Map; /** - * Turns get(name) into get(name, context) using the request given at construction time - * and the zone info. + * Turns get(name) into get(name, request) using the request given at construction time. * This is used to allow the query's request to be supplied to all property requests * without forcing users of the query.properties() to supply this explicitly. * @@ -19,36 +15,27 @@ import java.util.Map; */ public class RequestContextProperties extends Properties { - private final Map<String, String> context; - - public RequestContextProperties(Map<String, String> properties, ZoneInfo zoneInfo) { - if (zoneInfo == ZoneInfo.defaultInfo()) { - context = properties; - } - else { - Map<String, String> context = new HashMap<>(properties); - context.putIfAbsent("environment", zoneInfo.zone().environment().name()); - context.putIfAbsent("region", zoneInfo.zone().region()); - context.putIfAbsent("instance", zoneInfo.application().instance()); - this.context = Collections.unmodifiableMap(context); - } + private final Map<String, String> requestMap; + + public RequestContextProperties(Map<String, String> properties) { + this.requestMap = properties; } @Override public Object get(CompoundName name, Map<String,String> context, com.yahoo.processing.request.Properties substitution) { - return super.get(name, context == null ? this.context : context, substitution); + return super.get(name, context == null ? requestMap : context, substitution); } @Override public void set(CompoundName name, Object value, Map<String,String> context) { - super.set(name, value, context == null ? this.context : context); + super.set(name, value, context == null ? requestMap : context); } @Override public Map<String, Object> listProperties(CompoundName path, Map<String,String> context, com.yahoo.processing.request.Properties substitution) { - return super.listProperties(path, context == null ? this.context : context, substitution); + return super.listProperties(path, context == null ? requestMap : context, substitution); } } |