本文整理汇总了Java中redis.clients.util.Hashing.MURMUR_HASH属性的典型用法代码示例。如果您正苦于以下问题:Java Hashing.MURMUR_HASH属性的具体用法?Java Hashing.MURMUR_HASH怎么用?Java Hashing.MURMUR_HASH使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类redis.clients.util.Hashing
的用法示例。
在下文中一共展示了Hashing.MURMUR_HASH属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMasterSlaveShardingConsistency
@Test
public void testMasterSlaveShardingConsistency() {
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(3);
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT));
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 1));
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 2));
Sharded<Jedis, JedisShardInfo> sharded = new Sharded<Jedis, JedisShardInfo>(shards,
Hashing.MURMUR_HASH);
List<JedisShardInfo> otherShards = new ArrayList<JedisShardInfo>(3);
otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT));
otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT + 1));
otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT + 2));
Sharded<Jedis, JedisShardInfo> sharded2 = new Sharded<Jedis, JedisShardInfo>(otherShards,
Hashing.MURMUR_HASH);
for (int i = 0; i < 1000; i++) {
JedisShardInfo jedisShardInfo = sharded.getShardInfo(Integer.toString(i));
JedisShardInfo jedisShardInfo2 = sharded2.getShardInfo(Integer.toString(i));
assertEquals(shards.indexOf(jedisShardInfo), otherShards.indexOf(jedisShardInfo2));
}
}
示例2: testMasterSlaveShardingConsistencyWithShardNaming
@Test
public void testMasterSlaveShardingConsistencyWithShardNaming() {
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(3);
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT, "HOST1:1234"));
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 1, "HOST2:1234"));
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 2, "HOST3:1234"));
Sharded<Jedis, JedisShardInfo> sharded = new Sharded<Jedis, JedisShardInfo>(shards,
Hashing.MURMUR_HASH);
List<JedisShardInfo> otherShards = new ArrayList<JedisShardInfo>(3);
otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT, "HOST2:1234"));
otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT + 1, "HOST3:1234"));
otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT + 2, "HOST1:1234"));
Sharded<Jedis, JedisShardInfo> sharded2 = new Sharded<Jedis, JedisShardInfo>(otherShards,
Hashing.MURMUR_HASH);
for (int i = 0; i < 1000; i++) {
JedisShardInfo jedisShardInfo = sharded.getShardInfo(Integer.toString(i));
JedisShardInfo jedisShardInfo2 = sharded2.getShardInfo(Integer.toString(i));
assertEquals(jedisShardInfo.getName(), jedisShardInfo2.getName());
}
}
示例3: testMurmurSharding
@Test
public void testMurmurSharding() {
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(3);
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT));
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 1));
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 2));
Sharded<Jedis, JedisShardInfo> sharded = new Sharded<Jedis, JedisShardInfo>(shards,
Hashing.MURMUR_HASH);
int shard_6379 = 0;
int shard_6380 = 0;
int shard_6381 = 0;
for (int i = 0; i < 1000; i++) {
JedisShardInfo jedisShardInfo = sharded.getShardInfo(Integer.toString(i));
switch (jedisShardInfo.getPort()) {
case 6379:
shard_6379++;
break;
case 6380:
shard_6380++;
break;
case 6381:
shard_6381++;
break;
default:
fail("Attempting to use a non-defined shard!!:" + jedisShardInfo);
break;
}
}
assertTrue(shard_6379 > 300 && shard_6379 < 400);
assertTrue(shard_6380 > 300 && shard_6380 < 400);
assertTrue(shard_6381 > 300 && shard_6381 < 400);
}
示例4: init
public void init() {
try {
String[] hosts = servers.trim().split("\\|");
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
for (String host : hosts) {
String[] ss = host.split(":");
//升级 redis 构造变化
JedisShardInfo shard = new JedisShardInfo(ss[0], Integer.parseInt(ss[1]), DEFAULT_TIMEOUT, DEFAULT_TIMEOUT, 1);
shards.add(shard);
}
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxIdle(MAX_ACTIVE);
config.setMinIdle(MAX_IDLE);
config.setMaxWaitMillis(MAX_WAIT);
config.setMaxTotal(MAX_TOTAL);
pool = new ShardedJedisPool(config, shards, Hashing.MURMUR_HASH);
} catch (NumberFormatException e) {
System.out.println("redis客户端初始化连接异常!!!!!!!!! 链接参数:" + servers
+ " " + DEFAULT_TIMEOUT + " " + app);
logger.error("redis:{},exception:{}.", servers + " "
+ DEFAULT_TIMEOUT + " " + app, e.getMessage());
}
}
示例5: initPool
@Override
public Pool<ShardedJedis> initPool() throws Exception {
if (Check.isNullOrEmpty(getServers())) {
throw new IllegalArgumentException("未指定redis服务器地址");
}
String[] hosts = getServers().trim().split("\\|");
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
for (String host : hosts) {
String[] ss = host.split(":");
//升级 redis 构造变化
JedisShardInfo shard = new JedisShardInfo(ss[0], Integer.parseInt(ss[1]), connectTimeout, socketTimeout, 1);
shards.add(shard);
}
return new ShardedJedisPool(getPoolConfig(), shards, Hashing.MURMUR_HASH);
}
示例6: connect
private void connect() {
if (StringUtils.isEmpty(server.getHost())) {
shardJedis = new ShardedJedis(constructShardInfo(server.getUrl(),
poolConfig), Hashing.MURMUR_HASH, null);
} else {
shardJedis = new ShardedJedis(constructShardInfo(server.getHost(),
server.getPort(), poolConfig), Hashing.MURMUR_HASH, null);
}
}
示例7: createJedisPool
private ShardedJedisPool createJedisPool(final RedisConfig conf) {
Assert.notNull(conf);
try {
final String[] hostAndports = conf.getHostNames().split(";");
final List<String> redisHosts = Lists.newArrayList();
final List<Integer> redisPorts = Lists.newArrayList();
for (int i = 0; i < hostAndports.length; i++) {
final String[] hostPort = hostAndports[i].split(":");
redisHosts.add(hostPort[0]);
redisPorts.add(Integer.valueOf(hostPort[1]));
}
final List<JedisShardInfo> shards = Lists.newArrayList();
for (int i = 0; i < redisHosts.size(); i++) {
final String host = (String) redisHosts.get(i);
final Integer port = (Integer) redisPorts.get(i);
Integer timeout = conf.getTimeOut();
if (timeout == null || timeout < 0) {
timeout = DEFAULT_TIMEOUT;
}
JedisShardInfo si = new JedisShardInfo(host, port.intValue(), timeout);
shards.add(si);
}
return new ShardedJedisPool(getJedisPoolConfig(conf), shards, Hashing.MURMUR_HASH, Sharded.DEFAULT_KEY_TAG_PATTERN);
} catch (final Throwable e) {
throw new RedisClientException(e.getMessage(), e);
}
}
示例8: before
@Before
public void before() {
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
shards.add(new JedisShardInfo("127.0.0.1", 1200));
shards.add(new JedisShardInfo("127.0.0.1", 1201));
shards.add(new JedisShardInfo("127.0.0.1", 1202));
shards.add(new JedisShardInfo("127.0.0.1", 1203));
pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards, Hashing.MURMUR_HASH);
}
示例9: testMurmurSharding
@Test
public void testMurmurSharding() {
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(3);
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT));
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 1));
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 2));
Sharded<Jedis, JedisShardInfo> sharded = new Sharded<Jedis, JedisShardInfo>(
shards, Hashing.MURMUR_HASH);
int shard_6379 = 0;
int shard_6380 = 0;
int shard_6381 = 0;
for (int i = 0; i < 1000; i++) {
JedisShardInfo jedisShardInfo = sharded.getShardInfo(Integer
.toString(i));
switch (jedisShardInfo.getPort()) {
case 6379:
shard_6379++;
break;
case 6380:
shard_6380++;
break;
case 6381:
shard_6381++;
break;
default:
fail("Attempting to use a non-defined shard!!:"
+ jedisShardInfo);
break;
}
}
assertTrue(shard_6379 > 300 && shard_6379 < 400);
assertTrue(shard_6380 > 300 && shard_6380 < 400);
assertTrue(shard_6381 > 300 && shard_6381 < 400);
}
示例10: testMasterSlaveShardingConsistency
@Test
public void testMasterSlaveShardingConsistency() {
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(3);
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT));
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 1));
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 2));
Sharded<Jedis, JedisShardInfo> sharded = new Sharded<Jedis, JedisShardInfo>(
shards, Hashing.MURMUR_HASH);
List<JedisShardInfo> otherShards = new ArrayList<JedisShardInfo>(3);
otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT));
otherShards.add(new JedisShardInfo("otherhost",
Protocol.DEFAULT_PORT + 1));
otherShards.add(new JedisShardInfo("otherhost",
Protocol.DEFAULT_PORT + 2));
Sharded<Jedis, JedisShardInfo> sharded2 = new Sharded<Jedis, JedisShardInfo>(
otherShards, Hashing.MURMUR_HASH);
for (int i = 0; i < 1000; i++) {
JedisShardInfo jedisShardInfo = sharded.getShardInfo(Integer
.toString(i));
JedisShardInfo jedisShardInfo2 = sharded2.getShardInfo(Integer
.toString(i));
assertEquals(shards.indexOf(jedisShardInfo),
otherShards.indexOf(jedisShardInfo2));
}
}
示例11: testMasterSlaveShardingConsistencyWithShardNaming
@Test
public void testMasterSlaveShardingConsistencyWithShardNaming() {
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(3);
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT,
"HOST1:1234"));
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 1,
"HOST2:1234"));
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 2,
"HOST3:1234"));
Sharded<Jedis, JedisShardInfo> sharded = new Sharded<Jedis, JedisShardInfo>(
shards, Hashing.MURMUR_HASH);
List<JedisShardInfo> otherShards = new ArrayList<JedisShardInfo>(3);
otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT,
"HOST2:1234"));
otherShards.add(new JedisShardInfo("otherhost",
Protocol.DEFAULT_PORT + 1, "HOST3:1234"));
otherShards.add(new JedisShardInfo("otherhost",
Protocol.DEFAULT_PORT + 2, "HOST1:1234"));
Sharded<Jedis, JedisShardInfo> sharded2 = new Sharded<Jedis, JedisShardInfo>(
otherShards, Hashing.MURMUR_HASH);
for (int i = 0; i < 1000; i++) {
JedisShardInfo jedisShardInfo = sharded.getShardInfo(Integer
.toString(i));
JedisShardInfo jedisShardInfo2 = sharded2.getShardInfo(Integer
.toString(i));
assertEquals(jedisShardInfo.getName(), jedisShardInfo2.getName());
}
}
示例12: ShardedJedisPool
public ShardedJedisPool(final GenericObjectPoolConfig poolConfig, List<JedisShardInfo> shards) {
this(poolConfig, shards, Hashing.MURMUR_HASH);
}
示例13: DefaultSharded
/**
* 构造方法
* @param shards 分片列表
*/
public DefaultSharded(List<S> shards) {
/** MD5 is really not good as we works */
this(shards, Hashing.MURMUR_HASH);
}
示例14: ShardedJedisPool
public ShardedJedisPool(final GenericObjectPoolConfig poolConfig, List<JedisShardInfo> shards) {
this(poolConfig, shards, Hashing.MURMUR_HASH);
}
示例15: CustomShardedJedisPool
public CustomShardedJedisPool(GenericObjectPoolConfig poolConfig, List<JedisShardInfo> shards,
Pattern keyTagPattern, int timeBetweenServerStateCheckRunsMillis, int pingRetryTimes){
this(poolConfig, shards, Hashing.MURMUR_HASH, keyTagPattern, timeBetweenServerStateCheckRunsMillis,
pingRetryTimes);
}