diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 0974fdc9b0e..62dccec1eaa 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -60,6 +60,7 @@ import org.apache.cloudstack.framework.jobs.AsyncJobManager; import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO; import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.cloudstack.utils.identity.ManagementServerNode; +import org.apache.cloudstack.utils.usage.UsageUtils; import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; @@ -219,7 +220,6 @@ import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.resource.ResourceManager; import com.cloud.server.ConfigurationServer; -import com.cloud.server.StatsCollector; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.VMTemplateVO; @@ -794,9 +794,9 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V _dailyOrHourly = false; } - if (_usageAggregationRange < StatsCollector.USAGE_AGGREGATION_RANGE_MIN) { - s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + StatsCollector.USAGE_AGGREGATION_RANGE_MIN); - _usageAggregationRange = StatsCollector.USAGE_AGGREGATION_RANGE_MIN; + if (_usageAggregationRange < UsageUtils.USAGE_AGGREGATION_RANGE_MIN) { + s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN); + _usageAggregationRange = UsageUtils.USAGE_AGGREGATION_RANGE_MIN; } _networkStatsUpdateExecutor.scheduleAtFixedRate(new NetworkStatsUpdateTask(), (endDate - System.currentTimeMillis()), diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java index 1d869306969..fa36a8c9003 100755 --- a/server/src/com/cloud/server/StatsCollector.java +++ b/server/src/com/cloud/server/StatsCollector.java @@ -42,6 +42,7 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreDao; import org.apache.cloudstack.storage.datastore.db.ImageStoreVO; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; +import org.apache.cloudstack.utils.usage.UsageUtils; import com.cloud.resource.ResourceManager; @@ -138,7 +139,6 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc private String _usageTimeZone = "GMT"; private final long mgmtSrvrId = MacAddress.getMacAddress().toLong(); private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 5; // 5 seconds - public static final int USAGE_AGGREGATION_RANGE_MIN = 1; private boolean _dailyOrHourly = false; //private final GlobalLock m_capacityCheckLock = GlobalLock.getInternLock("capacity.check"); @@ -224,9 +224,9 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc endDate = cal.getTime().getTime(); _dailyOrHourly = false; } - if (_usageAggregationRange < USAGE_AGGREGATION_RANGE_MIN) { - s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + USAGE_AGGREGATION_RANGE_MIN); - _usageAggregationRange = USAGE_AGGREGATION_RANGE_MIN; + if (_usageAggregationRange < UsageUtils.USAGE_AGGREGATION_RANGE_MIN) { + s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN); + _usageAggregationRange = UsageUtils.USAGE_AGGREGATION_RANGE_MIN; } _diskStatsUpdateExecutor.scheduleAtFixedRate(new VmDiskStatsUpdaterTask(), (endDate - System.currentTimeMillis()), (_usageAggregationRange * 60 * 1000), TimeUnit.MILLISECONDS); diff --git a/usage/src/com/cloud/usage/UsageManagerImpl.java b/usage/src/com/cloud/usage/UsageManagerImpl.java index ba78ea49448..117d00fa779 100644 --- a/usage/src/com/cloud/usage/UsageManagerImpl.java +++ b/usage/src/com/cloud/usage/UsageManagerImpl.java @@ -41,10 +41,10 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.managed.context.ManagedContext; import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.cloudstack.usage.UsageTypes; +import org.apache.cloudstack.utils.usage.UsageUtils; import org.springframework.stereotype.Component; import com.cloud.alert.AlertManager; -import com.cloud.server.StatsCollector; import com.cloud.event.EventTypes; import com.cloud.event.UsageEventVO; import com.cloud.event.dao.UsageEventDao; @@ -223,9 +223,9 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna s_logger.debug("Current Time: "+currentDate.toString()); m_aggregationDuration = Integer.parseInt(aggregationRange); - if (m_aggregationDuration < StatsCollector.USAGE_AGGREGATION_RANGE_MIN) { - s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + StatsCollector.USAGE_AGGREGATION_RANGE_MIN); - m_aggregationDuration = StatsCollector.USAGE_AGGREGATION_RANGE_MIN; + if (m_aggregationDuration < UsageUtils.USAGE_AGGREGATION_RANGE_MIN) { + s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN); + m_aggregationDuration = UsageUtils.USAGE_AGGREGATION_RANGE_MIN; } m_hostname = InetAddress.getLocalHost().getHostName() + "/" + InetAddress.getLocalHost().getHostAddress(); } catch (NumberFormatException ex) { diff --git a/utils/src/org/apache/cloudstack/utils/usage/UsageUtils.java b/utils/src/org/apache/cloudstack/utils/usage/UsageUtils.java new file mode 100644 index 00000000000..a97aed15d36 --- /dev/null +++ b/utils/src/org/apache/cloudstack/utils/usage/UsageUtils.java @@ -0,0 +1,24 @@ +// +// 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.utils.usage; + +public class UsageUtils { + public static final int USAGE_AGGREGATION_RANGE_MIN = 1; +}