added cached exam update check for running on distributed system

This commit is contained in:
anhefti 2020-06-08 10:55:40 +02:00
parent 20c08e5db4
commit 8e7cb416ae
4 changed files with 10 additions and 11 deletions

View file

@ -18,15 +18,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import ch.ethz.seb.sebserver.gbl.api.EntityType;
/** A EntityKey uniquely identifies a domain entity within the SEB Server's domain model.
* A EntityKey consists of the model identifier of a domain entity and the type of the entity.
* JSON:
* <pre>
*
*
* </pre>
*
* */
/** An EntityKey uniquely identifies a domain entity within the SEB Server's domain model.
* An EntityKey consists of the model identifier of a domain entity and the type of the entity. */
@JsonIgnoreProperties(ignoreUnknown = true)
public class EntityKey implements ModelIdAware, Serializable {

View file

@ -114,7 +114,7 @@ public interface ExamDAO extends ActivatableEntityDAO<Exam, Exam>, BulkActionSup
* @return Result refer to the lock-check-result or to an error if happened */
Result<Boolean> isLocked(Long examId);
/** Use this to check of the exam with the specified identifier is up to date
/** Use this to check if the exam with the specified identifier is up to date
*
* @param examId the exam identifier
* @param updateId the update identifier of the exam

View file

@ -199,6 +199,7 @@ public class ExamSessionServiceImpl implements ExamSessionService {
log.trace("Running exam request for exam {}", examId);
}
updateExamCache(examId);
final Exam exam = this.examSessionCacheService.getRunningExam(examId);
if (this.examSessionCacheService.isRunning(exam)) {
@ -327,6 +328,10 @@ public class ExamSessionServiceImpl implements ExamSessionService {
@Override
public Result<Exam> updateExamCache(final Long examId) {
final Exam exam = this.examSessionCacheService.getRunningExam(examId);
if (exam == null) {
return Result.ofEmpty();
}
final Boolean isUpToDate = this.examDAO.upToDate(examId, exam.lastUpdate)
.onError(t -> log.error("Failed to verify if cached exam is up to date: {}", exam, t))
.getOr(false);

View file

@ -270,7 +270,7 @@ public class ConfigurationNodeController extends EntityController<ConfigurationN
final Result<Configuration> doImport = doImport(password, request, followup);
if (doImport.hasError()) {
// rollback if the new configuration
// rollback of the new configuration
this.configurationNodeDAO.delete(new HashSet<>(Arrays.asList(new EntityKey(
followup.configurationNodeId,
EntityType.CONFIGURATION_NODE))));
@ -510,6 +510,7 @@ public class ConfigurationNodeController extends EntityController<ConfigurationN
final String password,
final HttpServletRequest request,
final Configuration configuration) throws IOException {
final InputStream inputStream = new BufferedInputStream(request.getInputStream());
try {