Merge branch 'prep/v4.0.0' into testing
This commit is contained in:
commit
9986e4c8bf
1 changed files with 51 additions and 55 deletions
|
|
@ -264,8 +264,6 @@ public class VmMonitor extends
|
|||
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
|
||||
public void onAssignVm(AssignVm event)
|
||||
throws ApiException, InterruptedException {
|
||||
VmPool vmPool = null;
|
||||
while (true) {
|
||||
// Search for existing assignment.
|
||||
var assignedVm = channelManager.channels().stream()
|
||||
.filter(c -> c.vmDefinition().assignedFrom()
|
||||
|
|
@ -280,14 +278,12 @@ public class VmMonitor extends
|
|||
}
|
||||
|
||||
// Get the pool definition for retention time calculations
|
||||
if (vmPool == null) {
|
||||
vmPool = newEventPipeline().fire(new GetPools()
|
||||
VmPool vmPool = newEventPipeline().fire(new GetPools()
|
||||
.withName(event.fromPool())).get().stream().findFirst()
|
||||
.orElse(null);
|
||||
if (vmPool == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Find available VM.
|
||||
var pool = vmPool;
|
||||
|
|
@ -316,12 +312,12 @@ public class VmMonitor extends
|
|||
assignment.set("lastUsed", Instant.now().toString());
|
||||
return status;
|
||||
});
|
||||
event.setResult(new VmData(vmDef, assignedVm.get()));
|
||||
|
||||
// Make sure that a newly assigned VM is running.
|
||||
fire(new ModifyVm(vmDef.name(), "state", "Running",
|
||||
assignedVm.get()));
|
||||
}
|
||||
}
|
||||
|
||||
private static Comparator<VmChannel> preferRunning
|
||||
= new Comparator<>() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue