Skip to content
Snippets Groups Projects
Commit f289131a authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

a bit of cleaning

parent 62dbeaa7
No related branches found
No related tags found
No related merge requests found
......@@ -47,15 +47,26 @@ public class ExperimentActor extends UntypedActor {
QueryResult queryResult = (QueryResult) message;
log.info("received query result for : " + expUUID.toString());
Experiment experiment = experimentRepository.findOne(expUUID);
if(experiment == null)
{
log.error("Experiment with UUID="+expUUID+" not found in DB");
return;
}
experiment.setResult(queryResult.data().get());
experiment.setFinished(new Date());
experimentRepository.save(experiment);
log.info("Experiment "+ expUUID +" updated (finished)");
}
else if (message instanceof QueryError) {
QueryError queryError = (QueryError) message;
log.warning("received query error");
Experiment experiment = experimentRepository.findOne(expUUID);
if(experiment == null)
{
log.error("Experiment with UUID="+expUUID+" not found in DB");
return;
}
experiment.setHasServerError(true);
experiment.setResult(queryError.message());
experimentRepository.save(experiment);
......@@ -63,6 +74,7 @@ public class ExperimentActor extends UntypedActor {
experimentRepository.save(experiment);
log.info("Experiment "+ expUUID +" updated (finished)");
}
else {
unhandled(message);
}
......
......@@ -23,7 +23,6 @@ import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
......@@ -46,8 +45,6 @@ public class ExperimentApi {
private static final Logger LOGGER = Logger.getLogger(ExperimentApi.class);
private static final String EXAREME_ALGO_JSON_FILE="data/exareme_algorithms.json";
private static final Gson gson = new Gson();
private static final Gson gsonOnlyExposed = new GsonBuilder()
......@@ -56,6 +53,8 @@ public class ExperimentApi {
.excludeFieldsWithoutExposeAnnotation()
.create();
private static final String EXAREME_ALGO_JSON_FILE="data/exareme_algorithms.json";
private static final String EXAREME_LR_ALGO = "WP_LINEAR_REGRESSION";
@Value("#{'${services.woken.experimentUrl:http://dockerhost:8087/experiment}'}")
......@@ -79,9 +78,6 @@ public class ExperimentApi {
@Autowired
private ActorSystem actorSystem;
@Autowired
private ApplicationContext applicationContext;
@Value("#{'${akka.woken-path:akka.tcp://woken@127.0.0.1:8088/user/entrypoint}'}")
private String wokenPath;
......@@ -216,8 +212,6 @@ public class ExperimentApi {
public ResponseEntity listAvailableMethodsAndValidations() throws IOException {
LOGGER.info("List available methods and validations");
StringBuilder response = new StringBuilder();
ActorSelection wokenActor = actorSystem.actorSelection(wokenPath);
ActorRef simpleActor = actorSystem.actorOf(Props.create(SimpleActor.class));
wokenActor.tell(new MethodsQuery(), simpleActor);
......@@ -292,6 +286,7 @@ public class ExperimentApi {
}
private void sendExaremeExperiment(Experiment experiment) {
// TODO: integrate Exareme
// this runs in the background. For future optimization: use a thread pool
// new Thread() {
// @Override
......@@ -325,12 +320,6 @@ public class ExperimentApi {
LOGGER.info("Experiment updated (finished)");
}
private static void setExperimentError(IOException e, Experiment experiment) {
experiment.setHasError(true);
experiment.setHasServerError(true);
experiment.setResult(e.getMessage());
}
private static boolean isExaremeAlgo(ExperimentQuery expQuery) {
return expQuery.getAlgorithms().size() >= 1 && "glm_exareme".equals(expQuery.getAlgorithms().get(0).getCode());
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment