From 26b0f3b30a35db283e9b30a0484f02c81681cc44 Mon Sep 17 00:00:00 2001 From: Ludovic Claude <ludovic.claude54@gmail.com> Date: Thu, 24 Jan 2019 23:32:54 +0100 Subject: [PATCH] Fail to start if additional variables cannot be created from datasets --- src/main/java/eu/hbp/mip/StartupTasks.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/hbp/mip/StartupTasks.java b/src/main/java/eu/hbp/mip/StartupTasks.java index b09bc06a5..b9c44c8ad 100644 --- a/src/main/java/eu/hbp/mip/StartupTasks.java +++ b/src/main/java/eu/hbp/mip/StartupTasks.java @@ -1,7 +1,5 @@ package eu.hbp.mip; -import akka.actor.ActorRef; -import akka.cluster.Cluster; import ch.chuv.lren.woken.messages.datasets.Dataset; import com.google.gson.Gson; import eu.hbp.mip.controllers.DatasetsApi; @@ -40,6 +38,8 @@ public class StartupTasks implements ApplicationListener<ApplicationReadyEvent> @Override public void onApplicationEvent(ApplicationReadyEvent event) { + boolean variablesRepositoryOk = false; + // 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 5 times, to be more robust in the face of cluster failures / slow startup @@ -49,17 +49,24 @@ public class StartupTasks implements ApplicationListener<ApplicationReadyEvent> final String code = dataset.dataset().code(); Variable v = variableRepository.findOne(code); if (v == null) { + LOGGER.info("Store additional variable {}", v.getCode()); v = new Variable(code); variableRepository.save(v); } } LOGGER.info("Datasets fetched from Woken"); + variablesRepositoryOk = true; break; } catch (Exception e) { + variablesRepositoryOk = false; LOGGER.error("Cannot initialise the variable repository. Is the connection to Woken working?", e); } } + if (!variablesRepositoryOk) { + System.exit(1); + } + /* for (String variableJson: variablesApi.loadVariables()) { String code = gson.fromJson(variableJson, Variable.class).getCode(); -- GitLab