StatsRequest extends AsciiRequest<Map<String, MemcachedStats>> implements AllRequest<Map<String, MemcachedStats>> { @Override protected void handle(final AsciiResponse response, final HostAndPort server) throws IOException { final AsciiResponse.Type type = response.type; final String host = server.getHostText() + ":" + server.getPort(); if (type == AsciiResponse.Type.STATS) { final StatsAsciiResponse statsResponse = (StatsAsciiResponse) response; succeed(ImmutableMap.of(host, new MemcachedStats(statsResponse.values))); } else if (type == AsciiResponse.Type.ERROR) { succeed(ImmutableMap.of(host, new MemcachedStats(ImmutableMap.of()))); } else { throw new IOException("Unexpected response type: " + type); } } StatsRequest(final String key); private  StatsRequest(final byte[] key); @Override ByteBuf writeRequest(final ByteBufAllocator alloc, final ByteBuffer dst); @Override Map<String, MemcachedStats> merge(final List<Map<String, MemcachedStats>> results); @Override Request<Map<String, MemcachedStats>> duplicate();  }
@Test public void testResponse() throws IOException, InterruptedException, ExecutionException { req.handle(new StatsAsciiResponse(), HostAndPort.fromParts("host", 123)); assertEquals(ImmutableMap.of("host:123", new MemcachedStats(ImmutableMap.of())), req.get()); }