fixed distributed cache for finished exams

This commit is contained in:
anhefti 2022-03-24 16:46:27 +01:00
parent 9cc020712a
commit 75eb9d9c04
6 changed files with 25 additions and 10 deletions

View file

@ -137,7 +137,8 @@ public class ClientConnectionDetails {
final ClientConnectionData connectionData = this.restCallBuilder
.call()
.get(error -> {
log.error("Unexpected error while trying to get current client connection data: ", error);
log.error("Unexpected error while trying to get current client connection data: {}",
error.getMessage());
recoverFromDisposedRestTemplate(error);
return null;
});

View file

@ -54,8 +54,14 @@ public class ClientIndicatorFactory {
}
public List<ClientIndicator> createFor(final ClientConnection clientConnection) {
final List<ClientIndicator> result = new ArrayList<>();
return createFor(clientConnection, false);
}
public List<ClientIndicator> createFor(
final ClientConnection clientConnection,
final boolean enableCachingOverride) {
final List<ClientIndicator> result = new ArrayList<>();
if (clientConnection.examId == null) {
return result;
}
@ -82,7 +88,7 @@ public class ClientIndicatorFactory {
indicatorDef,
clientConnection.id,
clientConnection.status.clientActiveStatus,
this.enableCaching);
this.enableCaching || enableCachingOverride);
result.add(indicator);
} catch (final Exception e) {
@ -111,7 +117,7 @@ public class ClientIndicatorFactory {
indicator,
clientConnection.id,
clientConnection.status.clientActiveStatus,
this.enableCaching);
this.enableCaching || enableCachingOverride);
result.add(pingIndicator);
}

View file

@ -148,7 +148,9 @@ public class ExamSessionCacheService {
if (clientConnection == null) {
return null;
} else {
return this.internalClientConnectionDataFactory.createClientConnectionData(clientConnection);
return this.internalClientConnectionDataFactory.createClientConnectionData(
clientConnection,
this.getRunningExam(clientConnection.examId) != null);
}
}

View file

@ -32,7 +32,16 @@ public class InternalClientConnectionDataFactory {
this.sebClientNotificationService = sebClientNotificationService;
}
public ClientConnectionDataInternal createClientConnectionData(final ClientConnection clientConnection) {
public ClientConnectionDataInternal createClientConnectionData(
final ClientConnection clientConnection,
final boolean examRunning) {
if (!examRunning) {
return new ClientConnectionDataInternal(
clientConnection,
() -> false,
this.clientIndicatorFactory.createFor(clientConnection, true));
}
if (clientConnection.status == ConnectionStatus.CLOSED
|| clientConnection.status == ConnectionStatus.DISABLED) {

View file

@ -287,10 +287,6 @@ public class DistributedIndicatorValueService implements DisposableBean {
if (value == null) {
try {
if (log.isDebugEnabled()) {
log.debug("*** Get and cache ping time: {}", indicatorPK);
}
value = this.clientIndicatorValueMapper.selectValueByPrimaryKey(indicatorPK);
if (value != null) {
this.indicatorValueCache.put(indicatorPK, value);

View file

@ -87,6 +87,7 @@ public final class PingIntervalClientIndicator extends AbstractPingIndicator {
final long currentTimeMillis = DateTimeUtils.currentTimeMillis();
this.currentValue = computeValueAt(currentTimeMillis);
this.lastUpdate = this.distributedPingCache.lastUpdate();
return (currentTimeMillis < this.currentValue)
? DateTimeUtils.currentTimeMillis() - this.currentValue
: currentTimeMillis - this.currentValue;