Package net.spy.memcached

Examples of net.spy.memcached.ConnectionFactory


  public boolean establish() throws KeyValueStoreClientException {
    if (_client != null) {
      shutdown();
    }
    try {
      ConnectionFactory cf = getConnectionFactory();
      if (cf == null) {
        this._client = new MemcachedClient(AddrUtil.getAddresses(_serverString));
      } else {
        this._client = new MemcachedClient(cf, AddrUtil.getAddresses(_serverString));
      }
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

    }

    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 ConnectionType connectionType = ConnectionType.valueOf(memcachedNodesManager.isCouchbaseBucketConfig(), username, password);
            if (connectionType.isCouchbaseBucketConfig()) {
                return createCouchbaseClient(memcachedNodesManager, memcachedProtocol, username, password, operationTimeout, maxReconnectDelay,
                        statistics);
            }
            final ConnectionFactory connectionFactory = createConnectionFactory(memcachedNodesManager, connectionType, memcachedProtocol,
                    username, password, operationTimeout, maxReconnectDelay, statistics);
            return new MemcachedClient(connectionFactory, memcachedNodesManager.getAllMemcachedAddresses());
        } catch (final Exception e) {
            throw new RuntimeException("Could not create memcached client", e);
        }
View Full Code Here

        return getTestUtils().tomcatBuilder().port(_portTomcat1).memcachedNodes(_memcachedNodes).sticky(true).jvmRoute("app1");
    }

    private MemcachedClient createMemcachedClient( final String memcachedNodes, final InetSocketAddress address ) throws IOException, InterruptedException {
        final MemcachedNodesManager nodesManager = MemcachedNodesManager.createFor(memcachedNodes, null, null, _memcachedClientCallback);
        final ConnectionFactory cf = nodesManager.isEncodeNodeIdInSessionId()
            ? new SuffixLocatorConnectionFactory( nodesManager, nodesManager.getSessionIdFormat(), Statistics.create(), 1000, 1000 )
            : new DefaultConnectionFactory();
        final MemcachedClient result = new MemcachedClient( cf, Arrays.asList( address ) );

        // Wait a little bit, so that the memcached client can connect and is ready when test starts
View Full Code Here

            LOG.error( "could not start tomcat.", e );
            throw e;
        }

        final MemcachedNodesManager nodesManager = MemcachedNodesManager.createFor(_memcachedNodes, null, null, _memcachedClientCallback);
        final ConnectionFactory cf = nodesManager.isEncodeNodeIdInSessionId()
            ? new SuffixLocatorConnectionFactory( nodesManager, nodesManager.getSessionIdFormat(), Statistics.create(), 1000, 1000 )
            : new DefaultConnectionFactory();
        _client = new MemcachedClient( cf, Arrays.asList( address ) );

        _httpClient = new DefaultHttpClient();
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

TOP

Related Classes of net.spy.memcached.ConnectionFactory

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.