157 lines
4.2 KiB
Java
157 lines
4.2 KiB
Java
package com.muyu.source.pool;//package com.muyu.etl.property.pool;
|
||
//
|
||
//import com.muyu.etl.property.domain.EtlDataScore;
|
||
//import com.muyu.etl.property.pool.exeption.RedisConnException;
|
||
//import lombok.extern.log4j.Log4j2;
|
||
//
|
||
//import java.util.Queue;
|
||
//import java.util.concurrent.LinkedBlockingQueue;
|
||
//import java.util.concurrent.atomic.AtomicInteger;
|
||
//
|
||
///**
|
||
// * @Author:作者姓名
|
||
// * @Package:com.muyu.etl.property.pool
|
||
// * @Project:cloud-etl-property
|
||
// * @name:RedisPool
|
||
// * @Date:2024/8/26 9:12
|
||
// */
|
||
//@Log4j2
|
||
//public class RedisPool implements BasePool<Jedis>{
|
||
//
|
||
// /**
|
||
// * 空闲队列
|
||
// */
|
||
// private Queue<Jedis> jedisBaseConnQueue = null;
|
||
//
|
||
// /**
|
||
// * 活动队列
|
||
// */
|
||
// private Queue<Jedis> jedisActiveConnQueue = null;
|
||
//
|
||
// /**
|
||
// * 总连接数
|
||
// */
|
||
// private AtomicInteger count=null;
|
||
//
|
||
// /**
|
||
// * redisPoolConfig
|
||
// */
|
||
//
|
||
// private EtlDataScore etlDataScore=null;
|
||
//
|
||
// /**
|
||
// * 实例化
|
||
// * @param etlDataScore
|
||
// */
|
||
// public RedisPool(EtlDataScore etlDataScore) {
|
||
// log.info("redis连接池实例化完成");
|
||
// this.etlDataScore = etlDataScore;
|
||
// }
|
||
//
|
||
// @Override
|
||
// public void init() {
|
||
//
|
||
// Integer maxCount = this.etlDataScore.getMaxCount();
|
||
//
|
||
// this.jedisBaseConnQueue = new LinkedBlockingQueue<Jedis>(maxCount);
|
||
// this.jedisActiveConnQueue = new LinkedBlockingQueue<Jedis>(maxCount);
|
||
//
|
||
// this.count = new AtomicInteger();
|
||
//
|
||
// Integer initCount = this.etlDataScore.getInitCount();
|
||
//
|
||
//
|
||
// for (Integer i = 0; i < initCount; i++) {
|
||
// this.jedisBaseConnQueue.offer(createConn());
|
||
// count.incrementAndGet();
|
||
// }
|
||
// log.info("redis连接池初始化完成!");
|
||
// }
|
||
//
|
||
// @Override
|
||
// public Jedis getConn() {
|
||
// long startTime = System.currentTimeMillis();
|
||
//
|
||
//
|
||
// while (true){
|
||
// Jedis jedis = this.jedisBaseConnQueue.poll();
|
||
// if (jedis!=null){
|
||
// this.jedisActiveConnQueue.offer(jedis);
|
||
// return jedis;
|
||
// }
|
||
//
|
||
// if (count.get()<this.etlDataScore.getMaxCount()){
|
||
// jedis = createConn();
|
||
// this.jedisActiveConnQueue.offer(jedis);
|
||
// count.incrementAndGet();
|
||
// return jedis;
|
||
// }
|
||
//
|
||
// if (System.currentTimeMillis() -startTime > this.dataSources.getMaxTime()){
|
||
// throw new RedisConnException("redis获取连接超时!");
|
||
// }
|
||
//
|
||
// }
|
||
//
|
||
// }
|
||
//
|
||
// @Override
|
||
// public void replease(Jedis conn) {
|
||
// if (this.jedisActiveConnQueue.remove(conn)){
|
||
// this.jedisBaseConnQueue.offer(conn);
|
||
// }else {
|
||
// count.decrementAndGet();
|
||
// }
|
||
//
|
||
// }
|
||
//
|
||
// @Override
|
||
// public Jedis createConn() {
|
||
// String ip = this.etlDataScore.getHost();
|
||
// String port = this.etlDataScore.getPort();
|
||
// Jedis jedis = new Jedis(ip, Integer.parseInt(port));
|
||
// log.info("初始化了一个redis的连接,{ip:"+ip+" port:"+port+"}");
|
||
// return jedis;
|
||
// }
|
||
//
|
||
// @Override
|
||
// public void closeConn() {
|
||
// closeJedisBaseConn();
|
||
// closeJedisActiveConn();
|
||
// }
|
||
//
|
||
// public void closeJedisBaseConn(){
|
||
// Jedis jedis = this.jedisBaseConnQueue.poll();
|
||
//
|
||
// if (jedis!=null){
|
||
// try {
|
||
// jedis.close();
|
||
// } catch (Exception e) {
|
||
// if (!jedis.isConnected()){
|
||
// this.jedisBaseConnQueue.offer(jedis);
|
||
// }
|
||
// throw new RuntimeException(e);
|
||
// }finally {
|
||
// closeJedisBaseConn();
|
||
// }
|
||
// }
|
||
// }
|
||
// public void closeJedisActiveConn(){
|
||
// Jedis jedis = this.jedisActiveConnQueue.poll();
|
||
//
|
||
// if (jedis!=null){
|
||
// try {
|
||
// jedis.close();
|
||
// } catch (Exception e) {
|
||
// if (!jedis.isConnected()){
|
||
// this.jedisActiveConnQueue.offer(jedis);
|
||
// }
|
||
// throw new RuntimeException(e);
|
||
// }finally {
|
||
// closeJedisActiveConn();
|
||
// }
|
||
// }
|
||
// }
|
||
//
|
||
//}
|