mirror of https://github.com/apache/cloudstack.git
quota: adding final where ever required
This commit is contained in:
parent
a539574ef0
commit
e14fbc5788
|
|
@ -154,7 +154,7 @@ public class QuotaDBUtilsImpl implements QuotaDBUtils {
|
|||
|
||||
@Override
|
||||
public QuotaStatementResponse createQuotaStatementResponse(List<QuotaUsageVO> quotaUsage) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy.open(TransactionLegacy.USAGE_DB).close();
|
||||
QuotaStatementResponse statement = new QuotaStatementResponse();
|
||||
Collections.sort(quotaUsage, new Comparator<QuotaUsageVO>() {
|
||||
|
|
@ -226,7 +226,7 @@ public class QuotaDBUtilsImpl implements QuotaDBUtils {
|
|||
|
||||
@Override
|
||||
public QuotaTariffVO updateQuotaTariffPlan(QuotaTariffUpdateCmd cmd) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy.open(TransactionLegacy.USAGE_DB).close();
|
||||
QuotaTariffVO result = null;
|
||||
boolean updateRecord = false;
|
||||
|
|
@ -260,8 +260,8 @@ public class QuotaDBUtilsImpl implements QuotaDBUtils {
|
|||
}
|
||||
|
||||
@Override
|
||||
public QuotaCreditsResponse addQuotaCredits(Long accountId, Long domainId, Double amount, Long updatedBy, Date despositedOn) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
public QuotaCreditsResponse addQuotaCredits(final Long accountId, final Long domainId, final Double amount, final Long updatedBy, final Date despositedOn) {
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
QuotaCreditsVO result = null;
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
|
||||
try {
|
||||
|
|
@ -283,8 +283,8 @@ public class QuotaDBUtilsImpl implements QuotaDBUtils {
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public Pair<List<? extends UsageVO>, Integer> getUsageRecords(long accountId, long domainId) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
public Pair<List<? extends UsageVO>, Integer> getUsageRecords(final long accountId, final long domainId) {
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy.open(TransactionLegacy.USAGE_DB).close();
|
||||
s_logger.debug("getting usage records for account: " + accountId + ", domainId: " + domainId);
|
||||
Filter usageFilter = new Filter(UsageVO.class, "startDate", true, 0L, s_recordtofetch);
|
||||
|
|
@ -303,8 +303,8 @@ public class QuotaDBUtilsImpl implements QuotaDBUtils {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ServiceOfferingVO findServiceOffering(Long vmId, long serviceOfferingId) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
public ServiceOfferingVO findServiceOffering(final Long vmId, final long serviceOfferingId) {
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
|
||||
ServiceOfferingVO result;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
|
|||
|
||||
@Override
|
||||
public boolean calculateQuotaUsage() {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
boolean jobResult = false;
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
|
||||
try {
|
||||
|
|
@ -218,7 +218,7 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
|
|||
}
|
||||
|
||||
@DB
|
||||
private QuotaUsageVO updateQuotaDiskUsage(UsageVO usageRecord, BigDecimal aggregationRatio, int quotaType) {
|
||||
private QuotaUsageVO updateQuotaDiskUsage(UsageVO usageRecord, final BigDecimal aggregationRatio, final int quotaType) {
|
||||
QuotaUsageVO quota_usage = null;
|
||||
QuotaTariffVO tariff = _quotaTariffDao.findTariffPlanByUsageType(quotaType, usageRecord.getEndDate());
|
||||
if (tariff != null) {
|
||||
|
|
@ -240,7 +240,7 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
|
|||
}
|
||||
|
||||
@DB
|
||||
private List<QuotaUsageVO> updateQuotaRunningVMUsage(UsageVO usageRecord, BigDecimal aggregationRatio) {
|
||||
private List<QuotaUsageVO> updateQuotaRunningVMUsage(UsageVO usageRecord, final BigDecimal aggregationRatio) {
|
||||
List<QuotaUsageVO> quotalist = new ArrayList<QuotaUsageVO>();
|
||||
QuotaUsageVO quota_usage;
|
||||
BigDecimal cpuquotausgage, speedquotausage, memoryquotausage, vmusage;
|
||||
|
|
@ -300,7 +300,7 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
|
|||
}
|
||||
|
||||
@DB
|
||||
private QuotaUsageVO updateQuotaAllocatedVMUsage(UsageVO usageRecord, BigDecimal aggregationRatio) {
|
||||
private QuotaUsageVO updateQuotaAllocatedVMUsage(UsageVO usageRecord, final BigDecimal aggregationRatio) {
|
||||
QuotaUsageVO quota_usage = null;
|
||||
QuotaTariffVO tariff = _quotaTariffDao.findTariffPlanByUsageType(QuotaTypes.ALLOCATED_VM, usageRecord.getEndDate());
|
||||
if (tariff != null) {
|
||||
|
|
@ -321,7 +321,7 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
|
|||
}
|
||||
|
||||
@DB
|
||||
private QuotaUsageVO updateQuotaRaw(UsageVO usageRecord, BigDecimal aggregationRatio, int ruleType) {
|
||||
private QuotaUsageVO updateQuotaRaw(UsageVO usageRecord, final BigDecimal aggregationRatio, final int ruleType) {
|
||||
QuotaUsageVO quota_usage = null;
|
||||
QuotaTariffVO tariff = _quotaTariffDao.findTariffPlanByUsageType(ruleType, usageRecord.getEndDate());
|
||||
if (tariff != null) {
|
||||
|
|
@ -341,7 +341,7 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
|
|||
}
|
||||
|
||||
@DB
|
||||
private QuotaUsageVO updateQuotaNetwork(UsageVO usageRecord, int transferType) {
|
||||
private QuotaUsageVO updateQuotaNetwork(UsageVO usageRecord, final int transferType) {
|
||||
QuotaUsageVO quota_usage = null;
|
||||
QuotaTariffVO tariff = _quotaTariffDao.findTariffPlanByUsageType(transferType, usageRecord.getEndDate());
|
||||
if (tariff != null) {
|
||||
|
|
@ -363,7 +363,7 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Date computeAdjustedTime(Date date) {
|
||||
public Date computeAdjustedTime(final Date date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
TimeZone localTZ = cal.getTimeZone();
|
||||
|
|
|
|||
|
|
@ -79,9 +79,9 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
|
|||
private TimeZone _usageTimezone;
|
||||
private int _aggregationDuration = 0;
|
||||
|
||||
static BigDecimal s_hoursInMonth = new BigDecimal(30 * 24);
|
||||
static BigDecimal s_minutesInMonth = new BigDecimal(30 * 24 * 60);
|
||||
static BigDecimal s_gb = new BigDecimal(1024 * 1024 * 1024);
|
||||
final static BigDecimal s_hoursInMonth = new BigDecimal(30 * 24);
|
||||
final static BigDecimal s_minutesInMonth = new BigDecimal(30 * 24 * 60);
|
||||
final static BigDecimal s_gb = new BigDecimal(1024 * 1024 * 1024);
|
||||
|
||||
public QuotaServiceImpl() {
|
||||
super();
|
||||
|
|
@ -132,7 +132,7 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
|
|||
|
||||
@Override
|
||||
public List<QuotaBalanceVO> getQuotaBalance(QuotaBalanceCmd cmd) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy.open(TransactionLegacy.CLOUD_DB).close();
|
||||
|
||||
Long accountId = cmd.getAccountId();
|
||||
|
|
@ -195,7 +195,7 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
|
|||
|
||||
@Override
|
||||
public List<QuotaUsageVO> getQuotaUsage(QuotaStatementCmd cmd) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy.open(TransactionLegacy.CLOUD_DB).close();
|
||||
Long accountId = cmd.getAccountId();
|
||||
String accountName = cmd.getAccountName();
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ public class QuotaBalanceDaoImpl extends GenericDaoBase<QuotaBalanceVO, Long> im
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public QuotaBalanceVO findLastBalanceEntry(long accountId, long domainId, Date beforeThis) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
public QuotaBalanceVO findLastBalanceEntry(final long accountId, final long domainId, final Date beforeThis) {
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy.open(TransactionLegacy.USAGE_DB).close();
|
||||
Filter filter = new Filter(QuotaBalanceVO.class, "updatedOn", false, 0L, 1L);
|
||||
SearchCriteria<QuotaBalanceVO> sc = createSearchCriteria();
|
||||
|
|
@ -55,8 +55,8 @@ public class QuotaBalanceDaoImpl extends GenericDaoBase<QuotaBalanceVO, Long> im
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public QuotaBalanceVO findLaterBalanceEntry(long accountId, long domainId, Date afterThis) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
public QuotaBalanceVO findLaterBalanceEntry(final long accountId, final long domainId, final Date afterThis) {
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy.open(TransactionLegacy.USAGE_DB).close();
|
||||
Filter filter = new Filter(QuotaBalanceVO.class, "updatedOn", true, 0L, 1L);
|
||||
SearchCriteria<QuotaBalanceVO> sc = createSearchCriteria();
|
||||
|
|
@ -70,8 +70,8 @@ public class QuotaBalanceDaoImpl extends GenericDaoBase<QuotaBalanceVO, Long> im
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveQuotaBalance(List<QuotaBalanceVO> credits) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
public void saveQuotaBalance(final List<QuotaBalanceVO> credits) {
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
|
||||
try {
|
||||
for (QuotaBalanceVO credit : credits) {
|
||||
|
|
@ -85,8 +85,8 @@ public class QuotaBalanceDaoImpl extends GenericDaoBase<QuotaBalanceVO, Long> im
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public List<QuotaBalanceVO> findCreditBalance(long accountId, long domainId, Date lastbalancedate, Date beforeThis) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
public List<QuotaBalanceVO> findCreditBalance(final long accountId, final long domainId, final Date lastbalancedate, final Date beforeThis) {
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy.open(TransactionLegacy.USAGE_DB).close();
|
||||
Filter filter = new Filter(QuotaBalanceVO.class, "updatedOn", true, 0L, Long.MAX_VALUE);
|
||||
SearchCriteria<QuotaBalanceVO> sc = createSearchCriteria();
|
||||
|
|
@ -105,8 +105,8 @@ public class QuotaBalanceDaoImpl extends GenericDaoBase<QuotaBalanceVO, Long> im
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public List<QuotaBalanceVO> findQuotaBalance(Long accountId, Long domainId, Date startDate, Date endDate) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
public List<QuotaBalanceVO> findQuotaBalance(final Long accountId, final Long domainId, final Date startDate, final Date endDate) {
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
|
||||
List<QuotaBalanceVO> quotaUsageRecords = null;
|
||||
|
|
@ -135,8 +135,8 @@ public class QuotaBalanceDaoImpl extends GenericDaoBase<QuotaBalanceVO, Long> im
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public List<QuotaBalanceVO> findQuotaBalance(Long accountId, Long domainId, Date startDate) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
public List<QuotaBalanceVO> findQuotaBalance(final Long accountId, final Long domainId, final Date startDate) {
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
|
||||
List<QuotaBalanceVO> quotaUsageRecords = null;
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ public class QuotaCreditsDaoImpl extends GenericDaoBase<QuotaCreditsVO, Long> im
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public List<QuotaCreditsVO> findCredits(long accountId, long domainId, Date startDate, Date endDate) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
public List<QuotaCreditsVO> findCredits(final long accountId, final long domainId, final Date startDate, final Date endDate) {
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy.open(TransactionLegacy.USAGE_DB);
|
||||
Filter filter = new Filter(QuotaCreditsVO.class, "updatedOn", true, 0L, Long.MAX_VALUE);
|
||||
SearchCriteria<QuotaCreditsVO> sc = createSearchCriteria();
|
||||
|
|
@ -58,8 +58,8 @@ public class QuotaCreditsDaoImpl extends GenericDaoBase<QuotaCreditsVO, Long> im
|
|||
}
|
||||
|
||||
@Override
|
||||
public QuotaCreditsVO saveCredits(QuotaCreditsVO credits) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
public QuotaCreditsVO saveCredits(final QuotaCreditsVO credits) {
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy.open(TransactionLegacy.USAGE_DB);
|
||||
persist(credits);
|
||||
// make an entry in the balance table
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ public class QuotaUsageDaoImpl extends GenericDaoBase<QuotaUsageVO, Long> implem
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public List<QuotaUsageVO> findQuotaUsage(Long accountId, Long domainId, Integer usageType, Date startDate, Date endDate) {
|
||||
short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
public List<QuotaUsageVO> findQuotaUsage(final Long accountId, final Long domainId, final Integer usageType, final Date startDate, final Date endDate) {
|
||||
final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
|
||||
List<QuotaUsageVO> quotaUsageRecords = null;
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue