Author: vgritsenko Date: Fri Apr 27 16:12:12 2007 New Revision: 533253 URL: http://svn.apache.org/viewvc?view=rev&rev=533253 Log: <action dev="VG" type="fix" fixes-bug="42272" due-to="Natalia Shilenkova"> Clear Paged and BTree cache on close. </action>
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTree.java xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Paged.java xml/xindice/trunk/java/src/org/apache/xindice/tools/DatabaseRebuild.java xml/xindice/trunk/status.xml Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTree.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTree.java?view=diff&rev=533253&r1=533252&r2=533253 ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTree.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTree.java Fri Apr 27 16:12:12 2007 @@ -147,6 +147,17 @@ return false; } + public synchronized boolean close() throws DBException { + boolean closed = super.close(); + if (closed) { + synchronized (cache) { + cache.clear(); + } + } + + return closed; + } + /** * addKey adds a Value to the BTree and associates a pointer with * it. The pointer can be used for referencing any type of data, it Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Paged.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Paged.java?view=diff&rev=533253&r1=533252&r2=533253 ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Paged.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Paged.java Fri Apr 27 16:12:12 2007 @@ -654,6 +654,11 @@ log.warn(descriptorsCount + " out of " + total + " files were not closed during close."); } } + + // clear cache + synchronized (pagesLock) { + pages.clear(); + } } catch (Exception e) { // Failed to close, leave open opened = true; Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/DatabaseRebuild.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/DatabaseRebuild.java?view=diff&rev=533253&r1=533252&r2=533253 ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/tools/DatabaseRebuild.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/tools/DatabaseRebuild.java Fri Apr 27 16:12:12 2007 @@ -50,7 +50,7 @@ private static final Log log = LogFactory.getLog(DatabaseRebuild.class); - private static final int CMD_ALL = 0; + private static final int CMD_ALL = 0; private static final int CMD_COPY = 1; private static final int CMD_INDEX = 2; @@ -75,10 +75,8 @@ command = CMD_ALL; } - String dbLocation = args[1]; - - File location = new File(dbLocation); - dbLocation = location.getAbsolutePath(); + File location = new File(args[1]); + String path = location.getAbsolutePath(); String name = location.getName(); if ("".equals(name) || !location.exists() || !location.isDirectory()) { @@ -87,31 +85,40 @@ } // create minimal database configuration instead of trying to locate system.xml - String config = "<root-collection dbroot='" + dbLocation + "/' name='" + name + "'/>"; + String config = "<root-collection dbroot='" + path + "/' name='" + name + "'/>"; Database db = new Database(); - boolean status = true; + boolean success = true; try { + System.out.println("Processing database " + path); System.out.println(); - System.out.println("CI\tCollection name"); + System.out.println("DI\tCollection name"); db.setConfig(new Configuration(DOMParser.toDocument(config))); if (log.isInfoEnabled()) { log.info("Rebuilding collections..."); } - status = processCollection(db, command); + success = processCollection(db, command); } finally { db.close(); System.out.println(); - if (status) { - System.out.println("Rebuilding database was successfull"); + System.out.println("Legend:"); + System.out.println(" D Data file"); + System.out.println(" I Index files"); + System.out.println(" _ File was skipped"); + System.out.println(" * File was processed successfuly"); + System.out.println(" ! File processing failed"); + + System.out.println(); + if (success) { + System.out.println("Rebuilding database was successfull."); } else { - System.out.println("Rebuilding database failed. Please check logs for more detail"); + System.out.println("Rebuilding database failed. Please check logs for more detail."); } - System.exit(status ? 0 : 2); + System.exit(success ? 0 : 2); } } @@ -119,9 +126,9 @@ private static void usage() { System.out.println("Xindice " + Xindice.Version + " Database Rebuild Utility"); System.out.println("Usage:"); - System.out.println("\txindice_rebuild copy <db location>"); - System.out.println("\txindice_rebuild index <db location>"); - System.out.println("\txindice_rebuild rebuild <db location>"); + System.out.println(" xindice_rebuild copy <db location>"); + System.out.println(" xindice_rebuild index <db location>"); + System.out.println(" xindice_rebuild rebuild <db location>"); System.out.println(); System.out.println("DB Location should point to the directory containing Xindice database files."); System.out.println(); @@ -389,7 +396,7 @@ Value v = filer.getValue(pointer); newFiler.writeRecord(new Key(value), v); } catch (Exception e) { - e.printStackTrace(); + log.error(e); } return true; Modified: xml/xindice/trunk/status.xml URL: http://svn.apache.org/viewvc/xml/xindice/trunk/status.xml?view=diff&rev=533253&r1=533252&r2=533253 ============================================================================== --- xml/xindice/trunk/status.xml (original) +++ xml/xindice/trunk/status.xml Fri Apr 27 16:12:12 2007 @@ -118,6 +118,9 @@ <changes> <release version="1.1-dev" date="(not released)"> + <action dev="VG" type="fix" fixes-bug="42272" due-to="Natalia Shilenkova"> + Clear Paged and BTree cache on close. + </action> <action dev="VG" type="update" fixes-bug="41854" due-to="Natalia Shilenkova"> Add support for HashFiler in database rebuild tool. </action>