Search in sources :

Example 16 with GlusterVolumeSnapshotConfig

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;
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)

Example 17 with GlusterVolumeSnapshotConfig

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;
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig)

Example 18 with GlusterVolumeSnapshotConfig

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());
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) Test(org.junit.Test)

Example 19 with GlusterVolumeSnapshotConfig

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());
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) Test(org.junit.Test)

Example 20 with GlusterVolumeSnapshotConfig

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);
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) Test(org.junit.Test)

Aggregations

GlusterVolumeSnapshotConfig (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig)23 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)5 HashMap (java.util.HashMap)4 Guid (org.ovirt.engine.core.compat.Guid)3 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)3 List (java.util.List)2 UpdateGlusterVolumeSnapshotConfigParameters (org.ovirt.engine.core.common.action.gluster.UpdateGlusterVolumeSnapshotConfigParameters)2 GlusterClusterSnapshotConfigModel (org.ovirt.engine.ui.uicommonweb.models.gluster.GlusterClusterSnapshotConfigModel)2 TextInputCell (com.google.gwt.cell.client.TextInputCell)1 Column (com.google.gwt.user.cellview.client.Column)1 NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Inject (javax.inject.Inject)1 Named (javax.inject.Named)1 Singleton (javax.inject.Singleton)1 StringUtils (org.apache.commons.lang.StringUtils)1