X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=validation.git;a=blobdiff_plain;f=ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fakraino%2Fvalidation%2Fui%2Fconf%2FValidationTestResultsGetter.java;fp=ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fakraino%2Fvalidation%2Fui%2Fconf%2FValidationNexusTestResultsGetter.java;h=981191b338c929cad13da9d5d2be75b14b7419ad;hp=769549a17711891a09686291948b8ecf3f3ab488;hb=147ecf7bf79ea9967a121d0038103151a38ebef2;hpb=e6b82a7ccd840c8b089ae4d5e69930fd0dd5ef35 diff --git a/ui/src/main/java/org/akraino/validation/ui/conf/ValidationNexusTestResultsGetter.java b/ui/src/main/java/org/akraino/validation/ui/conf/ValidationTestResultsGetter.java similarity index 56% rename from ui/src/main/java/org/akraino/validation/ui/conf/ValidationNexusTestResultsGetter.java rename to ui/src/main/java/org/akraino/validation/ui/conf/ValidationTestResultsGetter.java index 769549a..981191b 100644 --- a/ui/src/main/java/org/akraino/validation/ui/conf/ValidationNexusTestResultsGetter.java +++ b/ui/src/main/java/org/akraino/validation/ui/conf/ValidationTestResultsGetter.java @@ -15,13 +15,11 @@ */ package org.akraino.validation.ui.conf; -import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; -import org.akraino.validation.ui.client.nexus.resources.ValidationNexusTestResult; -import org.akraino.validation.ui.data.Lab; +import org.akraino.validation.ui.entity.ValidationDbTestResult; import org.akraino.validation.ui.service.DbResultAdapter; import org.akraino.validation.ui.service.IntegratedResultService; import org.akraino.validation.ui.service.utils.PrioritySupplier; @@ -36,10 +34,9 @@ import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.stereotype.Component; @Component -public class ValidationNexusTestResultsGetter implements ApplicationListener { +public class ValidationTestResultsGetter implements ApplicationListener { - private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate - .getLogger(ValidationNexusTestResultsGetter.class); + private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(ValidationTestResultsGetter.class); @Autowired IntegratedResultService integratedService; @@ -51,59 +48,64 @@ public class ValidationNexusTestResultsGetter implements ApplicationListener>> completableFuture = CompletableFuture + ValidationTestResultsGetterExecution task = new ValidationTestResultsGetterExecution(); + CompletableFuture completableFuture = CompletableFuture .supplyAsync(new PrioritySupplier<>(1, task::execute), service); - completableFuture.thenAcceptAsync(results -> this.callbackNotify(results)); + completableFuture.thenAcceptAsync(callOutcome -> this.callbackNotify(callOutcome)); } - private void callbackNotify(List> results) { + private void callbackNotify(Boolean outcome) { + LOGGER.debug(EELFLoggerDelegate.debugLogger, "Result of validation result getter execution: " + outcome); try { - for (List result : results) { - - LOGGER.debug(EELFLoggerDelegate.debugLogger, - "Validation test results retrieved from nexus with size : " + result.size()); - dbAdapter.deleteUnreferencedEntries(result); - dbAdapter.storeResultInDb(result); - } Thread.sleep(Integer.valueOf(PortalApiProperties.getProperty("thread_sleep"))); } catch (Exception e) { - LOGGER.error(EELFLoggerDelegate.errorLogger, - "Error in callback notification. " + UserUtils.getStackTrace(e)); + LOGGER.error(EELFLoggerDelegate.errorLogger, "Error in thread sleep. " + UserUtils.getStackTrace(e)); } // Trigger the next retrieval of results ApplicationContext context = new AnnotationConfigApplicationContext(ExecutorServiceInitializer.class); ExecutorService service = (ExecutorService) context.getBean("executorService"); - ValidationNexusTestResultsGetterExecution task = new ValidationNexusTestResultsGetterExecution(); - CompletableFuture>> completableFuture = CompletableFuture + ValidationTestResultsGetterExecution task = new ValidationTestResultsGetterExecution(); + CompletableFuture completableFuture = CompletableFuture .supplyAsync(new PrioritySupplier<>(1, task::execute), service); - completableFuture.thenAcceptAsync(newResults -> this.callbackNotify(newResults)); + completableFuture.thenAcceptAsync(callOutcome -> this.callbackNotify(callOutcome)); } - private class ValidationNexusTestResultsGetterExecution { + private class ValidationTestResultsGetterExecution { - public ValidationNexusTestResultsGetterExecution() { + public ValidationTestResultsGetterExecution() { } - public List> execute() { - List> results = new ArrayList>(); + public Boolean execute() { try { - for (Lab lab : integratedService.getLabsFromNexus()) { + for (String lab : integratedService.getLabsFromNexus()) { for (String blueprintName : integratedService.getBlueprintNamesOfLabFromNexus(lab)) { for (String version : integratedService.getBlueprintVersionsFromNexus(blueprintName, lab)) { LOGGER.debug(EELFLoggerDelegate.debugLogger, - "Trying to retrieve validation test result from nexus for: blueprint name: " - + blueprintName + ", version: " + version + " and lab: " + lab.name()); - results.add(integratedService.getResultsFromNexus(blueprintName, version, lab, - Integer.valueOf(PortalApiProperties.getProperty("no_last_timestamps")))); + "Trying to retrieve validation test result from nexus for blueprint name: " + + blueprintName + ", version: " + version + " and lab: " + lab); + try { + List results = integratedService.getResultsFromNexus( + blueprintName, version, lab, + Integer.valueOf(PortalApiProperties.getProperty("no_last_timestamps"))); + LOGGER.debug(EELFLoggerDelegate.debugLogger, + "Validation test results retrieved from nexus with size : " + results.size()); + dbAdapter.deleteUnreferencedEntries(results); + dbAdapter.storeResultsInDb(results); + } catch (Exception e) { + LOGGER.error(EELFLoggerDelegate.errorLogger, + "Error when trying to receive results from nexus for blueprint name: " + + blueprintName + ", version: " + version + " and lab: " + lab + ". " + + UserUtils.getStackTrace(e)); + } } } } } catch (Exception e) { LOGGER.error(EELFLoggerDelegate.errorLogger, "Error when retrieving Nexus results. " + UserUtils.getStackTrace(e)); + return false; } - return results; + return true; } }