Package net.spy.memcached

Examples of net.spy.memcached.ConnectionFactoryBuilder


  protected ConnectionFactoryBuilder getConnectionFactoryBuilder() {
    return new ConnectionFactoryBuilder();
  }

  protected ConnectionFactory getConnectionFactory() {
    ConnectionFactoryBuilder factoryBuilder = getConnectionFactoryBuilder();
    return factoryBuilder.build();
  }
View Full Code Here


    this._password = password;
  }

  @Override
  protected ConnectionFactoryBuilder getConnectionFactoryBuilder() {
    ConnectionFactoryBuilder factoryBuilder = super.getConnectionFactoryBuilder();
    AuthDescriptor ad = new AuthDescriptor(new String[] {"PLAIN"}, new PlainCallbackHandler(_username, _password));
    factoryBuilder.setAuthDescriptor(ad);
    return factoryBuilder;
  }
View Full Code Here

            String memcachePassword = ninjaProperties.getOrDie(NinjaConstant.MEMCACHED_PASSWORD);
           
            // Use plain SASL to connect to memcached
            AuthDescriptor ad = new AuthDescriptor(new String[]{"PLAIN"},
                                    new PlainCallbackHandler(memcachedUser, memcachePassword));
            ConnectionFactory cf = new ConnectionFactoryBuilder()
                                        .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY)
                                        .setAuthDescriptor(ad)
                                        .build();
           
            client = new MemcachedClient(cf, addrs);
View Full Code Here

  @Override
  public void afterPropertiesSet() throws Exception {
    clientPool = new ArrayList<SpyTokyotyrantClient>(poolSize);

    for (int i = 0; i < poolSize; i++) {
      ConnectionFactoryBuilder cfb = new ConnectionFactoryBuilder();

      cfb.setFailureMode(FailureMode.Redistribute);
      cfb.setDaemon(true);
      cfb.setProtocol(Protocol.TEXT);

      if (isConsistentHashing) {
        cfb.setLocatorType(Locator.CONSISTENT);
        cfb.setHashAlg(HashAlgorithm.KETAMA_HASH);
      }

      cfb.setOpTimeout(operationTimeout);

      try {
        MemcachedClient spyClient = new MemcachedClient(cfb.build(), AddrUtil.getAddresses(memcachedNodes));
        clientPool.add(new SpyTokyotyrantClient(spyClient));
      } catch (IOException e) {
        logger.error("MemcachedClient initilization error: ", e);
        throw e;
      }
View Full Code Here

  private long operationTimeout = 1000; //default value in Spy is 1000ms

  // 初始,关闭函数 //
  @Override
  public void afterPropertiesSet() throws Exception {
    ConnectionFactoryBuilder cfb = new ConnectionFactoryBuilder();

    cfb.setFailureMode(FailureMode.Redistribute);
    cfb.setDaemon(true);
    cfb.setProtocol(isBinaryProtocol ? Protocol.BINARY : Protocol.TEXT);

    if (isConsistentHashing) {
      cfb.setLocatorType(Locator.CONSISTENT);
      cfb.setHashAlg(HashAlgorithm.KETAMA_HASH);
    }

    cfb.setOpTimeout(operationTimeout);

    try {
      memcachedClient = new MemcachedClient(cfb.build(), AddrUtil.getAddresses(memcachedNodes));
    } catch (IOException e) {
      logger.error("MemcachedClient initilization error: ", e);
      throw e;
    }
  }
View Full Code Here

    }

    public MemcachedClient getMemcacheClient(HazelcastInstance instance) throws IOException {
        final LinkedList<InetSocketAddress> addresses = new LinkedList<InetSocketAddress>();
        addresses.add(instance.getCluster().getLocalMember().getInetSocketAddress());
        final ConnectionFactory factory = new ConnectionFactoryBuilder().setOpTimeout(60 * 60 * 60).setDaemon(true).setFailureMode(FailureMode.Retry).build();
        return new MemcachedClient(factory, addresses);
    }
View Full Code Here

            }
           
            // Use plain SASL to connect to memcached
            AuthDescriptor ad = new AuthDescriptor(new String[]{"PLAIN"},
                                    new PlainCallbackHandler(memcacheUser, memcachePassword));
            ConnectionFactory cf = new ConnectionFactoryBuilder()
                                        .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY)
                                        .setAuthDescriptor(ad)
                                        .build();
           
            client = new MemcachedClient(cf, addrs);
View Full Code Here

                final AuthDescriptor authDescriptor = new AuthDescriptor(new String[]{"PLAIN"}, new PlainCallbackHandler(username, password));
                return memcachedNodesManager.isEncodeNodeIdInSessionId()
                        ? new SuffixLocatorBinaryConnectionFactory( memcachedNodesManager,
                                memcachedNodesManager.getSessionIdFormat(), statistics, operationTimeout, maxReconnectDelay,
                                authDescriptor)
                        : new ConnectionFactoryBuilder().setProtocol(ConnectionFactoryBuilder.Protocol.BINARY)
                                .setAuthDescriptor(authDescriptor)
                                .setOpTimeout(operationTimeout)
                                .setMaxReconnectDelay(maxReconnectDelay)
                                .build();
            }
View Full Code Here

            }

            // Use plain SASL to connect to memcached
            AuthDescriptor ad = new AuthDescriptor(new String[]{"PLAIN"},
                    new PlainCallbackHandler(memcacheUser, memcachePassword));
            ConnectionFactory cf = new ConnectionFactoryBuilder()
                    .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY)
                    .setAuthDescriptor(ad)
                    .build();

            client = new MemcachedClient(cf, addrs);
View Full Code Here

    @Override
    protected void doStart() throws Exception {
        super.doStart();

        ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder();
        // VERY IMPORTANT! Otherwise, spymemcached optimizes away concurrent gets
        builder.setShouldOptimize(false);
        // We never want spymemcached to time out
        builder.setOpTimeout(9999999);
        // Retry upon failure
        builder.setFailureMode(FailureMode.Retry);
        memcachedConnectionFactory = builder.build();
    }
View Full Code Here

TOP

Related Classes of net.spy.memcached.ConnectionFactoryBuilder

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.