Merge pull request #674 from Mike Tutkowski (mike.tutkowski@solidfire.com)

* pr/674:
  getUsedBytes should query the SolidFire cluster to acquire the size of the given volume if there is no volume_details info for that volume (and then create a volume_details row for this volume so we don't have to make that cluster call for this purpose again)

Signed-off-by: Mike Tutkowski
Signed-off-by: Mike Tutkowski <mike.tutkowski@solidfire.com>
This commit is contained in:
Mike Tutkowski 2015-08-12 12:47:14 -06:00
commit 55ae168cdd
1 changed files with 14 additions and 2 deletions

View File

@ -307,6 +307,18 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
usedSpace += volumeSize;
}
else {
SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePool.getId(), _storagePoolDetailsDao);
long lVolumeId = Long.valueOf(volume.getFolder());
SolidFireUtil.SolidFireVolume sfVolume = SolidFireUtil.getSolidFireVolume(sfConnection, lVolumeId);
// SolidFireUtil.VOLUME_SIZE was introduced in 4.5.
// To be backward compatible with releases prior to 4.5, call updateVolumeDetails here.
// That way if SolidFireUtil.VOLUME_SIZE wasn't put in the volume_details table when the
// volume was initially created, it can be placed in volume_details here.
updateVolumeDetails(volume.getId(), sfVolume.getTotalSize());
}
}
}
@ -417,8 +429,6 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
if (dataObject.getType() == DataObjectType.VOLUME) {
VolumeInfo volumeInfo = (VolumeInfo)dataObject;
AccountVO account = _accountDao.findById(volumeInfo.getAccountId());
String sfAccountName = SolidFireUtil.getSolidFireAccountName(account.getUuid(), account.getAccountId());
long storagePoolId = dataStore.getId();
@ -427,6 +437,8 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
AccountDetailVO accountDetail = SolidFireUtil.getAccountDetail(volumeInfo.getAccountId(), storagePoolId, _accountDetailsDao);
if (accountDetail == null || accountDetail.getValue() == null) {
AccountVO account = _accountDao.findById(volumeInfo.getAccountId());
String sfAccountName = SolidFireUtil.getSolidFireAccountName(account.getUuid(), account.getAccountId());
SolidFireUtil.SolidFireAccount sfAccount = SolidFireUtil.getSolidFireAccount(sfConnection, sfAccountName);
if (sfAccount == null) {