Skip to content

Commit 37058a8

Browse files
committed
CLOUDSTACK-7903: Fix build regression from previous fix
The previous fix tried to access StatsCollector from UsageManagerImpl which is not possible due to dependency cycle. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> (cherry picked from commit 1e0880c) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> Conflicts: server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
1 parent 09ccf5a commit 37058a8

4 files changed

Lines changed: 36 additions & 12 deletions

File tree

‎server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
6161
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
6262
import org.apache.cloudstack.utils.identity.ManagementServerNode;
63+
import org.apache.cloudstack.utils.usage.UsageUtils;
6364
import org.apache.log4j.Logger;
6465

6566
import com.cloud.agent.AgentManager;
@@ -219,7 +220,6 @@
219220
import com.cloud.offerings.dao.NetworkOfferingDao;
220221
import com.cloud.resource.ResourceManager;
221222
import com.cloud.server.ConfigurationServer;
222-
import com.cloud.server.StatsCollector;
223223
import com.cloud.service.ServiceOfferingVO;
224224
import com.cloud.service.dao.ServiceOfferingDao;
225225
import com.cloud.storage.VMTemplateVO;
@@ -794,9 +794,9 @@ public boolean start() {
794794
_dailyOrHourly = false;
795795
}
796796

797-
if (_usageAggregationRange < StatsCollector.USAGE_AGGREGATION_RANGE_MIN) {
798-
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + StatsCollector.USAGE_AGGREGATION_RANGE_MIN);
799-
_usageAggregationRange = StatsCollector.USAGE_AGGREGATION_RANGE_MIN;
797+
if (_usageAggregationRange < UsageUtils.USAGE_AGGREGATION_RANGE_MIN) {
798+
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN);
799+
_usageAggregationRange = UsageUtils.USAGE_AGGREGATION_RANGE_MIN;
800800
}
801801

802802
_networkStatsUpdateExecutor.scheduleAtFixedRate(new NetworkStatsUpdateTask(), (endDate - System.currentTimeMillis()),

‎server/src/com/cloud/server/StatsCollector.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
4343
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
4444
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
45+
import org.apache.cloudstack.utils.usage.UsageUtils;
4546

4647
import com.cloud.resource.ResourceManager;
4748

@@ -138,7 +139,6 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
138139
private String _usageTimeZone = "GMT";
139140
private final long mgmtSrvrId = MacAddress.getMacAddress().toLong();
140141
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 5; // 5 seconds
141-
public static final int USAGE_AGGREGATION_RANGE_MIN = 1;
142142
private boolean _dailyOrHourly = false;
143143

144144
//private final GlobalLock m_capacityCheckLock = GlobalLock.getInternLock("capacity.check");
@@ -224,9 +224,9 @@ private void init(Map<String, String> configs) {
224224
endDate = cal.getTime().getTime();
225225
_dailyOrHourly = false;
226226
}
227-
if (_usageAggregationRange < USAGE_AGGREGATION_RANGE_MIN) {
228-
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + USAGE_AGGREGATION_RANGE_MIN);
229-
_usageAggregationRange = USAGE_AGGREGATION_RANGE_MIN;
227+
if (_usageAggregationRange < UsageUtils.USAGE_AGGREGATION_RANGE_MIN) {
228+
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN);
229+
_usageAggregationRange = UsageUtils.USAGE_AGGREGATION_RANGE_MIN;
230230
}
231231
_diskStatsUpdateExecutor.scheduleAtFixedRate(new VmDiskStatsUpdaterTask(), (endDate - System.currentTimeMillis()),
232232
(_usageAggregationRange * 60 * 1000), TimeUnit.MILLISECONDS);

‎usage/src/com/cloud/usage/UsageManagerImpl.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
import org.apache.cloudstack.managed.context.ManagedContext;
4242
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
4343
import org.apache.cloudstack.usage.UsageTypes;
44+
import org.apache.cloudstack.utils.usage.UsageUtils;
4445
import org.springframework.stereotype.Component;
4546

4647
import com.cloud.alert.AlertManager;
47-
import com.cloud.server.StatsCollector;
4848
import com.cloud.event.EventTypes;
4949
import com.cloud.event.UsageEventVO;
5050
import com.cloud.event.dao.UsageEventDao;
@@ -223,9 +223,9 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
223223
s_logger.debug("Current Time: "+currentDate.toString());
224224

225225
m_aggregationDuration = Integer.parseInt(aggregationRange);
226-
if (m_aggregationDuration < StatsCollector.USAGE_AGGREGATION_RANGE_MIN) {
227-
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + StatsCollector.USAGE_AGGREGATION_RANGE_MIN);
228-
m_aggregationDuration = StatsCollector.USAGE_AGGREGATION_RANGE_MIN;
226+
if (m_aggregationDuration < UsageUtils.USAGE_AGGREGATION_RANGE_MIN) {
227+
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN);
228+
m_aggregationDuration = UsageUtils.USAGE_AGGREGATION_RANGE_MIN;
229229
}
230230
m_hostname = InetAddress.getLocalHost().getHostName() + "/" + InetAddress.getLocalHost().getHostAddress();
231231
} catch (NumberFormatException ex) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package org.apache.cloudstack.utils.usage;
21+
22+
public class UsageUtils {
23+
public static final int USAGE_AGGREGATION_RANGE_MIN = 1;
24+
}

0 commit comments

Comments
 (0)