mirror of https://github.com/apache/cloudstack.git
bug 10893: Adding a new capacity type - Local Primary storage.
This commit is contained in:
parent
4b21650e23
commit
6423631522
|
|
@ -61,9 +61,12 @@ public class ListCapacityCmd extends BaseListCmd {
|
|||
"* CAPACITY_TYPE_CPU = 1" +
|
||||
"* CAPACITY_TYPE_STORAGE = 2" +
|
||||
"* CAPACITY_TYPE_STORAGE_ALLOCATED = 3" +
|
||||
"* CAPACITY_TYPE_PUBLIC_IP = 4" +
|
||||
"* CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = 4" +
|
||||
"* CAPACITY_TYPE_PRIVATE_IP = 5" +
|
||||
"* CAPACITY_TYPE_SECONDARY_STORAGE = 6")
|
||||
"* CAPACITY_TYPE_SECONDARY_STORAGE = 6" +
|
||||
"* CAPACITY_TYPE_VLAN = 7" +
|
||||
"* CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8" +
|
||||
"* CAPACITY_TYPE_LOCAL_STORAGE = 9.")
|
||||
|
||||
private Integer type;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public interface Capacity {
|
|||
public static final short CAPACITY_TYPE_SECONDARY_STORAGE = 6;
|
||||
public static final short CAPACITY_TYPE_VLAN = 7;
|
||||
public static final short CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8;
|
||||
public static final short CAPACITY_TYPE_LOCAL_STORAGE = 9;
|
||||
|
||||
public long getId();
|
||||
|
||||
|
|
|
|||
|
|
@ -284,7 +284,11 @@ public class AlertManagerImpl implements AlertManager {
|
|||
long disk = 0l;
|
||||
Pair<Long, Long> sizes = _volumeDao.getCountAndTotalByPool(pool.getId());
|
||||
disk = sizes.second();
|
||||
_storageMgr.createCapacityEntry(pool, disk);
|
||||
if (pool.isShared()){
|
||||
_storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, disk);
|
||||
}else {
|
||||
_storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, disk);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
|
@ -41,7 +40,6 @@ import com.cloud.capacity.dao.CapacityDao;
|
|||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.exception.ConnectionException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
|
|
@ -80,8 +78,6 @@ public class CapacityManagerImpl implements CapacityManager, StateListener<State
|
|||
@Inject
|
||||
AgentManager _agentManager;
|
||||
|
||||
private int _hostCapacityCheckerDelay;
|
||||
private int _hostCapacityCheckerInterval;
|
||||
private int _vmCapacityReleaseInterval;
|
||||
private ScheduledExecutorService _executor;
|
||||
private boolean _stopped;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
package com.cloud.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.Listener;
|
||||
|
|
@ -27,6 +29,9 @@ import com.cloud.agent.api.Command;
|
|||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupStorageCommand;
|
||||
import com.cloud.agent.api.StoragePoolInfo;
|
||||
import com.cloud.capacity.Capacity;
|
||||
import com.cloud.capacity.CapacityVO;
|
||||
import com.cloud.capacity.dao.CapacityDao;
|
||||
import com.cloud.exception.ConnectionException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
|
|
@ -35,14 +40,15 @@ import com.cloud.storage.dao.StoragePoolDao;
|
|||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
public class LocalStoragePoolListener implements Listener {
|
||||
private final static Logger s_logger = Logger.getLogger(LocalStoragePoolListener.class);
|
||||
@Inject StoragePoolDao _storagePoolDao;
|
||||
@Inject StoragePoolHostDao _storagePoolHostDao;
|
||||
|
||||
|
||||
@Inject CapacityDao _capacityDao;
|
||||
@Inject StorageManager _storageMgr;
|
||||
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
|
|
@ -106,6 +112,8 @@ public class LocalStoragePoolListener implements Listener {
|
|||
_storagePoolDao.persist(pool, pInfo.getDetails());
|
||||
StoragePoolHostVO poolHost = new StoragePoolHostVO(pool.getId(), host.getId(), pInfo.getLocalPath());
|
||||
_storagePoolHostDao.persist(poolHost);
|
||||
_storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, pool.getCapacityBytes() - pool.getAvailableBytes());
|
||||
|
||||
txn.commit();
|
||||
} else {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
|
@ -122,6 +130,9 @@ public class LocalStoragePoolListener implements Listener {
|
|||
poolHost = new StoragePoolHostVO(pool.getId(), host.getId(), pInfo.getLocalPath());
|
||||
_storagePoolHostDao.persist(poolHost);
|
||||
}
|
||||
|
||||
_storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, pool.getCapacityBytes() - pool.getAvailableBytes());
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ public interface StorageManager extends Manager {
|
|||
<T extends VMInstanceVO> DiskProfile allocateRawVolume(Type type, String name, DiskOfferingVO offering, Long size, T vm, Account owner);
|
||||
<T extends VMInstanceVO> DiskProfile allocateTemplatedVolume(Type type, String name, DiskOfferingVO offering, VMTemplateVO template, T vm, Account owner);
|
||||
|
||||
void createCapacityEntry(StoragePoolVO storagePool, long allocated);
|
||||
void createCapacityEntry(StoragePoolVO storagePool, short capacityType, long allocated);
|
||||
|
||||
|
||||
void prepare(VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest) throws StorageUnavailableException, InsufficientStorageCapacityException, ConcurrentOperationException;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ import com.cloud.api.commands.CreateVolumeCmd;
|
|||
import com.cloud.api.commands.DeletePoolCmd;
|
||||
import com.cloud.api.commands.UpdateStoragePoolCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.capacity.Capacity;
|
||||
import com.cloud.capacity.CapacityVO;
|
||||
import com.cloud.capacity.dao.CapacityDao;
|
||||
import com.cloud.cluster.ClusterManagerListener;
|
||||
|
|
@ -1801,18 +1802,18 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
|
||||
@Override
|
||||
public void createCapacityEntry(StoragePoolVO storagePool) {
|
||||
createCapacityEntry(storagePool, 0);
|
||||
createCapacityEntry(storagePool, Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createCapacityEntry(StoragePoolVO storagePool, long allocated) {
|
||||
public void createCapacityEntry(StoragePoolVO storagePool, short capacityType ,long allocated) {
|
||||
SearchCriteria<CapacityVO> capacitySC = _capacityDao.createSearchCriteria();
|
||||
|
||||
List<CapacityVO> capacities = _capacityDao.search(capacitySC, null);
|
||||
capacitySC = _capacityDao.createSearchCriteria();
|
||||
capacitySC.addAnd("hostOrPoolId", SearchCriteria.Op.EQ, storagePool.getId());
|
||||
capacitySC.addAnd("dataCenterId", SearchCriteria.Op.EQ, storagePool.getDataCenterId());
|
||||
capacitySC.addAnd("capacityType", SearchCriteria.Op.EQ, CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED);
|
||||
capacitySC.addAnd("capacityType", SearchCriteria.Op.EQ, capacityType);
|
||||
|
||||
capacities = _capacityDao.search(capacitySC, null);
|
||||
|
||||
|
|
@ -1822,7 +1823,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
}
|
||||
if (capacities.size() == 0) {
|
||||
CapacityVO capacity = new CapacityVO(storagePool.getId(), storagePool.getDataCenterId(), storagePool.getPodId(), storagePool.getClusterId(), allocated, storagePool.getCapacityBytes()
|
||||
* provFactor, CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED);
|
||||
* provFactor, capacityType);
|
||||
_capacityDao.persist(capacity);
|
||||
} else {
|
||||
CapacityVO capacity = capacities.get(0);
|
||||
|
|
@ -1840,7 +1841,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
_capacityDao.update(capacity.getId(), capacity);
|
||||
}
|
||||
}
|
||||
s_logger.debug("Successfully set Capacity - " + storagePool.getCapacityBytes() * _overProvisioningFactor + " for CAPACITY_TYPE_STORAGE_ALLOCATED, DataCenterId - "
|
||||
s_logger.debug("Successfully set Capacity - " + storagePool.getCapacityBytes() * _overProvisioningFactor + " for capacity type - " +capacityType+ " , DataCenterId - "
|
||||
+ storagePool.getDataCenterId() + ", HostOrPoolId - " + storagePool.getId() + ", PodId " + storagePool.getPodId());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue