1 package net.javacoding.jspider.core.throttle.impl; 2 3 4 import net.javacoding.jspider.core.throttle.Throttle; 5 import net.javacoding.jspider.core.throttle.ThrottleProvider; 6 import net.javacoding.jspider.core.util.config.PropertySet; 7 import net.javacoding.jspider.core.logging.LogFactory; 8 import net.javacoding.jspider.core.logging.Log; 9 10 11 20 public class DistributedLoadThrottleProvider implements ThrottleProvider { 21 22 public static final String INTERVAL = "interval"; 23 public static final int INTERVAL_DEFAULT = 1000; 24 public static final int INTERVAL_MIN = 250; 25 26 30 public Throttle createThrottle(PropertySet props) { 31 32 33 int interval = props.getInteger(INTERVAL, INTERVAL_DEFAULT); 34 35 Log log = LogFactory.getLog(DistributedLoadThrottleProvider.class); 36 37 if (interval < INTERVAL_MIN) { 38 log.warn("Throttle interval < " + INTERVAL_MIN + " ms is dangereous - set to minimum allowed of " + INTERVAL_MIN + " ms"); 39 interval = INTERVAL_MIN; 40 } 41 42 log.debug("throttle interval set to " + interval + " ms."); 43 44 return new DistributedLoadThrottleImpl(interval); 45 } 46 } 47 | Popular Tags |