Author: davsclaus
Date: Mon Mar 1 17:05:05 2010
New Revision: 917590
URL: http://svn.apache.org/viewvc?rev=917590&view=rev
Log:
CAMEL-217: Added debug logging for repo activity
Modified:
camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepository.java
camel/trunk/components/camel-hawtdb/src/test/resources/log4j.properties
Modified:
camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepository.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepository.java?rev=917590&r1=917589&r2=917590&view=diff
==============================================================================
---
camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepository.java
(original)
+++
camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepository.java
Mon Mar 1 17:05:05 2010
@@ -28,6 +28,8 @@
import org.apache.camel.spi.AggregationRepository;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.ServiceHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.fusesource.hawtdb.api.Index;
import org.fusesource.hawtdb.api.Transaction;
import org.fusesource.hawtdb.util.buffer.Buffer;
@@ -41,6 +43,7 @@
*/
public class HawtDBAggregationRepository<K> extends ServiceSupport implements
AggregationRepository<K> {
+ private static final transient Log LOG =
LogFactory.getLog(HawtDBAggregationRepository.class);
private HawtDBFile hawtDBFile;
private String persistentFileName;
private String repositoryName;
@@ -93,6 +96,9 @@
}
public Exchange add(CamelContext camelContext, K key, Exchange exchange) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Adding key [" + key + "] -> " + exchange);
+ }
try {
// If we could guarantee that the key and exchange are immutable,
// then we could have stuck them directly into the index,
@@ -111,14 +117,17 @@
return null;
}
// we can improve performance by not returning the old when adding
- return unmarshallExchange(camelContext, rc);
+ // return unmarshallExchange(camelContext, rc);
} catch (IOException e) {
throw new RuntimeException("Error adding to repository " +
repositoryName + " with key " + key, e);
}
+
+ return null;
}
public Exchange get(CamelContext camelContext, K key) {
+ Exchange answer = null;
try {
final Buffer keyBuffer = marshallKey(key);
Buffer rc = hawtDBFile.execute(new Work<Buffer>() {
@@ -127,16 +136,23 @@
return index.get(keyBuffer);
}
});
- if (rc == null) {
- return null;
+ if (rc != null) {
+ answer = unmarshallExchange(camelContext, rc);
}
- return unmarshallExchange(camelContext, rc);
} catch (IOException e) {
throw new RuntimeException("Error getting key " + key + " from
repository " + repositoryName, e);
}
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Getting key [" + key + "] -> " + answer);
+ }
+ return answer;
}
public void remove(CamelContext camelContext, K key) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Removing key [" + key + "]");
+ }
try {
final Buffer keyBuffer = marshallKey(key);
hawtDBFile.execute(new Work<Buffer>() {
Modified:
camel/trunk/components/camel-hawtdb/src/test/resources/log4j.properties
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-hawtdb/src/test/resources/log4j.properties?rev=917590&r1=917589&r2=917590&view=diff
==============================================================================
--- camel/trunk/components/camel-hawtdb/src/test/resources/log4j.properties
(original)
+++ camel/trunk/components/camel-hawtdb/src/test/resources/log4j.properties Mon
Mar 1 17:05:05 2010
@@ -28,7 +28,7 @@
log4j.appender.out=org.apache.log4j.ConsoleAppender
log4j.appender.out.layout=org.apache.log4j.PatternLayout
#log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
-log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} -
%m%n
+log4j.appender.out.layout.ConversionPattern=%d [%-50.50t] %-5p %-30.30c{1} -
%m%n
# File appender
log4j.appender.file=org.apache.log4j.FileAppender