simplification of sharding

This commit is contained in:
Alex Tkachman
2010-09-16 15:41:04 +02:00
parent ea784de98a
commit 53efb8471f
9 changed files with 163 additions and 190 deletions

View File

@@ -0,0 +1,80 @@
/*
* Copyright 2009-2010 MBTE Sweden AB.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package redis.clients.jedis;
import redis.clients.util.ShardInfo;
import redis.clients.util.Sharded;
public class JedisShardInfo extends ShardInfo<Jedis> {
@Override
public String toString() {
return "JedisShardInfo [host=" + host + ", port=" + port + ", weight="
+ getWeight() + "]";
}
private int timeout;
private String host;
private int port;
private String password = null;
public String getHost() {
return host;
}
public int getPort() {
return port;
}
public JedisShardInfo(String host) {
this(host, Protocol.DEFAULT_PORT);
}
public JedisShardInfo(String host, int port) {
this(host, port, 2000);
}
public JedisShardInfo(String host, int port, int timeout) {
this(host, port, timeout, Sharded.DEFAULT_WEIGHT);
}
public JedisShardInfo(String host, int port, int timeout, int weight) {
super(weight);
this.host = host;
this.port = port;
this.timeout = timeout;
}
public String getPassword() {
return password;
}
public void setPassword(String auth) {
this.password = auth;
}
public int getTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
@Override
public Jedis createResource() {
return new Jedis(this);
}
}