SimultaneousUsersThrottleProvider.java
上传用户:qing5858
上传日期:2015-10-27
资源大小:6056k
文件大小:2k
源码类别:

搜索引擎

开发平台:

Java

  1. package net.javacoding.jspider.core.throttle.impl;
  2. import net.javacoding.jspider.core.throttle.Throttle;
  3. import net.javacoding.jspider.core.throttle.ThrottleProvider;
  4. import net.javacoding.jspider.core.util.config.PropertySet;
  5. import net.javacoding.jspider.core.logging.LogFactory;
  6. import net.javacoding.jspider.core.logging.Log;
  7. /**
  8.  * Throttle Provider implementation that will create throttle objects that
  9.  * simulate multiple simultaneous users making requests on the webserver.
  10.  *
  11.  * $Id: SimultaneousUsersThrottleProvider.java,v 1.6 2003/04/03 15:57:21 vanrogu Exp $
  12.  *
  13.  * @author G黱ther Van Roey
  14.  */
  15. public class SimultaneousUsersThrottleProvider implements ThrottleProvider {
  16.     public static final String THINKTIME_MIN = "thinktime.min";
  17.     public static final String THINKTIME_MAX = "thinktime.max";
  18.     public static final int THINKTIME_MIN_DEFAULT = 1000;
  19.     public static final int THINKTIME_MAX_DEFAULT = 1000;
  20.     /**
  21.      * Factory method that will create the Throttle implementation for
  22.      * simultaneous user simulation, with the config parameters defined
  23.      * in the configuration file.
  24.      * @return Throttle implementation to be used
  25.      */
  26.     public Throttle createThrottle(PropertySet props) {
  27.         Log log = LogFactory.getLog(SimultaneousUsersThrottleProvider.class);
  28.         int min = props.getInteger(THINKTIME_MIN,THINKTIME_MIN_DEFAULT);
  29.         int max = props.getInteger(THINKTIME_MAX,THINKTIME_MAX_DEFAULT);
  30.         log.debug("min thinktime set to " + min);
  31.         log.debug("max thinktime set to " + max);
  32.         return new SimultaneousUsersThrottleImpl ( min, max );
  33.     }
  34. }