Package net.rubyeye.xmemcached

Examples of net.rubyeye.xmemcached.MemcachedClientBuilder


  }

  public static MemcachedClient getMemcachedClient(String servers) {
    try {
      // use text protocol by default
      MemcachedClientBuilder builder = new XMemcachedClientBuilder(
          AddrUtil.getAddresses(servers));
      return builder.build();
    } catch (IOException e) {
      System.err.println("Create MemcachedClient fail");
      e.printStackTrace();
    }
    return null;
View Full Code Here


  }

  public static MemcachedClient getMemcachedClient(String servers) {
    try {
      // use text protocol by default
      MemcachedClientBuilder builder = new XMemcachedClientBuilder(
          AddrUtil.getAddresses(servers));
      // Add my state listener
      builder.addStateListener(new MyListener());
      return builder.build();
    } catch (IOException e) {
      System.err.println("Create MemcachedClient fail");
      e.printStackTrace();
    }
    return null;
View Full Code Here

    if (args.length < 2) {
      System.err.println("Usage:java CASTest [threadNum] [server]");
      System.exit(1);
    }
    int NUM = Integer.parseInt(args[0]);
    MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil
        .getAddresses(args[1]));
    // use binary protocol
    builder.setCommandFactory(new BinaryCommandFactory());
    MemcachedClient mc = builder.build();
    // initial value is 0
    mc.set("a", 0, 0);
    CountDownLatch cdl = new CountDownLatch(NUM * 100);
    long start = System.currentTimeMillis();
    // start Num threads to increase 'a'
View Full Code Here

  }

  public static MemcachedClient getMemcachedClient(String servers,
      String username, String password) {
    try {
      MemcachedClientBuilder builder = new XMemcachedClientBuilder(
          AddrUtil.getAddresses(servers));
      builder.addAuthInfo(AddrUtil.getOneAddress(servers), AuthInfo
          .typical(username, password));
      // Must use binary protocol
      builder.setCommandFactory(new BinaryCommandFactory());
      return builder.build();
    } catch (IOException e) {
      System.err.println("Create MemcachedClient fail");
      e.printStackTrace();
    }
    return null;
View Full Code Here

    int size = 1024;

    String servers = args[0];
    final AtomicInteger failure = new AtomicInteger();
    final AtomicInteger success = new AtomicInteger();
    MemcachedClientBuilder builder = new XMemcachedClientBuilder(
        AddrUtil.getAddresses(servers));
    //builder.setCommandFactory(new BinaryCommandFactory());
    MemcachedClient client = builder.build();
    ClockWatch watch = new ClockWatch();
    CyclicBarrier barrier = new CyclicBarrier(threads + 1, watch);
    for (int i = 0; i < threads; i++) {
      new TestThread(repeat, i * repeat * 2, size, client, failure,
          success, barrier).start();
View Full Code Here

    }
  }

  public static MemcachedClient getMemcachedClient(String servers) {
    try {
      MemcachedClientBuilder builder = new XMemcachedClientBuilder(
          AddrUtil.getAddresses(servers));
      // use binary protocol
      builder.setCommandFactory(new BinaryCommandFactory());
      return builder.build();
    } catch (IOException e) {
      System.err.println("Create MemcachedClient fail");
      e.printStackTrace();
    }
    return null;
View Full Code Here

    if (properties.get("servers") == null) {
      System.err.print("Please config the memcached.properties");
      System.exit(1);
    }
    String servers = (String) properties.get("servers");
    MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil
        .getAddresses(servers));
    builder.setConnectionPoolSize(connCount);
    if (useBinaryProtocl) {
      builder.setCommandFactory(new BinaryCommandFactory());
    }

    MemcachedClient memcachedClient = builder.build();
    System.out.println("Xmemcached startup");
    warmUp(memcachedClient);

    for (int i = 0; i < THREADS.length; i++) {
      for (int j = 0; j < BYTES.length; j++) {
View Full Code Here

      }
    } else {
      memcachePort = port.toString();
    }

    MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses(memcacheHostName + ":" + memcachePort));
    builder.setCommandFactory(new BinaryCommandFactory());
    builder.setConnectionPoolSize(100);

    try {
      memcachedClient = builder.build();
      memcachedClient.setOpTimeout(30000);
      SerializingTranscoder st = new SerializingTranscoder(memcacheSize);
      memcachedClient.setTranscoder(st);
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

            String address = url.getAddress();
            String backup = url.getParameter(Constants.BACKUP_KEY);
            if (backup != null && backup.length() > 0) {
                address += "," + backup;
            }
            MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses(address));
            final MemcachedClient memcachedClient = builder.build();
            final int expiry = url.getParameter("expiry", 0);
            final String get = url.getParameter("get", "get");
            final String set = url.getParameter("set", Map.class.equals(type) ? "put" : "set");
            final String delete = url.getParameter("delete", Map.class.equals(type) ? "remove" : "delete");
            return new AbstractInvoker<T>(type, url) {
View Full Code Here

 
  public XMemcachedCacheProvider(Properties p) {
    super(p);
   
    try {
      MemcachedClientBuilder builder = new XMemcachedClientBuilder(
          AddrUtil.getAddresses(super.getUrlsProperty()));
      //builder.setCommandFactory(new BinaryCommandFactory());//use binary protocol
      client = builder.build();
     
      timeout = (super.getRequestTimeoutInSecondsProperty() > 0)?super.getRequestTimeoutInSecondsProperty():60;
      xmemcachedCache = new XMemcachedCache(this, client);
    } catch (Exception ex) {
      log.error("Error initiating memcached client: " + ex.getMessage(), ex);
View Full Code Here

TOP

Related Classes of net.rubyeye.xmemcached.MemcachedClientBuilder

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.