Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorZeng committed Nov 30, 2015
1 parent ce13f78 commit efe572a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.darkphoenixs</groupId>
<artifactId>connectionpool-client</artifactId>
<version>1.1</version>
<version>1.2</version>
<packaging>jar</packaging>

<name>ConnectionPoolClient</name>
Expand All @@ -20,7 +20,7 @@
<properties>
<kafka.version>0.8.2.1</kafka.version>
<hbase.version>1.1.1</hbase.version>
<redis.version>2.7.3</redis.version>
<redis.version>2.8.0</redis.version>
<oracle.version>11.2.0.1.0</oracle.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,22 @@ public Jedis createConnection() throws Exception {
Jedis jedis = new Jedis(hostAndPort.getHost(), hostAndPort.getPort(),
this.connectionTimeout, this.soTimeout);

jedis.connect();
if (null != this.password) {
jedis.auth(this.password);
}
if (this.database != 0) {
jedis.select(this.database);
}
if (this.clientName != null) {
jedis.clientSetname(this.clientName);
try {
jedis.connect();
if (null != this.password) {
jedis.auth(this.password);
}
if (this.database != 0) {
jedis.select(this.database);
}
if (this.clientName != null) {
jedis.clientSetname(this.clientName);
}
} catch (Exception je) {
jedis.close();
throw je;
}

return jedis;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ private HostAndPort initSentinels(Set<String> sentinels,
log.fine("Found Redis master at " + master);
break;
} catch (Exception e) {
log.warning("Cannot connect to sentinel running @ " + hap
+ ". Trying next one.");
log.warning("Cannot get master address from sentinel running @ " + hap
+ ". Reason: " + e + ". Trying next one.");
} finally {
if (jedis != null) {
jedis.close();
Expand Down Expand Up @@ -382,7 +382,7 @@ public Jedis getResource() {
// connected to the correct master
return jedis;
} else {
returnConnection(jedis);
invalidateResource(jedis);
}
}
}
Expand Down

0 comments on commit efe572a

Please sign in to comment.