clintropolis commented on code in PR #18687: URL: https://github.com/apache/druid/pull/18687#discussion_r2458521243
########## server/src/main/java/org/apache/druid/server/coordination/startup/HistoricalStartupCacheLoadStrategyFactory.java: ########## @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.server.coordination.startup; + +import org.apache.druid.error.DruidException; +import org.apache.druid.segment.loading.SegmentLoaderConfig; + +public class HistoricalStartupCacheLoadStrategyFactory +{ + public static HistoricalStartupCacheLoadStrategy factorize(SegmentLoaderConfig config) + { + String strategyName = config.getStartupCacheLoadStrategy(); + switch (strategyName) { + case LoadAllLazilyStrategy.STRATEGY_NAME: + return new LoadAllLazilyStrategy(); + case LoadAllEagerlyStrategy.STRATEGY_NAME: + return new LoadAllEagerlyStrategy(); + case LoadEagerlyBeforePeriod.STRATEGY_NAME: + return new LoadEagerlyBeforePeriod(config.getStartupLoadPeriod()); + default: + throw DruidException.forPersona(DruidException.Persona.OPERATOR) + .ofCategory(DruidException.Category.UNSUPPORTED) + .build("Unknown configured Historical Startup Loading Strategy[%s]", strategyName); Review Comment: couldn't these just be json annotated types or something and just let the json config stuff handle materializing the right one like on the segment loader config instead of having this factorize method? like the interface would be decorated with ``` @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonSubTypes(value = { @JsonSubTypes.Type(name = LoadAllEagerlyStrategy.STRATEGY_NAME, value = LoadAllEagerlyStrategy.class), @JsonSubTypes.Type(name = LoadAllLazilyStrategy.STRATEGY_NAME, value = LoadAllLazilyStrategy.class), @JsonSubTypes.Type(name = LoadEagerlyBeforePeriod.STRATEGY_NAME, value = LoadEagerlyBeforePeriod.class) }) public interface HistoricalStartupCacheLoadStrategy { ... } ``` and then make all of the implementations annotated with `@JsonCreator` and `@JsonProperty`, so then this is just a property on `SegmentLoaderConfig`, and the configs would be shifted to like ``` |`druid.segmentCache.startupLoadStrategy.type`|Selects the segment column metadata loading strategy during historical startup. Possible values are `loadAllEagerly`, `loadAllLazily`, and `loadEagerlyBeforePeriod`. More details on each strategy below.|`loadAllEagerly`| |`druid.segmentCache.startupLoadStrategy.period`| Used only when startup load strategy `loadEagerlyBeforePeriod` is configured. Suppose timestamp `t` is when the Historical started up. Any segment metadata with interval that does not overlap with the interval of `[t - startupLoadPeriod, t]` will be lazily loaded.|`P7D`| ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
