Search in sources :

Example 1 with NoMigrationPolicy

use of org.ovirt.engine.core.common.migration.NoMigrationPolicy in project ovirt-engine by oVirt.

the class ConvergenceConfigProvider method initMigrationPolicies.

void initMigrationPolicies(String policiesStr, Version version) {
    List<MigrationPolicy> policies = Collections.emptyList();
    try {
        policies = parse(policiesStr);
    } catch (IOException e) {
        log.error("The provided migration policies: '{}' are not valid, ignoring", policiesStr);
    }
    // init it to an empty map even the parsing failed
    Map<Guid, MigrationPolicy> migrationPolicies = policies.stream().collect(toMap(MigrationPolicy::getId, identity()));
    // the null object
    migrationPolicies.put(NoMigrationPolicy.ID, new NoMigrationPolicy());
    migrationPoliciesByVersion.put(version, migrationPolicies);
}
Also used : NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) IOException(java.io.IOException) Guid(org.ovirt.engine.core.compat.Guid) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy)

Example 2 with NoMigrationPolicy

use of org.ovirt.engine.core.common.migration.NoMigrationPolicy in project ovirt-engine by oVirt.

the class ConvergenceConfigProviderTest method jsonInvalidJson.

@Test
public void jsonInvalidJson() throws IOException {
    provider.initMigrationPolicies("this is not a valid json", VERSION);
    MigrationPolicy policy = provider.getMigrationPolicy(Guid.newGuid(), VERSION);
    assertTrue(policy instanceof NoMigrationPolicy);
}
Also used : NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy) Test(org.junit.Test)

Example 3 with NoMigrationPolicy

use of org.ovirt.engine.core.common.migration.NoMigrationPolicy in project ovirt-engine by oVirt.

the class ConvergenceConfigProviderTest method jsonProperlyFilled.

@Test
public void jsonProperlyFilled() throws IOException {
    Guid id = Guid.newGuid();
    List<MigrationPolicy> policies = new ArrayList<>();
    ConvergenceConfig config = new ConvergenceConfig();
    config.setInitialItems(Collections.singletonList(new ConvergenceItem("setDowntime2", 1)));
    config.setLastItems(Collections.singletonList(new ConvergenceItem("setDowntime3", 15)));
    config.setConvergenceItems(Collections.singletonList(new ConvergenceItemWithStallingLimit(1, "someAction", 12)));
    MigrationPolicy policy = new MigrationPolicy(id, "some name", "some long description", config);
    policies.add(policy);
    String json = JsonHelper.objectToJson(policies, false);
    provider.initMigrationPolicies(json, VERSION);
    // just basic sanity check
    assertEquals(policy.getName(), provider.getMigrationPolicy(id, VERSION).getName());
    assertEquals(policy.getDescription(), provider.getMigrationPolicy(id, VERSION).getDescription());
    assertTrue(provider.getMigrationPolicy(id, new Version()) instanceof NoMigrationPolicy);
}
Also used : NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) ConvergenceConfig(org.ovirt.engine.core.common.migration.ConvergenceConfig) Version(org.ovirt.engine.core.compat.Version) ConvergenceItem(org.ovirt.engine.core.common.migration.ConvergenceItem) ArrayList(java.util.ArrayList) ConvergenceItemWithStallingLimit(org.ovirt.engine.core.common.migration.ConvergenceItemWithStallingLimit) Guid(org.ovirt.engine.core.compat.Guid) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy) Test(org.junit.Test)

Aggregations

MigrationPolicy (org.ovirt.engine.core.common.migration.MigrationPolicy)3 NoMigrationPolicy (org.ovirt.engine.core.common.migration.NoMigrationPolicy)3 Test (org.junit.Test)2 Guid (org.ovirt.engine.core.compat.Guid)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ConvergenceConfig (org.ovirt.engine.core.common.migration.ConvergenceConfig)1 ConvergenceItem (org.ovirt.engine.core.common.migration.ConvergenceItem)1 ConvergenceItemWithStallingLimit (org.ovirt.engine.core.common.migration.ConvergenceItemWithStallingLimit)1 Version (org.ovirt.engine.core.compat.Version)1