Search in sources :

Example 6 with PolicyUnit

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);
    }
}
Also used : PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit)

Example 7 with PolicyUnit

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;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit)

Example 8 with PolicyUnit

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;
}
Also used : PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit)

Example 9 with PolicyUnit

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;
}
Also used : PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit)

Example 10 with PolicyUnit

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);
}
Also used : PolicyUnitImpl(org.ovirt.engine.core.bll.scheduling.PolicyUnitImpl) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit)

Aggregations

PolicyUnit (org.ovirt.engine.core.common.scheduling.PolicyUnit)24 Guid (org.ovirt.engine.core.compat.Guid)7 ArrayList (java.util.ArrayList)6 LinkedHashMap (java.util.LinkedHashMap)5 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 ClusterPolicy (org.ovirt.engine.core.common.scheduling.ClusterPolicy)4 HashSet (java.util.HashSet)2 RankSelectorPolicyUnit (org.ovirt.engine.core.bll.scheduling.policyunits.RankSelectorPolicyUnit)2 Pair (org.ovirt.engine.core.common.utils.Pair)2 FunctionPolicyUnitPanel (org.ovirt.engine.ui.webadmin.section.main.view.popup.scheduling.panels.FunctionPolicyUnitPanel)2 ImageResource (com.google.gwt.resources.client.ImageResource)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 Column (com.google.gwt.user.cellview.client.Column)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1