[infinispan-commits] Infinispan SVN: r2631 - in branches/4.2.x: cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra and 2 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Fri Oct 29 06:34:51 EDT 2010


Author: NadirX
Date: 2010-10-29 06:34:49 -0400 (Fri, 29 Oct 2010)
New Revision: 2631

Modified:
   branches/4.2.x/cachestore/cassandra/pom.xml
   branches/4.2.x/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStore.java
   branches/4.2.x/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStoreConfig.java
   branches/4.2.x/cachestore/cassandra/src/test/java/org/infinispan/loaders/cassandra/CassandraCacheStoreTest.java
   branches/4.2.x/parent/pom.xml
Log:
Update to new connection pool


Modified: branches/4.2.x/cachestore/cassandra/pom.xml
===================================================================
--- branches/4.2.x/cachestore/cassandra/pom.xml	2010-10-28 19:50:05 UTC (rev 2630)
+++ branches/4.2.x/cachestore/cassandra/pom.xml	2010-10-29 10:34:49 UTC (rev 2631)
@@ -20,9 +20,16 @@
 		<dependency>
 			<groupId>net.dataforte.cassandra</groupId>
 			<artifactId>cassandra-connection-pool</artifactId>
-			<version>0.1.0</version>
+			<version>${version.cassandra.connection.pool}</version>
 		</dependency>
+
 		<dependency>
+			<groupId>org.apache.cassandra</groupId>
+			<artifactId>apache-cassandra</artifactId>
+			<version>${version.cassandra}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
 			<groupId>org.slf4j</groupId>
 			<artifactId>slf4j-log4j12</artifactId>
 			<version>${version.slf4j}</version>

Modified: branches/4.2.x/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStore.java
===================================================================
--- branches/4.2.x/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStore.java	2010-10-28 19:50:05 UTC (rev 2630)
+++ branches/4.2.x/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStore.java	2010-10-29 10:34:49 UTC (rev 2631)
@@ -12,9 +12,10 @@
 import java.util.Map;
 import java.util.Set;
 
-import net.dataforte.cassandra.pool.ConnectionPool;
+import net.dataforte.cassandra.pool.DataSource;
 
 import org.apache.cassandra.thrift.Cassandra;
+import org.apache.cassandra.thrift.CassandraThriftDataSource;
 import org.apache.cassandra.thrift.Column;
 import org.apache.cassandra.thrift.ColumnOrSuperColumn;
 import org.apache.cassandra.thrift.ColumnParent;
@@ -60,9 +61,9 @@
 	private static final boolean trace = log.isTraceEnabled();
 
 	private CassandraCacheStoreConfig config;
+	
+	private CassandraThriftDataSource dataSource;
 
-	private ConnectionPool pool;
-
 	private ColumnPath entryColumnPath;
 	private ColumnParent entryColumnParent;
 	private ColumnParent expirationColumnParent;
@@ -83,7 +84,7 @@
 	public void start() throws CacheLoaderException {
 
 		try {
-			pool = new ConnectionPool(config.getPoolProperties());
+			dataSource = new DataSource(config.getPoolProperties());						
 			entryColumnPath = new ColumnPath(config.entryColumnFamily).setColumn(ENTRY_COLUMN_NAME.getBytes("UTF-8"));
 			entryColumnParent = new ColumnParent(config.entryColumnFamily);
 			expirationColumnParent = new ColumnParent(config.expirationColumnFamily);			
@@ -101,9 +102,9 @@
 	@Override
 	public InternalCacheEntry load(Object key) throws CacheLoaderException {
 		String hashKey = CassandraCacheStore.hashKey(key);
-		Cassandra.Iface cassandraClient = null;
+		Cassandra.Client cassandraClient = null;
 		try {
-			cassandraClient = pool.getConnection();
+			cassandraClient = dataSource.getConnection();
 			ColumnOrSuperColumn column = cassandraClient.get(config.keySpace, hashKey, entryColumnPath, ConsistencyLevel.ONE);
 			InternalCacheEntry ice = unmarshall(column.getColumn().getValue(), key);
 			if (ice != null && ice.isExpired()) {
@@ -117,7 +118,7 @@
 		} catch (Exception e) {
 			throw new CacheLoaderException(e);
 		} finally {
-			pool.release(cassandraClient);
+			dataSource.releaseConnection(cassandraClient);
 		}
 	}
 
@@ -128,9 +129,9 @@
 
 	@Override
 	public Set<InternalCacheEntry> load(int numEntries) throws CacheLoaderException {
-		Cassandra.Iface cassandraClient = null;
+		Cassandra.Client cassandraClient = null;
 		try {
-			cassandraClient = pool.getConnection();
+			cassandraClient = dataSource.getConnection();
 			Set<InternalCacheEntry> s = new HashSet<InternalCacheEntry>();
 			SlicePredicate slicePredicate = new SlicePredicate();
 			slicePredicate.setSlice_range(new SliceRange(entryColumnPath.getColumn(), emptyByteArray, false, 1));
@@ -183,15 +184,15 @@
 		} catch (Exception e) {
 			throw new CacheLoaderException(e);
 		} finally {
-			pool.release(cassandraClient);
+			dataSource.releaseConnection(cassandraClient);
 		}
 	}
 
 	@Override
 	public Set<Object> loadAllKeys(Set<Object> keysToExclude) throws CacheLoaderException {
-		Cassandra.Iface cassandraClient = null;
+		Cassandra.Client cassandraClient = null;
 		try {
-			cassandraClient = pool.getConnection();
+			cassandraClient = dataSource.getConnection();
 			Set<Object> s = new HashSet<Object>();
 			SlicePredicate slicePredicate = new SlicePredicate();
 			slicePredicate.setSlice_range(new SliceRange(entryColumnPath.getColumn(), emptyByteArray, false, 1));
@@ -221,7 +222,7 @@
 		} catch (Exception e) {
 			throw new CacheLoaderException(e);
 		} finally {
-			pool.release(cassandraClient);
+			dataSource.releaseConnection(cassandraClient);
 		}
 	}
 
@@ -231,14 +232,14 @@
 	 */
 	@Override
 	public void stop() {
-		pool.close();
+		
 	}
 
 	@Override
 	public void clear() throws CacheLoaderException {
-		Cassandra.Iface cassandraClient = null;
+		Cassandra.Client cassandraClient = null;
 		try {
-			cassandraClient = pool.getConnection();
+			cassandraClient = dataSource.getConnection();
 			SlicePredicate slicePredicate = new SlicePredicate();
 			slicePredicate.setSlice_range(new SliceRange(entryColumnPath.getColumn(), emptyByteArray, false, 1));
 			String startKey = "";
@@ -265,7 +266,7 @@
 		} catch (Exception e) {
 			throw new CacheLoaderException(e);
 		} finally {
-			pool.release(cassandraClient);
+			dataSource.releaseConnection(cassandraClient);
 		}
 
 	}
@@ -274,9 +275,9 @@
 	public boolean remove(Object key) throws CacheLoaderException {
 		if (trace)
 			log.trace("remove(\"{0}\") ", key);
-		Cassandra.Iface cassandraClient = null;
+		Cassandra.Client cassandraClient = null;
 		try {
-			cassandraClient = pool.getConnection();
+			cassandraClient = dataSource.getConnection();
 			Map<String, Map<String, List<Mutation>>> mutationMap = new HashMap<String, Map<String, List<Mutation>>>();
 			remove0(CassandraCacheStore.hashKey(key), mutationMap);
 			cassandraClient.batch_mutate(config.keySpace, mutationMap, ConsistencyLevel.ONE);
@@ -285,7 +286,7 @@
 			log.error("Exception while removing " + key, e);
 			return false;
 		} finally {
-			pool.release(cassandraClient);
+			dataSource.releaseConnection(cassandraClient);
 		}
 	}
 
@@ -306,10 +307,10 @@
 	}
 
 	public void store(InternalCacheEntry entry) throws CacheLoaderException {
-		Cassandra.Iface cassandraClient = null;
+		Cassandra.Client cassandraClient = null;
 
 		try {
-			cassandraClient = pool.getConnection();
+			cassandraClient = dataSource.getConnection();
 			Map<String, Map<String, List<Mutation>>> mutationMap = new HashMap<String, Map<String, List<Mutation>>>(2);
 			store0(entry, mutationMap);
 			
@@ -317,7 +318,7 @@
 		} catch (Exception e) {
 			throw new CacheLoaderException(e);
 		} finally {
-			pool.release(cassandraClient);
+			dataSource.releaseConnection(cassandraClient);
 		}
 	}
 
@@ -396,9 +397,9 @@
 	protected void purgeInternal() throws CacheLoaderException {
 		if (trace)
 			log.trace("purgeInternal");
-		Cassandra.Iface cassandraClient = null;
+		Cassandra.Client cassandraClient = null;
 		try {
-			cassandraClient = pool.getConnection();
+			cassandraClient = dataSource.getConnection();
 			// We need to get all supercolumns from the beginning of time until now, in SLICE_SIZE chunks
 			SlicePredicate predicate = new SlicePredicate();
 			predicate.setSlice_range(new SliceRange(emptyByteArray, longToBytes(System.currentTimeMillis()), false, SLICE_SIZE));
@@ -423,17 +424,17 @@
 		} catch (Exception e) {
 			throw new CacheLoaderException(e);
 		} finally {
-			pool.release(cassandraClient);
+			dataSource.releaseConnection(cassandraClient);
 		}
 
 	}
 
 	@Override
 	protected void applyModifications(List<? extends Modification> mods) throws CacheLoaderException {
-		Cassandra.Iface cassandraClient = null;
+		Cassandra.Client cassandraClient = null;
 
 		try {
-			cassandraClient = pool.getConnection();
+			cassandraClient = dataSource.getConnection();
 			Map<String, Map<String, List<Mutation>>> mutationMap = new HashMap<String, Map<String, List<Mutation>>>();
 
 			for (Modification m : mods) {
@@ -456,7 +457,7 @@
 		} catch (Exception e) {
 			throw new CacheLoaderException(e);
 		} finally {
-			pool.release(cassandraClient);
+			dataSource.releaseConnection(cassandraClient);
 		}
 
 	}

Modified: branches/4.2.x/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStoreConfig.java
===================================================================
--- branches/4.2.x/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStoreConfig.java	2010-10-28 19:50:05 UTC (rev 2630)
+++ branches/4.2.x/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStoreConfig.java	2010-10-29 10:34:49 UTC (rev 2631)
@@ -8,8 +8,6 @@
  * Configures {@link CassandraCacheStore}.
  */
 public class CassandraCacheStoreConfig extends LockSupportCacheStoreConfig {
-	
-	
 
 	/**
 	 * @configRef desc="The Cassandra keyspace"
@@ -26,7 +24,7 @@
 	 */
 	String expirationColumnFamily = "InfinispanExpiration";
 
-	PoolProperties poolProperties;
+	protected PoolProperties poolProperties;
 
 	public CassandraCacheStoreConfig() {
 		setCacheLoaderClassName(CassandraCacheStore.class.getName());
@@ -77,258 +75,37 @@
 		return poolProperties.getPort();
 	}
 
-	
-	public int getAbandonWhenPercentageFull() {
-		return poolProperties.getAbandonWhenPercentageFull();
+	public boolean isFramed() {
+		return poolProperties.isFramed();
 	}
 
-	
-	public boolean getFramed() {
-		return poolProperties.getFramed();
-	}
-
-	
-	public int getInitialSize() {
-		return poolProperties.getInitialSize();
-	}
-
-	
-	public int getMaxActive() {
-		return poolProperties.getMaxActive();
-	}
-
-	
-	public long getMaxAge() {
-		return poolProperties.getMaxAge();
-	}
-
-	
-	public int getMaxIdle() {
-		return poolProperties.getMaxIdle();
-	}
-
-	
-	public int getMaxWait() {
-		return poolProperties.getMaxWait();
-	}
-
-	
-	public int getMinEvictableIdleTimeMillis() {
-		return poolProperties.getMinEvictableIdleTimeMillis();
-	}
-
-	
-	public int getMinIdle() {
-		return poolProperties.getMinIdle();
-	}
-
-	
-	public String getName() {
-		return poolProperties.getName();
-	}
-
-	
-	public int getNumTestsPerEvictionRun() {
-		return poolProperties.getNumTestsPerEvictionRun();
-	}
-
-	
 	public String getPassword() {
 		return poolProperties.getPassword();
 	}
-	
-	public int getRemoveAbandonedTimeout() {
-		return poolProperties.getRemoveAbandonedTimeout();
-	}
 
-	
-	public int getSuspectTimeout() {
-		return poolProperties.getSuspectTimeout();
-	}
-
-	
-	public int getTimeBetweenEvictionRunsMillis() {
-		return poolProperties.getTimeBetweenEvictionRunsMillis();
-	}
-
-	
-	public boolean getUseLock() {
-		return poolProperties.getUseLock();
-	}
-
-	
 	public String getUsername() {
 		return poolProperties.getUsername();
 	}
 
-	
-	public long getValidationInterval() {
-		return poolProperties.getValidationInterval();
-	}
-	
-	public boolean isFairQueue() {
-		return poolProperties.isFairQueue();
-	}
-
-	
-	public boolean isJmxEnabled() {
-		return poolProperties.isJmxEnabled();
-	}
-
-	
-	public boolean isLogAbandoned() {
-		return poolProperties.isLogAbandoned();
-	}
-
-	
-	public boolean isRemoveAbandoned() {
-		return poolProperties.isRemoveAbandoned();
-	}
-
-	
-	public boolean isTestOnBorrow() {
-		return poolProperties.isTestOnBorrow();
-	}
-
-	
-	public boolean isTestOnConnect() {
-		return poolProperties.isTestOnConnect();
-	}
-
-	
-	public boolean isTestOnReturn() {
-		return poolProperties.isTestOnReturn();
-	}
-
-	
-	public boolean isTestWhileIdle() {
-		return poolProperties.isTestWhileIdle();
-	}
-
-	
-	public void setAbandonWhenPercentageFull(int percentage) {
-		poolProperties.setAbandonWhenPercentageFull(percentage);
-
-	}
-	
-	public void setFairQueue(boolean fairQueue) {
-		poolProperties.setFairQueue(fairQueue);
-
-	}
-
-	
 	public void setFramed(boolean framed) {
 		poolProperties.setFramed(framed);
 
 	}
 
-	
-	public void setInitialSize(int initialSize) {
-		poolProperties.setInitialSize(initialSize);
-
-	}
-
-	
-	public void setJmxEnabled(boolean jmxEnabled) {
-		poolProperties.setJmxEnabled(jmxEnabled);
-	}
-
-	
-	public void setLogAbandoned(boolean logAbandoned) {
-		poolProperties.setLogAbandoned(logAbandoned);
-	}
-
-	
-	public void setMaxActive(int maxActive) {
-		poolProperties.setMaxActive(maxActive);
-
-	}
-
-	
-	public void setMaxAge(long maxAge) {
-		poolProperties.setMaxAge(maxAge);
-
-	}
-
-	
-	public void setMaxIdle(int maxIdle) {
-		poolProperties.setMaxIdle(maxIdle);
-
-	}
-
-	
-	public void setMaxWait(int maxWait) {
-		poolProperties.setMaxWait(maxWait);
-
-	}
-
-	
-	public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
-		poolProperties.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
-
-	}
-
-	public void setMinIdle(int minIdle) {
-		poolProperties.setMinIdle(minIdle);
-
-	}
-
-	public void setName(String name) {
-		poolProperties.setName(name);
-	}
-
-	public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
-		poolProperties.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
-
-	}
-
 	public void setPassword(String password) {
 		poolProperties.setPassword(password);
 	}
 
-	public void setRemoveAbandoned(boolean removeAbandoned) {
-		poolProperties.setRemoveAbandoned(removeAbandoned);
+	public void setUsername(String username) {
+		poolProperties.setUsername(username);
 	}
-
 	
-	public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
-		poolProperties.setRemoveAbandonedTimeout(removeAbandonedTimeout);
-
+	public void setDatasourceJndiLocation(String location) {
+		poolProperties.setDataSourceJNDI(location);
 	}
-
-	public void setSuspectTimeout(int seconds) {
-		poolProperties.setSuspectTimeout(seconds);
-
+	
+	public String getDatasourceJndiLocation() {
+		return poolProperties.getDataSourceJNDI();
 	}
 
-	public void setTestOnBorrow(boolean testOnBorrow) {
-		poolProperties.setTestOnBorrow(testOnBorrow);
-
-	}
-
-	public void setTestOnConnect(boolean testOnConnect) {
-		poolProperties.setTestOnConnect(testOnConnect);
-
-	}
-
-	public void setTestOnReturn(boolean testOnReturn) {
-		poolProperties.setTestOnReturn(testOnReturn);
-	}
-
-	public void setTestWhileIdle(boolean testWhileIdle) {
-		poolProperties.setTestWhileIdle(testWhileIdle);
-	}
-
-	public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) {
-		poolProperties.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
-
-	}
-
-	public void setUsername(String username) {
-		poolProperties.setUsername(username);
-	}
-
-	public void setValidationInterval(long validationInterval) {
-		poolProperties.setValidationInterval(validationInterval);
-	}
 }

Modified: branches/4.2.x/cachestore/cassandra/src/test/java/org/infinispan/loaders/cassandra/CassandraCacheStoreTest.java
===================================================================
--- branches/4.2.x/cachestore/cassandra/src/test/java/org/infinispan/loaders/cassandra/CassandraCacheStoreTest.java	2010-10-28 19:50:05 UTC (rev 2630)
+++ branches/4.2.x/cachestore/cassandra/src/test/java/org/infinispan/loaders/cassandra/CassandraCacheStoreTest.java	2010-10-29 10:34:49 UTC (rev 2631)
@@ -8,6 +8,7 @@
 import org.apache.thrift.transport.TTransportException;
 import org.infinispan.loaders.BaseCacheStoreTest;
 import org.infinispan.loaders.CacheStore;
+import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
@@ -39,6 +40,11 @@
 		t.setDaemon(true);
 		t.start();
 	}
+	
+	@AfterClass
+	public static void cleanup() {
+		System.exit(0);
+	}
 
 	@Override
 	protected CacheStore createCacheStore() throws Exception {

Modified: branches/4.2.x/parent/pom.xml
===================================================================
--- branches/4.2.x/parent/pom.xml	2010-10-28 19:50:05 UTC (rev 2630)
+++ branches/4.2.x/parent/pom.xml	2010-10-29 10:34:49 UTC (rev 2631)
@@ -78,7 +78,8 @@
       <version.apacheds.jdbm>1.5.4</version.apacheds.jdbm>
       <version.bdbje>4.0.92</version.bdbje>
       <version.c3p0>0.9.1.2</version.c3p0>
-      <version.cassandra>0.6.5</version.cassandra>
+      <version.cassandra>0.6.6</version.cassandra>
+      <version.cassandra.connection.pool>0.3.0</version.cassandra.connection.pool>
       <version.com.intellij.forms_rt>6.0.5</version.com.intellij.forms_rt>
       <version.commons.compress>1.0</version.commons.compress>
       <version.commons.pool>1.5.4</version.commons.pool>



More information about the infinispan-commits mailing list