Examples of SockIOPool


Examples of com.danga.MemCached.SockIOPool

  @SuppressWarnings("rawtypes")
  protected void prepareClient() {

    // grab an instance of our connection pool
    SockIOPool pool = null;
    if (StringUtils.isBlank(getPoolName())) {
      pool = SockIOPool.getInstance();
      mcc = new MemCachedClient();
    } else {
      pool = SockIOPool.getInstance(getPoolName());
      mcc = new MemCachedClient(getPoolName());
    }

    // Integer[] weights = { 5, 1 };

    // 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(getInitConn());
    pool.setMinConn(getMinConn());
    pool.setMaxConn(getMaxConn());
    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);
//    pool.setBufferSize(1024);

    // 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(getConnectTimeout());

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

    // lets set some compression on for the client
    // compress anything larger than 64k
    // mcc.setCompressEnable(true);
    // mcc.setCompressThreshold(64 * 1024);
 
View Full Code Here

Examples of com.danga.MemCached.SockIOPool

    public Memcache createMemcacheClient() throws Exception {
        String poolName = getPoolName();

        // grab an instance of our connection pool
        SockIOPool pool = SockIOPool.getInstance(poolName);

        // set the servers and the weights
        pool.setServers(getServers());
        pool.setWeights(getWeights());

        // set some basic pool settings
        pool.setInitConn(getInitConn());
        pool.setMinConn(getMinConn());
        pool.setMaxConn(getMaxConn());
        pool.setMaxIdle(getMaxIdle());

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

        // set some TCP settings
        pool.setNagle(false);
        pool.setSocketTO(getSocketTimeout());
        pool.setSocketConnectTO(getSocketConnectTimeout());

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

        MemCachedClient client =
                new MemCachedClient(
                        getClassLoader(),
                        getErrorHandler(),
View Full Code Here

Examples of com.meetup.memcached.SockIOPool

  public MemcachedClient getClient() {
    return client;
  }

  public Memcache(final List<String> servers, final String poolName) {
    SockIOPool pool = SockIOPool.getInstance(poolName);
    this.poolName = poolName;
    String[] serv = new String[servers.size()];
    for (int i = 0; i < serv.length; i++) {
      serv[i] = servers.get(i);
    }
    pool.setServers(serv);
    // pool.setNagle(false);
    pool.setInitConn(5);
    pool.setMinConn(5);
    // default to 6 hours
    pool.setMaxIdle(1000 * 60 * 60 * 6);
    pool.setHashingAlg(SockIOPool.NEW_COMPAT_HASH);
    pool.setFailover(true);

    pool.initialize();
    client = new MemcachedClient(poolName);
    client.setPrimitiveAsString(false);
    client.setCompressEnable(true);
    client.setSanitizeKeys(true);
    Logger.getLogger(MemcachedClient.class.getName()).setLevel(Logger.LEVEL_WARN);
View Full Code Here

Examples of com.meetup.memcached.SockIOPool

  public void setPoolName(final String poolName) {
    this.poolName = poolName;
  }

  public void disconnect() {
    SockIOPool pool = SockIOPool.getInstance(getPoolName());
    if (pool != null && pool.isInitialized()) {
      SockIOPool.getInstance(getPoolName()).shutDown();
    }
  }
View Full Code Here

Examples of com.meetup.memcached.SockIOPool

        if ( args.length > 0 )
            serverlist = args;

        // initialize the pool for memcache servers
        SockIOPool pool = SockIOPool.getInstance( "test" );
        try {
          pool.setServers( serverlist );
          pool.setWeights( weights );
          pool.setMaxConn( 250 );
          pool.setNagle( false );
          pool.setHashingAlg( SockIOPool.CONSISTENT_HASH );
          pool.initialize();

          mc = new MemcachedClient( "test" );
          mc.flushAll();
          runAlTests( mc );
        } finally {
          pool.shutDown();
        }
        log.warn("Finished: " + ((System.currentTimeMillis() - time)/1000) + "s");
    }
View Full Code Here

Examples of com.meetup.memcached.SockIOPool

            return;
        }
        String[] serverlist = servers.split(",\\s*");

        // initialize the pool for memcache servers
        SockIOPool pool = SockIOPool.getInstance();
        pool.setServers(serverlist);

        pool.setInitConn(ERXProperties.intForKeyWithDefault("er.caching.initialConnections", 5));
        pool.setMinConn(ERXProperties.intForKeyWithDefault("er.caching.minConnections", 5));
        pool.setMaxConn(ERXProperties.intForKeyWithDefault("er.caching.maxConnections", 50));
        pool.setMaintSleep(ERXProperties.intForKeyWithDefault("er.caching.sleepTime", 30));

        pool.setNagle(ERXProperties.booleanForKeyWithDefault("er.caching.useNagle", false));
        pool.initialize();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.