From 351148e435322b7b211f05f303e11c46db8f0676 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 20 Jan 2020 09:48:02 +0100 Subject: [PATCH] sync session caches when needed, code cleanup --- .../sebserver/gui/content/MonitoringRunningExam.java | 2 +- .../gui/service/session/ClientConnectionTable.java | 4 +--- .../ch/ethz/seb/sebserver/gui/table/TableFilter.java | 12 +++++++++--- .../session/impl/ExamSessionCacheService.java | 9 ++++++--- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java index 9c5fcc8e..a3343662 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java @@ -82,7 +82,7 @@ public class MonitoringRunningExam implements TemplateComposer { final PageService pageService, final ResourceService resourceService, final InstructionProcessor instructionProcessor, - @Value("${sebserver.gui.webservice.poll-interval:500}") final long pollInterval) { + @Value("${sebserver.gui.webservice.poll-interval:1000}") final long pollInterval) { this.serverPushService = serverPushService; this.pageService = pageService; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java index ff2f731a..9ceea8f4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java @@ -64,10 +64,10 @@ public final class ClientConnectionTable { private static final Logger log = LoggerFactory.getLogger(ClientConnectionTable.class); private static final int BOTTOM_PADDING = 20; + private static final int NUMBER_OF_NONE_INDICATOR_COLUMNS = 3; private static final String INDICATOR_NAME_TEXT_KEY_PREFIX = "sebserver.monitoring.connection.list.column.indicator."; - private final static LocTextKey CONNECTION_ID_TEXT_KEY = new LocTextKey("sebserver.monitoring.connection.list.column.id"); private final static LocTextKey CONNECTION_ADDRESS_TEXT_KEY = @@ -75,8 +75,6 @@ public final class ClientConnectionTable { private final static LocTextKey CONNECTION_STATUS_TEXT_KEY = new LocTextKey("sebserver.monitoring.connection.list.column.status"); - private static final int NUMBER_OF_NONE_INDICATOR_COLUMNS = 3; - private final WidgetFactory widgetFactory; private final ResourceService resourceService; private final Exam exam; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/table/TableFilter.java b/src/main/java/ch/ethz/seb/sebserver/gui/table/TableFilter.java index eab41f91..1b50f0a3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/table/TableFilter.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/table/TableFilter.java @@ -579,14 +579,14 @@ public class TableFilter { @Override String getValue() { if (this.fromDateSelector != null && this.toDateSelector != null) { - final org.joda.time.DateTime fromDate = org.joda.time.DateTime.now(DateTimeZone.UTC) + org.joda.time.DateTime fromDate = org.joda.time.DateTime.now(DateTimeZone.UTC) .withYear(this.fromDateSelector.getYear()) .withMonthOfYear(this.fromDateSelector.getMonth() + 1) .withDayOfMonth(this.fromDateSelector.getDay()) .withHourOfDay((this.fromTimeSelector != null) ? this.fromTimeSelector.getHours() : 0) .withMinuteOfHour((this.fromTimeSelector != null) ? this.fromTimeSelector.getMinutes() : 0) .withSecondOfMinute((this.fromTimeSelector != null) ? this.fromTimeSelector.getSeconds() : 0); - final org.joda.time.DateTime toDate = org.joda.time.DateTime.now(DateTimeZone.UTC) + org.joda.time.DateTime toDate = org.joda.time.DateTime.now(DateTimeZone.UTC) .withYear(this.toDateSelector.getYear()) .withMonthOfYear(this.toDateSelector.getMonth() + 1) .withDayOfMonth(this.toDateSelector.getDay()) @@ -594,6 +594,13 @@ public class TableFilter { .withMinuteOfHour((this.toTimeSelector != null) ? this.toTimeSelector.getMinutes() : 0) .withSecondOfMinute((this.toTimeSelector != null) ? this.toTimeSelector.getSeconds() : 0); + if (this.fromTimeSelector == null) { + fromDate = fromDate.withTimeAtStartOfDay(); + } + if (this.toTimeSelector == null) { + toDate = toDate.plusDays(1).withTimeAtStartOfDay(); + } + return fromDate.toString(Constants.STANDARD_DATE_TIME_FORMATTER) + Constants.EMBEDDED_LIST_SEPARATOR + toDate.toString(Constants.STANDARD_DATE_TIME_FORMATTER); @@ -635,7 +642,6 @@ public class TableFilter { log.error("Failed to set date range filter attribute: ", e); } } - } } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionCacheService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionCacheService.java index bf8fc719..06a756c4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionCacheService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionCacheService.java @@ -77,7 +77,8 @@ public class ExamSessionCacheService { @Cacheable( cacheNames = CACHE_NAME_RUNNING_EXAM, key = "#examId", - unless = "#result == null") + unless = "#result == null", + sync = true) public Exam getRunningExam(final Long examId) { if (log.isDebugEnabled()) { @@ -165,7 +166,8 @@ public class ExamSessionCacheService { @Cacheable( cacheNames = CACHE_NAME_SEB_CONFIG_EXAM, key = "#exam.id", - unless = "#result == null") + unless = "#result == null", + sync = true) public InMemorySebConfig getDefaultSebConfigForExam(final Exam exam) { try { @@ -195,7 +197,8 @@ public class ExamSessionCacheService { @Cacheable( cacheNames = CACHE_NAME_PING_RECORD, key = "#connectionToken", - unless = "#result == null") + unless = "#result == null", + sync = true) @Transactional public ClientEventRecord getPingRecord(final String connectionToken) { if (log.isDebugEnabled()) {