Search in sources :

Example 1 with GlusterGeoRepNonEligibilityReason

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason in project ovirt-engine by oVirt.

the class GetNonEligibilityReasonsOfVolumeForGeoRepSessionQueryTest method testExecuteQueryCommnadOnVolume3.

@Test
public void testExecuteQueryCommnadOnVolume3() {
    GlusterVolumeEntity slaveVolume = baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_3_ID(), baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new GlusterVolumeSizeInfo(10000L, 4000L, 6000L));
    Guid slaveUpServerId = Guid.newGuid();
    doReturn(slaveUpServerId).when(geoRepUtil).getUpServerId(any());
    doReturn(true).when(geoRepUtil).checkEmptyGlusterVolume(slaveUpServerId, slaveVolume.getName());
    List<GlusterGeoRepNonEligibilityReason> actual = getQuery().getNonEligibilityReasons(baseTest.getGlusterVolume(baseTest.getMASTER_VOLUME_ID(), baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new GlusterVolumeSizeInfo(10000L, 4000L, 6000L)), slaveVolume);
    assertEquals(actual.size(), getNonEligibilityReasonsForSlaveVolume3().size());
    assertTrue(getNonEligibilityReasonsForSlaveVolume3().containsAll(actual));
}
Also used : GlusterVolumeSizeInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSizeInfo) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterGeoRepNonEligibilityReason(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test) AbstractQueryTest(org.ovirt.engine.core.bll.AbstractQueryTest)

Example 2 with GlusterGeoRepNonEligibilityReason

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason in project ovirt-engine by oVirt.

the class GetNonEligibilityReasonsOfVolumeForGeoRepSessionQueryTest method testExecuteQueryCommnadOnVolume2.

@Test
public void testExecuteQueryCommnadOnVolume2() {
    GlusterVolumeEntity slaveVolume = baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_2_ID(), baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.DOWN, new GlusterVolumeSizeInfo(4000L, 0L, 0L));
    Guid slaveUpServerID = Guid.newGuid();
    doReturn(slaveUpServerID).when(geoRepUtil).getUpServerId(any());
    doReturn(false).when(geoRepUtil).checkEmptyGlusterVolume(slaveUpServerID, slaveVolume.getName());
    List<GlusterGeoRepNonEligibilityReason> actual = getQuery().getNonEligibilityReasons(baseTest.getGlusterVolume(baseTest.getMASTER_VOLUME_ID(), baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new GlusterVolumeSizeInfo(10000L, 4000L, 6000L)), slaveVolume);
    assertEquals(actual.size(), getNonEligibilityReasonsForSlaveVolume2().size());
    assertTrue(getNonEligibilityReasonsForSlaveVolume2().containsAll(actual));
}
Also used : GlusterVolumeSizeInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSizeInfo) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterGeoRepNonEligibilityReason(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test) AbstractQueryTest(org.ovirt.engine.core.bll.AbstractQueryTest)

Example 3 with GlusterGeoRepNonEligibilityReason

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason in project ovirt-engine by oVirt.

the class GetNonEligibilityReasonsOfVolumeForGeoRepSessionQueryTest method testExecuteQueryCommnadOnVolume1.

@Test
public void testExecuteQueryCommnadOnVolume1() {
    GlusterVolumeEntity slaveVolume = baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_1_ID(), baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.UP, new GlusterVolumeSizeInfo(10000L, 4000L, 6000L));
    Guid slaveUpServerId = Guid.newGuid();
    doReturn(slaveUpServerId).when(geoRepUtil).getUpServerId(any());
    doReturn(true).when(geoRepUtil).checkEmptyGlusterVolume(slaveUpServerId, slaveVolume.getName());
    List<GlusterGeoRepNonEligibilityReason> actualNonEligibilityReasons = getQuery().getNonEligibilityReasons(baseTest.getGlusterVolume(baseTest.getMASTER_VOLUME_ID(), baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new GlusterVolumeSizeInfo(10000L, 4000L, 6000L)), slaveVolume);
    assertTrue(actualNonEligibilityReasons.isEmpty());
}
Also used : GlusterVolumeSizeInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSizeInfo) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterGeoRepNonEligibilityReason(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test) AbstractQueryTest(org.ovirt.engine.core.bll.AbstractQueryTest)

Example 4 with GlusterGeoRepNonEligibilityReason

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason in project ovirt-engine by oVirt.

the class GlusterGeoRepUtil method getEligibilityPredicates.

public Map<GlusterGeoRepNonEligibilityReason, Predicate<GlusterVolumeEntity>> getEligibilityPredicates(final GlusterVolumeEntity masterVolume) {
    Map<GlusterGeoRepNonEligibilityReason, Predicate<GlusterVolumeEntity>> eligibilityPredicates = new HashMap<>();
    final List<Guid> existingSessionSlavesIds = getSessionSlaveVolumeIds();
    eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SHOULD_BE_UP, slaveVolume -> slaveVolume.getStatus() == GlusterStatus.UP);
    eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_AND_MASTER_VOLUMES_SHOULD_NOT_BE_IN_SAME_CLUSTER, slaveVolume -> !masterVolume.getClusterId().equals(slaveVolume.getClusterId()));
    final Predicate<GlusterVolumeEntity> nonNullSlaveSizePredicate = slaveVolume -> slaveVolume.getAdvancedDetails().getCapacityInfo() != null;
    eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SIZE_TO_BE_AVAILABLE, nonNullSlaveSizePredicate);
    final Predicate<GlusterVolumeEntity> nonNullMasterSizePredicate = slaveVolume -> masterVolume.getAdvancedDetails().getCapacityInfo() != null;
    eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.MASTER_VOLUME_SIZE_TO_BE_AVAILABLE, nonNullMasterSizePredicate);
    Predicate<GlusterVolumeEntity> masterSlaveSizePredicate = slaveVolume -> {
        boolean eligible = nonNullSlaveSizePredicate.test(slaveVolume) && nonNullMasterSizePredicate.test(masterVolume);
        if (eligible) {
            eligible = slaveVolume.getAdvancedDetails().getCapacityInfo().getTotalSize() >= masterVolume.getAdvancedDetails().getCapacityInfo().getTotalSize();
        }
        return eligible;
    };
    eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SIZE_SHOULD_BE_GREATER_THAN_MASTER_VOLUME_SIZE, masterSlaveSizePredicate);
    eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SHOULD_NOT_BE_SLAVE_OF_ANOTHER_GEO_REP_SESSION, slaveVolume -> !existingSessionSlavesIds.contains(slaveVolume.getId()));
    eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_CLUSTER_AND_MASTER_CLUSTER_COMPATIBILITY_VERSIONS_DO_NOT_MATCH, slaveVolume -> {
        ClusterDao clusterDao = getClusterDao();
        Version slaveCompatibilityVersion = clusterDao.get(slaveVolume.getClusterId()).getCompatibilityVersion();
        Version masterCompatibilityVersion = clusterDao.get(masterVolume.getClusterId()).getCompatibilityVersion();
        return masterCompatibilityVersion.equals(slaveCompatibilityVersion);
    });
    eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.NO_UP_SLAVE_SERVER, slaveVolume -> {
        Guid slaveUpserverId = getUpServerId(slaveVolume.getClusterId());
        return slaveUpserverId != null;
    });
    eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_TO_BE_EMPTY, slaveVolume -> {
        Guid slaveUpserverId = getUpServerId(slaveVolume.getClusterId());
        return slaveUpserverId != null && checkEmptyGlusterVolume(slaveUpserverId, slaveVolume.getName());
    });
    return eligibilityPredicates;
}
Also used : GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) Backend(org.ovirt.engine.core.bll.Backend) Predicate(java.util.function.Predicate) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) GlusterVolumeVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeVDSParameters) GlusterGeoRepDao(org.ovirt.engine.core.dao.gluster.GlusterGeoRepDao) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Inject(javax.inject.Inject) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus) List(java.util.List) Map(java.util.Map) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) Version(org.ovirt.engine.core.compat.Version) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterGeoRepNonEligibilityReason(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason) HashMap(java.util.HashMap) Version(org.ovirt.engine.core.compat.Version) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterGeoRepNonEligibilityReason(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason) Guid(org.ovirt.engine.core.compat.Guid) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) Predicate(java.util.function.Predicate)

Aggregations

GlusterGeoRepNonEligibilityReason (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason)4 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)4 Guid (org.ovirt.engine.core.compat.Guid)4 Test (org.junit.Test)3 AbstractQueryTest (org.ovirt.engine.core.bll.AbstractQueryTest)3 GlusterVolumeSizeInfo (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSizeInfo)3 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 Backend (org.ovirt.engine.core.bll.Backend)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)1 GlusterStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus)1 VDSCommandType (org.ovirt.engine.core.common.vdscommands.VDSCommandType)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 GlusterVolumeVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeVDSParameters)1