public void setBufferAllocator(BufferAllocator allocator) { this.bufferAllocator = allocator; for (Session session : this.getSessionSet()) { ((MemcachedSession) session).setBufferAllocator(allocator); } }
public Collection<InetSocketAddress> getAvailableServers() { Set<Session> sessionSet = this.connector.getSessionSet(); Set<InetSocketAddress> result = new HashSet<InetSocketAddress>(); for (Session session : sessionSet) { result.add(session.getRemoteSocketAddress()); } return Collections.unmodifiableSet(result); }
public final List<String> getServersDescription() { final List<String> result = new ArrayList<String>(); for (Session session : this.connector.getSessionSet()) { InetSocketAddress socketAddress = session.getRemoteSocketAddress(); int weight = ((MemcachedSession) session).getInetSocketAddressWrapper().getWeight(); result.add(SystemUtils.getRawAddress(socketAddress) + ":" + socketAddress.getPort() + "(weight=" + weight + ")"); } return result; }
private void flushAllMemcachedServers(long timeout, boolean noreply, int exptime) throws MemcachedException, InterruptedException, TimeoutException { final Collection<Session> sessions = this.connector.getSessionSet(); CountDownLatch latch = new CountDownLatch(sessions.size()); List<Command> commands = new ArrayList<Command>(sessions.size()); for (Session session : sessions) { if (session != null && !session.isClosed()) { Command command = this.commandFactory.createFlushAllCommand(latch, exptime, noreply); session.write(command); } else { latch.countDown(); } } if (!noreply) { if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { for (Command cmd : commands) { cmd.cancel(); } throw new TimeoutException("Timed out waiting for operation"); } } }
if (this.connector.getSessionSet().size() <= 1) { commands = new ArrayList<Command>(1); latch = new CountDownLatch(1);
@SuppressWarnings("unchecked") public final Map<InetSocketAddress, Map<String, String>> getStatsByItem(String itemName, long timeout) throws MemcachedException, InterruptedException, TimeoutException { final Set<Session> sessionSet = this.connector.getSessionSet(); final Map<InetSocketAddress, Map<String, String>> collectResult = new HashMap<InetSocketAddress, Map<String, String>>(); if (sessionSet.size() == 0) { return collectResult; } final CountDownLatch latch = new CountDownLatch(sessionSet.size()); List<Command> commands = new ArrayList<Command>(sessionSet.size()); for (Session session : sessionSet) { Command command = this.commandFactory.createStatsCommand(session.getRemoteSocketAddress(), latch, itemName); session.write(command); commands.add(command); } if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { for (Command command : commands) { command.cancel(); } throw new TimeoutException("Timed out waiting for operation"); } for (Command command : commands) { this.checkException(command); collectResult.put(((ServerAddressAware) command).getServer(), (Map<String, String>) command.getResult()); } return collectResult; }
public final Map<InetSocketAddress, String> getVersions(long timeout) throws TimeoutException, InterruptedException, MemcachedException { final Set<Session> sessionSet = this.connector.getSessionSet(); Map<InetSocketAddress, String> collectResult = new HashMap<InetSocketAddress, String>(); if (sessionSet.size() == 0) { return collectResult; } final CountDownLatch latch = new CountDownLatch(sessionSet.size()); List<Command> commands = new ArrayList<Command>(sessionSet.size()); for (Session session : sessionSet) { Command command = this.commandFactory.createVersionCommand(latch, session.getRemoteSocketAddress()); session.write(command); commands.add(command); } if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { for (Command command : commands) { command.cancel(); } throw new TimeoutException("Timed out waiting for operation"); } for (Command command : commands) { this.checkException(command); collectResult.put(((ServerAddressAware) command).getServer(), (String) command.getResult()); } return collectResult; }
public Collection<InetSocketAddress> getAvailableServers() { Set<Session> sessionSet = this.connector.getSessionSet(); Set<InetSocketAddress> result = new HashSet<InetSocketAddress>(); for (Session session : sessionSet) { result.add(session.getRemoteSocketAddress()); } return Collections.unmodifiableSet(result); }
public void setBufferAllocator(BufferAllocator allocator) { this.bufferAllocator = allocator; for (Session session : this.getSessionSet()) { ((MemcachedSession) session).setBufferAllocator(allocator); } }
public final List<String> getServersDescription() { final List<String> result = new ArrayList<String>(); for (Session session : this.connector.getSessionSet()) { InetSocketAddress socketAddress = session.getRemoteSocketAddress(); int weight = ((MemcachedSession) session).getInetSocketAddressWrapper().getWeight(); result.add(SystemUtils.getRawAddress(socketAddress) + ":" + socketAddress.getPort() + "(weight=" + weight + ")"); } return result; }
if (this.connector.getSessionSet().size() <= 1) { commands = new ArrayList<Command>(1); latch = new CountDownLatch(1);
private void flushAllMemcachedServers(long timeout, boolean noreply, int exptime) throws MemcachedException, InterruptedException, TimeoutException { final Collection<Session> sessions = this.connector.getSessionSet(); CountDownLatch latch = new CountDownLatch(sessions.size()); List<Command> commands = new ArrayList<Command>(sessions.size()); for (Session session : sessions) { if (session != null && !session.isClosed()) { Command command = this.commandFactory.createFlushAllCommand(latch, exptime, noreply); session.write(command); } else { latch.countDown(); } } if (!noreply) { if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { for (Command cmd : commands) { cmd.cancel(); } throw new TimeoutException("Timed out waiting for operation"); } } }
public final Map<InetSocketAddress, String> getVersions(long timeout) throws TimeoutException, InterruptedException, MemcachedException { final Set<Session> sessionSet = this.connector.getSessionSet(); Map<InetSocketAddress, String> collectResult = new HashMap<InetSocketAddress, String>(); if (sessionSet.size() == 0) { return collectResult; } final CountDownLatch latch = new CountDownLatch(sessionSet.size()); List<Command> commands = new ArrayList<Command>(sessionSet.size()); for (Session session : sessionSet) { Command command = this.commandFactory.createVersionCommand(latch, session.getRemoteSocketAddress()); session.write(command); commands.add(command); } if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { for (Command command : commands) { command.cancel(); } throw new TimeoutException("Timed out waiting for operation"); } for (Command command : commands) { this.checkException(command); collectResult.put(((ServerAddressAware) command).getServer(), (String) command.getResult()); } return collectResult; }
@SuppressWarnings("unchecked") public final Map<InetSocketAddress, Map<String, String>> getStatsByItem(String itemName, long timeout) throws MemcachedException, InterruptedException, TimeoutException { final Set<Session> sessionSet = this.connector.getSessionSet(); final Map<InetSocketAddress, Map<String, String>> collectResult = new HashMap<InetSocketAddress, Map<String, String>>(); if (sessionSet.size() == 0) { return collectResult; } final CountDownLatch latch = new CountDownLatch(sessionSet.size()); List<Command> commands = new ArrayList<Command>(sessionSet.size()); for (Session session : sessionSet) { Command command = this.commandFactory.createStatsCommand(session.getRemoteSocketAddress(), latch, itemName); session.write(command); commands.add(command); } if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { for (Command command : commands) { command.cancel(); } throw new TimeoutException("Timed out waiting for operation"); } for (Command command : commands) { this.checkException(command); collectResult.put(((ServerAddressAware) command).getServer(), (Map<String, String>) command.getResult()); } return collectResult; }