Project

General

Profile

« Previous | Next » 

Revision 55000

catch and ignore all the exceptions to keep the autocommit task scheduled

View differences:

modules/dnet-directindex-api/trunk/src/main/java/eu/dnetlib/openaire/directindex/api/IndexClientMap.java
5 5
import java.util.Map;
6 6
import javax.annotation.Resource;
7 7

  
8
import com.google.common.collect.Lists;
8 9
import com.google.common.collect.Maps;
9 10
import eu.dnetlib.data.index.CloudIndexClient;
10 11
import eu.dnetlib.data.index.CloudIndexClientException;
......
36 37
    private Map<IndexDsInfo, CloudIndexClient> clients = Maps.newHashMap();
37 38

  
38 39
    public Map<IndexDsInfo, CloudIndexClient> getClients() throws DirecIndexApiException {
40
        final List<IndexDsInfo> idxList = Lists.newArrayList();
39 41
        try {
40
            final List<IndexDsInfo> idxList = indexDSRetriever.calculateCurrentIndexDsInfo();
42
            idxList.addAll(indexDSRetriever.calculateCurrentIndexDsInfo());
43
        } catch (Throwable e) {
44
            log.warn("Unable to retrieve IndexDS data from the IS", e);
45
        }
41 46

  
42
            if (idxList == null || idxList.isEmpty()) {
43
                throw new DirecIndexApiException("cannot create index: no public Search Service found");
44
            }
45
            if (idxList.size() > 1) {
46
                log.warn("found more than 1 public search service");
47
            }
47
        if (idxList == null || idxList.isEmpty()) {
48
            throw new DirecIndexApiException("cannot create index: no public Search Service found");
49
        }
50
        if (idxList.size() > 1) {
51
            log.warn("found more than 1 public search service");
52
        }
48 53

  
49
            for(IndexDsInfo i : idxList) {
50
                if (!clients.containsKey(i)) {
54
        for(IndexDsInfo i : idxList) {
55
            if (!clients.containsKey(i)) {
56
                try {
51 57
                    clients.put(i, CloudIndexClientFactory.newIndexClient(i.getIndexBaseUrl(), i.getColl(), false));
58
                } catch (Throwable e) {
59
                    log.warn("Unable to create index client", e);
52 60
                }
53 61
            }
54
            return clients;
55

  
56
        } catch (IOException | ISLookUpException | CloudIndexClientException e) {
57
            throw new DirecIndexApiException(e);
58 62
        }
63
        return clients;
59 64
    }
60 65

  
61 66
}
modules/dnet-directindex-api/trunk/src/main/java/eu/dnetlib/openaire/directindex/api/ResultSubmitterService.java
55 55
                            log.error("error performing commit on " + i.getColl(), e);
56 56
                        }
57 57
                    }
58
                } catch (DirecIndexApiException e) {
59
                    log.error(e);
58
                } catch (Throwable e) {
59
                    log.error("unable to perform commit", e);
60 60
                }
61 61
            }
62 62
        }, 0, getCommitfrquency(), TimeUnit.SECONDS);

Also available in: Unified diff