/** * XMemcached Constructor. * * @param inetSocketAddress * @param weight * @throws IOException */ public XMemcachedClient(final InetSocketAddress inetSocketAddress, int weight, CommandFactory cmdFactory) throws IOException { super(); if (inetSocketAddress == null) { throw new IllegalArgumentException("Null InetSocketAddress"); } if (cmdFactory == null) { throw new IllegalArgumentException("Null command factory."); } if (weight <= 0) { throw new IllegalArgumentException("weight<=0"); } this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), cmdFactory, new SerializingTranscoder()); this.start0(); this.connect(new InetSocketAddressWrapper(inetSocketAddress, this.serverOrderCount.incrementAndGet(), weight, null)); }
public final Session getSessionByKey(final String key) { if (this.sessions == null || this.sessions.size() == 0) { return null; } // Copy on read List<List<Session>> sessionList = this.sessions; int size = sessionList.size(); if (size == 0) { return null; } long start = this.getHash(size, key); List<Session> sessions = sessionList.get((int) start); Session session = getRandomSession(sessions); // If it is not failure mode,get next available session if (!this.failureMode && (session == null || session.isClosed())) { long next = this.getNext(size, start); while ((session == null || session.isClosed()) && next != start) { sessions = sessionList.get((int) next); next = this.getNext(size, next); session = getRandomSession(sessions); } } return session; }
public final Session getSessionByKey(final String key) { if (this.sessions == null || this.sessions.size() == 0) { return null; } // Copy on read List<List<Session>> sessionList = this.sessions; int size = sessionList.size(); if (size == 0) { return null; } long start = this.getHash(size, key); List<Session> sessions = sessionList.get((int) start); Session session = getRandomSession(sessions); // If it is not failure mode,get next available session if (!this.failureMode && (session == null || session.isClosed())) { long next = this.getNext(size, start); while ((session == null || session.isClosed()) && next != start) { sessions = sessionList.get((int) next); next = this.getNext(size, next); session = getRandomSession(sessions); } } return session; }
/** * XMemcached Constructor.Every server's weight is one by default. * * @param cmdFactory command factory * @param addressList memcached server socket address list. * @throws IOException */ public XMemcachedClient(List<InetSocketAddress> addressList, CommandFactory cmdFactory) throws IOException { super(); if (cmdFactory == null) { throw new IllegalArgumentException("Null command factory."); } if (addressList == null || addressList.isEmpty()) { throw new IllegalArgumentException("Empty address list"); } BufferAllocator simpleBufferAllocator = new SimpleBufferAllocator(); this.buildConnector(new ArrayMemcachedSessionLocator(), simpleBufferAllocator, XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), cmdFactory, new SerializingTranscoder()); this.start0(); for (InetSocketAddress inetSocketAddress : addressList) { this.connect(new InetSocketAddressWrapper(inetSocketAddress, this.serverOrderCount.incrementAndGet(), 1, null)); } }
/** * Construct an AWSElasticCacheClient instance with config server addresses. * * @since 2.3.0 * @param addrs config server list. * @param pollConfigIntervalMills config poll interval in milliseconds. * @param commandFactory protocol command factory. * @throws IOException */ @SuppressWarnings("unchecked") public AWSElasticCacheClient(List<InetSocketAddress> addrs, long pollConfigIntervalMills, CommandFactory commandFactory) throws IOException { this(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder(), (List<MemcachedClientStateListener>) Collections.EMPTY_LIST, (Map<InetSocketAddress, AuthInfo>) Collections.EMPTY_MAP, 1, XMemcachedClient.DEFAULT_CONNECT_TIMEOUT, null, true, addrs, pollConfigIntervalMills); }
public XMemcachedClient() throws IOException { super(); this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder()); this.start0(); }
/** * XMemcached constructor * * @param host server host * @param port server port * @param weight server weight * @throws IOException */ public XMemcachedClient(final String host, final int port, int weight) throws IOException { super(); if (weight <= 0) { throw new IllegalArgumentException("weight<=0"); } this.checkServerPort(host, port); this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder()); this.start0(); this.connect(new InetSocketAddressWrapper(this.newSocketAddress(host, port), this.serverOrderCount.incrementAndGet(), weight, null)); }
CommandFactory commandFactory, Transcoder transcoder) { if (locator == null) { locator = new ArrayMemcachedSessionLocator();
/** * XMemcached Constructor.Every server's weight is one by default. * * @param cmdFactory command factory * @param addressList memcached server socket address list. * @throws IOException */ public XMemcachedClient(List<InetSocketAddress> addressList, CommandFactory cmdFactory) throws IOException { super(); if (cmdFactory == null) { throw new IllegalArgumentException("Null command factory."); } if (addressList == null || addressList.isEmpty()) { throw new IllegalArgumentException("Empty address list"); } BufferAllocator simpleBufferAllocator = new SimpleBufferAllocator(); this.buildConnector(new ArrayMemcachedSessionLocator(), simpleBufferAllocator, XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), cmdFactory, new SerializingTranscoder()); this.start0(); for (InetSocketAddress inetSocketAddress : addressList) { this.connect(new InetSocketAddressWrapper(inetSocketAddress, this.serverOrderCount.incrementAndGet(), 1, null)); } }
/** * XMemcached Constructor. * * @param inetSocketAddress * @param weight * @throws IOException */ public XMemcachedClient(final InetSocketAddress inetSocketAddress, int weight, CommandFactory cmdFactory) throws IOException { super(); if (inetSocketAddress == null) { throw new IllegalArgumentException("Null InetSocketAddress"); } if (cmdFactory == null) { throw new IllegalArgumentException("Null command factory."); } if (weight <= 0) { throw new IllegalArgumentException("weight<=0"); } this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), cmdFactory, new SerializingTranscoder()); this.start0(); this.connect(new InetSocketAddressWrapper(inetSocketAddress, this.serverOrderCount.incrementAndGet(), weight, null)); }
/** * Construct an AWSElasticCacheClient instance with config server addresses. * * @since 2.3.0 * @param addrs config server list. * @param pollConfigIntervalMills config poll interval in milliseconds. * @param commandFactory protocol command factory. * @throws IOException */ @SuppressWarnings("unchecked") public AWSElasticCacheClient(List<InetSocketAddress> addrs, long pollConfigIntervalMills, CommandFactory commandFactory) throws IOException { this(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder(), (List<MemcachedClientStateListener>) Collections.EMPTY_LIST, (Map<InetSocketAddress, AuthInfo>) Collections.EMPTY_MAP, 1, XMemcachedClient.DEFAULT_CONNECT_TIMEOUT, null, true, addrs, pollConfigIntervalMills); }
public XMemcachedClient() throws IOException { super(); this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder()); this.start0(); }
/** * XMemcached constructor * * @param host server host * @param port server port * @param weight server weight * @throws IOException */ public XMemcachedClient(final String host, final int port, int weight) throws IOException { super(); if (weight <= 0) { throw new IllegalArgumentException("weight<=0"); } this.checkServerPort(host, port); this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder()); this.start0(); this.connect(new InetSocketAddressWrapper(this.newSocketAddress(host, port), this.serverOrderCount.incrementAndGet(), weight, null)); }
CommandFactory commandFactory, Transcoder transcoder) { if (locator == null) { locator = new ArrayMemcachedSessionLocator();