Java Code Examples for redis.clients.jedis.JedisPoolConfig#setFairness()

The following examples show how to use redis.clients.jedis.JedisPoolConfig#setFairness() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Client.java    From JRedisBloom with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Create a new client to ReBloom
 * @param host the redis host
 * @param port the redis port
 * @param timeout connection timeout
 * @param poolSize the poolSize of JedisPool
 */
public Client(String host, int port, int timeout, int poolSize) {
  JedisPoolConfig conf = new JedisPoolConfig();
  conf.setMaxTotal(poolSize);
  conf.setTestOnBorrow(false);
  conf.setTestOnReturn(false);
  conf.setTestOnCreate(false);
  conf.setTestWhileIdle(false);
  conf.setMinEvictableIdleTimeMillis(60000);
  conf.setTimeBetweenEvictionRunsMillis(30000);
  conf.setNumTestsPerEvictionRun(-1);
  conf.setFairness(true);

  pool = new JedisPool(conf, host, port, timeout);
}
 
Example 2
Source File: TestRedisDelayQueue.java    From delay-queue with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
	String ip = "192.168.2.160";
	Set<HostAndPort> nodes = new HashSet<>();
	nodes.add(new HostAndPort(ip, 7701));
	nodes.add(new HostAndPort(ip, 7702));
	nodes.add(new HostAndPort(ip, 7703));
	nodes.add(new HostAndPort(ip, 7704));
	nodes.add(new HostAndPort(ip, 7705));
	nodes.add(new HostAndPort(ip, 7706));
	JedisPoolConfig pool = new JedisPoolConfig();
	pool.setMaxTotal(100);
	pool.setFairness(false);
	pool.setNumTestsPerEvictionRun(100);
	pool.setMaxWaitMillis(5000);
	pool.setTestOnBorrow(true);
	jedisCluster = new JedisCluster(nodes, 1000, 1000, 100, null, pool); // maxAttempt必须调大
	jedisCluster.set("test", "test");
	queue = new RedisDelayQueue("com.meipian", "delayqueue", jedisCluster, 60 * 1000,
			new DelayQueueProcessListener() {
				@Override
				public void pushCallback(Message message) {

				}

				@Override
				public void peekCallback(Message message) {
					System.out.println("message----->" + message);
					queue.ack(message.getId());//确认操作。将会删除消息
				}

				@Override
				public void ackCallback(Message message) {
				}
			});

}