Changeset 6036
- Timestamp:
- 2003-11-28T17:45:01+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/msm/GDMManager.java
r5997 r6036 50 50 import org.greenstone.gatherer.msm.MSMListener; 51 51 import org.greenstone.gatherer.util.HashMap3D; 52 import org.greenstone.gatherer.util.StaticStrings; 52 53 import org.greenstone.gatherer.util.Utility; 53 54 import org.w3c.dom.*; … … 64 65 private TreeNode root = null; 65 66 /** The threaded object responsible for loading all of the existing metadata.xml files prior to any save action. This is necessary so that hierarchy indexes within the metadata.xml files stay fresh. */ 66 private GDMLoader gdm_loader = null;67 //private GDMLoader gdm_loader = null; 67 68 /** The maximum number of GDMDocuments to load at any one time */ 68 69 static final private int MAX_DOCUMENTS = 25; 69 static final private String METADATA_XML = "metadata.xml";70 70 /** Constructor. */ 71 71 public GDMManager() { 72 this(false);73 }74 75 public GDMManager(boolean dummy_load) {76 72 super(); 77 73 this.metadata_cache = new HashMap3D(Gatherer.c_man.getCollection().msm.getSize()); 78 74 // Connect 79 75 Gatherer.c_man.getCollection().msm.addMSMListener(this); 80 // Now create and start the synchronous GDM loader.81 gdm_loader = new GDMLoader(dummy_load);82 gdm_loader.start();83 ///atherer.println("New GDMManager created.");84 76 } 85 77 … … 136 128 File metadata_file = null; 137 129 if(file.isFile()) { 138 metadata_file = new File(file.getParentFile(), METADATA_XML);130 metadata_file = new File(file.getParentFile(), StaticStrings.METADATA_XML); 139 131 } 140 132 else { 141 metadata_file = new File(file, METADATA_XML);133 metadata_file = new File(file, StaticStrings.METADATA_XML); 142 134 } 143 135 // Then try to retrieve it from cache. First we consider the case of a cache hit. … … 163 155 } 164 156 157 /* 165 158 // returns metadata file from cache or creates a new one 166 159 public GDMDocument getDummyDocument(File file) { … … 170 163 File metadata_file = null; 171 164 if(file.isFile()) { 172 metadata_file = new File(file.getParentFile(), METADATA_XML);165 metadata_file = new File(file.getParentFile(), StaticStrings.METADATA_XML); 173 166 } 174 167 else { 175 metadata_file = new File(file, METADATA_XML);168 metadata_file = new File(file, StaticStrings.METADATA_XML); 176 169 } 177 170 // Then try to retrieve it from cache. First we consider the case of a cache hit. … … 185 178 return metadata_xml; 186 179 } 187 180 */ 181 182 /* 188 183 public synchronized void dummyGetMetadata(File file) { 189 184 String filename = null; … … 193 188 } 194 189 GDMDocument document = getDummyDocument(file); 195 196 197 } 190 } 191 */ 192 198 193 /** Recover the metadata associated with a particular file. Note that this call is synchronized, so that all of the data holders don't need to be. */ 199 194 public synchronized ArrayList getMetadata(File file) { … … 430 425 431 426 public void waitUntilComplete() { 432 433 434 427 //if(gdm_loader != null) { 428 // gdm_loader.waitUntilComplete(); 429 //} 435 430 } 436 431 … … 446 441 447 442 /** A separately threaded class to load all of the current metadata.xml files. Note that files can still be loaded on demand if they're not already in the cache. Also provides the functionality to block any other thread until the loading is complete, such as is necessary when moving values about in the value tree hierarchy. */ 443 /* 448 444 private class GDMLoader 449 445 extends Thread { … … 504 500 } 505 501 } 506 507 protected boolean removeEldestEntry(Map.Entry eldest) { 502 */ 503 504 protected boolean removeEldestEntry(Map.Entry eldest) { 508 505 if(size() > MAX_DOCUMENTS) { 509 510 511 512 513 514 515 516 517 518 519 520 506 // Save the oldest document before its dumped 507 File file = (File) eldest.getKey(); 508 ///ystem.err.println("Dumping oldest Document: " + file.getAbsolutePath()); 509 GDMDocument document = (GDMDocument) eldest.getValue(); 510 save(file, document); 511 // And then dump it 512 return true; 513 } 514 else { 515 return false; 516 } 517 } 521 518 }
Note:
See TracChangeset
for help on using the changeset viewer.