Permalink
Browse files

Add a few more public settings to pass over to GenericObjectPool: lif…

…o, minEvictableIdleTimeMillis and timeBetweenEvictionRunsMillis (contributed by B. Todd Burruss)
  • Loading branch information...
1 parent 2d0b6d5 commit e5f29a4fc798e25b69f25d24bd813aea2c7f139d @rantav rantav committed Jun 10, 2010
View
@@ -5,6 +5,10 @@ Changes by version:
0.6.0-* work well with cassandra's 0.6.*
+0.6.0-15
+========
+Add a few more public settings to pass over to GenericObjectPool: lifo, minEvictableIdleTimeMillis and timeBetweenEvictionRunsMillis (contributed by B. Todd Burruss)
+
0.6.0-14
========
View
@@ -9,7 +9,7 @@
<!-- ====================================================================== -->
<!-- Build environment properties -->
<!-- ====================================================================== -->
- <property name="version" value="0.6.0-14"/>
+ <property name="version" value="0.6.0-15"/>
<property name="final-name" value="hector-${version}"/>
<property name="build.dir" value="target"/>
<property name="project.build.directory" value="${build.outputDir}"/>
View
@@ -5,7 +5,7 @@
<artifactId>hector</artifactId>
<packaging>jar</packaging>
<!-- The version follows Cassandra's major version changes, e.g. 0.5.1 goes with the 0.5.1 cassandra release-->
- <version>0.6.0-14</version>
+ <version>0.6.0-15</version>
<name>hector</name>
<description>Cassandra Java Client Library</description>
<url>http://github.com/rantav/hector</url>
@@ -25,6 +25,10 @@
private final int port;
private final int maxActive;
private final int maxIdle;
+ private final boolean lifo;
+ private final long minEvictableIdleTimeMillis;
+ private final long timeBetweenEvictionRunsMillis;
+
private final ExhaustedPolicy exhaustedPolicy;
private final long maxWaitTimeWhenExhausted;
private final GenericObjectPool pool;
@@ -59,6 +63,9 @@ public CassandraClientPoolByHostImpl(CassandraHost cassandraHost,
this.name = cassandraHost.getName();
this.maxActive = cassandraHost.getMaxActive();
this.maxIdle = cassandraHost.getMaxIdle();
+ this.lifo = cassandraHost.getLifo();
+ this.minEvictableIdleTimeMillis = cassandraHost.getMinEvictableIdleTimeMillis();
+ this.timeBetweenEvictionRunsMillis = cassandraHost.getTimeBetweenEvictionRunsMillis();
this.maxWaitTimeWhenExhausted = cassandraHost.getMaxWaitTimeWhenExhausted();
this.exhaustedPolicy = cassandraHost.getExhaustedPolicy();
this.clientFactory = cassandraClientFactory;
@@ -98,6 +105,12 @@ private String toDebugString() {
s.append(pool.getMaxActive());
s.append("&maxIdle=");
s.append(pool.getMaxIdle());
+ s.append("&lifo=");
+ s.append(pool.getLifo());
+ s.append("&minEvictableIdleTimeMillis=");
+ s.append(pool.getMinEvictableIdleTimeMillis());
+ s.append("&timeBetweenEvictionRunsMillis=");
+ s.append(pool.getTimeBetweenEvictionRunsMillis());
s.append("&blockedThreadCount=");
s.append(blockedThreadsCount);
s.append("&liveClientsFromPool.size=");
@@ -154,6 +167,11 @@ private GenericObjectPool createPool() {
// maxIdle controls the maximum number of objects that can sit idle in the pool at any time.
// When negative, there is no limit to the number of objects that may be idle at one time.
p.setMaxIdle(maxIdle);
+
+ p.setLifo(lifo);
+ p.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
+ p.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
+
return p;
}
@@ -262,4 +280,12 @@ public void invalidateAll() {
}
}
+ public Long getMinEvictableIdleTimeMillis() {
+ return minEvictableIdleTimeMillis;
+ }
+
+ public Long getTimeBetweenEvictionRunsMillis() {
+ return timeBetweenEvictionRunsMillis;
+ }
+
}
@@ -3,8 +3,7 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
-import me.prettyprint.cassandra.service.CassandraClient.FailoverPolicy;
-
+import org.apache.commons.pool.impl.GenericObjectPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -18,7 +17,6 @@
public class CassandraHost {
private static Logger log = LoggerFactory.getLogger(CassandraHost.class);
-
public static final int DEFAULT_MAX_ACTIVE = 50;
/**
@@ -38,6 +36,10 @@
*/
public static final int DEFAULT_MAX_IDLE = -1;
+ public static final boolean DEFAULT_LIFO = GenericObjectPool.DEFAULT_LIFO;
+ public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
+ public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
+
public static final TimestampResolution DEFAULT_TIMESTAMP_RESOLUTION =
TimestampResolution.MICROSECONDS;
@@ -47,6 +49,11 @@
private int maxActive = DEFAULT_MAX_ACTIVE;
private int maxIdle = DEFAULT_MAX_IDLE;
+
+ private boolean lifo = DEFAULT_LIFO;
+ private long minEvictableIdleTimeMillis = DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
+ private long timeBetweenEvictionRunsMillis = DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
+
private long maxWaitTimeWhenExhausted = DEFAULT_MAX_WAITTIME_WHEN_EXHAUSTED;
private int cassandraThriftSocketTimeout;
private ExhaustedPolicy exhaustedPolicy = ExhaustedPolicy.WHEN_EXHAUSTED_BLOCK;
@@ -88,6 +95,7 @@ public String getUrlPort() {
/**
* Checks whether name resolution should occur.
+ *
* @return
*/
public boolean isPerformNameResolution() {
@@ -194,4 +202,29 @@ public void setTimestampResolution(TimestampResolution timestampResolution) {
public TimestampResolution getTimestampResolution() {
return timestampResolution;
}
+
+ public boolean getLifo() {
+ return lifo;
+ }
+
+ public void setLifo(boolean lifo) {
+ this.lifo = lifo;
+ }
+
+ public long getMinEvictableIdleTimeMillis() {
+ return minEvictableIdleTimeMillis;
+ }
+
+ public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
+ this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
+ }
+
+ public long getTimeBetweenEvictionRunsMillis() {
+ return timeBetweenEvictionRunsMillis;
+ }
+
+ public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
+ this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
+ }
+
}
@@ -6,11 +6,14 @@
private String hosts;
private int maxActive;
private int maxIdle;
+ private boolean lifo;
+ private long minEvictableIdleTimeMillis;
+ private long timeBetweenEvictionRunsMillis;
+
private long maxWaitTimeWhenExhausted;
private int cassandraThriftSocketTimeout;
private ExhaustedPolicy exhaustedPolicy;
private TimestampResolution timestampResolution;
- private boolean useThriftFramedTransport;
public CassandraHostConfigurator() {
@@ -23,7 +26,7 @@ public CassandraHostConfigurator(String hosts) {
public CassandraHost[] buildCassandraHosts() {
if (this.hosts == null) {
- return null;
+ return null;
}
String[] hostVals = hosts.split(",");
CassandraHost[] cassandraHosts = new CassandraHost[hostVals.length];
@@ -35,6 +38,15 @@ public CassandraHostConfigurator(String hosts) {
if (maxIdle != CassandraHost.DEFAULT_MAX_IDLE) {
cassandraHost.setMaxIdle(maxIdle);
}
+ if (lifo != CassandraHost.DEFAULT_LIFO) {
+ cassandraHost.setLifo(lifo);
+ }
+ if (minEvictableIdleTimeMillis != CassandraHost.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS) {
+ cassandraHost.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
+ }
+ if (timeBetweenEvictionRunsMillis != CassandraHost.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS) {
+ cassandraHost.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
+ }
if (maxWaitTimeWhenExhausted > 0) {
cassandraHost.setMaxWaitTimeWhenExhausted(maxWaitTimeWhenExhausted);
}
@@ -47,9 +59,6 @@ public CassandraHostConfigurator(String hosts) {
if (timestampResolution != null) {
cassandraHost.setTimestampResolution(timestampResolution);
}
- if (useThriftFramedTransport) {
- cassandraHost.setUseThriftFramedTransport(useThriftFramedTransport);
- }
cassandraHosts[x] = cassandraHost;
}
@@ -78,10 +87,6 @@ public void setCassandraThriftSocketTimeout(int cassandraThriftSocketTimeout) {
public void setExhaustedPolicy(ExhaustedPolicy exhaustedPolicy) {
this.exhaustedPolicy = exhaustedPolicy;
- }
-
- public void setUseThriftFramedTransport(boolean useThriftFramedTransport) {
- this.useThriftFramedTransport = useThriftFramedTransport;
}
/**
@@ -112,4 +117,29 @@ public String toString() {
s.append(">");
return s.toString();
}
+
+ public boolean getLifo() {
+ return lifo;
+ }
+
+ public void setLifo(boolean lifo) {
+ this.lifo = lifo;
+ }
+
+ public long getMinEvictableIdleTimeMillis() {
+ return minEvictableIdleTimeMillis;
+ }
+
+ public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
+ this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
+ }
+
+ public long getTimeBetweenEvictionRunsMillis() {
+ return timeBetweenEvictionRunsMillis;
+ }
+
+ public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
+ this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
+ }
+
}

0 comments on commit e5f29a4

Please sign in to comment.