Skip to content
This repository was archived by the owner on Jan 15, 2020. It is now read-only.

Commit 1e0880c

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>
1 parent 0d9c38e commit 1e0880c

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
@@ -57,6 +57,7 @@
5757
import org.apache.cloudstack.network.topology.NetworkTopology;
5858
import org.apache.cloudstack.network.topology.NetworkTopologyContext;
5959
import org.apache.cloudstack.utils.identity.ManagementServerNode;
60+
import org.apache.cloudstack.utils.usage.UsageUtils;
6061
import org.apache.log4j.Logger;
6162
import org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder;
6263
import org.springframework.beans.factory.annotation.Autowired;
@@ -183,7 +184,6 @@
183184
import com.cloud.offerings.dao.NetworkOfferingDao;
184185
import com.cloud.resource.ResourceManager;
185186
import com.cloud.server.ConfigurationServer;
186-
import com.cloud.server.StatsCollector;
187187
import com.cloud.service.ServiceOfferingVO;
188188
import com.cloud.service.dao.ServiceOfferingDao;
189189
import com.cloud.storage.Storage.ProvisioningType;
@@ -681,9 +681,9 @@ public boolean start() {
681681
_dailyOrHourly = false;
682682
}
683683

684-
if (_usageAggregationRange < StatsCollector.USAGE_AGGREGATION_RANGE_MIN) {
685-
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + StatsCollector.USAGE_AGGREGATION_RANGE_MIN);
686-
_usageAggregationRange = StatsCollector.USAGE_AGGREGATION_RANGE_MIN;
684+
if (_usageAggregationRange < UsageUtils.USAGE_AGGREGATION_RANGE_MIN) {
685+
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN);
686+
_usageAggregationRange = UsageUtils.USAGE_AGGREGATION_RANGE_MIN;
687687
}
688688

689689
_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
@@ -33,6 +33,7 @@
3333

3434
import javax.inject.Inject;
3535

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

@@ -223,7 +224,6 @@ public String toString() {
223224
private String _usageTimeZone = "GMT";
224225
private final long mgmtSrvrId = MacAddress.getMacAddress().toLong();
225226
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 5; // 5 seconds
226-
public static final int USAGE_AGGREGATION_RANGE_MIN = 1;
227227
private boolean _dailyOrHourly = false;
228228

229229
//private final GlobalLock m_capacityCheckLock = GlobalLock.getInternLock("capacity.check");
@@ -344,9 +344,9 @@ private void init(Map<String, String> configs) {
344344
endDate = cal.getTime().getTime();
345345
_dailyOrHourly = false;
346346
}
347-
if (_usageAggregationRange < USAGE_AGGREGATION_RANGE_MIN) {
348-
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + USAGE_AGGREGATION_RANGE_MIN);
349-
_usageAggregationRange = USAGE_AGGREGATION_RANGE_MIN;
347+
if (_usageAggregationRange < UsageUtils.USAGE_AGGREGATION_RANGE_MIN) {
348+
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN);
349+
_usageAggregationRange = UsageUtils.USAGE_AGGREGATION_RANGE_MIN;
350350
}
351351
_diskStatsUpdateExecutor.scheduleAtFixedRate(new VmDiskStatsUpdaterTask(), (endDate - System.currentTimeMillis()), (_usageAggregationRange * 60 * 1000),
352352
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)