use of org.ovirt.engine.core.common.scheduling.PolicyUnit in project ovirt-engine by oVirt.
the class ClusterPolicyPopupView method updateTooltips.
private void updateTooltips(NewClusterPolicyModel model) {
PolicyUnit selectedItem = model.getLoadBalanceList().getSelectedItem();
if (selectedItem != null) {
loadBalanceListEditor.getElement().setTitle(selectedItem.getDescription());
// $NON-NLS-1$
String text = "";
if (!selectedItem.isInternal()) {
// $NON-NLS-1$
text = constants.externalPolicyUnitLabel() + " ";
}
if (!selectedItem.isEnabled()) {
text += constants.disabledPolicyUnit();
}
externalLabel.setText(text);
}
}
use of org.ovirt.engine.core.common.scheduling.PolicyUnit in project ovirt-engine by oVirt.
the class ExternalSchedulerDiscovery method discover.
/**
* Discover external schedulers and process its policy units. This operation may take time and is recommended to run
* in a different thread. If we found new policy units we save them to db and expose them for usage.
*
* @return {@code true} if new policies where found and saved to db, {@code false} otherwise.
*/
public boolean discover() {
boolean dbUpdated;
Optional<ExternalSchedulerDiscoveryResult> discoveryResult = broker.runDiscover();
if (discoveryResult.isPresent()) {
updateDB(discoveryResult.get());
log.debug("PolicyUnits updated for external broker.");
dbUpdated = true;
} else {
AuditLogable loggable = new AuditLogableImpl();
auditLogDirector.log(loggable, AuditLogType.FAILED_TO_CONNECT_TO_SCHEDULER_PROXY);
log.warn("Discovery returned empty result when talking to broker. Disabling external units");
List<PolicyUnit> failingPolicyUnits = policyUnitDao.getAll().stream().collect(Collectors.toList());
markExternalPoliciesAsDisabled(failingPolicyUnits);
dbUpdated = true;
}
return dbUpdated;
}
use of org.ovirt.engine.core.common.scheduling.PolicyUnit in project ovirt-engine by oVirt.
the class ExternalSchedulerDiscovery method sendToDb.
private PolicyUnit sendToDb(ExternalSchedulerDiscoveryUnit discovery, /* Nullable */
PolicyUnit policyUnit, PolicyUnitType type) {
PolicyUnit policy = createFromDiscoveryUnit(discovery, type);
if (policyUnit != null) {
log.warn("Policy unit {} already reported by broker.", policyUnit.getName());
}
if (policyUnit != null && policyUnit.getId() != null) {
policy.setId(policyUnit.getId());
policyUnitDao.update(policy);
} else {
policy.setId(Guid.newGuid());
policyUnitDao.save(policy);
}
return policy;
}
use of org.ovirt.engine.core.common.scheduling.PolicyUnit in project ovirt-engine by oVirt.
the class ExternalSchedulerDiscovery method createFromDiscoveryUnit.
private PolicyUnit createFromDiscoveryUnit(ExternalSchedulerDiscoveryUnit discoveryUnit, PolicyUnitType type) {
PolicyUnit policy = new PolicyUnit();
policy.setInternal(false);
policy.setName(discoveryUnit.getName());
policy.setPolicyUnitType(type);
policy.setDescription(discoveryUnit.getDescription());
if (!StringUtils.isEmpty(discoveryUnit.getRegex())) {
policy.setParameterRegExMap(SimpleCustomPropertiesUtil.getInstance().convertProperties(discoveryUnit.getRegex()));
} else {
policy.setParameterRegExMap(new LinkedHashMap<>());
}
return policy;
}
use of org.ovirt.engine.core.common.scheduling.PolicyUnit in project ovirt-engine by oVirt.
the class GetAllPolicyUnitsQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
Map<Guid, PolicyUnitImpl> map = schedulingManager.getPolicyUnitsMap();
List<PolicyUnit> retList = new ArrayList<>();
for (PolicyUnitImpl policyUnitImpl : map.values()) {
retList.add(policyUnitImpl.getPolicyUnit());
}
getQueryReturnValue().setReturnValue(retList);
}
Aggregations