Search in sources :

Example 1 with DeleteEntityDownloadURLCommand

use of com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand in project cosmic by MissionCriticalCloud.

the class UploadMonitorImpl method cleanupStorage.

public void cleanupStorage() {
    final int EXTRACT_URL_LIFE_LIMIT_IN_SECONDS = _urlExpirationInterval;
    final List<UploadVO> extractJobs = _uploadDao.listByModeAndStatus(Mode.HTTP_DOWNLOAD, Status.DOWNLOAD_URL_CREATED);
    for (final UploadVO extractJob : extractJobs) {
        if (getTimeDiff(extractJob.getLastUpdated()) > EXTRACT_URL_LIFE_LIMIT_IN_SECONDS) {
            final String path = extractJob.getInstallPath();
            final DataStore secStore = storeMgr.getDataStore(extractJob.getDataStoreId(), DataStoreRole.Image);
            // Would delete the symlink for the Type and if Type == VOLUME then also the volume
            final DeleteEntityDownloadURLCommand cmd = new DeleteEntityDownloadURLCommand(path, extractJob.getType(), extractJob.getUploadUrl(), ((ImageStoreVO) secStore).getParent());
            final EndPoint ep = _epSelector.select(secStore);
            if (ep == null) {
                s_logger.warn("UploadMonitor cleanup: There is no secondary storage VM for secondary storage host " + extractJob.getDataStoreId());
                // TODO: why continue? why not break?
                continue;
            }
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("UploadMonitor cleanup: Sending deletion of extract URL " + extractJob.getUploadUrl() + " to ssvm " + ep.getHostAddr());
            }
            final Answer ans = ep.sendMessage(cmd);
            if (ans != null && ans.getResult()) {
                _uploadDao.remove(extractJob.getId());
            } else {
                s_logger.warn("UploadMonitor cleanup: Unable to delete the link for " + extractJob.getType() + " id=" + extractJob.getTypeId() + " url=" + extractJob.getUploadUrl() + " on ssvm " + ep.getHostAddr());
            }
        }
    }
}
Also used : Answer(com.cloud.agent.api.Answer) DataStore(com.cloud.engine.subsystem.api.storage.DataStore) UploadVO(com.cloud.storage.UploadVO) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) DeleteEntityDownloadURLCommand(com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand)

Example 2 with DeleteEntityDownloadURLCommand

use of com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand in project cloudstack by apache.

the class UploadMonitorImpl method cleanupStorage.

public void cleanupStorage() {
    final int EXTRACT_URL_LIFE_LIMIT_IN_SECONDS = _urlExpirationInterval;
    List<UploadVO> extractJobs = _uploadDao.listByModeAndStatus(Mode.HTTP_DOWNLOAD, Status.DOWNLOAD_URL_CREATED);
    for (UploadVO extractJob : extractJobs) {
        if (getTimeDiff(extractJob.getLastUpdated()) > EXTRACT_URL_LIFE_LIMIT_IN_SECONDS) {
            String path = extractJob.getInstallPath();
            DataStore secStore = storeMgr.getDataStore(extractJob.getDataStoreId(), DataStoreRole.Image);
            // Would delete the symlink for the Type and if Type == VOLUME then also the volume
            DeleteEntityDownloadURLCommand cmd = new DeleteEntityDownloadURLCommand(path, extractJob.getType(), extractJob.getUploadUrl(), ((ImageStoreVO) secStore).getParent());
            EndPoint ep = _epSelector.select(secStore);
            if (ep == null) {
                s_logger.warn("UploadMonitor cleanup: There is no secondary storage VM for secondary storage host " + extractJob.getDataStoreId());
                // TODO: why continue? why not break?
                continue;
            }
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("UploadMonitor cleanup: Sending deletion of extract URL " + extractJob.getUploadUrl() + " to ssvm " + ep.getHostAddr());
            }
            Answer ans = ep.sendMessage(cmd);
            if (ans != null && ans.getResult()) {
                _uploadDao.remove(extractJob.getId());
            } else {
                s_logger.warn("UploadMonitor cleanup: Unable to delete the link for " + extractJob.getType() + " id=" + extractJob.getTypeId() + " url=" + extractJob.getUploadUrl() + " on ssvm " + ep.getHostAddr());
            }
        }
    }
}
Also used : Answer(com.cloud.agent.api.Answer) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) UploadVO(com.cloud.storage.UploadVO) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) DeleteEntityDownloadURLCommand(com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand)

Example 3 with DeleteEntityDownloadURLCommand

use of com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand in project cloudstack by apache.

the class CloudStackImageStoreDriverImpl method deleteEntityExtractUrl.

@Override
public void deleteEntityExtractUrl(DataStore store, String installPath, String downloadUrl, Upload.Type entityType) {
    // find an endpoint to send command based on the ssvm on which the url was created.
    EndPoint ep = _epSelector.select(store, downloadUrl);
    // Delete Symlink at ssvm. In case of volume also delete the volume.
    DeleteEntityDownloadURLCommand cmd = new DeleteEntityDownloadURLCommand(installPath, entityType, downloadUrl, ((ImageStoreEntity) store).getMountPoint());
    Answer ans = null;
    if (ep == null) {
        String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
        s_logger.error(errMsg);
        ans = new Answer(cmd, false, errMsg);
    } else {
        ans = ep.sendMessage(cmd);
    }
    if (ans == null || !ans.getResult()) {
        String errorString = "Unable to delete the url " + downloadUrl + " for path " + installPath + " on ssvm, " + ans.getDetails();
        s_logger.error(errorString);
        throw new CloudRuntimeException(errorString);
    }
}
Also used : Answer(com.cloud.agent.api.Answer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) DeleteEntityDownloadURLCommand(com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand)

Example 4 with DeleteEntityDownloadURLCommand

use of com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand in project cosmic by MissionCriticalCloud.

the class CloudStackImageStoreDriverImpl method deleteEntityExtractUrl.

@Override
public void deleteEntityExtractUrl(final DataStore store, final String installPath, final String downloadUrl, final Upload.Type entityType) {
    // find an endpoint to send command based on the ssvm on which the url was created.
    final EndPoint ep = _epSelector.select(store, downloadUrl);
    // Delete Symlink at ssvm. In case of volume also delete the volume.
    final DeleteEntityDownloadURLCommand cmd = new DeleteEntityDownloadURLCommand(installPath, entityType, downloadUrl, ((ImageStoreEntity) store).getMountPoint());
    Answer ans = null;
    if (ep == null) {
        final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
        s_logger.error(errMsg);
        ans = new Answer(cmd, false, errMsg);
    } else {
        ans = ep.sendMessage(cmd);
    }
    if (ans == null || !ans.getResult()) {
        final String errorString = "Unable to delete the url " + downloadUrl + " for path " + installPath + " on ssvm, " + ans.getDetails();
        s_logger.error(errorString);
        throw new CloudRuntimeException(errorString);
    }
}
Also used : Answer(com.cloud.agent.api.Answer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) DeleteEntityDownloadURLCommand(com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand)

Aggregations

Answer (com.cloud.agent.api.Answer)4 DeleteEntityDownloadURLCommand (com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand)4 EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)2 UploadVO (com.cloud.storage.UploadVO)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 EndPoint (org.apache.cloudstack.engine.subsystem.api.storage.EndPoint)2 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)1 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)1