Skip to content

Commit 5241d0f

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 e124781 commit 5241d0f

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
@@ -178,7 +178,6 @@
178178
import com.cloud.offerings.dao.NetworkOfferingDao;
179179
import com.cloud.resource.ResourceManager;
180180
import com.cloud.server.ConfigurationServer;
181-
import com.cloud.server.StatsCollector;
182181
import com.cloud.service.ServiceOfferingVO;
183182
import com.cloud.service.dao.ServiceOfferingDao;
184183
import com.cloud.storage.GuestOSVO;
@@ -261,6 +260,7 @@
261260
import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
262261
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
263262
import org.apache.cloudstack.utils.identity.ManagementServerNode;
263+
import org.apache.cloudstack.utils.usage.UsageUtils;
264264
import org.apache.log4j.Logger;
265265

266266
import javax.ejb.Local;
@@ -808,9 +808,9 @@ public boolean start() {
808808
_dailyOrHourly = false;
809809
}
810810

811-
if (_usageAggregationRange < StatsCollector.USAGE_AGGREGATION_RANGE_MIN) {
812-
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + StatsCollector.USAGE_AGGREGATION_RANGE_MIN);
813-
_usageAggregationRange = StatsCollector.USAGE_AGGREGATION_RANGE_MIN;
811+
if (_usageAggregationRange < UsageUtils.USAGE_AGGREGATION_RANGE_MIN) {
812+
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN);
813+
_usageAggregationRange = UsageUtils.USAGE_AGGREGATION_RANGE_MIN;
814814
}
815815

816816
_networkStatsUpdateExecutor.scheduleAtFixedRate(new NetworkStatsUpdateTask(), (endDate - System.currentTimeMillis()), (_usageAggregationRange * 60 * 1000),

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import javax.inject.Inject;
3333

34+
import org.apache.cloudstack.utils.usage.UsageUtils;
3435
import org.apache.log4j.Logger;
3536
import org.springframework.stereotype.Component;
3637

@@ -199,7 +200,6 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
199200
private String _usageTimeZone = "GMT";
200201
private final long mgmtSrvrId = MacAddress.getMacAddress().toLong();
201202
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 5; // 5 seconds
202-
public static final int USAGE_AGGREGATION_RANGE_MIN = 1;
203203
private boolean _dailyOrHourly = false;
204204

205205
//private final GlobalLock m_capacityCheckLock = GlobalLock.getInternLock("capacity.check");
@@ -290,9 +290,9 @@ private void init(Map<String, String> configs) {
290290
endDate = cal.getTime().getTime();
291291
_dailyOrHourly = false;
292292
}
293-
if (_usageAggregationRange < USAGE_AGGREGATION_RANGE_MIN) {
294-
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + USAGE_AGGREGATION_RANGE_MIN);
295-
_usageAggregationRange = USAGE_AGGREGATION_RANGE_MIN;
293+
if (_usageAggregationRange < UsageUtils.USAGE_AGGREGATION_RANGE_MIN) {
294+
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN);
295+
_usageAggregationRange = UsageUtils.USAGE_AGGREGATION_RANGE_MIN;
296296
}
297297
_diskStatsUpdateExecutor.scheduleAtFixedRate(new VmDiskStatsUpdaterTask(), (endDate - System.currentTimeMillis()), (_usageAggregationRange * 60 * 1000),
298298
TimeUnit.MILLISECONDS);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import javax.inject.Inject;
3535
import javax.naming.ConfigurationException;
3636

37+
import org.apache.cloudstack.utils.usage.UsageUtils;
3738
import org.apache.log4j.Logger;
3839
import org.springframework.stereotype.Component;
3940

@@ -42,7 +43,6 @@
4243
import org.apache.cloudstack.usage.UsageTypes;
4344

4445
import com.cloud.alert.AlertManager;
45-
import com.cloud.server.StatsCollector;
4646
import com.cloud.event.EventTypes;
4747
import com.cloud.event.UsageEventDetailsVO;
4848
import com.cloud.event.UsageEventVO;
@@ -246,9 +246,9 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
246246
s_logger.debug("Current Time: " + currentDate.toString());
247247

248248
_aggregationDuration = Integer.parseInt(aggregationRange);
249-
if (_aggregationDuration < StatsCollector.USAGE_AGGREGATION_RANGE_MIN) {
250-
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + StatsCollector.USAGE_AGGREGATION_RANGE_MIN);
251-
_aggregationDuration = StatsCollector.USAGE_AGGREGATION_RANGE_MIN;
249+
if (_aggregationDuration < UsageUtils.USAGE_AGGREGATION_RANGE_MIN) {
250+
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN);
251+
_aggregationDuration = UsageUtils.USAGE_AGGREGATION_RANGE_MIN;
252252
}
253253
_hostname = InetAddress.getLocalHost().getHostName() + "/" + InetAddress.getLocalHost().getHostAddress();
254254
} 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)