Author: vgritsenko
Date: Fri Aug 10 21:25:23 2007
New Revision: 564833
URL: http://svn.apache.org/viewvc?view=rev&rev=564833
Log:
make DatabaseChangeObserver less chatty; add javadoc tags
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java
xml/xindice/trunk/java/src/org/apache/xindice/core/DatabaseChangeObserver.java
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java?view=diff&rev=564833&r1=564832&r2=564833
==============================================================================
---
xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java
(original)
+++
xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java
Fri Aug 10 21:25:23 2007
@@ -57,8 +57,8 @@
*/
public class CollectionImpl extends XindiceCollection {
- private Database db = null;
- private Collection col = null;
+ private Database db;
+ private Collection col;
/**
* Creates new <code>CollectionImpl</code> instance representing connection
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/core/DatabaseChangeObserver.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/DatabaseChangeObserver.java?view=diff&rev=564833&r1=564832&r2=564833
==============================================================================
---
xml/xindice/trunk/java/src/org/apache/xindice/core/DatabaseChangeObserver.java
(original)
+++
xml/xindice/trunk/java/src/org/apache/xindice/core/DatabaseChangeObserver.java
Fri Aug 10 21:25:23 2007
@@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
+ * $Id$
*/
-
package org.apache.xindice.core;
import java.util.Hashtable;
@@ -39,20 +39,26 @@
* This current version we are only going to worry about document changes and
* their Filer storage are kept updated.
*
- * <a href="mailto:[EMAIL PROTECTED]">Todd Byrne</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Todd Byrne</a>
+ * @version $Revision$, $Date$
*/
public class DatabaseChangeObserver extends DBObserver {
+
private static final Log log =
LogFactory.getLog(DatabaseChangeObserver.class);
+
+ /** One minute flush period **/
+ private static final long FLUSH_PERIOD = 1000 * 60;
+
// by using a hashtable instead of a queue collections only get added once.
- private Hashtable collectionDirtyFlags;
+ private final Hashtable collectionDirtyFlags;
private Timer flushTimer;
- /** One minute flush period **/
- private long FLUSH_PERIOD = 1000 * 60;
+
public DatabaseChangeObserver() {
collectionDirtyFlags = new Hashtable();
flushTimer = new Timer(true);
- flushTimer.schedule(new FlushTask(),FLUSH_PERIOD,FLUSH_PERIOD);
+ flushTimer.schedule(new FlushTask(), FLUSH_PERIOD, FLUSH_PERIOD);
}
+
/**
* Queues the collection to be flushed by the FlushTask synchronized
* by the hashtable
@@ -63,6 +69,7 @@
public void dropDocument(Collection col, Key key) throws DBException {
collectionDirtyFlags.put(col,Boolean.TRUE);
}
+
/**
*
* @param col Collection
@@ -92,6 +99,7 @@
*/
public void loadDocument(Collection col, Record record, Document document)
throws DBException {
}
+
/**
*
* @param col Collection
@@ -124,35 +132,36 @@
*/
public void setDatabaseConfig(Database db, Map collections, Configuration
cfg) {
}
+
/**
* FlushTask handles the work of
*/
- private class FlushTask extends TimerTask{
- public FlushTask(){
+ private class FlushTask extends TimerTask {
+ public FlushTask() {
}
- public void run(){
-
- synchronized(collectionDirtyFlags) {
- Iterator collections =
collectionDirtyFlags.entrySet().iterator();
+ public void run() {
+ synchronized (collectionDirtyFlags) {
int flushCount = 0;
- while(collections.hasNext())
- {
- Map.Entry e = (Map.Entry)collections.next();
- Collection c = (Collection)e.getKey();
- try
- {
+ Iterator collections =
collectionDirtyFlags.entrySet().iterator();
+ while (collections.hasNext()) {
+ Map.Entry e = (Map.Entry) collections.next();
+ Collection c = (Collection) e.getKey();
+ try {
// don't need to flush indexes because everytime a
document
// gets added the indexes get flushed.
c.getFiler().flush();
flushCount ++;
+ } catch (DBException ex) {
+ log.error("Couldn't flush collection: " + c.getName(),
ex);
}
- catch(DBException ex) {
- log.error("Couldn't flush collection: " + c.getName()
, ex);
- }
}
- log.info("Successfully flushed " + flushCount + " collections
out of " +
- collectionDirtyFlags.size());
+
+ if (flushCount > 0) {
+ log.info("Successfully flushed " + flushCount + "
collections out of " +
+ collectionDirtyFlags.size());
+ }
+
collectionDirtyFlags.clear();
}
}