Ignore:
Timestamp:
02/25/15 11:11:38 (9 years ago)
Author:
emanuel.dima@uni-tuebingen.de
Message:
  1. alpha 22: backup for corpora cache file + fix popup trigger
File:
1 edited

Legend:

Unmodified
Added
Removed
  • SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/ScanCrawlTask.java

    r5971 r6049  
    2424        private AtomicReference<Corpora> corporaAtom;
    2525        private File cachedCorpora;
     26        private File oldCachedCorpora;
    2627        private AtomicReference<Statistics> scanStatisticsAtom;
    2728        private AtomicReference<Statistics> searchStatisticsAtom;
     
    3233                        int cacheMaxDepth, List<URL> additionalCQLEndpoints,
    3334                        EndpointFilter filter,
    34                         AtomicReference<Corpora> corporaAtom, File cachedCorpora,
     35                        AtomicReference<Corpora> corporaAtom,
     36                        File cachedCorpora, File oldCachedCorpora,
    3537                        AtomicReference<Statistics> scanStatisticsAtom,
    3638                        AtomicReference<Statistics> searchStatisticsAtom
    37                         ) {
     39        ) {
    3840                this.sruClient = sruClient;
    3941                this.centerRegistryUrl = centerRegistryUrl;
     
    4345                this.corporaAtom = corporaAtom;
    4446                this.cachedCorpora = cachedCorpora;
     47                this.oldCachedCorpora = oldCachedCorpora;
    4548                this.scanStatisticsAtom = scanStatisticsAtom;
    4649                this.searchStatisticsAtom = searchStatisticsAtom;
     
    8386                                log.warn("ScanCrawlTask: Skipped writing to disk (no corpora). Finished.");
    8487                        } else {
    85                                 ObjectMapper mapper = new ObjectMapper();
    86                                 mapper.writerWithDefaultPrettyPrinter().writeValue(cachedCorpora, corpora);
     88                                dump(corpora, cachedCorpora, oldCachedCorpora);
    8789                                log.info("ScanCrawlTask: wrote to disk, finished");
    8890                        }
     
    9496                }
    9597        }
     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        }
    96116}
Note: See TracChangeset for help on using the changeset viewer.