use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.
the class NumaSupportModel method initFirstLevelDistanceSetList.
private void initFirstLevelDistanceSetList() {
firstLevelDistanceSetList = new ArrayList<>();
for (VdsNumaNode node : getNumaNodeList()) {
Map<Integer, Set<VdsNumaNode>> distances = new HashMap<>();
for (Entry<Integer, Integer> entry : node.getNumaNodeDistances().entrySet()) {
Set<VdsNumaNode> sameDistanceNodes = distances.get(entry.getValue());
if (sameDistanceNodes == null) {
sameDistanceNodes = new HashSet<>();
sameDistanceNodes.add(getNodeByIndex(entry.getKey()));
distances.put(entry.getValue(), sameDistanceNodes);
}
sameDistanceNodes.add(node);
}
Entry<Integer, Set<VdsNumaNode>> minDistance = null;
for (Entry<Integer, Set<VdsNumaNode>> entry : distances.entrySet()) {
if (minDistance == null || entry.getKey() < minDistance.getKey()) {
minDistance = entry;
}
}
boolean found = false;
for (Pair<Integer, Set<VdsNumaNode>> group : firstLevelDistanceSetList) {
// 'true' if the two specified collections have no elements in common
boolean isDisjoint = Collections.disjoint(group.getSecond(), minDistance.getValue());
if (group.getFirst().equals(minDistance.getKey()) && !isDisjoint) {
group.getSecond().addAll(minDistance.getValue());
found = true;
break;
}
}
if (!found && minDistance != null) {
firstLevelDistanceSetList.add(new Pair<>(minDistance.getKey(), minDistance.getValue()));
}
}
}
use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.
the class BackendHostNumaNodesResource method list.
@Override
public NumaNodes list() {
NumaNodes ret = new NumaNodes();
List<VdsNumaNode> nodes = getCollection();
for (VdsNumaNode node : nodes) {
NumaNode numanode = populate(map(node, null), node);
ret.getNumaNodes().add(addLinks(numanode));
}
return ret;
}
use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.
the class NumaMapper method map.
@Mapping(from = VdsNumaNode.class, to = NumaNode.class)
public static NumaNode map(VdsNumaNode entity, NumaNode template) {
NumaNode model = template != null ? template : new NumaNode();
if (entity.getId() != null) {
model.setId(entity.getId().toString());
}
model.setIndex(entity.getIndex());
model.setMemory(entity.getMemTotal());
if (entity.getCpuIds() != null && entity.getCpuIds().size() > 0) {
Cpu cpu = new Cpu();
Cores cores = new Cores();
for (int id : entity.getCpuIds()) {
Core core = new Core();
core.setIndex(id);
cores.getCores().add(core);
}
cpu.setCores(cores);
model.setCpu(cpu);
}
if (entity.getNumaNodeDistances() != null && entity.getNumaNodeDistances().size() > 0) {
model.setNodeDistance(StringUtils.join(entity.getNumaNodeDistances().values(), " "));
}
return model;
}
use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.
the class NumaSupportModel method initVNumaNodes.
protected void initVNumaNodes() {
unassignedNumaNodes = new LinkedHashSet<>();
assignedNumaNodes = new HashMap<>();
final Set<Integer> hostIndices = new HashSet<>();
for (VdsNumaNode numaNode : numaNodeList) {
hostIndices.add(numaNode.getIndex());
}
for (final VM vm : getVmsWithvNumaNodeList()) {
numaModelsPerVm.put(vm.getId(), new HashMap<Integer, VNodeModel>());
for (VmNumaNode vmNumaNode : vm.getvNumaNodeList()) {
VNodeModel vNodeModel = new VNodeModel(vm, vmNumaNode);
numaModelsPerVm.get(vm.getId()).put(vNodeModel.getIndex(), vNodeModel);
if (vNodeModel.isPinned()) {
if (!hostIndices.contains(vNodeModel.getHostNodeIndex())) {
// host numa node does not exist. Unpin the numa node and update the configuration
vNodeModel.unpin();
vmsToUpdate.add(vm.getId());
}
}
if (!vNodeModel.isPinned()) {
// virtual numa node is not assigned to any host numa node
unassignedNumaNodes.add(vNodeModel);
} else {
// virtual numa node is assigned to a host numa node
assignVNumaToPhysicalNuma(vNodeModel);
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.
the class VdsManager method updateNumaData.
/**
* Save or update numa data to DB
*/
public void updateNumaData(final VDS vds) {
if (vds.getNumaNodeList() == null || vds.getNumaNodeList().isEmpty()) {
return;
}
final List<VdsNumaNode> numaNodesToSave = new ArrayList<>();
final List<VdsNumaNode> numaNodesToUpdate = new ArrayList<>();
final List<Guid> numaNodesToRemove = new ArrayList<>();
List<VdsNumaNode> dbVdsNumaNodes = vdsNumaNodeDao.getAllVdsNumaNodeByVdsId(vds.getId());
for (VdsNumaNode node : vds.getNumaNodeList()) {
VdsNumaNode searchNode = NumaUtils.getVdsNumaNodeByIndex(dbVdsNumaNodes, node.getIndex());
if (searchNode != null) {
node.setId(searchNode.getId());
numaNodesToUpdate.add(node);
dbVdsNumaNodes.remove(searchNode);
} else {
node.setId(Guid.newGuid());
numaNodesToSave.add(node);
}
}
for (VdsNumaNode node : dbVdsNumaNodes) {
numaNodesToRemove.add(node.getId());
}
// The database operation should be in one transaction
TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> {
if (!numaNodesToRemove.isEmpty()) {
vdsNumaNodeDao.massRemoveNumaNodeByNumaNodeId(numaNodesToRemove);
}
if (!numaNodesToUpdate.isEmpty()) {
vdsNumaNodeDao.massUpdateNumaNode(numaNodesToUpdate);
}
if (!numaNodesToSave.isEmpty()) {
vdsNumaNodeDao.massSaveNumaNode(numaNodesToSave, vds.getId());
}
return null;
});
}
Aggregations