Github user Ethanlm commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2199#discussion_r135337335
  
    --- Diff: 
storm-server/src/main/java/org/apache/storm/scheduler/utils/IConfigLoader.java 
---
    @@ -0,0 +1,138 @@
    +/**
    + * 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.storm.scheduler.utils;
    +
    +import java.io.File;
    +import java.io.FileInputStream;
    +import java.io.InputStreamReader;
    +import java.net.URI;
    +import java.net.URISyntaxException;
    +import java.util.Map;
    +
    +import org.apache.storm.Config;
    +import org.apache.storm.DaemonConfig;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.yaml.snakeyaml.Yaml;
    +import org.yaml.snakeyaml.constructor.SafeConstructor;
    +
    +public interface IConfigLoader {
    +
    +    /**
    +     * Load scheduler configs
    +     * It first retrieves parameters like the location of the scheduler 
config file from the conf;
    +     * and then get the actual scheduler configs associated with the 
configKey from that location.
    +     * @param configKey The key from which we want to get the scheduler 
config.
    +     * @return The scheduler configs
    +     */
    +    Map<?,?> load(String configKey);
    +
    +    String SCHEDULER_CONFIG_LOADER_URI = "scheduler.config.loader.uri";
    +    String SCHEDULER_CONFIG_LOADER_POLLTIME_SECS = 
"scheduler.config.loader.polltime.secs";
    +    String SCHEDULER_CONFIG_LOADER_TIMEOUT_SECS = 
"scheduler.config.loader.timeout.secs";
    +
    +    int DEFAULT_POLLTIME_SECS = 600;
    +    int DEFAULT_TIMEOUT_SECONDS = 10;
    +
    +    static IConfigLoader getConfigLoader(Map<String, Object> conf) {
    +        Map loaderParams = (Map) 
conf.get(DaemonConfig.SCHEDULER_USER_POOLS_LOADER_PARAMS);
    +        if (loaderParams != null) {
    +            String uriString = (String) 
loaderParams.get(SCHEDULER_CONFIG_LOADER_URI);
    +            if (uriString != null) {
    +                try {
    +                    URI uri = new URI(uriString);
    +                    String scheme = uri.getScheme();
    +                    switch (SchemeType.toSchemeType(scheme)) {
    +                        case FILE:
    +                            return new FileConfigLoader(loaderParams);
    --- End diff --
    
    This seems a great idea to me. I will try to do so. Thanks


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to