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

    https://github.com/apache/storm/pull/1674#discussion_r93205840
  
    --- Diff: 
storm-core/src/jvm/org/apache/storm/scheduler/blacklist/BlacklistScheduler.java 
---
    @@ -0,0 +1,252 @@
    +/**
    + * 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.blacklist;
    +
    +import org.apache.storm.Config;
    +import org.apache.storm.metric.StormMetricsRegistry;
    +import org.apache.storm.scheduler.Cluster;
    +import org.apache.storm.scheduler.IScheduler;
    +import org.apache.storm.scheduler.SupervisorDetails;
    +import org.apache.storm.scheduler.Topologies;
    +import org.apache.storm.scheduler.WorkerSlot;
    +import org.apache.storm.scheduler.blacklist.reporters.IReporter;
    +import org.apache.storm.scheduler.blacklist.strategies.IBlacklistStrategy;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.HashMap;
    +import java.util.HashSet;
    +import java.util.Map;
    +import java.util.Set;
    +import java.util.concurrent.Callable;
    +
    +public class BlacklistScheduler implements IScheduler {
    +    private static final Logger LOG = 
LoggerFactory.getLogger(BlacklistScheduler.class);
    +    IScheduler underlyingScheduler;
    +    @SuppressWarnings("rawtypes")
    +    private Map _conf;
    +
    +    private int toleranceTime;
    +    private int toleranceCount;
    +    private int resumeTime;
    +    private IReporter reporter;
    +    private IBlacklistStrategy blacklistStrategy;
    +
    +    private int nimbusMonitorFreqSecs;
    +
    +    private Map<String, Set<Integer>> cachedSupervisors;
    +
    +    //key is supervisor key ,value is supervisor ports
    +    private CircularBuffer<HashMap<String, Set<Integer>>> 
badSupervisorsTolerance;
    +    private Set<String> blacklistHost;
    +
    +    public BlacklistScheduler(IScheduler underlyingScheduler) {
    +        this.underlyingScheduler = underlyingScheduler;
    +    }
    +
    +    @Override
    +    public void prepare(Map conf) {
    +        LOG.info("prepare black list scheduler");
    +        LOG.info(conf.toString());
    +        underlyingScheduler.prepare(conf);
    +        _conf = conf;
    +        if (_conf.containsKey(Config.BLACKLIST_SCHEDULER_TOLERANCE_TIME)) {
    +            toleranceTime = (Integer) 
_conf.get(Config.BLACKLIST_SCHEDULER_TOLERANCE_TIME);
    +        }
    +        if (_conf.containsKey(Config.BLACKLIST_SCHEDULER_TOLERANCE_COUNT)) 
{
    +            toleranceCount = (Integer) 
_conf.get(Config.BLACKLIST_SCHEDULER_TOLERANCE_COUNT);
    +        }
    +        if (_conf.containsKey(Config.BLACKLIST_SCHEDULER_RESUME_TIME)) {
    +            resumeTime = (Integer) 
_conf.get(Config.BLACKLIST_SCHEDULER_RESUME_TIME);
    +        }
    +        String reporterClassName = 
_conf.containsKey(Config.BLACKLIST_SCHEDULER_REPORTER) ? (String) 
_conf.get(Config.BLACKLIST_SCHEDULER_REPORTER) : "";
    +        try {
    +            reporter = (IReporter) 
Class.forName(reporterClassName).newInstance();
    +        } catch (ClassNotFoundException e) {
    +            LOG.error("Can't find blacklist reporter for name {}", 
reporterClassName);
    +            throw new RuntimeException(e);
    +        } catch (InstantiationException e) {
    +            LOG.error("Throw InstantiationException blacklist reporter for 
name {}", reporterClassName);
    +            throw new RuntimeException(e);
    +        } catch (IllegalAccessException e) {
    +            LOG.error("Throw illegalAccessException blacklist reporter for 
name {}", reporterClassName);
    +            throw new RuntimeException(e);
    +        }
    +
    +        String strategyClassName = 
_conf.containsKey(Config.BLACKLIST_SCHEDULER_STRATEGY) ? (String) 
_conf.get(Config.BLACKLIST_SCHEDULER_STRATEGY) : "";
    +        try {
    +            blacklistStrategy = (IBlacklistStrategy) 
Class.forName(strategyClassName).newInstance();
    +        } catch (ClassNotFoundException e) {
    +            LOG.error("Can't find blacklist strategy for name {}", 
strategyClassName);
    +            throw new RuntimeException(e);
    +        } catch (InstantiationException e) {
    +            LOG.error("Throw InstantiationException blacklist strategy for 
name {}", strategyClassName);
    +            throw new RuntimeException(e);
    +        } catch (IllegalAccessException e) {
    +            LOG.error("Throw illegalAccessException blacklist strategy for 
name {}", strategyClassName);
    +            throw new RuntimeException(e);
    +        }
    +
    +        nimbusMonitorFreqSecs = (Integer) 
_conf.get(Config.NIMBUS_MONITOR_FREQ_SECS);
    --- End diff --
    
    I think it's hard to avoid the influence of NIMBUS_MONITOR_FREQ_SECS, as 
the blacklist scheduler is a SCHEDULER at first. It is called every 
NIMBUS_MONITOR_FREQ_SECS.
    I take this conf here only to calculate the length of sliding window. The 
window size is "toleranceTime / nimbusMonitorFreqSecs ", so every time the 
scheduler is called ,the window will slide for 1 step.
    I think even if I create a new configure for this, it MUST equal to 
NIMBUS_MONITOR_FREQ_SECS so that the sliding window can work properly . So 
there is no need to do so.



---
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