diff --git a/src/main/java/eu/hbp/mip/StartupTasks.java b/src/main/java/eu/hbp/mip/StartupTasks.java index a72e119529fb6fcd497b8ad90fc0b60d4dd7c14a..4fc511a7a0b994490d8e9d71a2a6a192a88019b0 100644 --- a/src/main/java/eu/hbp/mip/StartupTasks.java +++ b/src/main/java/eu/hbp/mip/StartupTasks.java @@ -40,17 +40,22 @@ public class StartupTasks implements ApplicationListener<ApplicationReadyEvent> public void onApplicationEvent(ApplicationReadyEvent event) { // Pre-fill the local variable repository with the list of datasets, interpreted here as variables // (a bit like a categorical variable can be split into a set of variables (a.k.a one hot encoding in Data science) ) - try { - for (Dataset dataset: datasetsApi.fetchDatasets()) { - final String code = dataset.dataset().code(); - Variable v = variableRepository.findOne(code); - if (v == null) { - v = new Variable(code); - variableRepository.save(v); + // Try 5 times, to be more robust in the face of cluster failures / slow startup + for (int i = 0; i < 5; i++) { + try { + for (Dataset dataset : datasetsApi.fetchDatasets()) { + final String code = dataset.dataset().code(); + Variable v = variableRepository.findOne(code); + if (v == null) { + v = new Variable(code); + variableRepository.save(v); + } } + LOGGER.info("Datasets fetched from Woken"); + break; + } catch (Exception e) { + LOGGER.error("Cannot initialise the variable repository. Is the connection to Woken working?", e); } - } catch (Exception e) { - LOGGER.error("Cannot initialise the variable repository. Is the connection to Woken working?", e); } /*