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")
|
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
|
||||||
public void onAssignVm(AssignVm event)
|
public void onAssignVm(AssignVm event)
|
||||||
throws ApiException, InterruptedException {
|
throws ApiException, InterruptedException {
|
||||||
VmPool vmPool = null;
|
|
||||||
while (true) {
|
|
||||||
// Search for existing assignment.
|
// Search for existing assignment.
|
||||||
var assignedVm = channelManager.channels().stream()
|
var assignedVm = channelManager.channels().stream()
|
||||||
.filter(c -> c.vmDefinition().assignedFrom()
|
.filter(c -> c.vmDefinition().assignedFrom()
|
||||||
|
|
@ -280,14 +278,12 @@ public class VmMonitor extends
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the pool definition for retention time calculations
|
// Get the pool definition for retention time calculations
|
||||||
if (vmPool == null) {
|
VmPool vmPool = newEventPipeline().fire(new GetPools()
|
||||||
vmPool = newEventPipeline().fire(new GetPools()
|
|
||||||
.withName(event.fromPool())).get().stream().findFirst()
|
.withName(event.fromPool())).get().stream().findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (vmPool == null) {
|
if (vmPool == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Find available VM.
|
// Find available VM.
|
||||||
var pool = vmPool;
|
var pool = vmPool;
|
||||||
|
|
@ -316,12 +312,12 @@ public class VmMonitor extends
|
||||||
assignment.set("lastUsed", Instant.now().toString());
|
assignment.set("lastUsed", Instant.now().toString());
|
||||||
return status;
|
return status;
|
||||||
});
|
});
|
||||||
|
event.setResult(new VmData(vmDef, assignedVm.get()));
|
||||||
|
|
||||||
// Make sure that a newly assigned VM is running.
|
// Make sure that a newly assigned VM is running.
|
||||||
fire(new ModifyVm(vmDef.name(), "state", "Running",
|
fire(new ModifyVm(vmDef.name(), "state", "Running",
|
||||||
assignedVm.get()));
|
assignedVm.get()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static Comparator<VmChannel> preferRunning
|
private static Comparator<VmChannel> preferRunning
|
||||||
= new Comparator<>() {
|
= new Comparator<>() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue