当前位置: 首页>>代码示例>>Java>>正文


Java Hashing.MURMUR_HASH属性代码示例

本文整理汇总了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));
  }

}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:23,代码来源:ShardedJedisTest.java

示例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());
  }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:22,代码来源:ShardedJedisTest.java

示例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);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:32,代码来源:ShardedJedisTest.java

示例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());
		}
	}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:28,代码来源:RedisCacheClient.java

示例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);
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:15,代码来源:RedisShardedCacheClient.java

示例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);
    }
}
 
开发者ID:sunguangran,项目名称:navi,代码行数:9,代码来源:NaviShardJedisDriver.java

示例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);
    }
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:30,代码来源:RedisClientPool.java

示例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);
}
 
开发者ID:robertomarin,项目名称:redis-de-cache-a-nosql,代码行数:12,代码来源:Redis03Sharding.java

示例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);
   }
 
开发者ID:EdwardLee03,项目名称:jedis-sr,代码行数:34,代码来源:ShardedJedisTest.java

示例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));
}

   }
 
开发者ID:EdwardLee03,项目名称:jedis-sr,代码行数:28,代码来源:ShardedJedisTest.java

示例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());
}
   }
 
开发者ID:EdwardLee03,项目名称:jedis-sr,代码行数:30,代码来源:ShardedJedisTest.java

示例12: ShardedJedisPool

public ShardedJedisPool(final GenericObjectPoolConfig poolConfig, List<JedisShardInfo> shards) {
	this(poolConfig, shards, Hashing.MURMUR_HASH);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:3,代码来源:ShardedJedisPool.java

示例13: DefaultSharded

/**
 * 构造方法
 * @param shards 分片列表
 */
public DefaultSharded(List<S> shards) {
    /** MD5 is really not good as we works */
    this(shards, Hashing.MURMUR_HASH);
}
 
开发者ID:m18507308080,项目名称:onolisa,代码行数:8,代码来源:DefaultSharded.java

示例14: ShardedJedisPool

public ShardedJedisPool(final GenericObjectPoolConfig poolConfig, List<JedisShardInfo> shards) {
  this(poolConfig, shards, Hashing.MURMUR_HASH);
}
 
开发者ID:x7-framework,项目名称:x7,代码行数:3,代码来源:ShardedJedisPool.java

示例15: CustomShardedJedisPool

public CustomShardedJedisPool(GenericObjectPoolConfig poolConfig, List<JedisShardInfo> shards,
                              Pattern keyTagPattern, int timeBetweenServerStateCheckRunsMillis, int pingRetryTimes){
    this(poolConfig, shards, Hashing.MURMUR_HASH, keyTagPattern, timeBetweenServerStateCheckRunsMillis,
         pingRetryTimes);
}
 
开发者ID:EdwardLee03,项目名称:jedis-x,代码行数:5,代码来源:CustomShardedJedisPool.java


注:本文中的redis.clients.util.Hashing.MURMUR_HASH属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。