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));
}
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));
}
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());
}
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;
}
Aggregations