use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig in project ovirt-engine by oVirt.
the class GlusterDBUtils method isVolumeSnapshotSoftLimitReached.
public boolean isVolumeSnapshotSoftLimitReached(Guid volumeId) {
GlusterVolumeEntity volume = glusterVolumeDao.getById(volumeId);
if (volume != null) {
GlusterVolumeSnapshotConfig config = glusterVolumeSnapshotConfigDao.getConfigByClusterIdAndName(volume.getClusterId(), "snap-max-soft-limit");
if (config != null) {
// remove the % sign in the last
String configValue = StringUtils.removeEnd(config.getParamValue(), "%");
int snapMaxSoftLimitPcnt = Integer.parseInt(configValue);
int snapshotCount = volume.getSnapshotsCount();
int snapMaxLimit = volume.getSnapMaxLimit();
return snapshotCount >= (snapMaxLimit * snapMaxSoftLimitPcnt) / 100;
}
}
return false;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotConfigDaoTest method insertTestConfig.
private GlusterVolumeSnapshotConfig insertTestConfig() {
GlusterVolumeSnapshotConfig config = new GlusterVolumeSnapshotConfig();
config.setClusterId(CLUSTER_ID);
config.setVolumeId(VOLUME_ID);
config.setParamName(NEW_PARAM_NAME);
config.setParamValue("new_value");
dao.save(config);
return config;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotConfigDaoTest method testUpdateByClusterIdAndName.
@Test
public void testUpdateByClusterIdAndName() {
GlusterVolumeSnapshotConfig config = dao.getConfigByClusterIdAndName(CLUSTER_ID, PARAM_NAME_3);
assertNotNull(config);
assertEquals("value3", config.getParamValue());
dao.updateConfigByClusterIdAndName(CLUSTER_ID, PARAM_NAME_3, "new_value");
GlusterVolumeSnapshotConfig modifiedConfig = dao.getConfigByClusterIdAndName(CLUSTER_ID, PARAM_NAME_3);
assertNotNull(modifiedConfig);
assertEquals("new_value", modifiedConfig.getParamValue());
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotConfigDaoTest method testUpdateByVolumeIdAndName.
@Test
public void testUpdateByVolumeIdAndName() {
GlusterVolumeSnapshotConfig config = dao.getConfigByVolumeIdAndName(CLUSTER_ID, VOLUME_ID, PARAM_NAME_1);
assertNotNull(config);
assertEquals("value1", config.getParamValue());
dao.updateConfigByVolumeIdAndName(CLUSTER_ID, VOLUME_ID, PARAM_NAME_1, "new_value");
GlusterVolumeSnapshotConfig modifiedConfig = dao.getConfigByVolumeIdAndName(CLUSTER_ID, VOLUME_ID, PARAM_NAME_1);
assertNotNull(modifiedConfig);
assertEquals("new_value", modifiedConfig.getParamValue());
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotConfigDaoTest method testSaveAndGetByVolumeId.
@Test
public void testSaveAndGetByVolumeId() {
GlusterVolumeSnapshotConfig config = dao.getConfigByVolumeIdAndName(CLUSTER_ID, VOLUME_ID, NEW_PARAM_NAME);
assertNull(config);
newConfig = insertTestConfig();
config = dao.getConfigByVolumeIdAndName(CLUSTER_ID, VOLUME_ID, NEW_PARAM_NAME);
assertNotNull(config);
assertEquals(newConfig, config);
}
Aggregations