CLOUDSTACK-8592: refactoring, cleanup

This commit is contained in:
Abhinandan Prateek 2015-07-09 09:18:36 +05:30 committed by Rohit Yadav
parent 53c22f6ba7
commit 1b579afaeb
41 changed files with 826 additions and 721 deletions

View File

@ -783,8 +783,9 @@ listOpenDaylightControllers=1
addGloboDnsHost=1
### Quota Service
listQuotaConfigurations=15
quotaEditResourceMapping=15
quotaTypes=15
quotaMapping=15
quotaEditMapping=15
quotaRefresh=15
quotaCredits=15
quotaStatement=15

View File

@ -26,6 +26,7 @@
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="QuotaManager" class="org.apache.cloudstack.quota.QuotaManagerImpl" />
<bean id="QuotaDBUtils" class="org.apache.cloudstack.quota.QuotaDBUtilsImpl" />
<bean id="QuotaConfigurationDao" class="org.apache.cloudstack.quota.dao.QuotaConfigurationDaoImpl" />
<bean id="QuotaBalanceDao" class="org.apache.cloudstack.quota.dao.QuotaBalanceDaoImpl"/>
<bean id="QuotaCreditsDao" class="org.apache.cloudstack.quota.dao.QuotaCreditsDaoImpl"/>

View File

@ -28,21 +28,21 @@ import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.QuotaCreditsResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.quota.QuotaManager;
import org.apache.cloudstack.quota.QuotaDBUtilsImpl;
import com.cloud.user.Account;
@APICommand(name = "quotaCredits", responseObject = QuotaCreditsResponse.class, description = "Add +-credits to an account", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class QuotaCreditsCmd extends BaseCmd {
@Inject
QuotaDBUtilsImpl _quotaDBUtils;
public static final Logger s_logger = Logger
.getLogger(QuotaStatementCmd.class.getName());
private static final String s_name = "quotacreditsresponse";
@Inject
private QuotaManager _quotaManager;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "Account Id for which quota credits need to be added")
private String accountName;
@ -80,9 +80,9 @@ public class QuotaCreditsCmd extends BaseCmd {
super();
}
public QuotaCreditsCmd(final QuotaManager quotaManager) {
public QuotaCreditsCmd(final QuotaDBUtilsImpl quotaDBUtils) {
super();
_quotaManager = quotaManager;
_quotaDBUtils = quotaDBUtils;
}
@Override
@ -99,7 +99,7 @@ public class QuotaCreditsCmd extends BaseCmd {
"The account does not exists or has been removed/disabled");
}
final QuotaCreditsResponse credit_response = _quotaManager
final QuotaCreditsResponse credit_response = _quotaDBUtils
.addQuotaCredits(accountId, domainId, value, CallContext
.current().getCallingAccount().getId());

View File

@ -0,0 +1,106 @@
//Licensed to the Apache Software Foundation (ASF) under one
//or more contributor license agreements. See the NOTICE file
//distributed with this work for additional information
//regarding copyright ownership. The ASF licenses this file
//to you under the Apache License, Version 2.0 (the
//"License"); you may not use this file except in compliance
//with the License. You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing,
//software distributed under the License is distributed on an
//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//KIND, either express or implied. See the License for the
//specific language governing permissions and limitations
//under the License.
package org.apache.cloudstack.api.command;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
import org.apache.cloudstack.api.response.QuotaCreditsResponse;
import org.apache.cloudstack.quota.QuotaConfigurationVO;
import org.apache.cloudstack.quota.QuotaDBUtilsImpl;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
@APICommand(name = "quotaEditMapping", responseObject = QuotaCreditsResponse.class, description = "Edit the mapping for a resource", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class QuotaEditMappingCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class.getName());
private static final String s_name = "quotaconfigurationresponse";
@Inject
QuotaDBUtilsImpl _quotaDBUtils;
@Parameter(name = "type", type = CommandType.STRING, required = false, description = "Usage type of the resource")
private String usageType;
@Parameter(name = "value", type = CommandType.INTEGER, entityType = DomainResponse.class, description = "The quota vale of the resource as per the default unit")
private Integer value;
public String getUsageType() {
return usageType;
}
public void setUsageType(String usageType) {
this.usageType = usageType;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public QuotaEditMappingCmd() {
super();
}
public QuotaEditMappingCmd(final QuotaDBUtilsImpl quotaDBUtils) {
super();
_quotaDBUtils = quotaDBUtils;
}
@Override
public String getCommandName() {
return s_name;
}
@Override
public void execute() {
final Pair<List<QuotaConfigurationVO>, Integer> result = _quotaDBUtils.editQuotaMapping(this);
final List<QuotaConfigurationResponse> responses = new ArrayList<QuotaConfigurationResponse>();
for (final QuotaConfigurationVO resource : result.first()) {
final QuotaConfigurationResponse configurationResponse = _quotaDBUtils.createQuotaConfigurationResponse(resource);
configurationResponse.setObjectName("QuotaConfiguration");
responses.add(configurationResponse);
}
final ListResponse<QuotaConfigurationResponse> response = new ListResponse<QuotaConfigurationResponse>();
response.setResponses(responses, responses.size());
response.setResponseName(getCommandName());
setResponseObject(response);
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -1,112 +0,0 @@
//Licensed to the Apache Software Foundation (ASF) under one
//or more contributor license agreements. See the NOTICE file
//distributed with this work for additional information
//regarding copyright ownership. The ASF licenses this file
//to you under the Apache License, Version 2.0 (the
//"License"); you may not use this file except in compliance
//with the License. You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing,
//software distributed under the License is distributed on an
//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//KIND, either express or implied. See the License for the
//specific language governing permissions and limitations
//under the License.
package org.apache.cloudstack.api.command;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
import org.apache.cloudstack.api.response.QuotaCreditsResponse;
import org.apache.cloudstack.quota.QuotaConfigurationVO;
import org.apache.cloudstack.quota.QuotaManager;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
@APICommand(name = "quotaEditResourceMapping", responseObject = QuotaCreditsResponse.class, description = "Edit the mapping for a resource", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class QuotaEditResourceMappingCmd extends BaseCmd {
public static final Logger s_logger = Logger
.getLogger(QuotaStatementCmd.class.getName());
private static final String s_name = "quotaconfigurationresponse";
@Parameter(name = "type", type = CommandType.STRING, required = false, description = "Usage type of the resource")
private String usageType;
@Parameter(name = "value", type = CommandType.INTEGER, entityType = DomainResponse.class, description = "The quota vale of the resource as per the default unit")
private Integer value;
@Inject
private QuotaManager _quotaManager;
public String getUsageType() {
return usageType;
}
public void setUsageType(String usageType) {
this.usageType = usageType;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public QuotaEditResourceMappingCmd() {
super();
}
public QuotaEditResourceMappingCmd(final QuotaManager quotaManager) {
super();
_quotaManager = quotaManager;
}
@Override
public String getCommandName() {
return s_name;
}
@Override
public void execute() {
final Pair<List<QuotaConfigurationVO>, Integer> result = _quotaManager.editQuotaMapping(this);
final List<QuotaConfigurationResponse> responses = new ArrayList<QuotaConfigurationResponse>();
for (final QuotaConfigurationVO resource : result.first()) {
final QuotaConfigurationResponse configurationResponse = _quotaManager.createQuotaConfigurationResponse(resource);
configurationResponse.setObjectName("QuotaConfiguration");
responses.add(configurationResponse);
}
final ListResponse<QuotaConfigurationResponse> response = new ListResponse<QuotaConfigurationResponse>();
response.setResponses(responses, responses.size());
response.setResponseName(getCommandName());
setResponseObject(response);
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -16,91 +16,67 @@
//under the License.
package org.apache.cloudstack.api.command;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.quota.QuotaManager;
import org.apache.cloudstack.api.response.QuotaEmailTemplateResponse;
@APICommand(name = "quotaEmailTemplateAdd", responseObject = QuotaEmailTemplateResponse.class, description = "Add a new email template", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class QuotaEmailTemplateAddCmd extends BaseListCmd {
public static final Logger s_logger = Logger
.getLogger(QuotaEmailTemplateAddCmd.class.getName());
public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateAddCmd.class.getName());
private static final String s_name = "quotaemailtemplateresponse";
private static final String s_name = "quotaemailtemplateresponse";
@Inject
private QuotaManager _quotaManager;
@Parameter(name = "templatename", type = CommandType.STRING, description = "The name of email template")
private String templateName;
@Parameter(name = "templatename", type = CommandType.STRING, description = "The name of email template")
private String templateName;
@Parameter(name = "templatetext", type = CommandType.STRING, description = "The text of the email")
private Long templateText;
@Parameter(name = "templatetext", type = CommandType.STRING, description = "The text of the email")
private Long templateText;
@Parameter(name = "locale", type = CommandType.STRING, description = "The locale of the email text")
private Integer locale;
@Parameter(name = "locale", type = CommandType.STRING, description = "The locale of the email text")
private Integer locale;
public QuotaEmailTemplateAddCmd() {
super();
}
@Override
public String getCommandName() {
return s_name;
}
@Override
public void execute() {
public QuotaEmailTemplateAddCmd() {
super();
}
final QuotaEmailTemplateResponse templResponse = null;
setResponseObject(templResponse);
}
public QuotaEmailTemplateAddCmd(final QuotaManager quotaManager) {
super();
_quotaManager = quotaManager;
}
public String getTemplateName() {
return templateName;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
@Override
public String getCommandName() {
return s_name;
}
public Long getTemplateText() {
return templateText;
}
public void setTemplateText(Long templateText) {
this.templateText = templateText;
}
@Override
public void execute() {
final QuotaEmailTemplateResponse templResponse = null;
setResponseObject(templResponse);
}
public String getTemplateName() {
return templateName;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public Long getTemplateText() {
return templateText;
}
public void setTemplateText(Long templateText) {
this.templateText = templateText;
}
public Integer getLocale() {
return locale;
}
public void setLocale(Integer locale) {
this.locale = locale;
}
public Integer getLocale() {
return locale;
}
public void setLocale(Integer locale) {
this.locale = locale;
}
}

View File

@ -28,44 +28,40 @@ import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.quota.QuotaConfigurationVO;
import org.apache.cloudstack.quota.QuotaManager;
import org.apache.cloudstack.quota.QuotaDBUtilsImpl;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
@APICommand(name = "listQuotaConfigurations", responseObject = QuotaConfigurationResponse.class, description = "Lists all Quota and Usage configurations", since = "4.2.0",
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ListQuotaConfigurationsCmd extends BaseListCmd {
@APICommand(name = "quotaMapping", responseObject = QuotaConfigurationResponse.class, description = "Lists all Quota and Usage configurations", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class QuotaMapping extends BaseListCmd {
public static final Logger s_logger = Logger
.getLogger(ListQuotaConfigurationsCmd.class.getName());
public static final Logger s_logger = Logger.getLogger(QuotaMapping.class.getName());
private static final String s_name = "quotaconfigurationresponse";
@Inject
private QuotaManager _quotaManager;
QuotaDBUtilsImpl _quotaDBUtils;
@Parameter(name = "type", type = CommandType.STRING, required = false, description = "Usage type of the resource")
private String usageType;
public ListQuotaConfigurationsCmd() {
public QuotaMapping() {
super();
}
public ListQuotaConfigurationsCmd(final QuotaManager quotaManager) {
public QuotaMapping(final QuotaDBUtilsImpl quotaDBUtils) {
super();
_quotaManager = quotaManager;
_quotaDBUtils = quotaDBUtils;
}
@Override
public void execute() {
final Pair<List<QuotaConfigurationVO>, Integer> result = _quotaManager.listConfigurations(this);
final Pair<List<QuotaConfigurationVO>, Integer> result = _quotaDBUtils.listConfigurations(this);
final List<QuotaConfigurationResponse> responses = new ArrayList<QuotaConfigurationResponse>();
for (final QuotaConfigurationVO resource : result.first()) {
final QuotaConfigurationResponse configurationResponse = _quotaManager.createQuotaConfigurationResponse(resource);
final QuotaConfigurationResponse configurationResponse = _quotaDBUtils.createQuotaConfigurationResponse(resource);
configurationResponse.setObjectName("QuotaConfiguration");
responses.add(configurationResponse);
}
@ -90,10 +86,8 @@ public class ListQuotaConfigurationsCmd extends BaseListCmd {
return usageType;
}
public void setUsageType(String usageType) {
this.usageType = usageType;
}
}

View File

@ -16,37 +16,25 @@
//under the License.
package org.apache.cloudstack.api.command;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.QuotaRefreshResponse;
import org.apache.cloudstack.quota.QuotaManager;
import com.cloud.user.Account;
@APICommand(name = "quotaRefresh", responseObject = QuotaRefreshResponse.class, description = "Refresh the quota for all accounts if enabled", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class QuotaRefreshCmd extends BaseCmd {
public static final Logger s_logger = Logger
.getLogger(QuotaStatementCmd.class.getName());
public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class.getName());
private static final String s_name = "quotarefreshresponse";
@Inject
private QuotaManager _quotaManager;
public QuotaRefreshCmd() {
super();
}
public QuotaRefreshCmd(final QuotaManager quotaManager) {
super();
_quotaManager = quotaManager;
}
@Override
public String getCommandName() {
return s_name;
@ -54,8 +42,7 @@ public class QuotaRefreshCmd extends BaseCmd {
@Override
public void execute() throws ServerApiException {
final QuotaRefreshResponse response = new QuotaRefreshResponse(
"Success");
final QuotaRefreshResponse response = new QuotaRefreshResponse("Success");
setResponseObject(response);
}

View File

@ -16,8 +16,6 @@
//under the License.
package org.apache.cloudstack.api.command;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -26,7 +24,6 @@ import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.quota.QuotaManager;
import org.apache.cloudstack.api.response.QuotaStatementResponse;
import com.cloud.user.Account;
@ -34,63 +31,53 @@ import com.cloud.user.Account;
@APICommand(name = "quotaStatement", responseObject = QuotaStatementResponse.class, description = "Create a quota statement", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class QuotaStatementCmd extends BaseListCmd {
public static final Logger s_logger = Logger
.getLogger(QuotaStatementCmd.class.getName());
public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class.getName());
private static final String s_name = "quotastatementresponse";
private static final String s_name = "quotastatementresponse";
@Inject
private QuotaManager _quotaManager;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "Optional, Account Id for which statement needs to be generated")
private String accountName;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "Optional, Account Id for which statement needs to be generated")
private String accountName;
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "Optional, If domain Id is given and the caller is domain admin then the statement is generated for domain.")
private Long domainId;
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "Optional, If domain Id is given and the caller is domain admin then the statement is generated for domain.")
private Long domainId;
public QuotaStatementCmd() {
super();
}
@Override
public String getCommandName() {
return s_name;
}
public QuotaStatementCmd() {
super();
}
@Override
public long getEntityOwnerId() {
Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true);
if (accountId == null) {
return CallContext.current().getCallingAccount().getId();
}
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute() {
/**
* final Pair<List<QuotaConfigurationVO>, Integer> result =
* _quotaManager.listConfigurations(this);
*
* final List<QuotaStatementResponse> responses = new
* ArrayList<QuotaStatementResponse>(); for (final QuotaConfigurationVO
* resource : result.first()) { final QuotaStatementResponse
* configurationResponse =
* _quotaManager.createQuotaConfigurationResponse(resource);
* configurationResponse.setObjectName("QuotaConfiguration");
* responses.add(configurationResponse); }
**/
public QuotaStatementCmd(final QuotaManager quotaManager) {
super();
_quotaManager = quotaManager;
}
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true);
if (accountId == null) {
return CallContext.current().getCallingAccount().getId();
}
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute() {
/**final Pair<List<QuotaConfigurationVO>, Integer> result = _quotaManager.listConfigurations(this);
final List<QuotaStatementResponse> responses = new ArrayList<QuotaStatementResponse>();
for (final QuotaConfigurationVO resource : result.first()) {
final QuotaStatementResponse configurationResponse = _quotaManager.createQuotaConfigurationResponse(resource);
configurationResponse.setObjectName("QuotaConfiguration");
responses.add(configurationResponse);
}**/
final ListResponse<QuotaStatementResponse> response = new ListResponse<QuotaStatementResponse>();
//response.setResponses(responses, responses.size());
response.setResponseName(getCommandName());
setResponseObject(response);
}
final ListResponse<QuotaStatementResponse> response = new ListResponse<QuotaStatementResponse>();
// response.setResponses(responses, responses.size());
response.setResponseName(getCommandName());
setResponseObject(response);
}
}

View File

@ -0,0 +1,61 @@
//Licensed to the Apache Software Foundation (ASF) under one
//or more contributor license agreements. See the NOTICE file
//distributed with this work for additional information
//regarding copyright ownership. The ASF licenses this file
//to you under the Apache License, Version 2.0 (the
//"License"); you may not use this file except in compliance
//with the License. You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing,
//software distributed under the License is distributed on an
//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//KIND, either express or implied. See the License for the
//specific language governing permissions and limitations
//under the License.
package org.apache.cloudstack.api.command;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.QuotaTypeResponse;
import org.apache.cloudstack.quota.QuotaUsageTypes;
import com.cloud.user.Account;
@APICommand(name = "quotaTypes", responseObject = QuotaConfigurationResponse.class, description = "Lists all Quota type resources", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class QuotaTypesCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(QuotaTypesCmd.class.getName());
private static final String s_name = "quotatyperesponse";
public QuotaTypesCmd() {
super();
}
@Override
public void execute() {
final List<QuotaTypeResponse> responses = QuotaUsageTypes.listQuotaUsageTypes();
final ListResponse<QuotaTypeResponse> response = new ListResponse<QuotaTypeResponse>();
response.setResponses(responses, responses.size());
response.setResponseName(getCommandName());
setResponseObject(response);
}
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -48,15 +48,14 @@ public class QuotaConfigurationResponse extends BaseResponse {
@Param(description = "description")
private String description;
public QuotaConfigurationResponse() {
super();
}
public QuotaConfigurationResponse() {
super();
}
public QuotaConfigurationResponse(final String usageType) {
super();
this.usageType = usageType;
}
public QuotaConfigurationResponse(final String usageType) {
super();
this.usageType = usageType;
}
public String getUsageType() {
return usageType;

View File

@ -43,61 +43,50 @@ public class QuotaCreditsResponse extends BaseResponse {
@Param(description = "the account name of the admin who updated the credits")
private Timestamp updatedOn;
public QuotaCreditsResponse() {
super();
}
public QuotaCreditsResponse() {
super();
}
public QuotaCreditsResponse(QuotaCreditsVO result) {
super();
if (result != null){
this.credits = 100;
this.balance = 200;
this.updatedBy = "1";
this.updatedOn = new Timestamp(System.currentTimeMillis());
}
}
public QuotaCreditsResponse(QuotaCreditsVO result) {
super();
if (result != null) {
this.credits = 100;
this.balance = 200;
this.updatedBy = "1";
this.updatedOn = new Timestamp(System.currentTimeMillis());
}
}
public Integer getCredits() {
return credits;
}
public void setCredits(Integer credits) {
this.credits = credits;
}
public Integer getBalance() {
return balance;
}
public void setBalance(Integer balance) {
this.balance = balance;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Timestamp getUpdatedOn() {
return updatedOn;
}
public void setUpdatedOn(Timestamp updatedOn) {
this.updatedOn = updatedOn;
}
}

View File

@ -25,7 +25,6 @@ import org.apache.cloudstack.api.BaseResponse;
import com.cloud.serializer.Param;
public class QuotaEmailTemplateResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
@ -44,51 +43,40 @@ public class QuotaEmailTemplateResponse extends BaseResponse {
@Param(description = "the account name of the admin who updated the credits")
private Timestamp SentOn;
public QuotaEmailTemplateResponse() {
super();
}
public QuotaEmailTemplateResponse() {
super();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public String getDomainId() {
return domainId;
}
public void setDomainId(String domainId) {
this.domainId = domainId;
}
public Timestamp getSentOn() {
return SentOn;
}
public void setSentOn(Timestamp sentOn) {
SentOn = sentOn;
}
}

View File

@ -23,12 +23,10 @@ import com.google.gson.annotations.SerializedName;
public class QuotaRefreshResponse extends BaseResponse {
@SerializedName("result")
@Param(description = "Execution result for the quota refresh command")
private String result;
public QuotaRefreshResponse() {
super();
// TODO Auto-generated constructor stub
@ -38,6 +36,7 @@ public class QuotaRefreshResponse extends BaseResponse {
super();
this.result = result;
}
public String getResult() {
return result;
}

View File

@ -24,86 +24,85 @@ import com.cloud.serializer.Param;
public class QuotaStatementResponse extends BaseResponse {
@SerializedName("usageType")
@Param(description = "usageType")
private String usageType;
@SerializedName("usageType")
@Param(description = "usageType")
private String usageType;
@SerializedName("usageUnit")
@Param(description = "usageUnit")
private String usageUnit;
@SerializedName("usageUnit")
@Param(description = "usageUnit")
private String usageUnit;
@SerializedName("usageDiscriminator")
@Param(description = "usageDiscriminator")
private String usageDiscriminator;
@SerializedName("usageDiscriminator")
@Param(description = "usageDiscriminator")
private String usageDiscriminator;
@SerializedName("currencyValue")
@Param(description = "currencyValue")
private int currencyValue;
@SerializedName("currencyValue")
@Param(description = "currencyValue")
private int currencyValue;
@SerializedName("include")
@Param(description = "include")
private int include;
@SerializedName("include")
@Param(description = "include")
private int include;
@SerializedName("description")
@Param(description = "description")
private String description;
@SerializedName("description")
@Param(description = "description")
private String description;
public QuotaStatementResponse() {
super();
}
public QuotaStatementResponse() {
super();
}
public QuotaStatementResponse(final String usageType) {
super();
this.usageType = usageType;
}
public QuotaStatementResponse(final String usageType) {
super();
this.usageType = usageType;
}
public String getUsageType() {
return usageType;
}
public String getUsageType() {
return usageType;
}
public void setUsageType(String usageType) {
this.usageType = usageType;
}
public void setUsageType(String usageType) {
this.usageType = usageType;
}
public String getUsageUnit() {
return usageUnit;
}
public String getUsageUnit() {
return usageUnit;
}
public void setUsageUnit(String usageUnit) {
this.usageUnit = usageUnit;
}
public void setUsageUnit(String usageUnit) {
this.usageUnit = usageUnit;
}
public String getUsageDiscriminator() {
return usageDiscriminator;
}
public String getUsageDiscriminator() {
return usageDiscriminator;
}
public void setUsageDiscriminator(String usageDiscriminator) {
this.usageDiscriminator = usageDiscriminator;
}
public void setUsageDiscriminator(String usageDiscriminator) {
this.usageDiscriminator = usageDiscriminator;
}
public int getCurrencyValue() {
return currencyValue;
}
public int getCurrencyValue() {
return currencyValue;
}
public void setCurrencyValue(int currencyValue) {
this.currencyValue = currencyValue;
}
public void setCurrencyValue(int currencyValue) {
this.currencyValue = currencyValue;
}
public int getInclude() {
return include;
}
public int getInclude() {
return include;
}
public void setInclude(int include) {
this.include = include;
}
public void setInclude(int include) {
this.include = include;
}
public String getDescription() {
return description;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@ -0,0 +1,58 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.response;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import com.cloud.serializer.Param;
public class QuotaTypeResponse extends BaseResponse {
@SerializedName("quotatypeid")
@Param(description = "quota type")
private Integer quotaType;
@SerializedName(ApiConstants.DESCRIPTION)
@Param(description = "description of usage type")
private String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getQuotaType() {
return quotaType;
}
public void setQuotaType(Integer quotaType) {
this.quotaType = quotaType;
}
public QuotaTypeResponse(Integer quotaType, String description) {
this.quotaType = quotaType;
this.description = description;
setObjectName("usagetype");
}
}

View File

@ -61,9 +61,7 @@ public class QuotaBalanceVO implements InternalIdentity {
public QuotaBalanceVO() {
}
public QuotaBalanceVO(Long accountId, Long domainId,
BigDecimal creditBalance, Date updatedOn, Long previousUpdateId,
Date previousUpdateOn) {
public QuotaBalanceVO(Long accountId, Long domainId, BigDecimal creditBalance, Date updatedOn, Long previousUpdateId, Date previousUpdateOn) {
super();
this.accountId = accountId;
this.domainId = domainId;

View File

@ -67,11 +67,9 @@ public class QuotaConfigurationVO implements InternalIdentity {
@Column(name = "description")
private String description;
public QuotaConfigurationVO() {
}
public QuotaConfigurationVO(final String usagetype, final String usageunit, final String usagediscriminator, final int currencyvalue, final int include, final String description) {
this.usageType = usagetype;
this.usageUnit = usageunit;
@ -81,67 +79,54 @@ public class QuotaConfigurationVO implements InternalIdentity {
this.description = description;
}
public String getUsageType() {
return usageType;
}
public void setUsageType(String usageType) {
this.usageType = usageType;
}
public String getUsageUnit() {
return usageUnit;
}
public void setUsageUnit(String usageUnit) {
this.usageUnit = usageUnit;
}
public String getUsageDiscriminator() {
return usageDiscriminator;
}
public void setUsageDiscriminator(String usageDiscriminator) {
this.usageDiscriminator = usageDiscriminator;
}
public int getCurrencyValue() {
return currencyValue;
}
public void setCurrencyValue(int currencyValue) {
this.currencyValue = currencyValue;
}
public int getInclude() {
return include;
}
public void setInclude(int include) {
this.include = include;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public long getId() {
// TODO Auto-generated method stub

View File

@ -54,8 +54,7 @@ public class QuotaCreditsVO implements InternalIdentity {
public QuotaCreditsVO() {
}
public QuotaCreditsVO(long accountId, long domainId, int credit,
long updatedBy) {
public QuotaCreditsVO(long accountId, long domainId, int credit, long updatedBy) {
super();
this.accountId = accountId;
this.domainId = domainId;

View File

@ -0,0 +1,39 @@
//Licensed to the Apache Software Foundation (ASF) under one
//or more contributor license agreements. See the NOTICE file
//distributed with this work for additional information
//regarding copyright ownership. The ASF licenses this file
//to you under the Apache License, Version 2.0 (the
//"License"); you may not use this file except in compliance
//with the License. You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing,
//software distributed under the License is distributed on an
//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//KIND, either express or implied. See the License for the
//specific language governing permissions and limitations
//under the License.
package org.apache.cloudstack.quota;
import java.util.List;
import org.apache.cloudstack.api.command.QuotaEditMappingCmd;
import org.apache.cloudstack.api.command.QuotaMapping;
import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
import org.apache.cloudstack.api.response.QuotaCreditsResponse;
import com.cloud.utils.Pair;
import com.cloud.utils.component.PluggableService;
public interface QuotaDBUtils extends PluggableService {
Pair<List<QuotaConfigurationVO>, Integer> editQuotaMapping(QuotaEditMappingCmd cmd);
Pair<List<QuotaConfigurationVO>, Integer> listConfigurations(QuotaMapping cmd);
QuotaConfigurationResponse createQuotaConfigurationResponse(QuotaConfigurationVO configuration);
QuotaCreditsResponse addQuotaCredits(Long accountId, Long domainId, Integer amount, Long updatedBy);
}

View File

@ -0,0 +1,100 @@
//Licensed to the Apache Software Foundation (ASF) under one
//or more contributor license agreements. See the NOTICE file
//distributed with this work for additional information
//regarding copyright ownership. The ASF licenses this file
//to you under the Apache License, Version 2.0 (the
//"License"); you may not use this file except in compliance
//with the License. You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing,
//software distributed under the License is distributed on an
//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//KIND, either express or implied. See the License for the
//specific language governing permissions and limitations
//under the License.
package org.apache.cloudstack.quota;
import java.util.Date;
import java.util.List;
import javax.ejb.Local;
import javax.inject.Inject;
import org.apache.cloudstack.api.command.QuotaEditMappingCmd;
import org.apache.cloudstack.api.command.QuotaMapping;
import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
import org.apache.cloudstack.api.response.QuotaCreditsResponse;
import org.apache.cloudstack.quota.dao.QuotaConfigurationDao;
import org.apache.cloudstack.quota.dao.QuotaCreditsDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.utils.Pair;
import com.cloud.utils.db.TransactionLegacy;
@Component
@Local(value = QuotaDBUtilsImpl.class)
public class QuotaDBUtilsImpl {
private static final Logger s_logger = Logger.getLogger(QuotaDBUtilsImpl.class.getName());
@Inject
private QuotaConfigurationDao _quotaConfigurationDao;
@Inject
private QuotaCreditsDao _quotaCreditsDao;
public QuotaConfigurationResponse createQuotaConfigurationResponse(final QuotaConfigurationVO configuration) {
final QuotaConfigurationResponse response = new QuotaConfigurationResponse();
response.setUsageType(configuration.getUsageType());
response.setUsageUnit(configuration.getUsageUnit());
response.setUsageDiscriminator(configuration.getUsageDiscriminator());
response.setCurrencyValue(configuration.getCurrencyValue());
response.setInclude(configuration.getInclude());
response.setDescription(configuration.getDescription());
return response;
}
public Pair<List<QuotaConfigurationVO>, Integer> listConfigurations(final QuotaMapping cmd) {
final Pair<List<QuotaConfigurationVO>, Integer> result = _quotaConfigurationDao.searchConfigurations();
TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
return result;
}
public Pair<List<QuotaConfigurationVO>, Integer> editQuotaMapping(QuotaEditMappingCmd cmd) {
String resourceName = cmd.getUsageType();
Integer quotaMapping = cmd.getValue();
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
try {
QuotaConfigurationVO result = _quotaConfigurationDao.findByUsageType(resourceName);
if (result == null)
throw new InvalidParameterValueException(resourceName);
s_logger.info("Old value=" + result.getCurrencyValue() + ", new value = " + quotaMapping + ", for resource =" + resourceName);
result.setCurrencyValue(quotaMapping);
_quotaConfigurationDao.persist(result);
} finally {
txn.close();
}
final Pair<List<QuotaConfigurationVO>, Integer> result = _quotaConfigurationDao.searchConfigurations();
TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
return result;
}
public QuotaCreditsResponse addQuotaCredits(Long accountId, Long domainId, Integer amount, Long updatedBy) {
QuotaCreditsVO result = null;
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
try {
QuotaCreditsVO credits = new QuotaCreditsVO(accountId, domainId, amount, updatedBy);
credits.setUpdatedOn(new Date());
result = _quotaCreditsDao.persist(credits);
} finally {
txn.close();
}
TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
return new QuotaCreditsResponse(result);
}
}

View File

@ -43,7 +43,6 @@ public class QuotaEmailTemplatesVO implements InternalIdentity {
@Column(name = "template_text")
private String templateText;
@Column(name = "category")
private Integer category;
@ -60,8 +59,7 @@ public class QuotaEmailTemplatesVO implements InternalIdentity {
public QuotaEmailTemplatesVO() {
}
public QuotaEmailTemplatesVO(String templateName, String templateText,
String locale, Integer version) {
public QuotaEmailTemplatesVO(String templateName, String templateText, String locale, Integer version) {
super();
this.templateName = templateName;
this.templateText = templateText;
@ -91,7 +89,6 @@ public class QuotaEmailTemplatesVO implements InternalIdentity {
this.templateText = templateText;
}
public Integer getCategory() {
return category;
}

View File

@ -16,26 +16,10 @@
//under the License.
package org.apache.cloudstack.quota;
import java.util.List;
import org.apache.cloudstack.api.command.ListQuotaConfigurationsCmd;
import org.apache.cloudstack.api.command.QuotaEditResourceMappingCmd;
import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
import org.apache.cloudstack.api.response.QuotaCreditsResponse;
import com.cloud.utils.Pair;
import com.cloud.utils.component.PluggableService;
public interface QuotaManager extends PluggableService {
public void calculateQuotaUsage(QuotaJobVO job, long startDateMillis, long endDateMillis);
Pair<List<QuotaConfigurationVO>, Integer> editQuotaMapping(QuotaEditResourceMappingCmd cmd);
Pair<List<QuotaConfigurationVO>, Integer> listConfigurations(ListQuotaConfigurationsCmd cmd);
QuotaConfigurationResponse createQuotaConfigurationResponse(QuotaConfigurationVO configuration);
QuotaCreditsResponse addQuotaCredits(Long accountId, Long domainId, Integer amount, Long updatedBy);
}

View File

@ -24,37 +24,25 @@ import java.util.TimeZone;
import javax.ejb.Local;
import javax.inject.Inject;
import org.apache.cloudstack.api.command.ListQuotaConfigurationsCmd;
import org.apache.cloudstack.api.command.QuotaMapping;
import org.apache.cloudstack.api.command.QuotaCreditsCmd;
import org.apache.cloudstack.api.command.QuotaEditResourceMappingCmd;
import org.apache.cloudstack.api.command.QuotaEditMappingCmd;
import org.apache.cloudstack.api.command.QuotaEmailTemplateAddCmd;
import org.apache.cloudstack.api.command.QuotaRefreshCmd;
import org.apache.cloudstack.api.command.QuotaStatementCmd;
import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
import org.apache.cloudstack.api.response.QuotaCreditsResponse;
import org.apache.cloudstack.quota.dao.QuotaConfigurationDao;
import org.apache.cloudstack.quota.dao.QuotaCreditsDao;
import org.apache.cloudstack.api.command.QuotaTypesCmd;
import org.apache.cloudstack.quota.dao.QuotaJobDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.usage.UsageJobVO;
import com.cloud.utils.Pair;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.db.TransactionLegacy;
@Component
@Local(value = QuotaManager.class)
public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
private static final Logger s_logger = Logger
.getLogger(QuotaManagerImpl.class.getName());
@Inject
private QuotaConfigurationDao _quotaConfigurationDao;
@Inject
private QuotaCreditsDao _quotaCreditsDao;
private static final Logger s_logger = Logger.getLogger(QuotaManagerImpl.class.getName());
@Inject
private QuotaJobDao _quotaJobDao;
@ -67,88 +55,21 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
super();
}
public QuotaManagerImpl(final QuotaConfigurationDao quotaConfigurationDao) {
super();
_quotaConfigurationDao = quotaConfigurationDao;
}
@Override
public List<Class<?>> getCommands() {
final List<Class<?>> cmdList = new ArrayList<Class<?>>();
cmdList.add(ListQuotaConfigurationsCmd.class);
cmdList.add(QuotaTypesCmd.class);
cmdList.add(QuotaMapping.class);
cmdList.add(QuotaCreditsCmd.class);
cmdList.add(QuotaEmailTemplateAddCmd.class);
cmdList.add(QuotaRefreshCmd.class);
cmdList.add(QuotaStatementCmd.class);
cmdList.add(QuotaEditResourceMappingCmd.class);
cmdList.add(QuotaEditMappingCmd.class);
return cmdList;
}
@Override
public Pair<List<QuotaConfigurationVO>, Integer> listConfigurations(
final ListQuotaConfigurationsCmd cmd) {
final Pair<List<QuotaConfigurationVO>, Integer> result = _quotaConfigurationDao
.searchConfigurations();
TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
return result;
}
@Override
public QuotaConfigurationResponse createQuotaConfigurationResponse(
final QuotaConfigurationVO configuration) {
final QuotaConfigurationResponse response = new QuotaConfigurationResponse();
response.setUsageType(configuration.getUsageType());
response.setUsageUnit(configuration.getUsageUnit());
response.setUsageDiscriminator(configuration.getUsageDiscriminator());
response.setCurrencyValue(configuration.getCurrencyValue());
response.setInclude(configuration.getInclude());
response.setDescription(configuration.getDescription());
return response;
}
@Override
public Pair<List<QuotaConfigurationVO>, Integer> editQuotaMapping(
QuotaEditResourceMappingCmd cmd) {
String resourceName = cmd.getUsageType();
Integer quotaMapping = cmd.getValue();
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
try {
QuotaConfigurationVO result = _quotaConfigurationDao.findByUsageType(resourceName);
if (result==null) throw new InvalidParameterValueException(resourceName);
s_logger.info("Old value=" + result.getCurrencyValue() + ", new value = " + quotaMapping + ", for resource =" + resourceName);
result.setCurrencyValue(quotaMapping);
_quotaConfigurationDao.persist(result);
} finally {
txn.close();
}
final Pair<List<QuotaConfigurationVO>, Integer> result = _quotaConfigurationDao.searchConfigurations();
TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
return result;
}
@Override
public QuotaCreditsResponse addQuotaCredits(Long accountId, Long domainId,
Integer amount, Long updatedBy) {
QuotaCreditsVO result = null;
TransactionLegacy txn = TransactionLegacy
.open(TransactionLegacy.USAGE_DB);
try {
QuotaCreditsVO credits = new QuotaCreditsVO(accountId, domainId,
amount, updatedBy);
credits.setUpdatedOn(new Date());
result = _quotaCreditsDao.persist(credits);
} finally {
txn.close();
}
TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
return new QuotaCreditsResponse(result);
}
@Override
public void calculateQuotaUsage(QuotaJobVO job, long startDateMillis,
long endDateMillis) {
public void calculateQuotaUsage(QuotaJobVO job, long startDateMillis, long endDateMillis) {
boolean success = false;
long timeStart = System.currentTimeMillis();
@ -170,7 +91,8 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
TransactionLegacy jobUpdateTxn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
try {
jobUpdateTxn.start();
// everything seemed to work...set endDate as the last success date
// everything seemed to work...set endDate as the last
// success date
_quotaJobDao.updateJobSuccess(job.getId(), startDateMillis, endDateMillis, System.currentTimeMillis() - timeStart, success);
// create a new job if this is a recurring job
@ -191,8 +113,7 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
s_logger.info("Calculating quota usage for records between " + startDate + " and " + endDate);
}
//get all the accounts from usage db
TransactionLegacy userTxn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
// get all the accounts from usage db
} catch (Exception e) {
s_logger.error("Quota Manager error", e);
}

View File

@ -30,9 +30,7 @@ import org.apache.cloudstack.api.InternalIdentity;
@Entity
@Table(name = "quota_sent_emails")
public class QuotaSentEmailsVO implements InternalIdentity {
public QuotaSentEmailsVO(Long id, String fromAddress, String toAddress,
String ccAddress, String bccAddress, Date sendDate, String subject,
String mailText, Long version, Long updatedBy) {
public QuotaSentEmailsVO(Long id, String fromAddress, String toAddress, String ccAddress, String bccAddress, Date sendDate, String subject, String mailText, Long version, Long updatedBy) {
super();
this.id = id;
this.fromAddress = fromAddress;
@ -46,7 +44,6 @@ public class QuotaSentEmailsVO implements InternalIdentity {
this.updatedBy = updatedBy;
}
private static final long serialVersionUID = -7117933845287653210L;
@Id

View File

@ -0,0 +1,58 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.quota;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.api.response.QuotaTypeResponse;
import org.apache.cloudstack.usage.UsageTypes;
public class QuotaUsageTypes extends UsageTypes {
public static final int CPU_CLOCK_RATE = 24;
public static final int CPU_NUMBER = 25;
public static final int MEMORY = 26;
public static List<QuotaTypeResponse> responseList = new ArrayList<QuotaTypeResponse>();
public static List<QuotaTypeResponse> listQuotaUsageTypes() {
responseList.add(new QuotaTypeResponse(RUNNING_VM, "Running Vm Usage"));
responseList.add(new QuotaTypeResponse(ALLOCATED_VM, "Allocated Vm Usage"));
responseList.add(new QuotaTypeResponse(IP_ADDRESS, "IP Address Usage"));
responseList.add(new QuotaTypeResponse(NETWORK_BYTES_SENT, "Network Usage (Bytes Sent)"));
responseList.add(new QuotaTypeResponse(NETWORK_BYTES_RECEIVED, "Network Usage (Bytes Received)"));
responseList.add(new QuotaTypeResponse(VOLUME, "Volume Usage"));
responseList.add(new QuotaTypeResponse(TEMPLATE, "Template Usage"));
responseList.add(new QuotaTypeResponse(ISO, "ISO Usage"));
responseList.add(new QuotaTypeResponse(SNAPSHOT, "Snapshot Usage"));
responseList.add(new QuotaTypeResponse(SECURITY_GROUP, "Security Group Usage"));
responseList.add(new QuotaTypeResponse(LOAD_BALANCER_POLICY, "Load Balancer Usage"));
responseList.add(new QuotaTypeResponse(PORT_FORWARDING_RULE, "Port Forwarding Usage"));
responseList.add(new QuotaTypeResponse(NETWORK_OFFERING, "Network Offering Usage"));
responseList.add(new QuotaTypeResponse(VPN_USERS, "VPN users usage"));
responseList.add(new QuotaTypeResponse(VM_DISK_IO_READ, "VM Disk usage(I/O Read)"));
responseList.add(new QuotaTypeResponse(VM_DISK_IO_WRITE, "VM Disk usage(I/O Write)"));
responseList.add(new QuotaTypeResponse(VM_DISK_BYTES_READ, "VM Disk usage(Bytes Read)"));
responseList.add(new QuotaTypeResponse(VM_DISK_BYTES_WRITE, "VM Disk usage(Bytes Write)"));
responseList.add(new QuotaTypeResponse(VM_SNAPSHOT, "VM Snapshot storage usage"));
responseList.add(new QuotaTypeResponse(CPU_CLOCK_RATE, "Quota mapping for usign 1 CPU of clock rate 100MHz"));
responseList.add(new QuotaTypeResponse(CPU_NUMBER, "Quota mapping for running VM that has 1vCPU"));
responseList.add(new QuotaTypeResponse(MEMORY, "Quota mapping for usign 1MB or RAM for 1 hour"));
return responseList;
}
}

View File

@ -58,8 +58,7 @@ public class QuotaUsageVO implements InternalIdentity {
public QuotaUsageVO() {
}
public QuotaUsageVO(Long usageItemId, String usageType,
BigDecimal quotaUsed, Date startDate, Date endDate) {
public QuotaUsageVO(Long usageItemId, String usageType, BigDecimal quotaUsed, Date startDate, Date endDate) {
super();
this.usageItemId = usageItemId;
this.usageType = usageType;

View File

@ -27,8 +27,8 @@ import com.cloud.utils.db.SearchCriteria;
public interface QuotaBalanceDao extends GenericDao<QuotaBalanceVO, Long> {
Pair<List<QuotaBalanceVO>, Integer> searchBalance(SearchCriteria<QuotaBalanceVO> sc, Filter filter);
Pair<List<QuotaBalanceVO>, Integer> searchBalance(SearchCriteria<QuotaBalanceVO> sc, Filter filter);
void saveQuotaBalance(List<QuotaBalanceVO> credits);
void saveQuotaBalance(List<QuotaBalanceVO> credits);
}

View File

@ -29,12 +29,11 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchCriteria;
@Component
@Local(value = {QuotaBalanceDao.class})
@Local(value = { QuotaBalanceDao.class })
public class QuotaBalanceDaoImpl extends GenericDaoBase<QuotaBalanceVO, Long> implements QuotaBalanceDao {
@Override
public Pair<List<QuotaBalanceVO>, Integer> searchBalance(
SearchCriteria<QuotaBalanceVO> sc, Filter filter) {
public Pair<List<QuotaBalanceVO>, Integer> searchBalance(SearchCriteria<QuotaBalanceVO> sc, Filter filter) {
// TODO Auto-generated method stub
return null;
}

View File

@ -25,8 +25,8 @@ import com.cloud.utils.db.GenericDao;
public interface QuotaConfigurationDao extends GenericDao<QuotaConfigurationVO, Long> {
QuotaConfigurationVO findByUsageType(String usageType);
QuotaConfigurationVO findByUsageType(String usageType);
Pair<List<QuotaConfigurationVO>, Integer> searchConfigurations();
Pair<List<QuotaConfigurationVO>, Integer> searchConfigurations();
}

View File

@ -30,40 +30,39 @@ import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.TransactionLegacy;
@Component
@Local(value = {QuotaConfigurationDao.class})
@Local(value = { QuotaConfigurationDao.class })
public class QuotaConfigurationDaoImpl extends GenericDaoBase<QuotaConfigurationVO, Long> implements QuotaConfigurationDao {
private final SearchBuilder<QuotaConfigurationVO> searchUsageType;
private final SearchBuilder<QuotaConfigurationVO> listAllIncludedUsageType;
private final SearchBuilder<QuotaConfigurationVO> searchUsageType;
private final SearchBuilder<QuotaConfigurationVO> listAllIncludedUsageType;
public QuotaConfigurationDaoImpl() {
super();
searchUsageType = createSearchBuilder();
searchUsageType.and("usage_type", searchUsageType.entity().getUsageType(), SearchCriteria.Op.EQ);
searchUsageType.done();
public QuotaConfigurationDaoImpl() {
super();
searchUsageType = createSearchBuilder();
searchUsageType.and("usage_type", searchUsageType.entity().getUsageType(), SearchCriteria.Op.EQ);
searchUsageType.done();
listAllIncludedUsageType = createSearchBuilder();
listAllIncludedUsageType.and("include", listAllIncludedUsageType.entity().getInclude(), SearchCriteria.Op.EQ);
listAllIncludedUsageType.done();
}
listAllIncludedUsageType = createSearchBuilder();
listAllIncludedUsageType.and("include", listAllIncludedUsageType.entity().getInclude(), SearchCriteria.Op.EQ);
listAllIncludedUsageType.done();
}
@Override
public QuotaConfigurationVO findByUsageType(final String usageType) {
final SearchCriteria<QuotaConfigurationVO> sc = searchUsageType.create();
sc.setParameters("usage_type", usageType);
return findOneBy(sc);
}
@Override
public Pair<List<QuotaConfigurationVO>, Integer> searchConfigurations() {
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
try {
final SearchCriteria<QuotaConfigurationVO> sc = listAllIncludedUsageType.create();
sc.setParameters("include", 1);
return searchAndCount(sc, null);
} finally {
txn.close();
}
}
@Override
public QuotaConfigurationVO findByUsageType(final String usageType) {
final SearchCriteria<QuotaConfigurationVO> sc = searchUsageType.create();
sc.setParameters("usage_type", usageType);
return findOneBy(sc);
}
@Override
public Pair<List<QuotaConfigurationVO>, Integer> searchConfigurations() {
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
try {
final SearchCriteria<QuotaConfigurationVO> sc = listAllIncludedUsageType.create();
sc.setParameters("include", 1);
return searchAndCount(sc, null);
} finally {
txn.close();
}
}
}

View File

@ -27,8 +27,8 @@ import com.cloud.utils.db.SearchCriteria;
public interface QuotaCreditsDao extends GenericDao<QuotaCreditsVO, Long> {
Pair<List<QuotaCreditsVO>, Integer> searchAndCountAllRecords(SearchCriteria<QuotaCreditsVO> sc, Filter filter);
Pair<List<QuotaCreditsVO>, Integer> searchAndCountAllRecords(SearchCriteria<QuotaCreditsVO> sc, Filter filter);
void saveQuotaCredits(List<QuotaCreditsVO> credits);
void saveQuotaCredits(List<QuotaCreditsVO> credits);
}

View File

@ -29,12 +29,11 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchCriteria;
@Component
@Local(value = {QuotaCreditsDao.class})
@Local(value = { QuotaCreditsDao.class })
public class QuotaCreditsDaoImpl extends GenericDaoBase<QuotaCreditsVO, Long> implements QuotaCreditsDao {
@Override
public Pair<List<QuotaCreditsVO>, Integer> searchAndCountAllRecords(
SearchCriteria<QuotaCreditsVO> sc, Filter filter) {
public Pair<List<QuotaCreditsVO>, Integer> searchAndCountAllRecords(SearchCriteria<QuotaCreditsVO> sc, Filter filter) {
// TODO Auto-generated method stub
return null;
}

View File

@ -28,8 +28,8 @@ import com.cloud.utils.db.SearchCriteria;
public interface QuotaEmailTemplatesDao extends GenericDao<QuotaEmailTemplatesVO, Long> {
QuotaEmailTemplatesVO fetchTemplate(String templateName);
QuotaEmailTemplatesVO fetchTemplate(String templateName);
Pair<List<QuotaBalanceVO>, Integer> searchBalance(SearchCriteria<QuotaBalanceVO> sc, Filter filter);
Pair<List<QuotaBalanceVO>, Integer> searchBalance(SearchCriteria<QuotaBalanceVO> sc, Filter filter);
}

View File

@ -30,7 +30,7 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchCriteria;
@Component
@Local(value = {QuotaEmailTemplatesDao.class})
@Local(value = { QuotaEmailTemplatesDao.class })
public class QuotaEmailTemplatesDaoImpl extends GenericDaoBase<QuotaEmailTemplatesVO, Long> implements QuotaEmailTemplatesDao {
@Override
@ -40,8 +40,7 @@ public class QuotaEmailTemplatesDaoImpl extends GenericDaoBase<QuotaEmailTemplat
}
@Override
public Pair<List<QuotaBalanceVO>, Integer> searchBalance(
SearchCriteria<QuotaBalanceVO> sc, Filter filter) {
public Pair<List<QuotaBalanceVO>, Integer> searchBalance(SearchCriteria<QuotaBalanceVO> sc, Filter filter) {
// TODO Auto-generated method stub
return null;
}

View File

@ -23,19 +23,19 @@ import org.apache.cloudstack.quota.QuotaJobVO;
import com.cloud.utils.db.GenericDao;
public interface QuotaJobDao extends GenericDao<QuotaJobVO, Long> {
Long checkHeartbeat(String hostname, int pid, int aggregationDuration);
Long checkHeartbeat(String hostname, int pid, int aggregationDuration);
void createNewJob(String hostname, int pid, int jobType);
void createNewJob(String hostname, int pid, int jobType);
QuotaJobVO getLastJob();
QuotaJobVO getLastJob();
QuotaJobVO getNextImmediateJob();
QuotaJobVO getNextImmediateJob();
long getLastJobSuccessDateMillis();
long getLastJobSuccessDateMillis();
Date getLastHeartbeat();
Date getLastHeartbeat();
QuotaJobVO isOwner(String hostname, int pid);
QuotaJobVO isOwner(String hostname, int pid);
void updateJobSuccess(Long jobId, long startMillis, long endMillis, long execTime, boolean success);
void updateJobSuccess(Long jobId, long startMillis, long endMillis, long execTime, boolean success);
}

View File

@ -34,168 +34,168 @@ import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.exception.CloudRuntimeException;
@Component
@Local(value = {QuotaJobDao.class})
@Local(value = { QuotaJobDao.class })
public class QuotaJobDaoImpl extends GenericDaoBase<QuotaJobVO, Long> implements QuotaJobDao {
private static final Logger s_logger = Logger.getLogger(QuotaJobDaoImpl.class.getName());
private static final Logger s_logger = Logger.getLogger(QuotaJobDaoImpl.class.getName());
private static final String GET_LAST_JOB_SUCCESS_DATE_MILLIS =
"SELECT end_millis FROM cloud_usage.usage_job WHERE end_millis > 0 and success = 1 ORDER BY end_millis DESC LIMIT 1";
private static final String GET_LAST_JOB_SUCCESS_DATE_MILLIS = "SELECT end_millis FROM cloud_usage.usage_job WHERE end_millis > 0 and success = 1 ORDER BY end_millis DESC LIMIT 1";
@Override
public long getLastJobSuccessDateMillis() {
TransactionLegacy txn = TransactionLegacy.currentTxn();
PreparedStatement pstmt = null;
String sql = GET_LAST_JOB_SUCCESS_DATE_MILLIS;
try {
pstmt = txn.prepareAutoCloseStatement(sql);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
return rs.getLong(1);
}
} catch (Exception ex) {
s_logger.error("error getting last usage job success date", ex);
} finally {
txn.close();
}
return 0L;
}
@Override
public long getLastJobSuccessDateMillis() {
TransactionLegacy txn = TransactionLegacy.currentTxn();
PreparedStatement pstmt = null;
String sql = GET_LAST_JOB_SUCCESS_DATE_MILLIS;
try {
pstmt = txn.prepareAutoCloseStatement(sql);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
return rs.getLong(1);
}
} catch (Exception ex) {
s_logger.error("error getting last usage job success date", ex);
} finally {
txn.close();
}
return 0L;
}
@Override
public void updateJobSuccess(Long jobId, long startMillis, long endMillis, long execTime, boolean success) {
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
try {
txn.start();
@Override
public void updateJobSuccess(Long jobId, long startMillis, long endMillis, long execTime, boolean success) {
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
try {
txn.start();
QuotaJobVO job = lockRow(jobId, Boolean.TRUE);
QuotaJobVO jobForUpdate = createForUpdate();
jobForUpdate.setStartMillis(startMillis);
jobForUpdate.setEndMillis(endMillis);
jobForUpdate.setExecTime(execTime);
jobForUpdate.setStartDate(new Date(startMillis));
jobForUpdate.setEndDate(new Date(endMillis));
jobForUpdate.setSuccess(success);
update(job.getId(), jobForUpdate);
QuotaJobVO job = lockRow(jobId, Boolean.TRUE);
QuotaJobVO jobForUpdate = createForUpdate();
jobForUpdate.setStartMillis(startMillis);
jobForUpdate.setEndMillis(endMillis);
jobForUpdate.setExecTime(execTime);
jobForUpdate.setStartDate(new Date(startMillis));
jobForUpdate.setEndDate(new Date(endMillis));
jobForUpdate.setSuccess(success);
update(job.getId(), jobForUpdate);
txn.commit();
} catch (Exception ex) {
txn.rollback();
s_logger.error("error updating job success date", ex);
throw new CloudRuntimeException(ex.getMessage());
} finally {
txn.close();
}
}
txn.commit();
} catch (Exception ex) {
txn.rollback();
s_logger.error("error updating job success date", ex);
throw new CloudRuntimeException(ex.getMessage());
} finally {
txn.close();
}
}
@Override
public Long checkHeartbeat(String hostname, int pid, int aggregationDuration) {
QuotaJobVO job = getNextRecurringJob();
if (job == null) {
return null;
}
@Override
public Long checkHeartbeat(String hostname, int pid, int aggregationDuration) {
QuotaJobVO job = getNextRecurringJob();
if (job == null) {
return null;
}
if (job.getHost().equals(hostname) && (job.getPid() != null) && (job.getPid().intValue() == pid)) {
return job.getId();
}
if (job.getHost().equals(hostname) && (job.getPid() != null) && (job.getPid().intValue() == pid)) {
return job.getId();
}
Date lastHeartbeat = job.getHeartbeat();
if (lastHeartbeat == null) {
return null;
}
Date lastHeartbeat = job.getHeartbeat();
if (lastHeartbeat == null) {
return null;
}
long sinceLastHeartbeat = System.currentTimeMillis() - lastHeartbeat.getTime();
long sinceLastHeartbeat = System.currentTimeMillis() - lastHeartbeat.getTime();
// TODO: Make this check a little smarter..but in the mean time we want the mgmt
// server to monitor the usage server, we need to make sure other usage
// servers take over as the usage job owner more aggressively. For now
// this is hardcoded to 5 minutes.
if (sinceLastHeartbeat > (5 * 60 * 1000)) {
return job.getId();
}
return null;
}
// TODO: Make this check a little smarter..but in the mean time we want
// the mgmt
// server to monitor the usage server, we need to make sure other usage
// servers take over as the usage job owner more aggressively. For now
// this is hardcoded to 5 minutes.
if (sinceLastHeartbeat > (5 * 60 * 1000)) {
return job.getId();
}
return null;
}
@Override
public QuotaJobVO isOwner(String hostname, int pid) {
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
try {
if ((hostname == null) || (pid <= 0)) {
return null;
}
@Override
public QuotaJobVO isOwner(String hostname, int pid) {
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
try {
if ((hostname == null) || (pid <= 0)) {
return null;
}
QuotaJobVO job = getLastJob();
if (job == null) {
return null;
}
QuotaJobVO job = getLastJob();
if (job == null) {
return null;
}
if (hostname.equals(job.getHost()) && (job.getPid() != null) && (pid == job.getPid().intValue())) {
return job;
}
} finally {
txn.close();
}
return null;
}
if (hostname.equals(job.getHost()) && (job.getPid() != null) && (pid == job.getPid().intValue())) {
return job;
}
} finally {
txn.close();
}
return null;
}
@Override
public void createNewJob(String hostname, int pid, int jobType) {
QuotaJobVO newJob = new QuotaJobVO();
newJob.setHost(hostname);
newJob.setPid(pid);
newJob.setHeartbeat(new Date());
newJob.setJobType(jobType);
persist(newJob);
}
@Override
public void createNewJob(String hostname, int pid, int jobType) {
QuotaJobVO newJob = new QuotaJobVO();
newJob.setHost(hostname);
newJob.setPid(pid);
newJob.setHeartbeat(new Date());
newJob.setJobType(jobType);
persist(newJob);
}
@Override
public QuotaJobVO getLastJob() {
Filter filter = new Filter(QuotaJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
SearchCriteria<QuotaJobVO> sc = createSearchCriteria();
sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
List<QuotaJobVO> jobs = search(sc, filter);
@Override
public QuotaJobVO getLastJob() {
Filter filter = new Filter(QuotaJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
SearchCriteria<QuotaJobVO> sc = createSearchCriteria();
sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
List<QuotaJobVO> jobs = search(sc, filter);
if ((jobs == null) || jobs.isEmpty()) {
return null;
}
return jobs.get(0);
}
if ((jobs == null) || jobs.isEmpty()) {
return null;
}
return jobs.get(0);
}
private QuotaJobVO getNextRecurringJob() {
Filter filter = new Filter(QuotaJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
SearchCriteria<QuotaJobVO> sc = createSearchCriteria();
sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
sc.addAnd("jobType", SearchCriteria.Op.EQ, Integer.valueOf(QuotaJobVO.JOB_TYPE_RECURRING));
List<QuotaJobVO> jobs = search(sc, filter);
private QuotaJobVO getNextRecurringJob() {
Filter filter = new Filter(QuotaJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
SearchCriteria<QuotaJobVO> sc = createSearchCriteria();
sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
sc.addAnd("jobType", SearchCriteria.Op.EQ, Integer.valueOf(QuotaJobVO.JOB_TYPE_RECURRING));
List<QuotaJobVO> jobs = search(sc, filter);
if ((jobs == null) || jobs.isEmpty()) {
return null;
}
return jobs.get(0);
}
if ((jobs == null) || jobs.isEmpty()) {
return null;
}
return jobs.get(0);
}
@Override
public QuotaJobVO getNextImmediateJob() {
Filter filter = new Filter(QuotaJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
SearchCriteria<QuotaJobVO> sc = createSearchCriteria();
sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
sc.addAnd("jobType", SearchCriteria.Op.EQ, Integer.valueOf(QuotaJobVO.JOB_TYPE_SINGLE));
sc.addAnd("scheduled", SearchCriteria.Op.EQ, Integer.valueOf(0));
List<QuotaJobVO> jobs = search(sc, filter);
@Override
public QuotaJobVO getNextImmediateJob() {
Filter filter = new Filter(QuotaJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
SearchCriteria<QuotaJobVO> sc = createSearchCriteria();
sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
sc.addAnd("jobType", SearchCriteria.Op.EQ, Integer.valueOf(QuotaJobVO.JOB_TYPE_SINGLE));
sc.addAnd("scheduled", SearchCriteria.Op.EQ, Integer.valueOf(0));
List<QuotaJobVO> jobs = search(sc, filter);
if ((jobs == null) || jobs.isEmpty()) {
return null;
}
return jobs.get(0);
}
if ((jobs == null) || jobs.isEmpty()) {
return null;
}
return jobs.get(0);
}
@Override
public Date getLastHeartbeat() {
Filter filter = new Filter(QuotaJobVO.class, "heartbeat", false, Long.valueOf(0), Long.valueOf(1));
SearchCriteria<QuotaJobVO> sc = createSearchCriteria();
List<QuotaJobVO> jobs = search(sc, filter);
@Override
public Date getLastHeartbeat() {
Filter filter = new Filter(QuotaJobVO.class, "heartbeat", false, Long.valueOf(0), Long.valueOf(1));
SearchCriteria<QuotaJobVO> sc = createSearchCriteria();
List<QuotaJobVO> jobs = search(sc, filter);
if ((jobs == null) || jobs.isEmpty()) {
return null;
}
return jobs.get(0).getHeartbeat();
}
if ((jobs == null) || jobs.isEmpty()) {
return null;
}
return jobs.get(0).getHeartbeat();
}
}

View File

@ -29,12 +29,11 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchCriteria;
@Component
@Local(value = {QuotaSentEmailsDao.class})
@Local(value = { QuotaSentEmailsDao.class })
public class QuotaSentEmailsDaoImpl extends GenericDaoBase<QuotaSentEmailsVO, Long> implements QuotaSentEmailsDao {
@Override
public Pair<List<QuotaSentEmailsVO>, Integer> searchEmails(
SearchCriteria<QuotaSentEmailsVO> sc, Filter filter) {
public Pair<List<QuotaSentEmailsVO>, Integer> searchEmails(SearchCriteria<QuotaSentEmailsVO> sc, Filter filter) {
// TODO Auto-generated method stub
return null;
}

View File

@ -27,8 +27,8 @@ import com.cloud.utils.db.SearchCriteria;
public interface QuotaUsageDao extends GenericDao<QuotaUsageVO, Long> {
Pair<List<QuotaUsageVO>, Integer> searchAndCountAllRecords(SearchCriteria<QuotaUsageVO> sc, Filter filter);
Pair<List<QuotaUsageVO>, Integer> searchAndCountAllRecords(SearchCriteria<QuotaUsageVO> sc, Filter filter);
void saveQuotaUsage(List<QuotaUsageVO> credits);
void saveQuotaUsage(List<QuotaUsageVO> credits);
}

View File

@ -20,7 +20,8 @@ import java.util.List;
import javax.ejb.Local;
import org.springframework.stereotype.Component;import org.apache.cloudstack.quota.QuotaUsageVO;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.quota.QuotaUsageVO;
import com.cloud.utils.Pair;
import com.cloud.utils.db.Filter;
@ -28,12 +29,11 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchCriteria;
@Component
@Local(value = {QuotaUsageDao.class})
public class QuotaUsageDaoImpl extends GenericDaoBase<QuotaUsageVO, Long> implements QuotaUsageDao {
@Local(value = { QuotaUsageDao.class })
public class QuotaUsageDaoImpl extends GenericDaoBase<QuotaUsageVO, Long> implements QuotaUsageDao {
@Override
public Pair<List<QuotaUsageVO>, Integer> searchAndCountAllRecords(
SearchCriteria<QuotaUsageVO> sc, Filter filter) {
public Pair<List<QuotaUsageVO>, Integer> searchAndCountAllRecords(SearchCriteria<QuotaUsageVO> sc, Filter filter) {
// TODO Auto-generated method stub
return null;
}

View File

@ -125,7 +125,7 @@
var data = {};
listViewDataProvider(args, data);
$.ajax({
url: createURL('listQuotaConfigurations'),
url: createURL('quotaMapping'),
data: data,
success: function(json) {
var items = json.quotaconfigurationresponse.QuotaConfiguration;
@ -183,7 +183,7 @@
var items = [];
console.log(args);
$.ajax({
url: createURL("listQuotaConfigurations&hostname=" + args.context.quotaConfiguration[0].hostname),
url: createURL("quotaMapping&hostname=" + args.context.quotaConfiguration[0].hostname),
dataType: "json",
async: true,
success: function(json) {