Changeset 6049


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
Location:
SRUAggregator/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • SRUAggregator/trunk/aggregator.yml

    r6043 r6049  
    1313
    1414  # AGGREGATOR_FILE_PATH: /data/fcsAggregator/fcsAggregatorCorpora.json
     15  # AGGREGATOR_FILE_PATH_BACKUP: /data/fcsAggregator/fcsAggregatorCorpora.backup.json
    1516  AGGREGATOR_FILE_PATH: /Users/edima/fcsAggregatorCorpora.json
    16 
     17  AGGREGATOR_FILE_PATH_BACKUP: /Users/edima/fcsAggregatorCorpora.backup.json
    1718  SCAN_MAX_DEPTH: 1 # recommended 3
    1819  SCAN_TASK_INITIAL_DELAY: 0
  • SRUAggregator/trunk/pom.xml

    r6043 r6049  
    88        <groupId>eu.clarin.sru.fcs</groupId>
    99        <artifactId>Aggregator2</artifactId>
    10         <version>2.0.0-alpha-21</version>
     10        <version>2.0.0-alpha-22</version>
    1111        <name>FCS Aggregator</name>
    1212
  • SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/app/Aggregator.java

    r6043 r6049  
    8888 * @author edima
    8989 *
    90  * TODO: Use weblicht with results
    91  *
    92  * TODO: disable popups easily
    93  *
    94  * TODO: atomic replace of cached corpora (file)
    95  *
    9690 * TODO: zoom into the results from a corpus, allow functionality only for
    9791 * the view (search for next set of results)
    9892 *
    99  * TODO: fix search bug after going to stats
     93 * TODO: Use weblicht with results
    10094 *
    10195 * TODO: Export search results to personal workspace as csv, excel, tcf, plain
     
    151145                bootstrap.addBundle(new AssetsBundle("/assets", "/", "index.html", "static"));
    152146        }
    153 
    154147
    155148        @Override
     
    221214
    222215                File corporaCacheFile = new File(params.AGGREGATOR_FILE_PATH);
    223                 try {
    224                         Corpora corpora = new ObjectMapper().readValue(corporaCacheFile, Corpora.class);
    225                         scanCacheAtom.set(corpora);
    226                         log.info("corpus list read from file; number of root corpora: " + scanCacheAtom.get().getCorpora().size());
    227                 } catch (Exception e) {
    228                         log.error("Error while reading cached corpora:", e);
     216                File corporaOldCacheFile = new File(params.AGGREGATOR_FILE_PATH_BACKUP);
     217
     218                // init corpora from file
     219                {
     220                        Corpora corpora = null;
     221                        try {
     222                                corpora = new ObjectMapper().readValue(corporaCacheFile, Corpora.class);
     223                        } catch (Exception xc) {
     224                                log.error("Failed to load cached corpora from primary file:", xc);
     225                        }
     226                        if (corpora == null) {
     227                                try {
     228                                        corpora = new ObjectMapper().readValue(corporaOldCacheFile, Corpora.class);
     229                                } catch (Exception e) {
     230                                        log.error("Failed to load cached corpora from backup file:", e);
     231                                }
     232                        }
     233                        if (corpora != null) {
     234                                scanCacheAtom.set(corpora);
     235                                log.info("corpus list read from file; number of root corpora: " + scanCacheAtom.get().getCorpora().size());
     236                        }
    229237                }
    230238
     
    236244                                params.CENTER_REGISTRY_URL, params.SCAN_MAX_DEPTH,
    237245                                params.additionalCQLEndpoints,
    238                                 null, scanCacheAtom, corporaCacheFile,
     246                                null, scanCacheAtom, corporaCacheFile, corporaOldCacheFile,
    239247                                scanStatsAtom, searchStatsAtom);
    240248                scheduler.scheduleAtFixedRate(task, params.SCAN_TASK_INITIAL_DELAY,
  • SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/app/AggregatorConfiguration.java

    r5971 r6049  
    2525                @JsonProperty
    2626                String AGGREGATOR_FILE_PATH;
     27
     28                @NotEmpty
     29                @JsonProperty
     30                String AGGREGATOR_FILE_PATH_BACKUP;
    2731
    2832                @JsonProperty
  • 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}
  • SRUAggregator/trunk/src/main/resources/assets/js/components.js

    r5931 r6049  
    122122
    123123        refresh: function() {
     124                console.log("popover refresh", this.props.title);
    124125                $(this.getDOMNode()).popover('destroy');
    125126
    126127                var content;
    127128                if (Array.isArray(this.props.children))
    128                         content = this.props.children.map(React.renderToString).join(" ");
     129                        content = this.props.children.map(React.renderToString).join("");
    129130                else
    130131                        content = React.renderToString(this.props.children);
     
    136137                        placement: this.props.placement,
    137138                        title: this.props.title,
    138                         trigger: 'click',
     139                        trigger: 'focus',
    139140                        html: true,
    140141                });
  • SRUAggregator/trunk/src/main/resources/assets/js/components.jsx

    r5931 r6049  
    126126                var content;
    127127                if (Array.isArray(this.props.children))
    128                         content = this.props.children.map(React.renderToString).join(" ");
     128                        content = this.props.children.map(React.renderToString).join("");
    129129                else
    130130                        content = React.renderToString(this.props.children);
     
    136136                        placement: this.props.placement,
    137137                        title: this.props.title,
    138                         trigger: 'click',
     138                        trigger: 'focus',
    139139                        html: true,
    140140                });
  • SRUAggregator/trunk/src/main/resources/assets/js/main.js

    r6043 r6049  
    33"use strict";
    44
    5 var VERSION = "VERSION 2.0.0.α21";
     5var VERSION = "VERSION 2.0.0.α22";
    66var URLROOT = "/Aggregator-testing";
    77
  • SRUAggregator/trunk/src/main/resources/assets/js/main.jsx

    r6043 r6049  
    33"use strict";
    44
    5 var VERSION = "VERSION 2.0.0.α21";
     5var VERSION = "VERSION 2.0.0.α22";
    66var URLROOT = "/Aggregator-testing";
    77
  • SRUAggregator/trunk/src/main/resources/assets/js/search.js

    r6043 r6049  
    604604        renderDiagnostic: function(d) {
    605605                return  React.createElement("div", {className: "alert alert-warning"},
    606                                         React.createElement("div", null, "Diagnostic: ", d.diagnostic.message)
     606                                        React.createElement("div", null, "Diagnostic: ", d.message)
    607607                                );
    608608        },
  • SRUAggregator/trunk/src/main/resources/assets/js/search.jsx

    r6043 r6049  
    604604        renderDiagnostic: function(d) {
    605605                return  <div className="alert alert-warning">
    606                                         <div>Diagnostic: {d.diagnostic.message}</div>
     606                                        <div>Diagnostic: {d.message}</div>
    607607                                </div>;
    608608        },
Note: See TracChangeset for help on using the changeset viewer.