public static Integer getIntProperty(String name) { return getIntProperty(name, null); }
private static ThreadPoolExecutor createThreadPoolExecutor() { ThreadPoolExecutor executor = new ThreadPoolExecutor( PropertyHolder.getIntProperty("message.executor.coreSize", 1), // 设置核心线程数量 PropertyHolder.getIntProperty("message.executor.maxPoolSize", 10), // 线程池维护线程的最大数量 PropertyHolder.getIntProperty("message.executor.keepAliveSeconds", 600), TimeUnit.SECONDS, // 允许的空闲时间 new ArrayBlockingQueue<>(PropertyHolder.getIntProperty("message.executor.queueCapacity", 10))); // 缓存队列 return executor; } }
public static KafkaProducer<String, byte[]> getProducer() { synchronized (lock) { if (kafkaProducer == null) { Properties props = new Properties(); props.put("bootstrap.servers", PropertyHolder.getProperty("message.kafka.bootstrap.servers")); props.put("acks", PropertyHolder.getProperty("message.kafka.acks", "all")); props.put("retries", PropertyHolder.getIntProperty("message.kafka.retries", 0)); props.put("batch.size", PropertyHolder.getIntProperty("message.kafka.batch.size", 16384)); props.put("linger.ms", PropertyHolder.getIntProperty("message.kafka.linger.ms", 1)); props.put("buffer.memory", PropertyHolder.getLongProperty("message.kafka.buffer.memory", 33554432L)); props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); props.put("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer"); kafkaProducer = new KafkaProducer<String, byte[]>(props); } } return kafkaProducer; }
private static JedisPoolConfig getConfig() { JedisPoolConfig config = new JedisPoolConfig(); // 最大连接数, 默认30个 config.setMaxTotal(PropertyHolder.getIntProperty("message.redis.max.total", MAX_TOTLE)); // 控制一个pool最多有多少个状态为idle(空闲的)的jedis实例。 config.setMaxIdle(PropertyHolder.getIntProperty("message.redis.max.idle", MAX_IDLE)); // 表示当borrow(引入)一个jedis实例时,最大的等待时间,如果超过等待时间,则直接抛出JedisConnectionException; config.setMaxWaitMillis(1000 * PropertyHolder.getIntProperty("message.redis.max.wait", MAX_WAIT)); // 在borrow一个jedis实例时,是否提前进行validate操作;如果为true,则得到的jedis实例均是可用的; config.setTestOnBorrow(PropertyHolder.getBooleanProperty("message.redis.testonborrow", VALIDATE)); return config; }
protected JedisPoolConfig getConfig() { JedisPoolConfig config = new JedisPoolConfig(); // 控制一个pool最多有多少个状态为idle(空闲的)的jedis实例。 config.setMaxIdle(PropertyHolder.getIntProperty("cache.redis.max.idle", MAX_IDLE)); // 表示当borrow(引入)一个jedis实例时,最大的等待时间,如果超过等待时间,则直接抛出JedisConnectionException; config.setMaxWaitMillis(1000 * PropertyHolder.getIntProperty("cache.redis.max.wait", MAX_WAIT)); // 在borrow一个jedis实例时,是否提前进行validate操作;如果为true,则得到的jedis实例均是可用的; config.setTestOnBorrow(PropertyHolder.getBooleanProperty("cache.redis.testonborrow", validate)); return config; }
public ClusterRedisCache() { String cacheModel = PropertyHolder.getProperty("cache.model"); if (CACHE_MODEL.equals(cacheModel)) { Address[] addresses = getAddresses(); Set<HostAndPort> readSet = new HashSet<HostAndPort>(); for (Address addr : addresses) { HostAndPort hostAndPort = new HostAndPort(addr.getHost(), addr.getPort()); readSet.add(hostAndPort); } cluster = new BinaryJedisCluster(readSet, PropertyHolder.getIntProperty("cache.redis.cluster.max.timeout", 100000)); } }
private void init(String prefix) { this.code = prefix; this.dbType = PropertyHolder.getProperty(prefix + ".db.type", "mysql"); this.initialSize = PropertyHolder.getIntProperty(prefix + ".db.initialSize", 5); this.maxActive = PropertyHolder.getIntProperty(prefix + ".db.maxActive", 100); this.minIdle = PropertyHolder.getIntProperty(prefix + ".db.minIdle", 10); this.maxWait = PropertyHolder.getLongProperty(prefix + ".db.maxWait", 6000000L); this.validationQuery = PropertyHolder.getProperty(prefix + ".db.validationQuery", "SELECT 1"); this.testOnBorrow = PropertyHolder.getBooleanProperty(prefix + ".db.testOnBorrow", true); this.testOnReturn = PropertyHolder.getBooleanProperty(prefix + ".db.testOnReturn", false); this.testWhileIdle = PropertyHolder.getBooleanProperty(prefix + ".db.testWhileIdle", true); this.timeBetweenEvictionRunsMillis = PropertyHolder .getLongProperty(prefix + ".db.timeBetweenEvictionRunsMillis", 600000L); this.minEvictableIdleTimeMillis = PropertyHolder.getLongProperty(prefix + ".db.timeBetweenEvictionRunsMillis", 25200000L); this.removeAbandoned = PropertyHolder.getBooleanProperty(prefix + ".db.removeAbandoned", true); this.removeAbandonedTimeout = PropertyHolder.getIntProperty(prefix + ".db.removeAbandonedTimeout", 1800); this.logAbandoned = PropertyHolder.getBooleanProperty(prefix + ".db.logAbandoned", true); this.driverClass = PropertyHolder.getProperty(prefix + ".db.driverClass"); this.filters = PropertyHolder.getProperty(prefix + ".db.filters", "stat"); }
public static BinaryJedisCluster getBinaryJedisCluster() { synchronized (lock) { if (cluster == null) { String cacheModel = PropertyHolder.getProperty("cache.model"); if (CLUSTER_MESSAGE_MODEL.equals(cacheModel)) { Address[] addresses = getAddresses(); Set<HostAndPort> readSet = new HashSet<HostAndPort>(); for (Address addr : addresses) { HostAndPort hostAndPort = new HostAndPort(addr.getHost(), addr.getPort()); readSet.add(hostAndPort); } // cluster = new BinaryJedisCluster(readSet, // PropertyHolder.getIntProperty("message.redis.cluster.max.timeout", 100000)); cluster = new BinaryJedisCluster(readSet, PropertyHolder.getIntProperty("message.redis.cluster.max.timeout", 100000), 5, getConfig()); } } return cluster; } }
public static void before(String methodName, Object[] args) { // 开始执行时间 long beginTime = System.currentTimeMillis(); TransManager manager = TransManager.getInstance(); int maxDeepLen = PropertyHolder.getIntProperty("logservice.max.deep.size", 100); // 深度检测 if (manager.getStackSize() > maxDeepLen) { throw new FrameworkException(ErrorCodeDef.STACK_OVERFLOW_ERROR_10030); } // 父id String parentStackId = manager.peek(); // id String stackId = CommonUtil.getTransactionID(); manager.push(stackId, beginTime); // 执行记录 for (TransLoggerService service : getTransLoggerServices()) { service.before(stackId, parentStackId, beginTime, methodName, args); } }
PropertyHolder.getIntProperty("message.rocketmq.consumer.consumerBatchMaxSize", 0) == 0 ? 1 : PropertyHolder.getIntProperty("message.rocketmq.consumer.consumerBatchMaxSize", 0));// 设置批量消费,以提升消费吞吐量,默认是1
PropertyHolder.getIntProperty("message.rocketmq.producer.retrytimes", 10));