Fix group precondition not respecting priority
This commit is contained in:
parent
c6389b9481
commit
dedb97166b
|
@ -175,22 +175,27 @@ public class RecordingPreconditions {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String modelUrl : modelGroup.get().getModelUrls()) {
|
for (var groupModel : modelGroup.get().getModelUrls().stream()
|
||||||
if (modelUrl.equals(model.getUrl())) {
|
.map(modelUrl -> getModelForUrl(modelUrl))
|
||||||
|
.filter(x -> x.isPresent())
|
||||||
|
.map(x -> x.get())
|
||||||
|
.sorted((l, r) -> Integer.compare(r.getPriority(), l.getPriority())) // high to low
|
||||||
|
.toList()) {
|
||||||
|
if (model.getUrl().equals(groupModel.getUrl())) {
|
||||||
// no other model with higher prio is online, start recording
|
// no other model with higher prio is online, start recording
|
||||||
// but before that stop all recordings of models with lower prio
|
// but before that stop all recordings of models with lower prio
|
||||||
stopModelsWithLowerPrio(modelGroup.get());
|
stopModelsWithLowerPrio(modelGroup.get());
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Optional<Model> otherModel = getModelForUrl(modelUrl);
|
Optional<Model> otherModel = getModelForUrl(groupModel.getUrl());
|
||||||
if (otherModel.isPresent()) {
|
if (otherModel.isPresent()) {
|
||||||
if (otherModelIsRecorded(otherModel.get())) {
|
if (!otherModel.get().isSuspended() && otherModelIsRecorded(otherModel.get())) {
|
||||||
throw new PreconditionNotMetException(otherModel.get() + " from the same group is already recorded");
|
throw new PreconditionNotMetException(otherModel.get() + " from the same group is already recorded");
|
||||||
} else if (otherModelCanBeRecorded(otherModel.get())) {
|
} else if (otherModelCanBeRecorded(otherModel.get())) {
|
||||||
throw new PreconditionNotMetException(otherModel.get() + " from the same group can be recorded");
|
throw new PreconditionNotMetException(otherModel.get() + " from the same group can be recorded");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG.warn("Couldn't check if model from same group has higer prio for {}", modelUrl);
|
LOG.warn("Couldn't check if model from same group has higer prio for {}", groupModel.getUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue