当前位置: 首页>>代码示例>>Java>>正文


Java SockIOPool类代码示例

本文整理汇总了Java中com.whalin.MemCached.SockIOPool的典型用法代码示例。如果您正苦于以下问题:Java SockIOPool类的具体用法?Java SockIOPool怎么用?Java SockIOPool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SockIOPool类属于com.whalin.MemCached包,在下文中一共展示了SockIOPool类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMemcachedClient

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
protected MemCachedClient getMemcachedClient() {
  String memcachedAddr = System.getProperty("memcached.addr");
  String[] servers = {memcachedAddr};
  SockIOPool pool = SockIOPool.getInstance(POOL_NAME);
  pool.setServers(servers);
  /*
  pool.setFailover( true );
  pool.setInitConn( 10 );
  pool.setMinConn( 5 );
  pool.setMaxConn( 250 );
  pool.setMaintSleep( 30 );
  pool.setNagle( false );
  pool.setSocketTO( 3000 );
  pool.setAliveCheck( true );
  */
  pool.initialize();
  return new MemCachedClient(POOL_NAME, true, false);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:19,代码来源:WhalinMemcachedInstrumentationTest.java

示例2: getMemcachedClient

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
protected MemCachedClient getMemcachedClient() {
  String memcachedAddr = System.getProperty("memcached.addr");
  String[] servers = {memcachedAddr};
  SockIOPool pool = SockIOPool.getInstance(POOL_NAME);
  pool.setServers(servers);
  /*
  pool.setFailover( true );
  pool.setInitConn( 10 );
  pool.setMinConn( 5 );
  pool.setMaxConn( 250 );
  pool.setMaintSleep( 30 );
  pool.setNagle( false );
  pool.setSocketTO( 3000 );
  pool.setAliveCheck( true );
  */
  pool.initialize();
  return new MemCachedClient(POOL_NAME, true, true);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:19,代码来源:BinaryWhalinMemcachedInstrumentationTest.java

示例3: create

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
/**
 * Inits the.
 *
 * @param conf
 *          the conf
 * @return the i cache system
 */
public static ICacheSystem create(String server) {

  MemCache f = new MemCache();

  f.url = server.substring(Cache.MEMCACHED.length());

  SockIOPool pool = SockIOPool.getInstance();
  pool.setServers(new String[] { f.url });
  pool.setFailover(true);
  pool.setInitConn(10);
  pool.setMinConn(5);
  pool.setMaxConn(1000);
  pool.setMaintSleep(30);
  pool.setNagle(false);
  pool.setSocketTO(3000);
  pool.setAliveCheck(true);
  pool.initialize();

  f.memCachedClient = new MemCachedClient();

  return f;
}
 
开发者ID:giiwa,项目名称:giiwa,代码行数:30,代码来源:MemCache.java

示例4: init

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
private void init() {
	SockIOPool pool = SockIOPool.getInstance(poolName);
	pool.setServers(hostAndPort);
	pool.setWeights(hostWeight);
	pool.setInitConn(initConn);
	pool.setMinConn(minConn);
	pool.setMaxConn(maxConn);
	pool.setMaxIdle(maxIdleTime);
	pool.setMaintSleep(maintSleepTime);
	pool.setNagle(socketNagle);
	pool.setSocketTO(socketReadTimeOut);
	pool.setSocketConnectTO(socketConnectTimeOut);
	
	pool.setHashingAlg(SockIOPool.NATIVE_HASH);
	pool.setFailover(failover);
	pool.setFailback(failback);

	pool.initialize();
	memCachedClient = new MemCachedClient(poolName);
	memCachedClient.setPrimitiveAsString(primitiveAsString);
}
 
开发者ID:sogou-biztech,项目名称:compass,代码行数:22,代码来源:MyMemCache.java

示例5: start

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
/**
 * 
 */
@Start
public void start() {
    String path = plugin.getConfig(FILE_CONF, "");
    Properties _conf = MemcachedFactory.load(new File(path));
    if (_conf == null) {
        LOG.error("Not found memcached.file {}", path);
        return;
    }

    String pname = _conf.getProperty("mem.name");

    SockIOPool _pool = createPool(_conf);
    _pool.initialize();
    LOG.info("SockIOPool {} initialize successfully!", pname);

    mcc = new MemCachedClient(pname);
}
 
开发者ID:dzh,项目名称:jframe,代码行数:21,代码来源:MemcachedServiceImpl.java

示例6: ContactMemcachedClient

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
/**
* Initialize connection
*/
public ContactMemcachedClient() {
 
	SockIOPool pool = SockIOPool.getInstance();
	pool.setServers(servers);
	pool.setWeights( weights );
	if (!pool.isInitialized()) {
		pool.setInitConn(5);
		pool.setMinConn(5);
		pool.setMaxConn(250);
		pool.initialize();
	}
	MemCachedClient memCachedClient = new MemCachedClient();
	this.memcachedClient = memCachedClient;
}
 
开发者ID:PacktPublishing,项目名称:MySQL-8-for-Big-Data,代码行数:18,代码来源:ContactMemcachedClient.java

示例7: initializeSockIOPool

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
public void initializeSockIOPool(String name) {

            Properties memcacheProp = new Properties();
            InputStream input;
            SockIOPool pool = SockIOPool.getInstance(name);
            input = this.getClass().getClassLoader().getResourceAsStream(PROP_NAME);
            try {
                memcacheProp.load(input);
                input.close();
                pool.setServers(memcacheProp.getProperty("serversList").split(","));
                pool.setFailover(Boolean.parseBoolean(memcacheProp.getProperty("failover")));
                pool.setInitConn(Integer.parseInt(memcacheProp.getProperty("initConn")));
                pool.setMinConn(Integer.parseInt(memcacheProp.getProperty("minConn")));
                pool.setMaxConn(Integer.parseInt(memcacheProp.getProperty("maxConn")));
                pool.setMaintSleep(Long.parseLong(memcacheProp.getProperty("maintSleep")));
                pool.setNagle(Boolean.parseBoolean(memcacheProp.getProperty("nagle")));
                pool.setSocketTO(Integer.parseInt(memcacheProp.getProperty("docketTO")));
                pool.setAliveCheck(Boolean.parseBoolean(memcacheProp.getProperty("aliveCheck")));
            } catch (IOException e) {
                Log.error("could not create load/read memcache properties from file: " + PROP_NAME + ", will try with defaults, error: " + e, e);

                String[] servers = {"localhost:11211"};
                pool.setServers(servers);
                pool.setFailover(true);
                pool.setInitConn(10);
                pool.setMinConn(5);
                pool.setMaxConn(250);
                pool.setMaintSleep(30);
                pool.setNagle(false);
                pool.setSocketTO(3000);
                pool.setAliveCheck(true);
            }

            pool.initialize();
        }
 
开发者ID:canmogol,项目名称:FatJar,代码行数:36,代码来源:MemCache.java

示例8: setup

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
@BeforeClass
  public static void setup() throws Exception{

// 设置缓存服务器列表,当使用分布式缓存的时,可以指定多个缓存服务器。这里应该设置为多个不同的服务,我这里将两个服务设置为一样的,大家不要向我学习,呵呵。
      String[] servers =
              {
                      "127.0.0.1:11211"
              };

      // 设置服务器权重
      Integer[] weights = {3};

      // 创建一个Socked连接池实例
      SockIOPool pool = SockIOPool.getInstance();

    // 向连接池设置服务器和权重
      pool.setServers(servers);
      pool.setWeights(weights);

      // set some TCP settings
      // disable nagle
      // set the read timeout to 3 secs
      // and don't set a connect timeout
      pool.setNagle(false);
      pool.setSocketTO(3000);
      pool.setSocketConnectTO(0);

     // initialize the connection pool
      pool.initialize();
  }
 
开发者ID:MyCATApache,项目名称:Mycat-JCache,代码行数:31,代码来源:AppTestBinary.java

示例9: connect

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
@Override
public void connect() throws IOException
{
  pool = SockIOPool.getInstance();
  if (serverAddresses.isEmpty()) {
    pool.setServers(new String[]{"localhost:11211"});
  } else {
    pool.setServers(serverAddresses.toArray(new String[] {}));
  }
  pool.initialize();
  memcacheClient = new MemCachedClient();
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:13,代码来源:MemcacheStore.java

示例10: createPool

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
private static SockIOPool createPool(Properties _conf) {
    String pname = _conf.getProperty("mem.name");

    SockIOPool _pool = SockIOPool.getInstance(pname);
    String[] servers = _conf.getProperty("mem.servers").split("[,\\s+]");
    String[] memServers = new String[servers.length];
    Integer[] memWeights = new Integer[servers.length];
    for (int i = 0; i < servers.length; i++) {
        memServers[i] = _conf.getProperty("mem.server." + servers[i].trim() + ".host", "127.0.0.1") + ":"
                + _conf.getProperty("mem.server." + servers[i].trim() + ".port", "11211");
        memWeights[i] = Integer.parseInt(_conf.getProperty("mem." + servers[i] + ".weight", "1"));

        LOG.info("memcached -> {}", memServers[i]);
    }
    _pool.setServers(memServers);
    _pool.setWeights(memWeights);

    _pool.setInitConn(Integer.parseInt(_conf.getProperty("mem.initconn", "10")));
    _pool.setMinConn(Integer.parseInt(_conf.getProperty("mem.minconn", "5")));
    _pool.setMaxConn(Integer.parseInt(_conf.getProperty("mem.maxconn", "250")));
    _pool.setMaxIdle(Integer.parseInt(_conf.getProperty("mem.maxidle", "3600000")));

    _pool.setMaintSleep(30);
    _pool.setNagle(false);
    _pool.setSocketTO(Integer.parseInt(_conf.getProperty("mem.timeout.read", "3000")));
    _pool.setSocketConnectTO(Integer.parseInt(_conf.getProperty("mem.timeout.conn", "3000")));
    return _pool;
}
 
开发者ID:dzh,项目名称:jframe,代码行数:29,代码来源:MemcachedServiceImpl.java

示例11: initMemCachedClient

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
private MemCachedClient initMemCachedClient(String[] servers, int maxConn, boolean sanitizeKeys) {
	// logger.info("maxConn:" + maxConn + " sanitizeKeys:" + sanitizeKeys + " servers" + StringUtils.join(servers));
	Integer[] weights = new Integer[servers.length];
	for (int i = 0; i < weights.length; i++) {
		weights[i] = 3;
	}
	// { 3 };
	// grab an instance of our connection pool
	// String server = StringUtils.join(servers);
	// int hasCode = server.hashCode();
	String poolName = "pool" + servers.hashCode();
	// logger.info("init poolName:" + poolName + " server:" + server);
	SockIOPool pool = SockIOPool.getInstance(poolName);

	MemCachedClient mcc = new MemCachedClient(poolName);

	// mcc.setErrorHandler(new ErrorHandlerImpl());
	// set the servers and the weights
	pool.setServers(servers);
	pool.setWeights(weights);

	// set some basic pool settings
	// 5 initial, 5 min, and 250 max conns
	// and set the max idle time for a conn
	// to 6 hours
	pool.setInitConn(5);
	pool.setMinConn(5);
	pool.setMaxConn(maxConn);
	pool.setMaxIdle(1000 * 60 * 60 * 6);

	// set the sleep for the maint thread
	// it will wake up every x seconds and
	// maintain the pool size
	pool.setMaintSleep(30 * 1000);

	// set some TCP settings
	// disable nagle
	// set the read timeout to 3 secs
	pool.setNagle(false);
	pool.setSocketTO(3000);
	pool.setSocketConnectTO(0);

	// initialize the connection pool
	pool.initialize();

	mcc.setSanitizeKeys(sanitizeKeys);// 不要对key进行url编码
	// logger.info("connected poolName:" + poolName + " server:" + server + " maxConn:" + maxConn);
	// lets set some compression on for the client
	// compress anything larger than 64k
	// mcc.setCompressEnable(true);
	// mcc.setCompressThreshold(64 * 1024);
	return mcc;
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:54,代码来源:MemcacheImpl.java

示例12: cleanup

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
public void cleanup() {
    SockIOPool.getInstance().shutDown();
    memCachedClient = null;

}
 
开发者ID:ManuelB,项目名称:key-value-benchmark,代码行数:6,代码来源:MemcachedKeyValueLookup.java

示例13: getPool

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
public SockIOPool getPool() {
    return _pool;
}
 
开发者ID:dzh,项目名称:jframe,代码行数:4,代码来源:MemcachedServiceImpl.java

示例14: setPool

import com.whalin.MemCached.SockIOPool; //导入依赖的package包/类
public void setPool(SockIOPool pool) {
    this._pool = pool;
}
 
开发者ID:dzh,项目名称:jframe,代码行数:4,代码来源:MemcachedServiceImpl.java


注:本文中的com.whalin.MemCached.SockIOPool类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。