fixed distributed cache for finished exams
This commit is contained in:
parent
9cc020712a
commit
75eb9d9c04
6 changed files with 25 additions and 10 deletions
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue