Search in sources :

Example 1 with StoragePoolMonitor

use of com.cloud.storage.listener.StoragePoolMonitor in project cloudstack by apache.

the class StorageManagerImpl method configure.

@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    Map<String, String> configs = _configDao.getConfiguration("management-server", params);
    _storagePoolAcquisitionWaitSeconds = NumbersUtil.parseInt(configs.get("pool.acquisition.wait.seconds"), 1800);
    s_logger.info("pool.acquisition.wait.seconds is configured as " + _storagePoolAcquisitionWaitSeconds + " seconds");
    _agentMgr.registerForHostEvents(new StoragePoolMonitor(this, _storagePoolDao, _dataStoreProviderMgr), true, false, true);
    String value = _configDao.getValue(Config.StorageTemplateCleanupEnabled.key());
    _templateCleanupEnabled = (value == null ? true : Boolean.parseBoolean(value));
    s_logger.info("Storage cleanup enabled: " + StorageCleanupEnabled.value() + ", interval: " + StorageCleanupInterval.value() + ", delay: " + StorageCleanupDelay.value() + ", template cleanup enabled: " + _templateCleanupEnabled);
    String cleanupInterval = configs.get("extract.url.cleanup.interval");
    _downloadUrlCleanupInterval = NumbersUtil.parseInt(cleanupInterval, 7200);
    String urlExpirationInterval = configs.get("extract.url.expiration.interval");
    _downloadUrlExpirationInterval = NumbersUtil.parseInt(urlExpirationInterval, 14400);
    String workers = configs.get("expunge.workers");
    int wrks = NumbersUtil.parseInt(workers, 10);
    _executor = Executors.newScheduledThreadPool(wrks, new NamedThreadFactory("StorageManager-Scavenger"));
    _agentMgr.registerForHostEvents(ComponentContext.inject(LocalStoragePoolListener.class), true, false, false);
    _serverId = _msServer.getId();
    UpHostsInPoolSearch = _storagePoolHostDao.createSearchBuilder(Long.class);
    UpHostsInPoolSearch.selectFields(UpHostsInPoolSearch.entity().getHostId());
    SearchBuilder<HostVO> hostSearch = _hostDao.createSearchBuilder();
    hostSearch.and("status", hostSearch.entity().getStatus(), Op.EQ);
    hostSearch.and("resourceState", hostSearch.entity().getResourceState(), Op.EQ);
    UpHostsInPoolSearch.join("hosts", hostSearch, hostSearch.entity().getId(), UpHostsInPoolSearch.entity().getHostId(), JoinType.INNER);
    UpHostsInPoolSearch.and("pool", UpHostsInPoolSearch.entity().getPoolId(), Op.EQ);
    UpHostsInPoolSearch.done();
    StoragePoolSearch = _vmInstanceDao.createSearchBuilder();
    SearchBuilder<VolumeVO> volumeSearch = _volumeDao.createSearchBuilder();
    volumeSearch.and("volumeType", volumeSearch.entity().getVolumeType(), SearchCriteria.Op.EQ);
    volumeSearch.and("poolId", volumeSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
    volumeSearch.and("state", volumeSearch.entity().getState(), SearchCriteria.Op.EQ);
    StoragePoolSearch.join("vmVolume", volumeSearch, volumeSearch.entity().getInstanceId(), StoragePoolSearch.entity().getId(), JoinBuilder.JoinType.INNER);
    StoragePoolSearch.done();
    LocalStorageSearch = _storagePoolDao.createSearchBuilder();
    SearchBuilder<StoragePoolHostVO> storageHostSearch = _storagePoolHostDao.createSearchBuilder();
    storageHostSearch.and("hostId", storageHostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
    LocalStorageSearch.join("poolHost", storageHostSearch, storageHostSearch.entity().getPoolId(), LocalStorageSearch.entity().getId(), JoinBuilder.JoinType.INNER);
    LocalStorageSearch.and("type", LocalStorageSearch.entity().getPoolType(), SearchCriteria.Op.IN);
    LocalStorageSearch.done();
    Volume.State.getStateMachine().registerListener(new VolumeStateListener(_configDao, _vmInstanceDao));
    return true;
}
Also used : NamedThreadFactory(com.cloud.utils.concurrency.NamedThreadFactory) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) HostVO(com.cloud.host.HostVO) VolumeStateListener(com.cloud.storage.listener.VolumeStateListener) StoragePoolMonitor(com.cloud.storage.listener.StoragePoolMonitor)

Aggregations

HostVO (com.cloud.host.HostVO)1 StoragePoolMonitor (com.cloud.storage.listener.StoragePoolMonitor)1 VolumeStateListener (com.cloud.storage.listener.VolumeStateListener)1 NamedThreadFactory (com.cloud.utils.concurrency.NamedThreadFactory)1 EndPoint (org.apache.cloudstack.engine.subsystem.api.storage.EndPoint)1