Skip to content

Commit

Permalink
Moved the sorting of the executions to the client side. issue #187
Browse files Browse the repository at this point in the history
  • Loading branch information
itaiag committed Jan 17, 2018
1 parent 4ea1d22 commit a97ebfb
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
1 change: 1 addition & 0 deletions server/difido-server/docRoot/js/indexPageScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function populateTable() {
titleAttr: 'Export to PDF'
}],
aaSorting: [],
order: [[ 0, "desc" ]],
deferRender: true,
sPaginationType: "full_numbers",
iDisplayLength: 25,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,7 @@ public synchronized ExecutionMetadata get(int executionId) {
@Override
public synchronized List<ExecutionMetadata> getAll() {
readFromPersistency();
final List<ExecutionMetadata> result = new ArrayList<ExecutionMetadata>();
result.addAll(executionsCache.values());
// This synchronized is very important. See issue #81
synchronized (this) {
Collections.sort(result);
}
return result;

return new ArrayList<ExecutionMetadata>(executionsCache.values());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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(
Expand All @@ -68,6 +70,7 @@ public ExecutionMetadata createMetadata(ExecutionDetails executionDetails) {
setAllowedPropertiesToMetaData(metaData, executionDetails);
}
persistency.add(metaData);
stopWatch.stopAndLog();
return metaData;
}

Expand Down Expand Up @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a97ebfb

Please sign in to comment.