@Override public RedisClient route(String key) { if (this.ketamaClients == null || this.ketamaClients.size() == 0) { return null; } long hash = HashAlgorithm.KETAMA_HASH.hash(key); RedisClient client = this.getClientByHash(hash); int tries = 0; while ((client == null || client.isAvailable()) && tries++ < MAX_TRIES) { hash = this.nextHash(hash, key, tries); client = this.getClientByHash(hash); } return client; }
@Override public boolean isAvailable() { return master.isAvailable(); }