JBoss Cache SVN: r7892 - in core/branches/flat: src/main/java/org/horizon/loader and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: adriancole
Date: 2009-03-09 11:02:01 -0400 (Mon, 09 Mar 2009)
New Revision: 7892
Removed:
core/branches/flat/src/main/java/org/horizon/loader/jdbm/
core/branches/flat/src/test/java/org/horizon/loader/jdbm/
Modified:
core/branches/flat/pom.xml
Log:
removed jdbm as it is a dead api
Modified: core/branches/flat/pom.xml
===================================================================
--- core/branches/flat/pom.xml 2009-03-09 13:58:08 UTC (rev 7891)
+++ core/branches/flat/pom.xml 2009-03-09 15:02:01 UTC (rev 7892)
@@ -45,22 +45,7 @@
<version>2.2.10.GA</version>
</dependency>
- <!-- optional dependencies -->
<dependency>
- <groupId>jdbm</groupId>
- <artifactId>jdbm</artifactId>
- <version>1.0</version>
- <optional>true</optional>
- </dependency>
- <!-- needed for jdbm -->
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2.1</version>
- <optional>true</optional>
- </dependency>
-
- <dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
15 years, 10 months
JBoss Cache SVN: r7891 - in core/branches/flat/src/main/java/org/horizon/loader: file and 4 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-03-09 09:58:08 -0400 (Mon, 09 Mar 2009)
New Revision: 7891
Modified:
core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/jdbc/TableManipulation.java
core/branches/flat/src/main/java/org/horizon/loader/jdbc/binary/JdbcBinaryCacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/jdbc/binary/JdbcBinaryCacheStoreConfig.java
core/branches/flat/src/main/java/org/horizon/loader/jdbc/mixed/JdbcMixedCacheStoreConfig.java
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreConfig.java
Log:
1.batchSize and readSize are now configurable
2. created an marshaller field in AbstractCacheStore
Modified: core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheStore.java 2009-03-09 09:05:21 UTC (rev 7890)
+++ core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheStore.java 2009-03-09 13:58:08 UTC (rev 7891)
@@ -35,8 +35,11 @@
private ExecutorService purgerService;
+ private Marshaller marshaller;
+
public void init(CacheLoaderConfig config, Cache cache, Marshaller m) {
this.config = (AbstractCacheStoreConfig) config;
+ this.marshaller = m;
if (config == null) throw new IllegalStateException("Null config!!!");
}
@@ -129,4 +132,8 @@
throw new CacheLoaderException("Problems closing output stream", e);
}
}
+
+ protected Marshaller getMarshaller() {
+ return marshaller;
+ }
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStore.java 2009-03-09 09:05:21 UTC (rev 7890)
+++ core/branches/flat/src/main/java/org/horizon/loader/file/FileCacheStore.java 2009-03-09 13:58:08 UTC (rev 7891)
@@ -30,7 +30,6 @@
FileCacheStoreConfig config;
Cache cache;
- Marshaller marshaller;
File root;
/**
@@ -44,7 +43,6 @@
super.init(config, cache, m);
this.config = (FileCacheStoreConfig) config;
this.cache = cache;
- this.marshaller = m;
}
protected Set<StoredEntry> loadAllLockSafe() throws CacheLoaderException {
Modified: core/branches/flat/src/main/java/org/horizon/loader/jdbc/TableManipulation.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/jdbc/TableManipulation.java 2009-03-09 09:05:21 UTC (rev 7890)
+++ core/branches/flat/src/main/java/org/horizon/loader/jdbc/TableManipulation.java 2009-03-09 13:58:08 UTC (rev 7891)
@@ -22,6 +22,10 @@
private static Log log = LogFactory.getLog(TableManipulation.class);
+ public static final int DEFAULT_FETCH_SIZE = 100;
+
+ public static final int DEFAULT_BATCH_SIZE = 100;
+
private String idColumnName;
private String idColumnType;
private String tableName;
@@ -29,6 +33,8 @@
private String dataColumnType;
private String timestampColumnName;
private String timestampColumnType;
+ private int fetchSize = DEFAULT_FETCH_SIZE;
+ private int batchSize = DEFAULT_BATCH_SIZE;
/*
* following two params manage creation and destruction during start up/shutdown.
@@ -331,4 +337,36 @@
public String getTimestampColumnType() {
return timestampColumnType;
}
+
+ /**
+ * For DB queries (e.g. {@link org.horizon.loader.CacheStore#toStream(java.io.ObjectOutput)} ) the fetch size will be
+ * set on {@link java.sql.ResultSet#setFetchSize(int)}. This is optional parameter, if not specified will be
+ * defaulted to {@link #DEFAULT_FETCH_SIZE}.
+ */
+ public int getFetchSize() {
+ return fetchSize;
+ }
+
+ /**
+ * @see #getFetchSize()
+ */
+ public void setFetchSize(int fetchSize) {
+ this.fetchSize = fetchSize;
+ }
+
+ /**
+ * When doing repetitive DB inserts (e.g. on {@link org.horizon.loader.CacheStore#fromStream(java.io.ObjectInput)}
+ * this will be batched according to this parameter. This is an optional parameter, and if it is not specified it
+ * will be defaulted to {@link #DEFAULT_BATCH_SIZE}.
+ */
+ public int getBatchSize() {
+ return batchSize;
+ }
+
+ /**
+ * @see #getBatchSize()
+ */
+ public void setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ }
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/jdbc/binary/JdbcBinaryCacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/jdbc/binary/JdbcBinaryCacheStore.java 2009-03-09 09:05:21 UTC (rev 7890)
+++ core/branches/flat/src/main/java/org/horizon/loader/jdbc/binary/JdbcBinaryCacheStore.java 2009-03-09 13:58:08 UTC (rev 7891)
@@ -48,7 +48,6 @@
private JdbcBinaryCacheStoreConfig config;
private ConnectionFactory connectionFactory;
- private Marshaller marshaller;
private TableManipulation tableManipulation;
public void init(CacheLoaderConfig config, Cache cache, Marshaller m) {
@@ -56,7 +55,6 @@
log.trace("Initializing JdbcBinaryCacheStore " + config);
super.init(config, cache, m);
this.config = (JdbcBinaryCacheStoreConfig) config;
- this.marshaller = m;
}
public void start() throws CacheLoaderException {
@@ -86,7 +84,7 @@
}
conn = connectionFactory.getConnection();
ps = conn.prepareStatement(sql);
- ByteBuffer byteBuffer = JdbcUtil.marshall(marshaller, bucket);
+ ByteBuffer byteBuffer = JdbcUtil.marshall(getMarshaller(), bucket);
ps.setBinaryStream(1, byteBuffer.getStream(), byteBuffer.getLength());
ps.setLong(2, bucket.timestampOfFirstEntryToExpire());
ps.setString(3, bucket.getBucketName());
@@ -112,7 +110,7 @@
}
conn = connectionFactory.getConnection();
ps = conn.prepareStatement(sql);
- ByteBuffer buffer = JdbcUtil.marshall(marshaller, bucket);
+ ByteBuffer buffer = JdbcUtil.marshall(getMarshaller(), bucket);
ps.setBinaryStream(1, buffer.getStream(), buffer.getLength());
ps.setLong(2, bucket.timestampOfFirstEntryToExpire());
ps.setString(3, bucket.getBucketName());
@@ -144,7 +142,7 @@
if (!rs.next()) return null;
String bucketName = rs.getString(1);
InputStream inputStream = rs.getBinaryStream(2);
- Bucket bucket = (Bucket) JdbcUtil.unmarshall(marshaller, inputStream);
+ Bucket bucket = (Bucket) JdbcUtil.unmarshall(getMarshaller(), inputStream);
bucket.setBucketName(bucketName);//bucket name is volatile, so not persisted.
return bucket;
} catch (SQLException e) {
@@ -170,10 +168,11 @@
conn = connectionFactory.getConnection();
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
+ rs.setFetchSize(config.getFetchSize());
Set<StoredEntry> result = new HashSet<StoredEntry>();
while (rs.next()) {
InputStream binaryStream = rs.getBinaryStream(1);
- Bucket bucket = (Bucket) JdbcUtil.unmarshall(marshaller, binaryStream);
+ Bucket bucket = (Bucket) JdbcUtil.unmarshall(getMarshaller(), binaryStream);
result.addAll(bucket.getStoredEntries());
}
return result;
@@ -197,12 +196,12 @@
ps = conn.prepareStatement(sql);
int readBuckets = 0;
- int batchSize = 100;
+ int batchSize = config.getBatchSize();
String bucketName = (String) objectInput.readObject();
while (!bucketName.equals(BINARY_STREAM_DELIMITER)) {
Bucket bucket = (Bucket) objectInput.readObject();
readBuckets++;
- ByteBuffer buffer = JdbcUtil.marshall(marshaller, bucket);
+ ByteBuffer buffer = JdbcUtil.marshall(getMarshaller(), bucket);
ps.setBinaryStream(1, buffer.getStream(), buffer.getLength());
ps.setLong(2, bucket.timestampOfFirstEntryToExpire());
ps.setString(3, bucketName);
@@ -240,10 +239,10 @@
String sql = tableManipulation.getLoadAllRowsSql();
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
- rs.setFetchSize(100);
+ rs.setFetchSize(config.getFetchSize());
while (rs.next()) {
InputStream inputStream = rs.getBinaryStream(1);
- Bucket bucket = (Bucket) JdbcUtil.unmarshall(marshaller, inputStream);
+ Bucket bucket = (Bucket) JdbcUtil.unmarshall(getMarshaller(), inputStream);
String bucketName = rs.getString(2);
objectOutput.writeObject(bucketName);
objectOutput.writeObject(bucket);
@@ -296,7 +295,7 @@
if (immediateLockForWritting(key)) {
if (log.isTraceEnabled()) log.trace("Adding bucket keyed " + key + " for purging.");
InputStream binaryStream = rs.getBinaryStream(1);
- Bucket bucket = (Bucket) JdbcUtil.unmarshall(marshaller, binaryStream);
+ Bucket bucket = (Bucket) JdbcUtil.unmarshall(getMarshaller(), binaryStream);
bucket.setBucketName(key);
expiredBuckets.add(bucket);
} else {
@@ -329,7 +328,7 @@
Bucket bucket = it.next();
bucket.removeExpiredEntries();
if (!bucket.isEmpty()) {
- ByteBuffer byteBuffer = JdbcUtil.marshall(marshaller, bucket);
+ ByteBuffer byteBuffer = JdbcUtil.marshall(getMarshaller(), bucket);
ps.setBinaryStream(1, byteBuffer.getStream(), byteBuffer.getLength());
ps.setLong(2, bucket.timestampOfFirstEntryToExpire());
ps.addBatch();
Modified: core/branches/flat/src/main/java/org/horizon/loader/jdbc/binary/JdbcBinaryCacheStoreConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/jdbc/binary/JdbcBinaryCacheStoreConfig.java 2009-03-09 09:05:21 UTC (rev 7890)
+++ core/branches/flat/src/main/java/org/horizon/loader/jdbc/binary/JdbcBinaryCacheStoreConfig.java 2009-03-09 13:58:08 UTC (rev 7891)
@@ -143,6 +143,37 @@
}
public void setTableManipulation(TableManipulation tableManipulation) {
+ testImmutability("tableManipulation");
this.tableManipulation = tableManipulation;
}
+
+ /**
+ * @see org.horizon.loader.jdbc.TableManipulation#getFetchSize()
+ */
+ public void setFetchSize(int fetchSize) {
+ testImmutability("tableManipulation");
+ this.tableManipulation.setFetchSize(fetchSize);
+ }
+
+ /**
+ * @see org.horizon.loader.jdbc.TableManipulation#getBatchSize()
+ */
+ public void setBatchSize(int batchSize) {
+ testImmutability("tableManipulation");
+ this.tableManipulation.setBatchSize(batchSize);
+ }
+
+ /**
+ * @see org.horizon.loader.jdbc.TableManipulation#getFetchSize()
+ */
+ public int getFetchSize() {
+ return this.tableManipulation.getFetchSize();
+ }
+
+ /**
+ * @see org.horizon.loader.jdbc.TableManipulation#getBatchSize()
+ */
+ public int getBatchSize() {
+ return this.tableManipulation.getBatchSize();
+ }
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/jdbc/mixed/JdbcMixedCacheStoreConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/jdbc/mixed/JdbcMixedCacheStoreConfig.java 2009-03-09 09:05:21 UTC (rev 7890)
+++ core/branches/flat/src/main/java/org/horizon/loader/jdbc/mixed/JdbcMixedCacheStoreConfig.java 2009-03-09 13:58:08 UTC (rev 7891)
@@ -34,14 +34,17 @@
}
public void setConnectionFactoryConfig(ConnectionFactoryConfig connectionFactoryConfig) {
+ testImmutability("connectionFactoryConfig");
this.connectionFactoryConfig = connectionFactoryConfig;
}
public void setBinaryTableManipulation(TableManipulation binaryTableManipulation) {
+ testImmutability("binaryTableManipulation");
this.binaryTableManipulation = binaryTableManipulation;
}
public void setStringsTableManipulation(TableManipulation stringsTableManipulation) {
+ testImmutability("stringsTableManipulation");
this.stringsTableManipulation = stringsTableManipulation;
}
@@ -65,14 +68,17 @@
}
public void setIdColumnNameForStrings(String idColumnNameForStrings) {
+ testImmutability("stringsTableManipulation");
this.stringsTableManipulation.setIdColumnName(idColumnNameForStrings);
}
public void setIdColumnTypeForStrings(String idColumnTypeForStrings) {
+ testImmutability("stringsTableManipulation");
this.stringsTableManipulation.setIdColumnType(idColumnTypeForStrings);
}
public void setTableNameForStrings(String tableNameForStrings) {
+ testImmutability("stringsTableManipulation");
if (tableNameForStrings == null) throw new IllegalArgumentException("Null table name not allowed.");
if (tableNameForStrings.equals(this.binaryTableManipulation.getTableName())) {
throw new IllegalArgumentException("Same table name is used for both cache loaders, this is not allowed!");
@@ -81,26 +87,32 @@
}
public void setDataColumnNameForStrings(String dataColumnNameForStrings) {
+ testImmutability("stringsTableManipulation");
this.stringsTableManipulation.setDataColumnName(dataColumnNameForStrings);
}
public void setDataColumnTypeForStrings(String dataColumnTypeForStrings) {
+ testImmutability("stringsTableManipulation");
this.stringsTableManipulation.setDataColumnType(dataColumnTypeForStrings);
}
public void setTimestampColumnNameForStrings(String timestampColumnNameForStrings) {
+ testImmutability("stringsTableManipulation");
this.stringsTableManipulation.setTimestampColumnName(timestampColumnNameForStrings);
}
public void setTimestampColumnTypeForStrings(String timestampColumnTypeForStrings) {
+ testImmutability("stringsTableManipulation");
this.stringsTableManipulation.setTimestampColumnType(timestampColumnTypeForStrings);
}
public void setCreateTableOnStartForStrings(boolean createTableOnStartForStrings) {
+ testImmutability("stringsTableManipulation");
this.stringsTableManipulation.setCreateTableOnStart(createTableOnStartForStrings);
}
public void setDropTableOnExitForStrings(boolean dropTableOnExitForStrings) {
+ testImmutability("stringsTableManipulation");
this.stringsTableManipulation.setDropTableOnExit(dropTableOnExitForStrings);
}
@@ -109,10 +121,12 @@
}
public void setIdColumnTypeForBinary(String idColumnTypeForBinary) {
+ testImmutability("stringsTableManipulation");
this.binaryTableManipulation.setIdColumnType(idColumnTypeForBinary);
}
public void setTableNameForBinary(String tableNameForBinary) {
+ testImmutability("binaryTableManipulation");
if (tableNameForBinary == null) throw new IllegalArgumentException("Null table name not allowed.");
if (tableNameForBinary.equals(this.stringsTableManipulation.getTableName())) {
throw new IllegalArgumentException("Same table name is used for both cache loaders, this is not allowed!");
@@ -121,14 +135,17 @@
}
public void setDataColumnNameForBinary(String dataColumnNameForBinary) {
+ testImmutability("binaryTableManipulation");
this.binaryTableManipulation.setDataColumnName(dataColumnNameForBinary);
}
public void setDataColumnTypeForBinary(String dataColumnTypeForBinary) {
+ testImmutability("binaryTableManipulation");
this.binaryTableManipulation.setDataColumnType(dataColumnTypeForBinary);
}
public void setTimestampColumnNameForBinary(String timestampColumnNameForBinary) {
+ testImmutability("binaryTableManipulation");
this.binaryTableManipulation.setTimestampColumnName(timestampColumnNameForBinary);
}
@@ -137,26 +154,32 @@
}
public void setCreateTableOnStartForBinary(boolean createTableOnStartForBinary) {
+ testImmutability("binaryTableManipulation");
this.binaryTableManipulation.setCreateTableOnStart(createTableOnStartForBinary);
}
public void setDropTableOnExitForBinary(boolean dropTableOnExitForBinary) {
+ testImmutability("binaryTableManipulation");
this.binaryTableManipulation.setDropTableOnExit(dropTableOnExitForBinary);
}
public void setDriverClass(String driverClass) {
+ testImmutability("connectionFactoryConfig");
this.connectionFactoryConfig.setDriverClass(driverClass);
}
public void setConnectionUrl(String connectionUrl) {
+ testImmutability("connectionFactoryConfig");
this.connectionFactoryConfig.setConnectionUrl(connectionUrl);
}
public void setUserName(String userName) {
+ testImmutability("connectionFactoryConfig");
this.connectionFactoryConfig.setUserName(userName);
}
public void setPassword(String password) {
+ testImmutability("connectionFactoryConfig");
this.connectionFactoryConfig.setPassword(password);
}
@@ -165,18 +188,40 @@
}
public void setKey2StringMapperClass(String name) {
- this.key2StringMapper = name;
+ testImmutability("key2StringMapper");
+ this.key2StringMapper = name;
}
public void setLockConcurrencyLevelForStrings(int concurrencyLevel) {
+ testImmutability("stringsConcurrencyLevel");
this.stringsConcurrencyLevel = concurrencyLevel;
}
public void setLockConcurrencyLevelForBinary(int concurrencyLevel) {
+ testImmutability("binaryConcurrencyLevel");
this.binaryConcurrencyLevel = concurrencyLevel;
}
public void setLockAcquistionTimeout(int lockAcquistionTimeout) {
+ testImmutability("lockAcquistionTimeout");
this.lockAcquistionTimeout = lockAcquistionTimeout;
}
+
+ /**
+ * @see org.horizon.loader.jdbc.TableManipulation#getFetchSize()
+ */
+ public void setFetchSize(int fetchSize) {
+ testImmutability("tableManipulation");
+ this.binaryTableManipulation.setFetchSize(fetchSize);
+ this.stringsTableManipulation.setFetchSize(fetchSize);
+ }
+
+ /**
+ * @see org.horizon.loader.jdbc.TableManipulation#getBatchSize()
+ */
+ public void setBatchSize(int batchSize) {
+ testImmutability("tableManipulation");
+ this.binaryTableManipulation.setBatchSize(batchSize);
+ this.stringsTableManipulation.setBatchSize(batchSize);
+ }
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStore.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStore.java 2009-03-09 09:05:21 UTC (rev 7890)
+++ core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStore.java 2009-03-09 13:58:08 UTC (rev 7891)
@@ -49,12 +49,9 @@
private Key2StringMapper key2StringMapper;
private ConnectionFactory connectionFactory;
private TableManipulation tableManipulation;
- private Marshaller marshaller;
-
public void init(CacheLoaderConfig config, Cache cache, Marshaller m) {
super.init(config, cache, m);
this.config = (JdbcStringBasedCacheStoreConfig) config;
- this.marshaller = m;
}
@Override
@@ -98,7 +95,7 @@
try {
connection = connectionFactory.getConnection();
ps = connection.prepareStatement(sql);
- ByteBuffer byteBuffer = JdbcUtil.marshall(marshaller, ed);
+ ByteBuffer byteBuffer = JdbcUtil.marshall(getMarshaller(), ed);
ps.setBinaryStream(1, byteBuffer.getStream(), byteBuffer.getLength());
ps.setLong(2, ed.getExpiryTime());
ps.setString(3, lockingKey);
@@ -140,13 +137,13 @@
ps = conn.prepareStatement(sql);
int readStoredEntries = 0;
- int batchSize = 100;
+ int batchSize = config.getBatchSize();
Object objFromStream = objectInput.readObject();
while (!objFromStream.equals(STRING_STREAM_DELIMITER)) {
StoredEntry se = (StoredEntry) objFromStream;
readStoredEntries++;
String key = key2StringMapper.getStringMapping(se.getKey());
- ByteBuffer buffer = JdbcUtil.marshall(marshaller, se);
+ ByteBuffer buffer = JdbcUtil.marshall(getMarshaller(), se);
ps.setBinaryStream(1, buffer.getStream(), buffer.getLength());
ps.setLong(2, se.getExpiryTime());
ps.setString(3, key);
@@ -185,9 +182,10 @@
connection = connectionFactory.getConnection();
ps = connection.prepareStatement(sql);
rs = ps.executeQuery();
+ rs.setFetchSize(config.getFetchSize());
while (rs.next()) {
InputStream is = rs.getBinaryStream(1);
- StoredEntry se = (StoredEntry) JdbcUtil.unmarshall(marshaller, is);
+ StoredEntry se = (StoredEntry) JdbcUtil.unmarshall(getMarshaller(), is);
objectOutput.writeObject(se);
}
objectOutput.writeObject(STRING_STREAM_DELIMITER);
@@ -251,11 +249,11 @@
conn = connectionFactory.getConnection();
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
- rs.setFetchSize(100);
+ rs.setFetchSize(config.getFetchSize());
Set<StoredEntry> result = new HashSet<StoredEntry>();
while (rs.next()) {
InputStream inputStream = rs.getBinaryStream(1);
- StoredEntry se = (StoredEntry) JdbcUtil.unmarshall(marshaller, inputStream);
+ StoredEntry se = (StoredEntry) JdbcUtil.unmarshall(getMarshaller(), inputStream);
result.add(se);
}
return result;
@@ -282,7 +280,7 @@
rs = ps.executeQuery();
if (rs.next()) {
InputStream inputStream = rs.getBinaryStream(2);
- StoredEntry storedEntry = (StoredEntry) JdbcUtil.unmarshall(marshaller, inputStream);
+ StoredEntry storedEntry = (StoredEntry) JdbcUtil.unmarshall(getMarshaller(), inputStream);
if (storedEntry.isExpired()) {
if (log.isTraceEnabled()) {
log.trace("Not returning '" + storedEntry + "' as it is expired. It will be removed from DB by purging thread!");
Modified: core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreConfig.java 2009-03-09 09:05:21 UTC (rev 7890)
+++ core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreConfig.java 2009-03-09 13:58:08 UTC (rev 7891)
@@ -51,6 +51,7 @@
* @see org.horizon.loader.jdbc.stringbased.Key2StringMapper
*/
public void setKey2StringMapperClass(String className) {
+ testImmutability("key2StringMapper");
try {
key2StringMapper = (Key2StringMapper) Util.getInstance(className);
} catch (Exception e) {
@@ -62,6 +63,7 @@
* Sets the name of the table where data will be stored.
*/
public void setStringsTableName(String stringsTableName) {
+ testImmutability("tableManipulation");
this.tableManipulation.setTableName(stringsTableName);
}
@@ -73,6 +75,7 @@
* Mandatory.
*/
public void setIdColumnName(String idColumnName) {
+ testImmutability("tableManipulation");
this.tableManipulation.setIdColumnName(idColumnName);
}
@@ -80,6 +83,7 @@
* Sets the name of the column where the StoredEntry will be binary stored. Mandatory.
*/
public void setDataColumnName(String dataColumnName) {
+ testImmutability("tableManipulation");
this.tableManipulation.setDataColumnName(dataColumnName);
}
@@ -87,10 +91,12 @@
* Sets the name of the column where the timestamp (Long in java) will be stored. Mandatory.
*/
public void setTimestampColumnName(String timestampColumnName) {
+ testImmutability("tableManipulation");
this.tableManipulation.setTimestampColumnName(timestampColumnName);
}
public void setConnectionFactoryClass(String connectionFactoryClass) {
+ testImmutability("connectionFactoryConfig");
this.connectionFactoryConfig.setConnectionFactoryClass(connectionFactoryClass);
}
@@ -106,6 +112,7 @@
* Jdbc connection string for connecting to the database. Mandatory.
*/
public void setConnectionUrl(String connectionUrl) {
+ testImmutability("connectionFactoryConfig");
this.connectionFactoryConfig.setConnectionUrl(connectionUrl);
}
@@ -113,6 +120,7 @@
* Database username.
*/
public void setUserName(String userName) {
+ testImmutability("connectionFactoryConfig");
this.connectionFactoryConfig.setUserName(userName);
}
@@ -120,6 +128,7 @@
* Database username's password.
*/
public void setPassword(String password) {
+ testImmutability("connectionFactoryConfig");
this.connectionFactoryConfig.setPassword(password);
}
@@ -128,6 +137,7 @@
* connection.
*/
public void setDriverClass(String driverClassName) {
+ testImmutability("connectionFactoryConfig");
this.connectionFactoryConfig.setDriverClass(driverClassName);
}
@@ -135,6 +145,7 @@
* sql equivalent for java's String. Mandatory.
*/
public void setIdColumnType(String idColumnType) {
+ testImmutability("tableManipulation");
this.tableManipulation.setIdColumnType(idColumnType);
}
@@ -142,14 +153,17 @@
* Sets the type of the column where data will be binary stored. BLOB-like type, DBMS dependent. Mandatory.
*/
public void setDataColumnType(String dataColumnType) {
+ testImmutability("tableManipulation");
this.tableManipulation.setDataColumnType(dataColumnType);
}
public void setDropTableOnExit(boolean dropTableOnExit) {
+ testImmutability("tableManipulation");
this.tableManipulation.setDropTableOnExit(dropTableOnExit);
}
public void setCreateTableOnStart(boolean createTableOnStart) {
+ testImmutability("tableManipulation");
this.tableManipulation.setCreateTableOnStart(createTableOnStart);
}
@@ -163,6 +177,37 @@
}
public void setTableManipulation(TableManipulation tableManipulation) {
+ testImmutability("tableManipulation");
this.tableManipulation = tableManipulation;
}
+
+ /**
+ * @see org.horizon.loader.jdbc.TableManipulation#getFetchSize()
+ */
+ public void setFetchSize(int fetchSize) {
+ testImmutability("tableManipulation");
+ this.tableManipulation.setFetchSize(fetchSize);
+ }
+
+ /**
+ * @see org.horizon.loader.jdbc.TableManipulation#getBatchSize()
+ */
+ public void setBatchSize(int batchSize) {
+ testImmutability("tableManipulation");
+ this.tableManipulation.setBatchSize(batchSize);
+ }
+
+ /**
+ * @see org.horizon.loader.jdbc.TableManipulation#getFetchSize()
+ */
+ public int getFetchSize() {
+ return this.tableManipulation.getFetchSize();
+ }
+
+ /**
+ * @see org.horizon.loader.jdbc.TableManipulation#getBatchSize()
+ */
+ public int getBatchSize() {
+ return this.tableManipulation.getBatchSize();
+ }
}
15 years, 10 months
JBoss Cache SVN: r7890 - in core/branches/flat/src/main/java/org/horizon: factories and 6 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-09 05:05:21 -0400 (Mon, 09 Mar 2009)
New Revision: 7890
Modified:
core/branches/flat/src/main/java/org/horizon/commands/tx/PrepareCommand.java
core/branches/flat/src/main/java/org/horizon/factories/DefaultCacheFactory.java
core/branches/flat/src/main/java/org/horizon/interceptors/InvalidationInterceptor.java
core/branches/flat/src/main/java/org/horizon/interceptors/ReplicationInterceptor.java
core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java
core/branches/flat/src/main/java/org/horizon/marshall/HorizonMarshaller.java
core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/CommandAwareRpcDispatcher.java
core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/JGroupsTransport.java
core/branches/flat/src/main/java/org/horizon/statetransfer/StateTransferManagerImpl.java
core/branches/flat/src/main/java/org/horizon/transaction/TransactionLog.java
Log:
More performance improvements
Modified: core/branches/flat/src/main/java/org/horizon/commands/tx/PrepareCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/commands/tx/PrepareCommand.java 2009-03-09 09:03:53 UTC (rev 7889)
+++ core/branches/flat/src/main/java/org/horizon/commands/tx/PrepareCommand.java 2009-03-09 09:05:21 UTC (rev 7890)
@@ -28,9 +28,11 @@
import org.horizon.remoting.transport.Address;
import org.horizon.transaction.GlobalTransaction;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
/**
* // TODO: MANIK: Document this
@@ -41,19 +43,39 @@
public class PrepareCommand extends AbstractTransactionBoundaryCommand {
public static final byte METHOD_ID = 10;
- protected List<WriteCommand> modifications;
+ protected WriteCommand[] modifications;
protected Address localAddress;
protected boolean onePhaseCommit;
- public PrepareCommand(GlobalTransaction gtx, List<WriteCommand> modifications, Address localAddress, boolean onePhaseCommit) {
+ public PrepareCommand(GlobalTransaction gtx, Address localAddress, boolean onePhaseCommit, WriteCommand... modifications) {
this.gtx = gtx;
this.modifications = modifications;
this.localAddress = localAddress;
this.onePhaseCommit = onePhaseCommit;
}
+ public PrepareCommand(GlobalTransaction gtx, List<WriteCommand> commands, Address localAddress, boolean onePhaseCommit) {
+ this.gtx = gtx;
+ this.modifications = commands == null || commands.size() == 0 ? null : commands.toArray(new WriteCommand[commands.size()]);
+ this.localAddress = localAddress;
+ this.onePhaseCommit = onePhaseCommit;
+ }
+
public void removeModifications(Collection<WriteCommand> modificationsToRemove) {
- if (modifications != null) modifications.removeAll(modificationsToRemove);
+ if (modifications != null && modificationsToRemove != null && modificationsToRemove.size() > 0) {
+ // defensive copy
+ Set<WriteCommand> toRemove = new HashSet<WriteCommand>(modificationsToRemove);
+ WriteCommand[] newMods = new WriteCommand[modifications.length - modificationsToRemove.size()];
+ int i = 0;
+ for (WriteCommand c : modifications) {
+ if (toRemove.contains(c)) {
+ toRemove.remove(c);
+ } else {
+ newMods[i++] = c;
+ }
+ }
+ modifications = newMods;
+ }
}
public PrepareCommand() {
@@ -63,7 +85,7 @@
return visitor.visitPrepareCommand(ctx, this);
}
- public List<WriteCommand> getModifications() {
+ public WriteCommand[] getModifications() {
return modifications;
}
@@ -76,11 +98,11 @@
}
public boolean existModifications() {
- return modifications != null && modifications.size() > 0;
+ return modifications != null && modifications.length > 0;
}
public int getModificationsCount() {
- return modifications != null ? modifications.size() : 0;
+ return modifications != null ? modifications.length : 0;
}
public byte getCommandId() {
@@ -89,16 +111,27 @@
@Override
public Object[] getParameters() {
- return new Object[]{gtx, modifications, localAddress, onePhaseCommit};
+ int numMods = modifications == null ? 0 : modifications.length;
+ Object[] retval = new Object[numMods + 4];
+ retval[0] = gtx;
+ retval[1] = localAddress;
+ retval[2] = onePhaseCommit;
+ retval[3] = numMods;
+ if (numMods > 0) System.arraycopy(modifications, 0, retval, 4, numMods);
+ return retval;
}
@Override
@SuppressWarnings("unchecked")
public void setParameters(int commandId, Object[] args) {
gtx = (GlobalTransaction) args[0];
- modifications = (List<WriteCommand>) args[1];
- localAddress = (Address) args[2];
- onePhaseCommit = (Boolean) args[3];
+ localAddress = (Address) args[1];
+ onePhaseCommit = (Boolean) args[2];
+ int numMods = (Integer) args[3];
+ if (numMods > 0) {
+ modifications = new WriteCommand[numMods];
+ System.arraycopy(args, 4, modifications, 0, numMods);
+ }
}
@Override
@@ -129,7 +162,7 @@
PrepareCommand copy = new PrepareCommand();
copy.gtx = gtx;
copy.localAddress = localAddress;
- copy.modifications = modifications == null ? null : new ArrayList<WriteCommand>(modifications);
+ copy.modifications = modifications == null ? null : modifications.clone();
copy.onePhaseCommit = onePhaseCommit;
return copy;
}
@@ -138,7 +171,7 @@
public String toString() {
return "PrepareCommand{" +
"globalTransaction=" + gtx +
- ", modifications=" + modifications +
+ ", modifications=" + Arrays.toString(modifications) +
", localAddress=" + localAddress +
", onePhaseCommit=" + onePhaseCommit +
'}';
Modified: core/branches/flat/src/main/java/org/horizon/factories/DefaultCacheFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/DefaultCacheFactory.java 2009-03-09 09:03:53 UTC (rev 7889)
+++ core/branches/flat/src/main/java/org/horizon/factories/DefaultCacheFactory.java 2009-03-09 09:05:21 UTC (rev 7890)
@@ -54,9 +54,7 @@
*/
public Cache<K, V> createCache(Configuration configuration, GlobalComponentRegistry globalComponentRegistry, String cacheName) throws ConfigurationException {
try {
- AdvancedCache<K, V> cache = createAndWire(configuration, globalComponentRegistry, cacheName);
- cache.start();
- return cache;
+ return createAndWire(configuration, globalComponentRegistry, cacheName);
}
catch (ConfigurationException ce) {
throw ce;
Modified: core/branches/flat/src/main/java/org/horizon/interceptors/InvalidationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/interceptors/InvalidationInterceptor.java 2009-03-09 09:03:53 UTC (rev 7889)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/InvalidationInterceptor.java 2009-03-09 09:05:21 UTC (rev 7890)
@@ -45,7 +45,7 @@
import javax.transaction.SystemException;
import javax.transaction.Transaction;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -125,10 +125,10 @@
if (transactionContext.hasModifications()) {
List<WriteCommand> mods;
if (transactionContext.hasLocalModifications()) {
- mods = new ArrayList<WriteCommand>(command.getModifications());
+ mods = Arrays.asList(command.getModifications());
mods.removeAll(transactionContext.getLocalModifications());
} else {
- mods = command.getModifications();
+ mods = Arrays.asList(command.getModifications());
}
broadcastInvalidate(mods, tx, ctx);
} else {
@@ -254,4 +254,4 @@
public long getInvalidations() {
return invalidations.get();
}
-}
\ No newline at end of file
+}
Modified: core/branches/flat/src/main/java/org/horizon/interceptors/ReplicationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/interceptors/ReplicationInterceptor.java 2009-03-09 09:03:53 UTC (rev 7889)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/ReplicationInterceptor.java 2009-03-09 09:05:21 UTC (rev 7890)
@@ -57,7 +57,7 @@
Object retVal = invokeNextInterceptor(ctx, command);
TransactionContext transactionContext = ctx.getTransactionContext();
if (transactionContext.hasLocalModifications()) {
- PrepareCommand replicablePrepareCommand = command.copy(); // makre sure we remove any "local" transactions
+ PrepareCommand replicablePrepareCommand = command.copy(); // make sure we remove any "local" transactions
replicablePrepareCommand.removeModifications(transactionContext.getLocalModifications());
command = replicablePrepareCommand;
}
@@ -144,4 +144,4 @@
// this method will return immediately if we're the only member (because exclude_self=true)
replicateCall(ctx, prepareMethod, !async);
}
-}
\ No newline at end of file
+}
Modified: core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java 2009-03-09 09:03:53 UTC (rev 7889)
+++ core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java 2009-03-09 09:05:21 UTC (rev 7890)
@@ -374,4 +374,9 @@
public ComponentStatus getStatus() {
return globalComponentRegistry.getStatus();
}
+
+ @Override
+ public String toString() {
+ return super.toString() + "@Address:" + getAddress();
+ }
}
Modified: core/branches/flat/src/main/java/org/horizon/marshall/HorizonMarshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/marshall/HorizonMarshaller.java 2009-03-09 09:03:53 UTC (rev 7889)
+++ core/branches/flat/src/main/java/org/horizon/marshall/HorizonMarshaller.java 2009-03-09 09:05:21 UTC (rev 7890)
@@ -196,7 +196,10 @@
out.writeByte(MAGICNUMBER_TRANSACTION_LOG);
TransactionLog.LogEntry le = (TransactionLog.LogEntry) o;
marshallObject(le.getTransaction(), out, refMap);
- marshallObject(le.getModifications(), out, refMap);
+ WriteCommand[] cmds = le.getModifications();
+ writeUnsignedInt(out, cmds.length);
+ for (WriteCommand c : cmds)
+ marshallObject(c, out, refMap);
} else if (o instanceof Serializable) {
if (trace) log.trace("WARNING: using object serialization for [{0}]", o.getClass());
@@ -313,8 +316,11 @@
retVal = unmarshallJGroupsAddress(in);
return retVal;
case MAGICNUMBER_TRANSACTION_LOG:
- retVal = new TransactionLog.LogEntry((GlobalTransaction) unmarshallObject(in, refMap), (List<WriteCommand>) unmarshallObject(in, refMap));
- return retVal;
+ GlobalTransaction gtx = (GlobalTransaction) unmarshallObject(in, refMap);
+ int numCommands = readUnsignedInt(in);
+ WriteCommand[] cmds = new WriteCommand[numCommands];
+ for (int i = 0; i < numCommands; i++) cmds[i] = (WriteCommand) unmarshallObject(in, refMap);
+ return new TransactionLog.LogEntry(gtx, cmds);
case MAGICNUMBER_ARRAY:
return unmarshallArray(in, refMap);
case MAGICNUMBER_ARRAY_LIST:
@@ -783,4 +789,4 @@
public Object objectFromByteBuffer(byte[] bytes) throws IOException, ClassNotFoundException {
return objectFromByteBuffer(bytes, 0, bytes.length);
}
-}
\ No newline at end of file
+}
Modified: core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/CommandAwareRpcDispatcher.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/CommandAwareRpcDispatcher.java 2009-03-09 09:03:53 UTC (rev 7889)
+++ core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/CommandAwareRpcDispatcher.java 2009-03-09 09:05:21 UTC (rev 7890)
@@ -24,6 +24,7 @@
import org.horizon.CacheException;
import org.horizon.commands.RPCCommand;
import org.horizon.commands.ReplicableCommand;
+import org.horizon.commands.remote.ClusteredGetCommand;
import org.horizon.logging.Log;
import org.horizon.logging.LogFactory;
import org.horizon.remoting.InboundInvocationHandler;
@@ -166,10 +167,16 @@
if (replayIgnored) {
ExtendedResponse extended = new ExtendedResponse(retval);
extended.setReplayIgnoredRequests(true);
- retval = extended;
+ return extended;
+ } else {
+
+ // Do we really need a response?!? The caller would only ever expect a response for certain types of
+ // commands, such as a ClusteredGet
+ if (cmd.isSingleCommand() && cmd.getSingleCommand() instanceof ClusteredGetCommand)
+ return retval;
+ else
+ return null; // saves on serializing a response!
}
- return retval;
-
} finally {
if (unlock) distributedSync.releaseProcessingLock();
}
@@ -254,4 +261,4 @@
return retval;
}
}
-}
\ No newline at end of file
+}
Modified: core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/JGroupsTransport.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/JGroupsTransport.java 2009-03-09 09:03:53 UTC (rev 7889)
+++ core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/JGroupsTransport.java 2009-03-09 09:05:21 UTC (rev 7890)
@@ -307,7 +307,7 @@
}
public Address getAddress() {
- if (address == null) {
+ if (address == null && channel != null) {
address = new JGroupsAddress(channel.getLocalAddress());
}
return address;
Modified: core/branches/flat/src/main/java/org/horizon/statetransfer/StateTransferManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/statetransfer/StateTransferManagerImpl.java 2009-03-09 09:03:53 UTC (rev 7889)
+++ core/branches/flat/src/main/java/org/horizon/statetransfer/StateTransferManagerImpl.java 2009-03-09 09:05:21 UTC (rev 7890)
@@ -53,7 +53,7 @@
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
-import java.util.List;
+import java.util.Arrays;
import java.util.Set;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
@@ -195,8 +195,8 @@
private void processCommitLog(ObjectInputStream ois) throws Exception {
Object object = marshaller.objectFromObjectStream(ois);
while (object instanceof TransactionLog.LogEntry) {
- List<WriteCommand> mods = ((TransactionLog.LogEntry) object).getModifications();
- if (trace) log.trace("Mods = {0}", mods);
+ WriteCommand[] mods = ((TransactionLog.LogEntry) object).getModifications();
+ if (trace) log.trace("Mods = {0}", Arrays.toString(mods));
for (WriteCommand mod : mods) {
InvocationContext ctx = invocationContextContainer.get();
ctx.setOriginLocal(false);
Modified: core/branches/flat/src/main/java/org/horizon/transaction/TransactionLog.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/transaction/TransactionLog.java 2009-03-09 09:03:53 UTC (rev 7889)
+++ core/branches/flat/src/main/java/org/horizon/transaction/TransactionLog.java 2009-03-09 09:05:21 UTC (rev 7890)
@@ -48,9 +48,9 @@
public static class LogEntry {
private final GlobalTransaction transaction;
- private final List<WriteCommand> modifications;
+ private final WriteCommand[] modifications;
- public LogEntry(GlobalTransaction transaction, List<WriteCommand> modifications) {
+ public LogEntry(GlobalTransaction transaction, WriteCommand... modifications) {
this.transaction = transaction;
this.modifications = modifications;
}
@@ -59,7 +59,7 @@
return transaction;
}
- public List<WriteCommand> getModifications() {
+ public WriteCommand[] getModifications() {
return modifications;
}
}
@@ -75,20 +75,18 @@
// it is perfectly normal for a prepare not to be logged for this gtx, for example if a transaction did not
// modify anything, then beforeCompletion() is not invoked and logPrepare() will not be called to register the
// prepare.
- if (command != null) addEntry(new LogEntry(gtx, command.getModifications()));
+ if (command != null && isActive()) addEntry(gtx, command.getModifications());
}
- private void addEntry(LogEntry entry) {
- if (!isActive())
- return;
-
- for (; ;) {
+ private void addEntry(GlobalTransaction gtx, WriteCommand... commands) {
+ LogEntry entry = new LogEntry(gtx, commands);
+ boolean success = false;
+ while (!success) {
try {
- if (log.isTraceEnabled())
- log.trace("Added commit entry to tx log" + entry);
+ if (log.isTraceEnabled()) log.trace("Added commit entry to tx log {0}", entry);
entries.put(entry);
- break;
+ success = true;
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
@@ -99,16 +97,12 @@
public final void logOnePhaseCommit(GlobalTransaction gtx, List<WriteCommand> modifications) {
// Just in case...
if (gtx != null) pendingPrepares.remove(gtx);
- if (!modifications.isEmpty()) addEntry(new LogEntry(gtx, modifications));
+ if (isActive() && modifications != null && modifications.size() > 0)
+ addEntry(gtx, modifications.toArray(new WriteCommand[modifications.size()]));
}
public final void logNoTxWrite(WriteCommand write) {
- if (!isActive())
- return;
-
- ArrayList<WriteCommand> list = new ArrayList<WriteCommand>();
- list.add(write);
- addEntry(new LogEntry(null, list));
+ if (isActive()) addEntry(null, write);
}
public void rollback(GlobalTransaction gtx) {
@@ -130,7 +124,7 @@
entries.clear();
}
- public int size() {
+ public final int size() {
return entries.size();
}
15 years, 10 months
JBoss Cache SVN: r7889 - core/branches/flat/src/test/java/org/horizon/api.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-09 05:03:53 -0400 (Mon, 09 Mar 2009)
New Revision: 7889
Modified:
core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java
Log:
Improved test
Modified: core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java 2009-03-09 00:53:29 UTC (rev 7888)
+++ core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java 2009-03-09 09:03:53 UTC (rev 7889)
@@ -4,43 +4,39 @@
import org.horizon.config.Configuration;
import org.horizon.config.Configuration.CacheMode;
import org.horizon.manager.CacheManager;
+import org.horizon.test.MultipleCacheManagersTest;
import org.horizon.test.TestingUtil;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.List;
-@Test(groups = "functional", testName = "api.CacheClusterJoinTest")
-public class CacheClusterJoinTest {
+@Test(groups = "functional", testName = "api.CacheClusterJoinTest", enabled = false)
+public class CacheClusterJoinTest extends MultipleCacheManagersTest {
Cache cache1, cache2;
CacheManager cm1, cm2;
Configuration cfg;
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception {
- cm1 = TestingUtil.createClusteredCacheManager();
+ public CacheClusterJoinTest() {
+ cleanup = CleanupPhase.AFTER_METHOD;
+ }
+
+ protected void createCacheManagers() throws Throwable {
+ cm1 = addClusterEnabledCacheManager();
cfg = new Configuration();
cfg.setCacheMode(CacheMode.REPL_SYNC);
cfg.setFetchInMemoryState(false);
cm1.defineCache("cache", cfg);
}
- @AfterMethod
- public void tearDown()
- {
- TestingUtil.killCacheManagers(cm1, cm2);
- }
-
public void testGetMembers() throws Exception {
cm1.getCache("cache"); // this will make sure any lazy components are started.
List memb1 = cm1.getMembers();
- assert 1 == memb1.size();
+ assert 1 == memb1.size() : "Expected 1 member; was " + memb1;
Object coord = memb1.get(0);
- cm2 = TestingUtil.createClusteredCacheManager();
- cm2.defineCache("cache", cfg);
+ cm2 = addClusterEnabledCacheManager();
+ cm2.defineCache("cache", cfg.clone());
cm2.getCache("cache"); // this will make sure any lazy components are started.
TestingUtil.blockUntilViewsReceived(50000, true, cm1, cm2);
memb1 = cm1.getMembers();
@@ -57,10 +53,10 @@
public void testIsCoordinator() throws Exception {
cm1.getCache("cache"); // this will make sure any lazy components are started.
- assert cm1.isCoordinator();
+ assert cm1.isCoordinator() : "Should be coordinator!";
- cm2 = TestingUtil.createClusteredCacheManager();
- cm2.defineCache("cache", cfg);
+ cm2 = addClusterEnabledCacheManager();
+ cm2.defineCache("cache", cfg.clone());
cm2.getCache("cache"); // this will make sure any lazy components are started.
assert cm1.isCoordinator();
assert !cm2.isCoordinator();
@@ -69,4 +65,4 @@
TestingUtil.blockUntilViewsReceived(50000, false, cm2);
assert cm2.isCoordinator();
}
-}
\ No newline at end of file
+}
15 years, 10 months
JBoss Cache SVN: r7888 - core/branches/flat/src/test/java/org/horizon/loader/jdbm.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-08 20:53:29 -0400 (Sun, 08 Mar 2009)
New Revision: 7888
Modified:
core/branches/flat/src/test/java/org/horizon/loader/jdbm/JdbmLearningTest.java
Log:
Disabled for now
Modified: core/branches/flat/src/test/java/org/horizon/loader/jdbm/JdbmLearningTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/jdbm/JdbmLearningTest.java 2009-03-09 00:50:28 UTC (rev 7887)
+++ core/branches/flat/src/test/java/org/horizon/loader/jdbm/JdbmLearningTest.java 2009-03-09 00:53:29 UTC (rev 7888)
@@ -583,7 +583,6 @@
assert expected.isEmpty();
}
- @Test
public void testStoreAndRemoveAll() throws CacheLoaderException {
store(new StoredEntry("k1", "v1", -1, -1));
store(new StoredEntry("k2", "v2", -1, -1));
15 years, 10 months
JBoss Cache SVN: r7887 - core/branches/flat/src/test/java/org/horizon/loader/jdbm.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-08 20:50:28 -0400 (Sun, 08 Mar 2009)
New Revision: 7887
Modified:
core/branches/flat/src/test/java/org/horizon/loader/jdbm/JdbmLearningTest.java
Log:
Disabled for now
Modified: core/branches/flat/src/test/java/org/horizon/loader/jdbm/JdbmLearningTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/jdbm/JdbmLearningTest.java 2009-03-09 00:48:18 UTC (rev 7886)
+++ core/branches/flat/src/test/java/org/horizon/loader/jdbm/JdbmLearningTest.java 2009-03-09 00:50:28 UTC (rev 7887)
@@ -46,7 +46,7 @@
* @version $Id: $
* @since 1.0
*/
-@Test(groups = "unit", enabled = true, testName = "loader.bdbje.JdbmLearningTest")
+@Test(groups = "unit", enabled = false, testName = "loader.jdbm.JdbmLearningTest")
public class JdbmLearningTest {
private static final Log log = LogFactory.getLog(JdbmLearningTest.class);
15 years, 10 months
JBoss Cache SVN: r7886 - core/branches/flat/src/test/java/org/horizon/statetransfer.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-08 20:48:18 -0400 (Sun, 08 Mar 2009)
New Revision: 7886
Modified:
core/branches/flat/src/test/java/org/horizon/statetransfer/StateTransferCacheLoaderFunctionalTest.java
core/branches/flat/src/test/java/org/horizon/statetransfer/StateTransferFunctionalTest.java
Log:
Disabled state transfer tests for now
Modified: core/branches/flat/src/test/java/org/horizon/statetransfer/StateTransferCacheLoaderFunctionalTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/statetransfer/StateTransferCacheLoaderFunctionalTest.java 2009-03-08 23:58:09 UTC (rev 7885)
+++ core/branches/flat/src/test/java/org/horizon/statetransfer/StateTransferCacheLoaderFunctionalTest.java 2009-03-09 00:48:18 UTC (rev 7886)
@@ -10,7 +10,7 @@
import org.horizon.test.TestingUtil;
import org.testng.annotations.Test;
-@Test(groups = "functional", testName = "statetransfer.StateTransferCacheLoaderFunctionalTest", enabled = true)
+@Test(groups = "functional", testName = "statetransfer.StateTransferCacheLoaderFunctionalTest", enabled = false)
public class StateTransferCacheLoaderFunctionalTest extends StateTransferFunctionalTest {
int id;
ThreadLocal<Boolean> sharedCacheLoader = new ThreadLocal<Boolean>() {
Modified: core/branches/flat/src/test/java/org/horizon/statetransfer/StateTransferFunctionalTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/statetransfer/StateTransferFunctionalTest.java 2009-03-08 23:58:09 UTC (rev 7885)
+++ core/branches/flat/src/test/java/org/horizon/statetransfer/StateTransferFunctionalTest.java 2009-03-09 00:48:18 UTC (rev 7886)
@@ -16,7 +16,7 @@
import java.io.ObjectOutputStream;
import java.io.Serializable;
-@Test(groups = "functional", testName = "statetransfer.StateTransferFunctionalTest", enabled = true)
+@Test(groups = "functional", testName = "statetransfer.StateTransferFunctionalTest", enabled = false)
public class StateTransferFunctionalTest extends MultipleCacheManagersTest {
protected static final String ADDRESS_CLASSNAME = Address.class.getName();
15 years, 10 months
JBoss Cache SVN: r7885 - in core/trunk/src/main/java/org/jboss/cache: transaction and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-08 19:58:09 -0400 (Sun, 08 Mar 2009)
New Revision: 7885
Modified:
core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionLog.java
Log:
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2009-03-08 21:03:03 UTC (rev 7884)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2009-03-08 23:58:09 UTC (rev 7885)
@@ -21,24 +21,6 @@
*/
package org.jboss.cache.marshall;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.IdentityHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.commons.httpclient.cookie.IgnoreCookiesSpec;
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
@@ -56,6 +38,13 @@
import org.jgroups.Address;
import org.jgroups.stack.IpAddress;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.*;
+
/**
* An enhanced marshaller for RPC calls between CacheImpl instances.
*
@@ -485,7 +474,13 @@
private void marshallLogEntry(LogEntry log, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception
{
marshallObject(log.getTransaction(), out, refMap);
- marshallObject(log.getModifications(), out, refMap);
+ List<WriteCommand> mods = log.getModifications();
+ boolean isList = mods.size() > 1;
+ out.writeBoolean(isList);
+ if (isList)
+ marshallObject(log.getModifications(), out, refMap);
+ else
+ marshallObject(mods.get(0), out, refMap);
}
private void marshallGravitateResult(GravitateResult gravitateResult, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception
@@ -718,8 +713,12 @@
private LogEntry unmarshallLogEntry(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception
{
GlobalTransaction gtx = (GlobalTransaction)unmarshallObject(in, refMap);
- List<WriteCommand> mods = (List<WriteCommand>)unmarshallObject(in, refMap);
-
+ boolean isList = in.readBoolean();
+ List mods;
+ if (isList)
+ mods = (List)unmarshallObject(in, refMap);
+ else
+ mods = Collections.singletonList(unmarshallObject(in, refMap));
return new LogEntry(gtx, mods);
}
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionLog.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionLog.java 2009-03-08 21:03:03 UTC (rev 7884)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionLog.java 2009-03-08 23:58:09 UTC (rev 7885)
@@ -29,6 +29,7 @@
import java.io.ObjectOutputStream;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
@@ -82,13 +83,17 @@
// it is perfectly normal for a prepare not to be logged for this gtx, for example if a transaction did not
// modify anything, then beforeCompletion() is not invoked and logPrepare() will not be called to register the
// prepare.
- if (command != null) addEntry(new LogEntry(gtx, command.getModifications()));
+ if (command != null && isActive()) addEntry(gtx, command.getModifications());
}
- private void addEntry(LogEntry entry)
+ private void addEntry(GlobalTransaction gtx, WriteCommand command)
+ {
+ addEntry(gtx, Collections.singletonList(command));
+ }
+
+ private void addEntry(GlobalTransaction gtx, List<WriteCommand> commands)
{
- if (! isActive())
- return;
+ LogEntry entry = new LogEntry(gtx, commands);
for (;;)
{
@@ -111,17 +116,12 @@
{
// Just in case...
if (gtx != null) pendingPrepares.remove(gtx);
- if (!modifications.isEmpty()) addEntry(new LogEntry(gtx, modifications));
+ if (isActive() && !modifications.isEmpty()) addEntry(gtx, modifications);
}
public void logNoTxWrite(WriteCommand write)
{
- if (! isActive())
- return;
-
- ArrayList<WriteCommand> list = new ArrayList<WriteCommand>();
- list.add(write);
- addEntry(new LogEntry(null, list));
+ if (isActive()) addEntry(null, write);
}
public void rollback(GlobalTransaction gtx)
@@ -129,7 +129,7 @@
pendingPrepares.remove(gtx);
}
- public boolean isActive()
+ public final boolean isActive()
{
return active.get();
}
@@ -171,7 +171,7 @@
marshaller.objectToObjectStream(entry, out);
}
- public boolean hasPendingPrepare(PrepareCommand command)
+ public final boolean hasPendingPrepare(PrepareCommand command)
{
return pendingPrepares.containsKey(command.getGlobalTransaction());
}
15 years, 10 months