Package com.danga.MemCached

Examples of com.danga.MemCached.SockIOPool


            serverList = convertNameValueToStringArray(servers);

            //logger.info("size of the array is " + serverList.length);
            //String[] serverList = servers.split(",?[ *]");
            SockIOPool pool = SockIOPool.getInstance("livePool");
            pool.setServers(serverList);
            pool.initialize();

            cache = new MemCachedClient();
            //cache.setPoolName("livePool");
        }              
    }
View Full Code Here


     *
     * @param servers String []  servers:port.
     */
    public MemCacheUtility(String[] servers) {
        if (cache == null) {
            SockIOPool pool = SockIOPool.getInstance("livePool");
            pool.setServers(servers);
            pool.initialize();
            logger.info("In MemcacheUtility constructor");
            cache = new MemCachedClient();
            //cache.setPoolName("livePool");
        }
    }
View Full Code Here

            // the env memcachedInstances is in the
            // form host1:port1, host2:port2, etc.
            String servers = locator.getString("memcachedInstances");
            String[] serverList = servers.split(",?[ *]");
            //SockIOPool pool = SockIOPool.getInstance("livePool");
            SockIOPool pool = SockIOPool.getInstance();
           
            // Set equal weight for all servers
            if (serverList.length > 1) {
                Integer[] wts = new Integer[serverList.length];
                for (int i=0; i<wts.length; i++)
                    wts[i] = Integer.valueOf(1);
                pool.setWeights(wts);
            }
            pool.setServers(serverList);
           
            // The following options have been set based on the Whalin doc
            pool.setInitConn( 8 );
            pool.setMinConn( 8 );
            pool.setMaxConn( 128 );
            pool.setMaxIdle( 1000 * 60 * 60 * 6 );

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

            pool.initialize();

            cache = new MemCachedClient();
            MemCachedClient.getLogger().setLevel(Logger.LEVEL_WARN);
           
            // Set thelog level to WARNING -- The defautl is INFO which causes unecessary logging
View Full Code Here

            serverList = convertNameValueToStringArray(servers);

            //logger.info("size of the array is " + serverList.length);
            //String[] serverList = servers.split(",?[ *]");
            SockIOPool pool = SockIOPool.getInstance("livePool");
            pool.setServers(serverList);
            pool.initialize();

            cache = new MemCachedClient();
            //cache.setPoolName("livePool");
        }              
    }
View Full Code Here

     *
     * @param servers String []  servers:port.
     */
    public MemCacheUtility(String[] servers) {
        if (cache == null) {
            SockIOPool pool = SockIOPool.getInstance("livePool");
            pool.setServers(servers);
            pool.initialize();

            cache = new MemCachedClient();
            //cache.setPoolName("livePool");
        }
    }
View Full Code Here

  }

  @Override
  public Cache getCache(String poolName) {
    String upperCase = poolName.toUpperCase();
    SockIOPool pool = SockIOPool.getInstance(upperCase);
    if(!pool.isInitialized()) {
      try {
        initializePool(pool);
      } catch (Exception e) {
        throw new CacheUnreachableException("Can't create Memcached Instance");
      }
View Full Code Here

      System.exit(1);
    }

    String servers = (String) properties.get("servers");
    BasicConfigurator.configure();
    SockIOPool pool = SockIOPool.getInstance();
    pool.setMinConn(10);
    pool.setMaxConn(maxConn);
    pool.setMaxIdle(60 * 60 * 1000);
    pool.setServers(servers.split(" "));
    pool.initialize();

    MemCachedClient memcachedClient = new MemCachedClient();
    memcachedClient.setCompressThreshold(16 * 1024);
    System.out.println("Java-MemCached startup");
    warmUp(memcachedClient);

    for (int i = 0; i < THREADS.length; i++) {
      for (int j = 0; j < BYTES.length; j++) {
        int repeats = getReapts(i);
        test(memcachedClient, BYTES[j], THREADS[i], repeats, true);
      }
    }
    pool.shutDown();
  }
View Full Code Here

  }

  public void afterPropertiesSet() throws Exception {
    client = new MemCachedClient();
    // grab an instance of our connection pool
    SockIOPool pool = SockIOPool.getInstance();

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

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

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

            serverList = convertNameValueToStringArray(servers);

            //logger.info("size of the array is " + serverList.length);
            //String[] serverList = servers.split(",?[ *]");
            SockIOPool pool = SockIOPool.getInstance("livePool");
            pool.setServers(serverList);
            pool.initialize();

            cache = new MemCachedClient();
            //cache.setPoolName("livePool");
        }              
    }
View Full Code Here

     *
     * @param servers String []  servers:port.
     */
    public MemCacheUtility(String[] servers) {
        if (cache == null) {
            SockIOPool pool = SockIOPool.getInstance("livePool");
            pool.setServers(servers);
            pool.initialize();

            cache = new MemCachedClient();
            //cache.setPoolName("livePool");
        }
    }
View Full Code Here

TOP

Related Classes of com.danga.MemCached.SockIOPool

Copyright © 2018 www.massapicom. 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.