Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/768#discussion_r46782968 --- Diff: framework/quota/src/org/apache/cloudstack/quota/QuotaStatementImpl.java --- @@ -0,0 +1,376 @@ +//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.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import javax.ejb.Local; +import javax.inject.Inject; +import javax.naming.ConfigurationException; + +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.quota.QuotaAlertManagerImpl.DeferredQuotaEmail; +import org.apache.cloudstack.quota.constant.QuotaConfig; +import org.apache.cloudstack.quota.dao.QuotaAccountDao; +import org.apache.cloudstack.quota.dao.QuotaUsageDao; +import org.apache.cloudstack.quota.vo.QuotaAccountVO; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; + +import com.cloud.user.AccountVO; +import com.cloud.user.dao.AccountDao; +import com.cloud.utils.component.ManagerBase; + +@Component +@Local(value = QuotaStatement.class) +public class QuotaStatementImpl extends ManagerBase implements QuotaStatement { + private static final Logger s_logger = Logger.getLogger(QuotaStatementImpl.class); + + @Inject + private AccountDao _accountDao; + @Inject + private QuotaAccountDao _quotaAcc; + @Inject + private QuotaUsageDao _quotaUsage; + @Inject + private QuotaAlertManager _quotaAlert; + @Inject + private ConfigurationDao _configDao; + + final public static int s_LAST_STATEMENT_SENT_DAYS = 6; //ideally should be less than 7 days + + public enum STATEMENT_PERIODS { + BIMONTHLY, MONTHLY, QUATERLY, HALFYEARLY, YEARLY + }; + + private STATEMENT_PERIODS _period = STATEMENT_PERIODS.MONTHLY; + + public QuotaStatementImpl() { + super(); + } + + private void mergeConfigs(Map<String, String> dbParams, Map<String, Object> xmlParams) { + for (Map.Entry<String, Object> param : xmlParams.entrySet()) { + dbParams.put(param.getKey(), (String)param.getValue()); + } + } + + @Override + public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { + super.configure(name, params); + + Map<String, String> configs = _configDao.getConfiguration(params); + + if (params != null) { + mergeConfigs(configs, params); + } + String period_str = configs.get(QuotaConfig.QuotaStatementPeriod.key()); + int period = period_str == null ? 1 : Integer.valueOf(period_str); + + STATEMENT_PERIODS _period = STATEMENT_PERIODS.values()[period]; + return true; + } + + @Override + public boolean start() { + if (s_logger.isInfoEnabled()) { + s_logger.info("Starting Alert Manager"); + } + return true; + } + + @Override + public boolean stop() { + if (s_logger.isInfoEnabled()) { + s_logger.info("Stopping Alert Manager"); --- End diff -- This log message seems deceptive. This class is about quota statements not alerts.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---