You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by un...@apache.org on 2005/08/12 13:15:21 UTC
svn commit: r232270 - in
/jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src:
share/org/apache/slide/store/ share/org/apache/slide/transaction/
stores/org/apache/slide/store/impl/rdbms/
Author: unico
Date: Fri Aug 12 04:15:12 2005
New Revision: 232270
URL: http://svn.apache.org/viewcvs?rev=232270&view=rev
Log:
guarded logging
Modified:
jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/store/AbstractStore.java
jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/store/ExtendedStore.java
jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/transaction/SlideTransactionManager.java
jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/AbstractRDBMSStore.java
jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java
jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java
Modified: jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/store/AbstractStore.java
URL: http://svn.apache.org/viewcvs/jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/store/AbstractStore.java?rev=232270&r1=232269&r2=232270&view=diff
==============================================================================
--- jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/store/AbstractStore.java (original)
+++ jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/store/AbstractStore.java Fri Aug 12 04:15:12 2005
@@ -1581,7 +1581,9 @@
transaction.delistResource(service, TMFAIL);
String logMessage = Messages.format
(AbstractStore.class.getName() + ".delistFail", service);
- getLogger().log(logMessage, LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log(logMessage, LOG_CHANNEL, Logger.DEBUG);
+ }
}
} catch (Exception e) {
// Something went wrong.
Modified: jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/store/ExtendedStore.java
URL: http://svn.apache.org/viewcvs/jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/store/ExtendedStore.java?rev=232270&r1=232269&r2=232270&view=diff
==============================================================================
--- jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/store/ExtendedStore.java (original)
+++ jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/store/ExtendedStore.java Fri Aug 12 04:15:12 2005
@@ -397,9 +397,11 @@
* @param key the key under which the object is stored in the caches.
*/
public void removeObjectFromCache( Object key ) {
- getLogger().log( "Removing " + key + " from cache.",
- LOG_CHANNEL,
- Logger.DEBUG );
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log( "Removing " + key + " from cache.",
+ LOG_CHANNEL,
+ Logger.DEBUG );
+ }
if ( contentStore.cacheResults() && contentCachingEnabled ) {
contentCache.remove( key.toString(), "_" );
}
@@ -426,27 +428,24 @@
Xid txId = (Xid) activeTransactionBranch.get();
if (txId != null) {
try {
- GenericLock lock = (GenericLock) lockManager
- .atomicGetOrCreateLock(uri);
+ GenericLock lock = (GenericLock) lockManager.atomicGetOrCreateLock(uri);
if (lock.getLockLevel(txId) != 1) {
- Object owner = lock.getOwner();
- getLogger()
- .log(
- "Try lock: "
- + txId
- + " tries "
- + uri
- + (owner != null ? " ---> "
- + owner.toString()
- + " has it" : ""),
- LOG_CHANNEL, Logger.DEBUG);
+ Object owner = lock.getOwner();
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("Try lock: "
+ + txId + " tries " + uri
+ + (owner != null ? " ---> " + owner + " has it" : ""),
+ LOG_CHANNEL, Logger.DEBUG);
+ }
if (!lock.acquire(txId, 1, true, true, timeout)) {
throw new ServiceAccessException(this,
new ConflictException(uri));
}
((HashSet) locks.get()).add(lock);
- getLogger().log("Has lock: " + txId + " locks " + uri,
- LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("Has lock: " + txId + " locks " + uri,
+ LOG_CHANNEL, Logger.DEBUG);
+ }
}
} catch (InterruptedException e) {
throw new ServiceAccessException(this, new ConflictException(
@@ -469,7 +468,9 @@
String key = uri.toString() + "_" + revisionDescriptor.getRevisionNumber();
Object result = contentCache.get(key);
if (result != null) {
- getLogger().log("Retrieving content at '" + key + "' from cache", LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("Retrieving content at '" + key + "' from cache", LOG_CHANNEL, Logger.DEBUG);
+ }
// FIXME make a copy?! how?
return (NodeRevisionContent) result;
} else {
@@ -989,14 +990,14 @@
// FIXME needs suspend and resume here as well!
public void start(Xid xid, int flags) throws XAException {
- getLogger().log(
- "Thread "
- + Thread.currentThread()
- + (flags == TMNOFLAGS ? " starts"
- : flags == TMJOIN ? " joins" : " resumes")
- + " work on behalf of transaction branch " + xid,
- LOG_CHANNEL, Logger.DEBUG);
-
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("Thread " + Thread.currentThread()
+ + (flags == TMNOFLAGS ? " starts"
+ : flags == TMJOIN ? " joins"
+ : " resumes")
+ + " work on behalf of transaction branch " + xid,
+ LOG_CHANNEL, Logger.DEBUG);
+ }
Xid txId = (Xid) XidWrapper.wrap(xid);
activeTransactionBranch.set(txId);
if (flags == TMNOFLAGS || flags == TMJOIN) {
@@ -1016,14 +1017,14 @@
}
public void end(Xid xid, int flags) throws XAException {
- getLogger().log(
- "Thread "
- + Thread.currentThread()
- + (flags == TMSUSPEND ? " suspends"
- : flags == TMFAIL ? " fails" : " ends")
- + " work on behalf of transaction branch " + xid,
- LOG_CHANNEL, Logger.DEBUG);
-
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("Thread " + Thread.currentThread()
+ + (flags == TMSUSPEND ? " suspends"
+ : flags == TMFAIL ? " fails"
+ : " ends")
+ + " work on behalf of transaction branch " + xid,
+ LOG_CHANNEL, Logger.DEBUG);
+ }
if (flags == TMSUSPEND) {
Xid txId = (Xid) XidWrapper.wrap(xid);
suspendedLocks.put(txId, locks.get());
@@ -1047,10 +1048,11 @@
for (Iterator it = ((HashSet)locks.get()).iterator(); it.hasNext();) {
GenericLock lock = (GenericLock) it.next();
lock.release(txId);
- getLogger().log(
- "Release lock: " + txId + " released " + lock.getResourceId().toString(),
- LOG_CHANNEL,
- Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log(
+ "Release lock: " + txId + " released " + lock.getResourceId().toString(),
+ LOG_CHANNEL, Logger.DEBUG);
+ }
}
}
@@ -1197,7 +1199,9 @@
try {
Xid txId = (Xid) activeTransactionBranch.get();
txCache.remove(txId, key);
- getLogger().log("Removing content at '" + key + "' from cache", LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("Removing content at '" + key + "' from cache", LOG_CHANNEL, Logger.DEBUG);
+ }
} catch (Error e) {
fatalError(e);
} catch (RuntimeException re) {
@@ -1211,7 +1215,9 @@
try {
Xid txId = (Xid) activeTransactionBranch.get();
txCache.remove(txId, key, delimiter);
- getLogger().log("Removing content at '" + key + "' with delimeter '" + delimiter + "' from cache", LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("Removing content at '" + key + "' with delimeter '" + delimiter + "' from cache", LOG_CHANNEL, Logger.DEBUG);
+ }
} catch (Error e) {
fatalError(e);
} catch (RuntimeException re) {
@@ -1276,10 +1282,12 @@
revisionContent.getContentBytes();
((ByteSizeLimitedObjectCache) getTxCache()).put(null, key, revisionContent, byteSize);
- getLogger().log(
- "Globally caching content at '" + key + "' with " + byteSize + " bytes",
- LOG_CHANNEL,
- Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log(
+ "Globally caching content at '" + key + "' with " + byteSize + " bytes",
+ LOG_CHANNEL,
+ Logger.DEBUG);
+ }
}
} catch (Error e) {
@@ -1300,10 +1308,12 @@
revisionContent.getContentBytes();
((ByteSizeLimitedObjectCache) getTxCache()).put(txId, key, revisionContent, byteSize);
- getLogger().log(
- "Caching content at '" + key + "' with " + byteSize + " bytes",
- LOG_CHANNEL,
- Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log(
+ "Caching content at '" + key + "' with " + byteSize + " bytes",
+ LOG_CHANNEL,
+ Logger.DEBUG);
+ }
} else {
// if we can not cache it, we need to invalidate global entry upon commit
getTxCache().remove(txId, key);
Modified: jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/transaction/SlideTransactionManager.java
URL: http://svn.apache.org/viewcvs/jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/transaction/SlideTransactionManager.java?rev=232270&r1=232269&r2=232270&view=diff
==============================================================================
--- jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/transaction/SlideTransactionManager.java (original)
+++ jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/share/org/apache/slide/transaction/SlideTransactionManager.java Fri Aug 12 04:15:12 2005
@@ -217,8 +217,9 @@
String logMessage = Messages.format
(SlideTransactionManager.class.getName() + ".rollback",
currentTransaction.toString());
- logger.log(logMessage, LOG_CHANNEL, Logger.DEBUG);
-
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log(logMessage, LOG_CHANNEL, Logger.DEBUG);
+ }
currentTransaction.rollback();
}
Modified: jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/AbstractRDBMSStore.java
URL: http://svn.apache.org/viewcvs/jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/AbstractRDBMSStore.java?rev=232270&r1=232269&r2=232270&view=diff
==============================================================================
--- jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/AbstractRDBMSStore.java (original)
+++ jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/AbstractRDBMSStore.java Fri Aug 12 04:15:12 2005
@@ -205,8 +205,9 @@
}
public Xid[] recover(int flag) throws XAException {
-
- getLogger().log("recover() for thread: " + Thread.currentThread(), LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("recover() for thread: " + Thread.currentThread(), LOG_CHANNEL, Logger.DEBUG);
+ }
TransactionalResource id = getCurrentlyActiveTransactionalResource();
if (id != null && id.getStatus() == STATUS_PREPARED) {
@@ -866,11 +867,14 @@
* Get the Connection object associated with the current transaction.
*/
protected Connection getCurrentConnection() throws ServiceAccessException {
-
- getLogger().log("Getting current connection for thread " + Thread.currentThread(), LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("Getting current connection for thread " + Thread.currentThread(), LOG_CHANNEL, Logger.DEBUG);
+ }
TransactionId id = (TransactionId) getCurrentlyActiveTransactionalResource();
if (id == null) {
- getLogger().log("No id for current thread - called outside transaction?", LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("No id for current thread - called outside transaction?", LOG_CHANNEL, Logger.DEBUG);
+ }
return null;
}
return id.connection;
Modified: jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java
URL: http://svn.apache.org/viewcvs/jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java?rev=232270&r1=232269&r2=232270&view=diff
==============================================================================
--- jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java (original)
+++ jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java Fri Aug 12 04:15:12 2005
@@ -307,7 +307,9 @@
File tempFile = null;
if (bcompress) {
- getLogger().log("Compressing the data", LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("Compressing the data", LOG_CHANNEL, Logger.DEBUG);
+ }
StoreContentZip ziputil = new StoreContentZip();
ziputil.Zip(is);
is = ziputil.getInputStream();
@@ -367,11 +369,12 @@
if (is != null) {
// XXX some JDBC drivers seem to close the stream upon closing of
// the statement; if so this will raise an IOException
- // silently ignore it...
try {
is.close();
} catch (IOException ioe) {
- logger.log("Could not close stream", ioe, LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("Could not close stream", ioe, LOG_CHANNEL, Logger.DEBUG);
+ }
}
}
}
Modified: jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java
URL: http://svn.apache.org/viewcvs/jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java?rev=232270&r1=232269&r2=232270&view=diff
==============================================================================
--- jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java (original)
+++ jakarta/slide/branches/SLIDE_2_1_RELEASE_BRANCH/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java Fri Aug 12 04:15:12 2005
@@ -767,7 +767,9 @@
}
result = new NodeRevisionContent();
if (bcompress) {
- getLogger().log("DeCompressing the data", LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("DeCompressing the data", LOG_CHANNEL, Logger.DEBUG);
+ }
StoreContentZip ziputil = new StoreContentZip();
ziputil.UnZip(is);
revisionDescriptor.setContentLength(ziputil.getContentLength());
@@ -1063,10 +1065,12 @@
}
}
}
- getLogger().log(
- revisionDescriptors.getOriginalUri() + revisionDescriptors.getInitialRevision(),
- LOG_CHANNEL,
- Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log(
+ revisionDescriptors.getOriginalUri() + revisionDescriptors.getInitialRevision(),
+ LOG_CHANNEL,
+ Logger.DEBUG);
+ }
} catch (SQLException e) {
throw createException(e, uri.toString());
}
@@ -1206,7 +1210,9 @@
if (is != null) {
long contentLength = 0;
if (bcompress) {
- getLogger().log("Compressing the data", LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("Compressing the data", LOG_CHANNEL, Logger.DEBUG);
+ }
StoreContentZip ziputil = new StoreContentZip();
ziputil.Zip(is);
is = ziputil.getInputStream();
@@ -1262,11 +1268,12 @@
if (is != null) {
// XXX some JDBC drivers seem to close the stream upon closing of
// the statement; if so this will raise an IOException
- // silently ignore it...
try {
is.close();
} catch (IOException ioe) {
- logger.log("Could not close stream", ioe, LOG_CHANNEL, Logger.DEBUG);
+ if (getLogger().isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
+ getLogger().log("Could not close stream", ioe, LOG_CHANNEL, Logger.DEBUG);
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org