Skip to content

Commit 736d9b4

Browse files
committed
address review comments in UsageManagerImpl
1 parent 025ae71 commit 736d9b4

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

usage/src/main/java/com/cloud/usage/UsageManagerImpl.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ private void createIPHelperEvent(UsageEventVO event) {
14321432
private void deleteExistingSecondaryStorageUsageForVolume(long volId, long accountId, Date deletedDate) {
14331433
List<UsageStorageVO> storageVOs = _usageStorageDao.listById(accountId, volId, StorageTypes.VOLUME);
14341434
for (UsageStorageVO storageVO : storageVOs) {
1435-
logger.debug(String.format("Setting the volume with id: {} to 'deleted' in the usage_storage table for account: {}.", volId, accountId));
1435+
logger.debug("Setting the volume with id: {} to 'deleted' in the usage_storage table for account: {}.", volId, accountId);
14361436
storageVO.setDeleted(deletedDate);
14371437
_usageStorageDao.update(storageVO);
14381438
}
@@ -1442,8 +1442,8 @@ private void deleteExistingInstanceVolumeUsage(long volId, long accountId, Date
14421442
List<UsageVolumeVO> volumesVOs = _usageVolumeDao.listByVolumeId(volId, accountId);
14431443
for (UsageVolumeVO volumesVO : volumesVOs) {
14441444
if (volumesVO.getVmId() != null) {
1445-
logger.debug(String.format("Setting the volume with id: {} for instance id: {} to 'deleted' in the usage_volume table for account {}.",
1446-
volumesVO.getVolumeId(), volumesVO.getVmId(), accountId));
1445+
logger.debug("Setting the volume with id: {} for instance id: {} to 'deleted' in the usage_volume table for account {}.",
1446+
volumesVO.getVolumeId(), volumesVO.getVmId(), accountId);
14471447
volumesVO.setDeleted(deletedDate);
14481448
_usageVolumeDao.update(volumesVO.getId(), volumesVO);
14491449
}
@@ -1453,7 +1453,7 @@ private void deleteExistingInstanceVolumeUsage(long volId, long accountId, Date
14531453
private void deleteExistingVolumeUsage(long volId, long accountId, Date deletedDate) {
14541454
List<UsageVolumeVO> volumesVOs = _usageVolumeDao.listByVolumeId(volId, accountId);
14551455
for (UsageVolumeVO volumesVO : volumesVOs) {
1456-
logger.debug(String.format("Setting the volume with id: {} to 'deleted' in the usage_storage table for account: {}.", volId, accountId));
1456+
logger.debug("Setting the volume with id: {} to 'deleted' in the usage_volume table for account: {}.", volId, accountId);
14571457
volumesVO.setDeleted(deletedDate);
14581458
_usageVolumeDao.update(volumesVO.getId(), volumesVO);
14591459
}
@@ -1479,7 +1479,7 @@ private void createVolumeHelperEvent(UsageEventVO event) {
14791479
deleteExistingVolumeUsage(volId, event.getAccountId(), event.getCreateDate());
14801480
}
14811481

1482-
logger.debug(String.format("Creating a new entry in usage_volume for volume with id: {} for account: {}", volId, event.getVmId(), event.getAccountId()));
1482+
logger.debug("Creating a new entry in usage_volume for volume with id: {} for account: {}", volId, event.getAccountId());
14831483
volumeVO = new UsageVolumeVO(volId, event.getZoneId(), event.getAccountId(), acct.getDomainId(), event.getOfferingId(), event.getTemplateId(), null, event.getSize(), event.getCreateDate(), null);
14841484
_usageVolumeDao.persist(volumeVO);
14851485

@@ -1494,10 +1494,9 @@ private void createVolumeHelperEvent(UsageEventVO event) {
14941494
for (UsageVolumeVO volumesVO : volumesVOs) {
14951495
String delete_msg = String.format("Setting the volume with id: {} to 'deleted' in the usage_storage table for account: {}.", volId, event.getAccountId());
14961496
String create_msg = String.format("Creating a new entry in usage_volume for volume with id: {} after resize for account: {}", volId, event.getAccountId());
1497-
Long vmId = null;
1497+
Long vmId = volumesVO.getVmId();
14981498
if (vmId != null) {
1499-
vmId = volumesVO.getVmId();
1500-
delete_msg = String.format("Setting the volume with id: {} for instance id: {} to 'deleted' in the usage_storage table for account: {}.",
1499+
delete_msg = String.format("Setting the volume with id: {} for instance id: {} to 'deleted' in the usage_volume table for account: {}.",
15011500
volId, vmId, event.getAccountId());
15021501
create_msg = String.format("Creating a new entry in usage_volume for volume with id: {} and instance id: {} after resize for account: {}",
15031502
volId, vmId, event.getAccountId());
@@ -1519,8 +1518,8 @@ private void createVolumeHelperEvent(UsageEventVO event) {
15191518
case EventTypes.EVENT_VOLUME_ATTACH:
15201519
deleteExistingInstanceVolumeUsage(event.getResourceId(), event.getAccountId(), event.getCreateDate());
15211520

1522-
logger.debug(String.format("Creating a new entry in usage_volume for volume with id: {}, and instance id: {} for account: {}",
1523-
volId, event.getVmId(), event.getAccountId()));
1521+
logger.debug("Creating a new entry in usage_volume for volume with id: {}, and instance id: {} for account: {}",
1522+
volId, event.getVmId(), event.getAccountId());
15241523
volumeVO = new UsageVolumeVO(volId, event.getZoneId(), event.getAccountId(), acct.getDomainId(), event.getOfferingId(), event.getTemplateId(), event.getVmId(), event.getSize(), event.getCreateDate(), null);
15251524
_usageVolumeDao.persist(volumeVO);
15261525
break;
@@ -1532,7 +1531,7 @@ private void createVolumeHelperEvent(UsageEventVO event) {
15321531
case EventTypes.EVENT_VOLUME_UPLOAD:
15331532
deleteExistingSecondaryStorageUsageForVolume(volId, event.getAccountId(), event.getCreateDate());
15341533

1535-
logger.debug(String.format("Creating a new entry in usage_storage for volume with id : {} for account: {}", volId, event.getAccountId()));
1534+
logger.debug("Creating a new entry in usage_storage for volume with id : {} for account: {}", volId, event.getAccountId());
15361535
UsageStorageVO storageVO = new UsageStorageVO(volId, event.getZoneId(), event.getAccountId(), acct.getDomainId(), StorageTypes.VOLUME, event.getTemplateId(), event.getSize(), event.getCreateDate(), null);
15371536
_usageStorageDao.persist(storageVO);
15381537
break;

0 commit comments

Comments
 (0)