Author: adriancole
Date: 2009-03-02 13:59:01 -0500 (Mon, 02 Mar 2009)
New Revision: 7824
Modified:
core/branches/flat/src/main/java/org/horizon/loader/bdbje/BdbjeCacheStore.java
Log:
guarding trace logging
Modified: core/branches/flat/src/main/java/org/horizon/loader/bdbje/BdbjeCacheStore.java
===================================================================
---
core/branches/flat/src/main/java/org/horizon/loader/bdbje/BdbjeCacheStore.java 2009-03-02
18:52:30 UTC (rev 7823)
+++
core/branches/flat/src/main/java/org/horizon/loader/bdbje/BdbjeCacheStore.java 2009-03-02
18:59:01 UTC (rev 7824)
@@ -58,6 +58,7 @@
public class BdbjeCacheStore extends AbstractCacheStore {
private static final Log log = LogFactory.getLog(BdbjeCacheStore.class);
+ private static final boolean trace = log.isTraceEnabled();
private BdbjeCacheStoreConfig cfg;
private Cache cache;
@@ -81,7 +82,7 @@
* @see BdbjeCacheStoreConfig
*/
public void init(CacheLoaderConfig config, Cache cache, Marshaller m) {
- log.trace("initializing BdbjeCacheStore");
+ if (trace) log.trace("initializing BdbjeCacheStore");
printLicense();
this.cfg = (BdbjeCacheStoreConfig) config;
this.cache = cache;
@@ -104,7 +105,7 @@
* transactional services are instantiated.
*/
public void start() throws CacheLoaderException {
- log.trace("starting BdbjeCacheStore");
+ if (trace) log.trace("starting BdbjeCacheStore");
checkNotOpen();
if (cache == null) {
@@ -155,7 +156,7 @@
envConfig.setConfigParam("je.txn.deadlockStackTrace",
"true");
envConfig.setConfigParam("je.txn.dumpLocks", "true");
}
- log.trace("creating je environment with home dir {0}", location);
+ if (trace) log.trace("creating je environment with home dir {0}",
location);
env = new Environment(location, envConfig);
log.debug("created je environment {0} for cache store {1}", env,
this);
/* Open cache and catalog databases. */
@@ -178,17 +179,17 @@
* associated} with the stored entry and class catalog databases.
*/
private void openDatabases() throws DatabaseException {
- log.trace("opening databases");
+ if (trace) log.trace("opening databases");
/* Use a generic database config, with no duplicates allowed. */
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
- log.trace("opening or creating stored entry database {0}", cacheDbName);
+ if (trace) log.trace("opening or creating stored entry database {0}",
cacheDbName);
cacheDb = env.openDatabase(null, cacheDbName, dbConfig);
log.debug("opened stored entry database {0}", cacheDbName);
- log.trace("opening or creating class catalog database {0}",
catalogDbName);
+ if (trace) log.trace("opening or creating class catalog database {0}",
catalogDbName);
Database catalogDb = env.openDatabase(null, catalogDbName, dbConfig);
catalog = new StoredClassCatalog(catalogDb);
log.debug("created stored class catalog from database {0}",
catalogDbName);
@@ -223,7 +224,7 @@
* not removed from the file system. Exceptions during close are ignored.
*/
private void closeDatabases() {
- log.trace("closing databases");
+ if (trace) log.trace("closing databases");
try {
cacheDb.close();
catalog.close();
@@ -243,7 +244,7 @@
*/
public void stop() throws CacheLoaderException {
checkOpen();
- log.trace("stopping BdbjeCacheStore");
+ if (trace) log.trace("stopping BdbjeCacheStore");
transactionRunner = null;
currentTransaction = null;
txnMap = null;
@@ -307,7 +308,7 @@
try {
transactionRunner.prepare(new ModificationsTransactionWorker(this, mods));
Transaction txn = currentTransaction.getTransaction();
- log.trace("transaction {0} == sleepycat transaction {1}", tx, txn);
+ if (trace) log.trace("transaction {0} == sleepycat transaction {1}",
tx, txn);
txnMap.put(tx, txn);
ReflectionUtil.setValue(currentTransaction, "localTrans", new
ThreadLocal());
} catch (Exception e) {
@@ -410,7 +411,7 @@
public boolean remove(Object key) throws CacheLoaderException {
checkOpen();
checkNonNull(key, "key");
- log.trace("Removing key {0}", key);
+ if (trace) log.trace("Removing key {0}", key);
try {
if (cacheMap.containsKey(key)) {
cacheMap.remove(key);
@@ -430,7 +431,7 @@
public StoredEntry load(Object key) throws CacheLoaderException {
checkOpen();
checkNonNull(key, "key");
- log.trace("Loading key {0}", key);
+ if (trace) log.trace("Loading key {0}", key);
try {
StoredEntry s = cacheMap.get(key);
if (s == null)
@@ -452,7 +453,7 @@
public void store(StoredEntry ed) throws CacheLoaderException {
checkOpen();
checkNonNull(ed, "entry");
- log.trace("Storing entry {0}", ed);
+ if (trace) log.trace("Storing entry {0}", ed);
try {
cacheMap.put(ed.getKey(), ed);
} catch (Exception caught) {
@@ -466,7 +467,7 @@
*/
public void clear() throws CacheLoaderException {
checkOpen();
- log.trace("Clearing store");
+ if (trace) log.trace("Clearing store");
try {cacheMap.clear(); } catch (Exception caught) {
caught = ExceptionUnwrapper.unwrap(caught);
throw new CacheLoaderException("error clearing store", caught);
@@ -478,7 +479,7 @@
*/
public Set<StoredEntry> loadAll() throws CacheLoaderException {
checkOpen();
- log.trace("Loading all entries");
+ if (trace) log.trace("Loading all entries");
try {
return new HashSet(cacheMap.values());
} catch (Exception caught) {
@@ -537,7 +538,7 @@
*/
public void toStream(ObjectOutput oos) throws CacheLoaderException {
checkOpen();
- log.trace("dumping current database to outputstream");
+ if (trace) log.trace("dumping current database to outputstream");
Cursor cursor = null;
try {
currentTransaction.beginTransaction(null);