Added a "long getUsedIops(StoragePool)" method to the PrimaryDataStoreDriver interface

This commit is contained in:
Mike Tutkowski 2014-11-12 12:50:33 -07:00
parent 52bc084231
commit 2042660a68
7 changed files with 48 additions and 13 deletions

View File

@ -41,6 +41,11 @@ public interface PrimaryDataStoreDriver extends DataStoreDriver {
// if not managed storage, return 0
public long getUsedBytes(StoragePool storagePool);
// intended for managed storage (cloud.storage_pool.managed = true)
// if managed storage, return the total number of IOPS currently in use for the storage pool in question
// if not managed storage, return 0
public long getUsedIops(StoragePool storagePool);
public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);
public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback);

View File

@ -59,6 +59,11 @@ public class FakePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
return 0;
}
@Override
public long getUsedIops(StoragePool storagePool) {
return 0;
}
@Override
public long getVolumeSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool pool) {
return volume.getSize();

View File

@ -162,6 +162,11 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
return 0;
}
@Override
public long getUsedIops(StoragePool storagePool) {
return 0;
}
@Override
public long getVolumeSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool pool) {
return volume.getSize();

View File

@ -72,6 +72,11 @@ public class NexentaPrimaryDataStoreDriver implements PrimaryDataStoreDriver {
return 0;
}
@Override
public long getUsedIops(StoragePool storagePool) {
return 0;
}
@Override
public long getVolumeSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool pool) {
return 0; //To change body of implemented methods use File | Settings | File Templates.

View File

@ -92,6 +92,11 @@ public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
return 0;
}
@Override
public long getUsedIops(StoragePool storagePool) {
return 0;
}
@Override
public long getVolumeSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool pool) {
return volume.getSize();

View File

@ -48,7 +48,6 @@ import com.cloud.agent.api.to.DataObjectType;
import com.cloud.agent.api.to.DataStoreTO;
import com.cloud.agent.api.to.DataTO;
import com.cloud.agent.api.to.DiskTO;
import com.cloud.capacity.CapacityManager;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.ClusterDetailsVO;
import com.cloud.dc.ClusterDetailsDao;
@ -79,7 +78,6 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
@Inject private AccountDao _accountDao;
@Inject private AccountDetailsDao _accountDetailsDao;
@Inject private CapacityManager _capacityMgr;
@Inject private ClusterDao _clusterDao;
@Inject private ClusterDetailsDao _clusterDetailsDao;
@Inject private HostDao _hostDao;
@ -305,6 +303,21 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
return usedSpace;
}
@Override
public long getUsedIops(StoragePool storagePool) {
long usedIops = 0;
List<VolumeVO> volumes = _volumeDao.findByPoolId(storagePool.getId(), null);
if (volumes != null) {
for (VolumeVO volume : volumes) {
usedIops += volume.getMinIops() != null ? volume.getMinIops() : 0;
}
}
return usedIops;
}
@Override
public long getVolumeSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool pool) {
long volumeSize = volume.getSize();
@ -536,9 +549,8 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
storagePool.setUsedBytes(usedBytes);
/** @todo Mike T. fill in the CloudStackVolumeSize */
long sfNewVolumeId = SolidFireUtil.createSolidFireVolume(sfConnection, snapshotInfo.getUuid(), sfVolume.getAccountId(), sfVolumeSize,
sfVolume.isEnable512e(), "", sfVolume.getMinIops(), sfVolume.getMaxIops(), sfVolume.getBurstIops());
sfVolume.isEnable512e(), NumberFormat.getInstance().format(volumeInfo.getSize()), sfVolume.getMinIops(), 50000, 75000);
// Now that we have successfully created a volume, update the space usage in the storage_pool table
// (even though storage_pool.used_bytes is likely no longer in use).
@ -691,7 +703,7 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
// if the desire is for more IOPS
if (diffInMinIops > 0) {
long usedIops = _capacityMgr.getUsedIops(storagePool);
long usedIops = getUsedIops(storagePool);
long capacityIops = storagePool.getCapacityIops();
if (usedIops + diffInMinIops > capacityIops) {

View File

@ -77,7 +77,6 @@ import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.StorageManager;
import com.cloud.storage.VMTemplateStoragePoolVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.VMTemplatePoolDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.DateUtil;
@ -531,17 +530,16 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
@Override
public long getUsedIops(StoragePoolVO pool) {
long usedIops = 0;
DataStoreProvider storeProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName());
DataStoreDriver storeDriver = storeProvider.getDataStoreDriver();
List<VolumeVO> volumes = _volumeDao.findByPoolId(pool.getId(), null);
if (storeDriver instanceof PrimaryDataStoreDriver) {
PrimaryDataStoreDriver primaryStoreDriver = (PrimaryDataStoreDriver)storeDriver;
if (volumes != null) {
for (VolumeVO volume : volumes) {
usedIops += volume.getMinIops() != null ? volume.getMinIops() : 0;
}
return primaryStoreDriver.getUsedIops(pool);
}
return usedIops;
throw new CloudRuntimeException("Storage driver in CapacityManagerImpl.getUsedIops(StoragePoolVO) is not a PrimaryDataStoreDriver.");
}
@Override