forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCapacityManager.java
More file actions
147 lines (128 loc) · 7.12 KB
/
CapacityManager.java
File metadata and controls
147 lines (128 loc) · 7.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// 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 com.cloud.capacity;
import java.util.Map;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import com.cloud.host.Host;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.vm.VirtualMachine;
/**
* Capacity Manager manages the different capacities
* available within the Cloud Stack.
*
*/
public interface CapacityManager {
static final String CpuOverprovisioningFactorCK = "cpu.overprovisioning.factor";
static final String MemOverprovisioningFactorCK = "mem.overprovisioning.factor";
static final String StorageCapacityDisableThresholdCK = "pool.storage.capacity.disablethreshold";
static final String StorageOverprovisioningFactorCK = "storage.overprovisioning.factor";
static final String StorageAllocatedCapacityDisableThresholdCK = "pool.storage.allocated.capacity.disablethreshold";
static final String VmwareCreateCloneFullCK = "vmware.create.full.clone";
static final ConfigKey<Float> CpuOverprovisioningFactor = new ConfigKey<Float>(Float.class, CpuOverprovisioningFactorCK, "Advanced", "1.0",
"Used for CPU overprovisioning calculation; available CPU will be (actualCpuCapacity * cpu.overprovisioning.factor)", true, ConfigKey.Scope.Cluster, null);
static final ConfigKey<Float> MemOverprovisioningFactor = new ConfigKey<Float>(Float.class, MemOverprovisioningFactorCK, "Advanced", "1.0",
"Used for memory overprovisioning calculation", true, ConfigKey.Scope.Cluster, null);
static final ConfigKey<Double> StorageCapacityDisableThreshold = new ConfigKey<Double>("Alert", Double.class, StorageCapacityDisableThresholdCK, "0.85",
"Percentage (as a value between 0 and 1) of storage utilization above which allocators will disable using the pool for low storage available.", true,
ConfigKey.Scope.Zone);
static final ConfigKey<Double> StorageOverprovisioningFactor = new ConfigKey<Double>("Storage", Double.class, StorageOverprovisioningFactorCK, "2",
"Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)", true, ConfigKey.Scope.StoragePool);
static final ConfigKey<Double> StorageAllocatedCapacityDisableThreshold =
new ConfigKey<Double>(
"Alert",
Double.class,
StorageAllocatedCapacityDisableThresholdCK,
"0.85",
"Percentage (as a value between 0 and 1) of allocated storage utilization above which allocators will disable using the pool for low allocated storage available.",
true, ConfigKey.Scope.Zone);
static final ConfigKey<Boolean> StorageOperationsExcludeCluster =
new ConfigKey<Boolean>(
Boolean.class,
"cluster.storage.operations.exclude",
"Advanced",
"false",
"Exclude cluster from storage operations",
true,
ConfigKey.Scope.Cluster,
null);
static final ConfigKey<Boolean> VmwareCreateCloneFull =
new ConfigKey<Boolean>(
"Storage",
Boolean.class,
VmwareCreateCloneFullCK,
"false",
"If set to true, creates VMs as full clones on ESX hypervisor",
true,
ConfigKey.Scope.StoragePool);
static final ConfigKey<String> ImageStoreNFSVersion =
new ConfigKey<String>(
String.class,
"secstorage.nfs.version",
"Advanced",
null,
"Enforces specific NFS version when mounting Secondary Storage. If NULL default selection is performed",
true,
ConfigKey.Scope.ImageStore,
null);
static final ConfigKey<Float> SecondaryStorageCapacityThreshold = new ConfigKey<Float>("Advanced", Float.class, "secondary.storage.capacity.threshold", "0.90",
"Percentage (as a value between 0 and 1) of secondary storage capacity threshold.", true);
public boolean releaseVmCapacity(VirtualMachine vm, boolean moveFromReserved, boolean moveToReservered, Long hostId);
void allocateVmCapacity(VirtualMachine vm, boolean fromLastHost);
/**
* @param hostId Id of the host to check capacity
* @param cpu required CPU
* @param ram required RAM
* @param cpuOverprovisioningFactor factor to apply to the actual host cpu
*/
boolean checkIfHostHasCapacity(long hostId, Integer cpu, long ram, boolean checkFromReservedCapacity, float cpuOverprovisioningFactor, float memoryOvercommitRatio,
boolean considerReservedCapacity);
void updateCapacityForHost(Host host);
void updateCapacityForHost(Host host, Map<Long, ServiceOfferingVO> offeringsMap);
/**
* @param pool storage pool
* @param templateForVmCreation template that will be used for vm creation
* @return total allocated capacity for the storage pool
*/
long getAllocatedPoolCapacity(StoragePoolVO pool, VMTemplateVO templateForVmCreation);
/**
* Check if specified host's running VM count has reach hypervisor limit
* @param host the host to be checked
* @return true if the count of host's running VMs >= hypervisor limit
*/
boolean checkIfHostReachMaxGuestLimit(Host host);
/**
* Check if specified host has capability to support cpu cores and speed freq
* @param hostId the host to be checked
* @param cpuNum cpu number to check
* @param cpuSpeed cpu Speed to check
* @return true if the count of host's running VMs >= hypervisor limit
*/
boolean checkIfHostHasCpuCapability(long hostId, Integer cpuNum, Integer cpuSpeed);
/**
* Check if cluster will cross threshold if the cpu/memory requested are accomodated
* @param clusterId the clusterId to check
* @param cpuRequested cpu requested
* @param ramRequested cpu requested
* @return true if the customer crosses threshold, false otherwise
*/
boolean checkIfClusterCrossesThreshold(Long clusterId, Integer cpuRequested, long ramRequested);
float getClusterOverProvisioningFactor(Long clusterId, short capacityType);
long getUsedBytes(StoragePoolVO pool);
long getUsedIops(StoragePoolVO pool);
}