Skip to content

Commit

Permalink
v. 0.5 Reduce number of connections by default from 1 + 10 to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruslan Gainutdinov committed Aug 30, 2017
1 parent 11d1039 commit b8027e3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Maven repository is created using [jitpack.io](https://jitpack.io/) [![](https:/
<dependency>
<groupId>com.wizecore</groupId>
<artifactId>persistent-metrics</artifactId>
<version>0.4</version>
<version>0.5</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.wizecore</groupId>
<artifactId>persistent-metrics</artifactId>
<packaging>jar</packaging>
<version>0.4</version>
<version>0.5</version>
<name>persistent-metrics</name>
<url>http://github.com/wizecore/persistent-metrics</url>

Expand Down
21 changes: 16 additions & 5 deletions src/main/java/com/wizecore/metrics/PersistenceUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,30 @@ protected static void init() {

Config redisConf = null;
try {
redisConf = redisConfig != null ? Config.fromJSON(new File(redisConfig)) : null;

if (redisConf == null && redisAddr != null && !redisAddr.equals("")) {
String src = "defaults";
if (redisConfig != null) {
redisConf = Config.fromJSON(new File(redisConfig));
src = redisConfig;
} else {
String addr = "localhost:6379";
if (redisAddr != null && !redisAddr.equals("")) {
addr = redisAddr;
src = redisAddr;
}

redisConf = new Config();
SingleServerConfig ss = redisConf.useSingleServer();
ss.setAddress(redisAddr);
ss.setAddress(addr);

if (redisPassword != null && !redisPassword.equals("")) {
ss.setPassword(redisPassword);
}

// Reduce default usage of connections from 1 + 10 to 1
ss.setConnectionMinimumIdleSize(0);
}

log.info("Initializing persistent metrics via Redis with " + (redisConf != null ? redisConf.toJSON() : "defaults"));
log.info("Initializing persistent metrics via Redis with " + src);
redis = redisConf != null ? Redisson.create(redisConf) : Redisson.create();
} catch (IOException e) {
e.printStackTrace();
Expand Down

0 comments on commit b8027e3

Please sign in to comment.