Changeset 6049 for SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/ScanCrawlTask.java
- Timestamp:
- 02/25/15 11:11:38 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/ScanCrawlTask.java
r5971 r6049 24 24 private AtomicReference<Corpora> corporaAtom; 25 25 private File cachedCorpora; 26 private File oldCachedCorpora; 26 27 private AtomicReference<Statistics> scanStatisticsAtom; 27 28 private AtomicReference<Statistics> searchStatisticsAtom; … … 32 33 int cacheMaxDepth, List<URL> additionalCQLEndpoints, 33 34 EndpointFilter filter, 34 AtomicReference<Corpora> corporaAtom, File cachedCorpora, 35 AtomicReference<Corpora> corporaAtom, 36 File cachedCorpora, File oldCachedCorpora, 35 37 AtomicReference<Statistics> scanStatisticsAtom, 36 38 AtomicReference<Statistics> searchStatisticsAtom 37 39 ) { 38 40 this.sruClient = sruClient; 39 41 this.centerRegistryUrl = centerRegistryUrl; … … 43 45 this.corporaAtom = corporaAtom; 44 46 this.cachedCorpora = cachedCorpora; 47 this.oldCachedCorpora = oldCachedCorpora; 45 48 this.scanStatisticsAtom = scanStatisticsAtom; 46 49 this.searchStatisticsAtom = searchStatisticsAtom; … … 83 86 log.warn("ScanCrawlTask: Skipped writing to disk (no corpora). Finished."); 84 87 } else { 85 ObjectMapper mapper = new ObjectMapper(); 86 mapper.writerWithDefaultPrettyPrinter().writeValue(cachedCorpora, corpora); 88 dump(corpora, cachedCorpora, oldCachedCorpora); 87 89 log.info("ScanCrawlTask: wrote to disk, finished"); 88 90 } … … 94 96 } 95 97 } 98 99 private static void dump(Corpora corpora, 100 File cachedCorpora, File oldCachedCorpora) throws IOException { 101 if (cachedCorpora.exists()) { 102 try { 103 oldCachedCorpora.delete(); 104 } catch (Throwable txc) { 105 //ignore 106 } 107 try { 108 cachedCorpora.renameTo(oldCachedCorpora); 109 } catch (Throwable txc) { 110 // ignore 111 } 112 } 113 ObjectMapper mapper = new ObjectMapper(); 114 mapper.writerWithDefaultPrettyPrinter().writeValue(cachedCorpora, corpora); 115 } 96 116 }
Note: See TracChangeset
for help on using the changeset viewer.