From a97ebfbc73d8773bf1a1e5e66f646e3dfbb43a0d Mon Sep 17 00:00:00 2001 From: itaiag Date: Wed, 17 Jan 2018 20:05:25 +0200 Subject: [PATCH] Moved the sorting of the executions to the client side. issue #187 --- server/difido-server/docRoot/js/indexPageScript.js | 1 + .../main/java/il/co/topq/report/Application.java | 2 +- .../src/main/java/il/co/topq/report/StopWatch.java | 10 ++++++++++ .../execution/AbstactMetadataPersistency.java | 9 +-------- .../business/execution/MetadataController.java | 7 ++++++- .../co/topq/report/front/rest/MachineResource.java | 13 +++++++++++++ 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/server/difido-server/docRoot/js/indexPageScript.js b/server/difido-server/docRoot/js/indexPageScript.js index 4685c763..a20fe135 100644 --- a/server/difido-server/docRoot/js/indexPageScript.js +++ b/server/difido-server/docRoot/js/indexPageScript.js @@ -123,6 +123,7 @@ function populateTable() { titleAttr: 'Export to PDF' }], aaSorting: [], + order: [[ 0, "desc" ]], deferRender: true, sPaginationType: "full_numbers", iDisplayLength: 25, diff --git a/server/difido-server/src/main/java/il/co/topq/report/Application.java b/server/difido-server/src/main/java/il/co/topq/report/Application.java index c28e1146..a2965053 100644 --- a/server/difido-server/src/main/java/il/co/topq/report/Application.java +++ b/server/difido-server/src/main/java/il/co/topq/report/Application.java @@ -39,7 +39,7 @@ public Executor getAsyncExecutor() { executor.setCorePoolSize(1); // Do not change the number of threads here executor.setMaxPoolSize(1); - executor.setQueueCapacity(10000); + executor.setQueueCapacity(100000); executor.setThreadNamePrefix("AsyncActionQueue-"); executor.initialize(); return executor; diff --git a/server/difido-server/src/main/java/il/co/topq/report/StopWatch.java b/server/difido-server/src/main/java/il/co/topq/report/StopWatch.java index b18924ea..6dd6462b 100644 --- a/server/difido-server/src/main/java/il/co/topq/report/StopWatch.java +++ b/server/difido-server/src/main/java/il/co/topq/report/StopWatch.java @@ -15,6 +15,16 @@ public StopWatch(Logger log) { stopWatch.setKeepTaskList(false); this.log = log; } + + /** + * Builder method + * + * @param log + * @return + */ + public static StopWatch newStopWatch(Logger log) { + return new StopWatch(log); + } public StopWatch start(String taskName) { if (!log.isTraceEnabled()){ diff --git a/server/difido-server/src/main/java/il/co/topq/report/business/execution/AbstactMetadataPersistency.java b/server/difido-server/src/main/java/il/co/topq/report/business/execution/AbstactMetadataPersistency.java index b2d63dd5..2105063e 100644 --- a/server/difido-server/src/main/java/il/co/topq/report/business/execution/AbstactMetadataPersistency.java +++ b/server/difido-server/src/main/java/il/co/topq/report/business/execution/AbstactMetadataPersistency.java @@ -130,14 +130,7 @@ public synchronized ExecutionMetadata get(int executionId) { @Override public synchronized List getAll() { readFromPersistency(); - final List result = new ArrayList(); - result.addAll(executionsCache.values()); - // This synchronized is very important. See issue #81 - synchronized (this) { - Collections.sort(result); - } - return result; - + return new ArrayList(executionsCache.values()); } @Override diff --git a/server/difido-server/src/main/java/il/co/topq/report/business/execution/MetadataController.java b/server/difido-server/src/main/java/il/co/topq/report/business/execution/MetadataController.java index 4230b328..fa4f6f04 100644 --- a/server/difido-server/src/main/java/il/co/topq/report/business/execution/MetadataController.java +++ b/server/difido-server/src/main/java/il/co/topq/report/business/execution/MetadataController.java @@ -22,13 +22,14 @@ import il.co.topq.report.Common; import il.co.topq.report.Configuration; import il.co.topq.report.Configuration.ConfigProps; +import il.co.topq.report.StopWatch; import il.co.topq.report.events.ExecutionDeletedEvent; import il.co.topq.report.events.ExecutionEndedEvent; import il.co.topq.report.events.ExecutionUpdatedEvent; import il.co.topq.report.events.FileAddedToTestEvent; import il.co.topq.report.events.MachineCreatedEvent; import il.co.topq.report.events.TestDetailsCreatedEvent; - +import static il.co.topq.report.StopWatch.newStopWatch; @Component public class MetadataController implements MetadataProvider, MetadataCreator { @@ -51,6 +52,7 @@ public MetadataController(MetadataPersistency persistency) { */ @Override public ExecutionMetadata createMetadata(ExecutionDetails executionDetails) { + StopWatch stopWatch = newStopWatch(log).start("Creating new metadata"); Execution execution = new Execution(); final Date executionDate = new Date(); final ExecutionMetadata metaData = new ExecutionMetadata( @@ -68,6 +70,7 @@ public ExecutionMetadata createMetadata(ExecutionDetails executionDetails) { setAllowedPropertiesToMetaData(metaData, executionDetails); } persistency.add(metaData); + stopWatch.stopAndLog(); return metaData; } @@ -249,8 +252,10 @@ private void updateExecutionLastUpdateTime(int executionId) { @EventListener public void onMachineCreatedEvent(MachineCreatedEvent machineCreatedEvent) { + StopWatch stopWatch = newStopWatch(log).start("Machine created event for execution " + machineCreatedEvent.getExecutionId()); updateExecutionLastUpdateTime(machineCreatedEvent.getExecutionId()); updateAllExecutionsMetaData(); + stopWatch.stopAndLog(); } /** diff --git a/server/difido-server/src/main/java/il/co/topq/report/front/rest/MachineResource.java b/server/difido-server/src/main/java/il/co/topq/report/front/rest/MachineResource.java index 34ea7342..50cd2358 100644 --- a/server/difido-server/src/main/java/il/co/topq/report/front/rest/MachineResource.java +++ b/server/difido-server/src/main/java/il/co/topq/report/front/rest/MachineResource.java @@ -19,9 +19,11 @@ import org.springframework.web.bind.annotation.RestController; import il.co.topq.difido.model.execution.MachineNode; +import il.co.topq.report.StopWatch; import il.co.topq.report.business.execution.ExecutionMetadata; import il.co.topq.report.business.execution.MetadataProvider; import il.co.topq.report.events.MachineCreatedEvent; +import static il.co.topq.report.StopWatch.newStopWatch; @RestController @Path("api/executions/{execution}/machines") @@ -51,8 +53,13 @@ public int addNewMachine(@PathParam("execution") int executionId, MachineNode ma if (null == metadata) { throw new WebApplicationException("Execution with id " + executionId + " is not exist"); } + StopWatch stopWatch = newStopWatch(log).start("Adding machine to execution"); metadata.getExecution().addMachine(machine); + stopWatch.stopAndLog(); + + stopWatch = newStopWatch(log).start("Publishing machine create event"); publisher.publishEvent(new MachineCreatedEvent(metadata, machine)); + stopWatch.stopAndLog(); return metadata.getExecution().getMachines().indexOf(machine); } @@ -86,8 +93,14 @@ public void updateMachine(@PathParam("execution") int executionId, @PathParam("m throw new WebApplicationException( "Trying to update none existing machine with id " + machineId + " in execution " + executionId); } + + StopWatch stopWatch = newStopWatch(log).start("Updating machine in execution"); metadata.getExecution().getMachines().set(machineId, machine); + stopWatch.stopAndLog(); + + stopWatch = newStopWatch(log).start("Publishing machine created event"); publisher.publishEvent(new MachineCreatedEvent(metadata, machine)); + stopWatch.stopAndLog(); } @GET