Search in sources :

Example 21 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class ClusterPolicyListModel method remove.

private void remove() {
    if (getWindow() != null) {
        return;
    }
    ConfirmationModel model = new ConfirmationModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().removeClusterPolicyTitle());
    model.setHelpTag(HelpTag.remove_cluster_policy);
    // $NON-NLS-1$
    model.setHashName("remove_cluster_policy");
    if (getSelectedItems() == null) {
        return;
    }
    ArrayList<String> list = new ArrayList<>();
    for (ClusterPolicy item : getSelectedItems()) {
        list.add(item.getName());
    }
    model.setItems(list);
    // $NON-NLS-1$
    UICommand tempVar = UICommand.createDefaultOkUiCommand("OnRemove", this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 22 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class ClusterPolicyListModel method cloneEntity.

private void cloneEntity() {
    ClusterPolicy clusterPolicy = (ClusterPolicy) Cloner.clone(getSelectedItem());
    clusterPolicy.setId(null);
    clusterPolicy.setLocked(false);
    clusterPolicy.setName(COPY_OF + clusterPolicy.getName());
    initClusterPolicy(CommandType.Clone, clusterPolicy);
}
Also used : ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 23 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class NewClusterPolicyModel method save.

private void save() {
    if (getProgress() != null) {
        return;
    }
    if (!validate()) {
        return;
    }
    startProgress();
    ClusterPolicy policy = new ClusterPolicy();
    policy.setId(clusterPolicy.getId());
    policy.setName(getName().getEntity());
    policy.setDescription(getDescription().getEntity());
    ArrayList<Guid> keys = new ArrayList<>();
    for (PolicyUnit clusterPolicy : getUsedFilters()) {
        keys.add(clusterPolicy.getId());
    }
    policy.setFilters(keys);
    policy.setFilterPositionMap(getFilterPositionMap());
    ArrayList<Pair<Guid, Integer>> pairs = new ArrayList<>();
    for (Pair<PolicyUnit, Integer> pair : getUsedFunctions()) {
        pairs.add(new Pair<>(pair.getFirst().getId(), pair.getSecond()));
    }
    policy.setFunctions(pairs);
    policy.setBalance(getLoadBalanceList().getSelectedItem().getId());
    policy.setParameterMap(KeyValueModel.convertProperties(getCustomPropertySheet().serialize()));
    Frontend.getInstance().runAction(commandType == CommandType.Edit ? ActionType.EditClusterPolicy : ActionType.AddClusterPolicy, new ClusterPolicyCRUDParameters(policy.getId(), policy), result -> {
        NewClusterPolicyModel.this.stopProgress();
        if (result.getReturnValue().getSucceeded()) {
            NewClusterPolicyModel.this.cancel();
        }
    });
}
Also used : ClusterPolicyCRUDParameters(org.ovirt.engine.core.common.scheduling.parameters.ClusterPolicyCRUDParameters) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 24 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class SchedulingManager method performLoadBalancingImpl.

private void performLoadBalancingImpl() {
    log.debug("Load Balancer timer entered.");
    List<Cluster> clusters = clusterDao.getAll();
    for (Cluster cluster : clusters) {
        ClusterPolicy policy = policyMap.get(cluster.getClusterPolicyId());
        PolicyUnitImpl policyUnit = policyUnits.get(policy.getBalance());
        Optional<BalanceResult> balanceResult = Optional.empty();
        if (policyUnit.getPolicyUnit().isEnabled()) {
            List<VDS> hosts = vdsDao.getAllForClusterWithoutMigrating(cluster.getId());
            if (policyUnit.getPolicyUnit().isInternal()) {
                balanceResult = internalRunBalance(policyUnit, cluster, hosts);
            } else if (Config.<Boolean>getValue(ConfigValues.ExternalSchedulerEnabled)) {
                balanceResult = externalRunBalance(policyUnit, cluster, hosts);
            }
        }
        if (balanceResult.isPresent() && balanceResult.get().isValid()) {
            migrationHandler.migrateVM(balanceResult.get().getCandidateHosts(), balanceResult.get().getVmToMigrate(), MessageBundler.getMessage(AuditLogType.MIGRATION_REASON_LOAD_BALANCING));
        }
    }
}
Also used : BalanceResult(org.ovirt.engine.core.bll.scheduling.external.BalanceResult) VDS(org.ovirt.engine.core.common.businessentities.VDS) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 25 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class SchedulingManager method loadClusterPolicies.

private void loadClusterPolicies() {
    // Load internal cluster policies
    policyMap.putAll(InternalClusterPolicies.getClusterPolicies());
    Map<Guid, PolicyUnitType> internalTypes = new HashMap<>();
    for (PolicyUnitImpl unit : policyUnits.values()) {
        internalTypes.put(unit.getGuid(), unit.getType());
    }
    // Get all user provided cluster policies
    List<ClusterPolicy> allClusterPolicies = clusterPolicyDao.getAll(Collections.unmodifiableMap(internalTypes));
    for (ClusterPolicy clusterPolicy : allClusterPolicies) {
        policyMap.put(clusterPolicy.getId(), clusterPolicy);
    }
}
Also used : PolicyUnitType(org.ovirt.engine.core.common.scheduling.PolicyUnitType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Guid(org.ovirt.engine.core.compat.Guid) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Aggregations

ClusterPolicy (org.ovirt.engine.core.common.scheduling.ClusterPolicy)37 Guid (org.ovirt.engine.core.compat.Guid)20 HashMap (java.util.HashMap)10 LinkedHashMap (java.util.LinkedHashMap)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 ClusterPolicyCRUDParameters (org.ovirt.engine.core.common.scheduling.parameters.ClusterPolicyCRUDParameters)7 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 PolicyUnit (org.ovirt.engine.core.common.scheduling.PolicyUnit)4 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 Pair (org.ovirt.engine.core.common.utils.Pair)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)2 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 ValidationError (org.ovirt.engine.core.common.utils.customprop.ValidationError)2 Arrays (java.util.Arrays)1