### Eclipse Workspace Patch 1.0 #P jetspeed-2.2-trunk Index: components/jetspeed-statistics/src/main/java/org/apache/jetspeed/statistics/impl/BatchedStatistics.java =================================================================== --- components/jetspeed-statistics/src/main/java/org/apache/jetspeed/statistics/impl/BatchedStatistics.java (revision 801600) +++ components/jetspeed-statistics/src/main/java/org/apache/jetspeed/statistics/impl/BatchedStatistics.java (working copy) @@ -19,12 +19,15 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +import java.util.Collection; import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; +import java.util.concurrent.ConcurrentLinkedQueue; import javax.sql.DataSource; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** *
* BatchedStatistics
@@ -84,18 +87,19 @@
if ((logRecords.size() >= batchSize)
|| (msCurrentTime - msLastFlushTime > msElapsedTimeThreshold))
{
- flush();
+ do {
+ flush();
+ }
+ while (logRecords.size() >= batchSize);
+
msLastFlushTime = msCurrentTime;
}
}
public void addStatistic(LogRecord logRecord)
{
- synchronized (logRecords)
- {
logRecords.add(logRecord);
- checkAndDoFlush();
- }
+ //checkAndDoFlush();
}
public boolean isDone()
@@ -128,17 +132,11 @@
{
keepRunning = false;
}
- synchronized (logRecords)
- {
- checkAndDoFlush();
- }
+ checkAndDoFlush();
}
// force a flush on the way out even if the constraints have not been
// met
- synchronized (logRecords)
- {
- flush();
- }
+ flush();
done = true;
}
@@ -154,32 +152,32 @@
Connection con = null;
PreparedStatement stm = null;
+ boolean autoCommit = true;
try
{
con = getConnection();
- boolean autoCommit = con.getAutoCommit();
+ autoCommit = con.getAutoCommit();
con.setAutoCommit(false);
stm = getPreparedStatement(con);
- Iterator recordIterator = logRecords.iterator();
+ Iterator