redis.clients.util.Pool Java Examples
The following examples show how to use
redis.clients.util.Pool.
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: RedisGelfSenderProvider.java From xian with Apache License 2.0 | 6 votes |
@Override public GelfSender create(GelfSenderConfiguration configuration) throws IOException { String graylogHost = configuration.getHost(); URI hostUri = URI.create(graylogHost); int port = hostUri.getPort(); if (port <= 0) { port = configuration.getPort(); } if (port <= 0) { port = Protocol.DEFAULT_PORT; } if (hostUri.getFragment() == null || hostUri.getFragment().trim().equals("")) { throw new IllegalArgumentException("Redis URI must specify fragment"); } if (hostUri.getHost() == null) { throw new IllegalArgumentException("Redis URI must specify host"); } Pool<Jedis> pool = RedisSenderPoolProvider.getJedisPool(hostUri, port); return new GelfREDISSender(pool, hostUri.getFragment(), configuration.getErrorReporter()); }
Example #2
Source File: JetCacheConfig.java From jetcache with Apache License 2.0 | 6 votes |
@Bean public GlobalCacheConfig config(SpringConfigProvider configProvider, Pool<Jedis> pool){ Map localBuilders = new HashMap(); EmbeddedCacheBuilder localBuilder = LinkedHashMapCacheBuilder .createLinkedHashMapCacheBuilder() .keyConvertor(FastjsonKeyConvertor.INSTANCE); localBuilders.put(CacheConsts.DEFAULT_AREA, localBuilder); Map remoteBuilders = new HashMap(); RedisCacheBuilder remoteCacheBuilder = RedisCacheBuilder.createRedisCacheBuilder() .keyConvertor(FastjsonKeyConvertor.INSTANCE) .valueEncoder(JavaValueEncoder.INSTANCE) .valueDecoder(JavaValueDecoder.INSTANCE) .jedisPool(pool); remoteBuilders.put(CacheConsts.DEFAULT_AREA, remoteCacheBuilder); GlobalCacheConfig globalCacheConfig = new GlobalCacheConfig(); globalCacheConfig.setConfigProvider(configProvider); globalCacheConfig.setLocalCacheBuilders(localBuilders); globalCacheConfig.setRemoteCacheBuilders(remoteBuilders); globalCacheConfig.setStatIntervalMinutes(1); globalCacheConfig.setAreaInCacheName(false); return globalCacheConfig; }
Example #3
Source File: AbstractJedisFacade.java From HttpSessionReplacer with MIT License | 6 votes |
/** * Helper method that registers metrics for a jedis pool. * * @param jedisPool * the pool which is monitored * @param metrics * the registry to use for metrics */ static void addMetrics(final Pool<Jedis> jedisPool, MetricRegistry metrics) { final String host = jedisPool.getResource().getClient().getHost(); String prefix = name(RedisConfiguration.METRIC_PREFIX, "redis", host); metrics.register(name(prefix, "active"), new Gauge<Integer>() { @Override public Integer getValue() { return jedisPool.getNumActive(); } }); metrics.register(name(prefix, "idle"), new Gauge<Integer>() { @Override public Integer getValue() { return jedisPool.getNumIdle(); } }); metrics.register(name(prefix, "waiting"), new Gauge<Integer>() { @Override public Integer getValue() { return jedisPool.getNumWaiters(); } }); }
Example #4
Source File: JedisHealthTracker.java From pepper-metrics with Apache License 2.0 | 5 votes |
private static void addPool(String namespace, Pool jedisPool) { Assert.assertNotNull(namespace); Assert.assertFalse("Duplicate namespace error.", UNIQUE_NAME.contains(namespace)); UNIQUE_NAME.add(namespace); final JedisHealthStats stats = new JedisHealthStats(MetricsRegistry.getREGISTRY(), namespace, jedisPool); HealthTracker.addStats(stats); }
Example #5
Source File: RedisPoolMeterBinder.java From summerframework with Apache License 2.0 | 5 votes |
public RedisPoolMeterBinder(Iterable<Tag> tags, JedisConnectionFactory jedisConnectionFactory) { this.tags = tags; Field poolField = ReflectionUtils.findField(JedisConnectionFactory.class, "pool"); ReflectionUtils.makeAccessible(poolField); try { this.pool = (Pool<Jedis>)poolField.get(jedisConnectionFactory); } catch (Throwable e) { log.error(e.getMessage(), e); } }
Example #6
Source File: RedisPoolMeterBinder.java From summerframework with Apache License 2.0 | 5 votes |
@Override public void bindTo(MeterRegistry registry) { if (pool == null) { return; } Field internalPoolField = ReflectionUtils.findField(Pool.class, "internalPool"); ReflectionUtils.makeAccessible(internalPoolField); try { GenericObjectPool<Jedis> internalPool = (GenericObjectPool<Jedis>)internalPoolField.get(this.pool); Gauge.builder("redis.pool.active", internalPool, GenericObjectPool::getNumActive).tags(tags) .description("Active redis connection").register(registry); Gauge.builder("redis.pool.total", internalPool, GenericObjectPool::getMaxTotal).tags(tags) .description("MaxTotal redis connection").register(registry); Gauge.builder("redis.pool.idle", internalPool, GenericObjectPool::getNumIdle).tags(tags) .description("Idle redis connection").register(registry); Gauge.builder("redis.pool.waiters", internalPool, GenericObjectPool::getNumWaiters).tags(tags) .description( "The estimate of the number of threads currently blocked waiting for an object from the pool") .register(registry); Gauge.builder("redis.pool.borrowed", internalPool, GenericObjectPool::getBorrowedCount).tags(tags) .description("The total number of objects successfully borrowed from this pool").register(registry); Gauge.builder("redis.pool.created", internalPool, GenericObjectPool::getCreatedCount).tags(tags) .description("The total number of objects created for this pool ").register(registry); Gauge.builder("redis.pool.destroyed", internalPool, GenericObjectPool::getDestroyedCount).tags(tags) .description("The total number of objects destroyed by this pool").register(registry); } catch (IllegalAccessException e) { log.error(e.getMessage(), e); } }
Example #7
Source File: RedisConnectionFactory.java From mpush with Apache License 2.0 | 5 votes |
/** * Creates {@link JedisSentinelPool}. * * @return * @since 1.4 */ protected Pool<Jedis> createRedisSentinelPool() { Set<String> hostAndPorts = redisServers .stream() .map(redisNode -> new HostAndPort(redisNode.host, redisNode.port).toString()) .collect(Collectors.toSet()); return new JedisSentinelPool(sentinelMaster, hostAndPorts, poolConfig, getShardInfo().getSoTimeout(), getShardInfo().getPassword()); }
Example #8
Source File: TestJedisPoolFacade.java From HttpSessionReplacer with MIT License | 5 votes |
@SuppressWarnings("unchecked") @Before public void setup() { jedis = mock(Jedis.class); pool = mock(Pool.class); when(pool.getResource()).thenReturn(jedis); rf = new JedisPoolFacade(pool); }
Example #9
Source File: RedisShardedCacheClient.java From AsuraFramework with Apache License 2.0 | 5 votes |
@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); }
Example #10
Source File: JetCacheConfig.java From jetcache with Apache License 2.0 | 5 votes |
@Bean public Pool<Jedis> pool(){ GenericObjectPoolConfig pc = new GenericObjectPoolConfig(); pc.setMinIdle(2); pc.setMaxIdle(10); pc.setMaxTotal(10); return new JedisPool(pc, "localhost", 6379); }
Example #11
Source File: JedisHealthStats.java From pepper-metrics with Apache License 2.0 | 4 votes |
public JedisHealthStats(MeterRegistry registry, String namespace, Pool pool) { super(registry, namespace); this.pool = pool; }
Example #12
Source File: BaseRedisClient.java From search-commons with Apache License 2.0 | 4 votes |
protected BaseRedisClient(Pool<J> jedisPool) { super(jedisPool); }
Example #13
Source File: JedisTask.java From search-commons with Apache License 2.0 | 4 votes |
public JedisTask(Pool<J> jedisPool) { this.jedisPool = jedisPool; }
Example #14
Source File: DefaultRedisClient.java From search-commons with Apache License 2.0 | 4 votes |
public DefaultRedisClient(Pool<J> jedisPool, BytesConvert beanBytesConvert) { super(jedisPool); this.beanBytesConvert = beanBytesConvert; }
Example #15
Source File: DefaultRedisClient.java From search-commons with Apache License 2.0 | 4 votes |
public DefaultRedisClient(Pool<J> jedisPool) { this(jedisPool, BytesConverts.serializedBeanConvert()); }
Example #16
Source File: RedisConnectionFactory.java From mpush with Apache License 2.0 | 4 votes |
private Pool<Jedis> createPool() { if (StringUtils.isNotBlank(sentinelMaster)) { return createRedisSentinelPool(); } return createRedisPool(); }
Example #17
Source File: TracingJedisWrapper.java From java-redis-client with Apache License 2.0 | 4 votes |
@Override public void setDataSource(Pool<Jedis> jedisPool) { Span span = helper.buildSpan("setDataSource"); helper.decorate(span, () -> wrapped.setDataSource(jedisPool)); }
Example #18
Source File: RedisAction.java From DDMQ with Apache License 2.0 | 4 votes |
synchronized void shutdown() { jedisPools.forEach(Pool::close); jedisPools.clear(); }
Example #19
Source File: JedisHealthStats.java From pepper-metrics with Apache License 2.0 | 4 votes |
public Pool getPool() { return pool; }
Example #20
Source File: JedisClusterHealthStats.java From pepper-metrics with Apache License 2.0 | 4 votes |
public JedisClusterNodeHealthStats(MeterRegistry registry, String namespace, String node, Pool pool) { super(registry, namespace); this.pool = pool; this.node = node; }
Example #21
Source File: WxOpenInRedisConfigStorage.java From weixin-java-tools with Apache License 2.0 | 4 votes |
public WxOpenInRedisConfigStorage(Pool<Jedis> jedisPool) { this.jedisPool = jedisPool; }
Example #22
Source File: WxOpenInRedisConfigStorage.java From weixin-java-tools with Apache License 2.0 | 4 votes |
public WxOpenInRedisConfigStorage(Pool<Jedis> jedisPool, String keyPrefix) { this.jedisPool = jedisPool; this.keyPrefix = keyPrefix; }
Example #23
Source File: GelfREDISSender.java From xian with Apache License 2.0 | 4 votes |
public GelfREDISSender(Pool<Jedis> jedisPool, String redisKey, ErrorReporter errorReporter) throws IOException { this.jedisPool = jedisPool; this.errorReporter = errorReporter; this.redisKey = redisKey; }
Example #24
Source File: RedisAction.java From DDMQ with Apache License 2.0 | 4 votes |
synchronized void shutdown() { jedisPools.forEach(Pool::close); jedisPools.clear(); }
Example #25
Source File: RedisConnectionFactory.java From mpush with Apache License 2.0 | 2 votes |
/** * Creates {@link JedisPool}. * * @return * @since 1.4 */ protected Pool<Jedis> createRedisPool() { return new JedisPool(getPoolConfig(), shardInfo.getHost(), shardInfo.getPort(), shardInfo.getSoTimeout(), shardInfo.getPassword()); }
Example #26
Source File: JedisPoolFacade.java From HttpSessionReplacer with MIT License | 2 votes |
/** * Creates RedisFacade from {@link Pool} of {@link Jedis} connections. * * @param jedisPool * pool of jedis connections */ JedisPoolFacade(Pool<Jedis> jedisPool) { this.jedisPool = jedisPool; }
Example #27
Source File: RedisList.java From Voovan with Apache License 2.0 | 2 votes |
/** * 构造函数 * @param jedisPool redis 连接池 * @param name 在 redis 中的 HashMap的名称 */ public RedisList(Pool<Jedis> jedisPool, String name){ this.redisPool = jedisPool; this.name = name; }
Example #28
Source File: RedisList.java From Voovan with Apache License 2.0 | 2 votes |
/** * 构造函数 * @param jedisPool redis 连接池 */ public RedisList(Pool<Jedis> jedisPool){ this.redisPool = jedisPool; }
Example #29
Source File: RedisLock.java From Voovan with Apache License 2.0 | 2 votes |
/** * 构造函数 * @param jedisPool redis 连接池 * @param name 在 redis 中的 HashMap的名称 */ public RedisLock(Pool<Jedis> jedisPool, String name){ this.redisPool = jedisPool; this.lockName = lockName; }
Example #30
Source File: RedisLock.java From Voovan with Apache License 2.0 | 2 votes |
/** * 构造函数 * @param jedisPool redis 连接池 */ public RedisLock(Pool<Jedis> jedisPool){ this.redisPool = jedisPool; }