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

    https://github.com/apache/storm/pull/1674#discussion_r80849475
  
    --- Diff: 
storm-core/src/jvm/org/apache/storm/scheduler/blacklist/BlacklistScheduler.java 
---
    @@ -0,0 +1,212 @@
    +package org.apache.storm.scheduler.blacklist;
    +
    +import org.apache.storm.Config;
    +import org.apache.storm.scheduler.*;
    +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.*;
    +
    +/**
    + * Created by howard.li on 2016/6/29.
    + */
    +public class BlacklistScheduler implements IScheduler {
    +    private static final Logger LOG = 
LoggerFactory.getLogger(BlacklistScheduler.class);
    +    DefaultScheduler defaultScheduler;
    +    @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>>> toleranceBuffer;
    +
    +    @Override
    +    public void prepare(Map conf) {
    +        LOG.info("prepare black list scheduler");
    +        LOG.info(conf.toString());
    +        defaultScheduler=new DefaultScheduler();
    +        defaultScheduler.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);
    +        } catch (InstantiationException e) {
    +            LOG.error("Throw InstantiationException blacklist reporter for 
name {}", reporterClassName);
    +        } catch (IllegalAccessException e) {
    +            LOG.error("Throw illegalAccessException blacklist reporter for 
name {}", reporterClassName);
    +        }
    +
    +        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 
{}",reporterClassName);
    +        } catch (InstantiationException e) {
    +            LOG.error("Throw InstantiationException blacklist strategy for 
name {}", reporterClassName);
    +        } catch (IllegalAccessException e) {
    +            LOG.error("Throw illegalAccessException blacklist strategy for 
name {}", reporterClassName);
    +        }
    +
    +        
nimbusMonitorFreqSecs=(Integer)_conf.get(Config.NIMBUS_MONITOR_FREQ_SECS);
    +        
blacklistStrategy.prepare(reporter,toleranceTime,toleranceCount,resumeTime,nimbusMonitorFreqSecs);
    +
    +        toleranceBuffer=new 
CircularBuffer<HashMap<String,Set<Integer>>>(toleranceTime/nimbusMonitorFreqSecs);
    +        cachedSupervisors=new HashMap<>();
    +
    +
    +    }
    +
    +    @Override
    +    public void schedule(Topologies topologies, Cluster cluster) {
    +        LOG.info("running Black List scheduler");
    +        Map<String, SupervisorDetails> supervisors = 
cluster.getSupervisors();
    +        for(Map.Entry<String,SupervisorDetails> 
entry:supervisors.entrySet()){
    +            SupervisorDetails supervisorDetails=entry.getValue();
    +            String supervisorName=entry.getKey();
    +            Set<Integer> ports=supervisorDetails.getAllPorts();
    +            LOG.info("supervisor: "+supervisorDetails.getHost()+" 
ports"+ports);
    --- End diff --
    
    SupervisorDetails is a class with all the supervisors info in it. It's not 
necessary to show all the info here. But if I override toString method, I have 
to put everything in it.


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