CLOUDSTACK-9667 Enable resourcecount.check.interval by default

This commit is contained in:
Bharat Kumar 2017-05-09 19:01:10 +05:30 committed by Rohit Yadav
parent 2b5892e54a
commit d98520a6da
3 changed files with 20 additions and 12 deletions

View File

@ -23,9 +23,13 @@ import com.cloud.configuration.ResourceCount;
import com.cloud.configuration.ResourceLimit;
import com.cloud.domain.Domain;
import com.cloud.exception.ResourceAllocationException;
import org.apache.cloudstack.framework.config.ConfigKey;
public interface ResourceLimitService {
static final ConfigKey<Long> ResourceCountCheckInterval = new ConfigKey<Long>("Advanced", Long.class, "resourcecount.check.interval", "300",
"Time (in seconds) to wait before retrying resource count check task. Default is 300, Setting this to 0 will not run the task", false);
/**
* Updates an existing resource limit with the specified details. If a limit doesn't exist, will create one.
*

View File

@ -1458,15 +1458,6 @@ public enum Config {
"The default maximum secondary storage space (in GiB) that can be used for an account",
null),
ResourceCountCheckInterval(
"Advanced",
ManagementServer.class,
Long.class,
"resourcecount.check.interval",
"0",
"Time (in seconds) to wait before retrying resource count check task. Default is 0 which is to never run the task",
"Seconds"),
//disabling lb as cluster sync does not work with distributed cluster
SubDomainNetworkAccess(
"Advanced",

View File

@ -26,9 +26,12 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.config.Configurable;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@ -83,7 +86,6 @@ import com.cloud.user.AccountManager;
import com.cloud.user.AccountVO;
import com.cloud.user.ResourceLimitService;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.DB;
@ -107,7 +109,8 @@ import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
@Component
public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLimitService {
@Local(value = {ResourceLimitService.class})
public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLimitService, Configurable{
public static final Logger s_logger = Logger.getLogger(ResourceLimitManagerImpl.class);
@Inject
@ -205,7 +208,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
snapshotSizeSearch.join("snapshots", join2, snapshotSizeSearch.entity().getSnapshotId(), join2.entity().getId(), JoinBuilder.JoinType.INNER);
snapshotSizeSearch.done();
_resourceCountCheckInterval = NumbersUtil.parseInt(_configDao.getValue(Config.ResourceCountCheckInterval.key()), 0);
_resourceCountCheckInterval = ResourceCountCheckInterval.value();
if (_resourceCountCheckInterval > 0) {
_rcExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("ResourceCountChecker"));
}
@ -1061,6 +1064,16 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
}
}
@Override
public String getConfigComponentName() {
return ResourceLimitManagerImpl.class.getName();
}
@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {ResourceCountCheckInterval};
}
protected class ResourceCountCheckTask extends ManagedContextRunnable {
public ResourceCountCheckTask() {