Search in sources :

Example 11 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class AncientDataMotionStrategy method cloneVolume.

protected Answer cloneVolume(final DataObject template, final DataObject volume) {
    final CopyCommand cmd = new CopyCommand(template.getTO(), volume.getTO(), 0, VirtualMachineManager.ExecuteInSequence.value());
    try {
        final EndPoint ep = selector.select(volume.getDataStore());
        Answer answer = null;
        if (ep == null) {
            final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
            s_logger.error(errMsg);
            answer = new Answer(cmd, false, errMsg);
        } else {
            answer = ep.sendMessage(cmd);
        }
        return answer;
    } catch (final Exception e) {
        s_logger.debug("Failed to send to storage pool", e);
        throw new CloudRuntimeException("Failed to send to storage pool", e);
    }
}
Also used : MigrateVolumeAnswer(com.cloud.agent.api.storage.MigrateVolumeAnswer) Answer(com.cloud.agent.api.Answer) CopyCommand(com.cloud.storage.command.CopyCommand) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 12 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class AncientDataMotionStrategy method copyObject.

protected Answer copyObject(final DataObject srcData, final DataObject destData, final Host destHost) {
    final String value = configDao.getValue(Config.PrimaryStorageDownloadWait.toString());
    final int _primaryStorageDownloadWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue()));
    Answer answer = null;
    DataObject cacheData = null;
    DataObject srcForCopy = srcData;
    try {
        if (needCacheStorage(srcData, destData)) {
            final Scope destScope = pickCacheScopeForCopy(srcData, destData);
            srcForCopy = cacheData = cacheMgr.createCacheObject(srcData, destScope);
        }
        final CopyCommand cmd = new CopyCommand(srcForCopy.getTO(), destData.getTO(), _primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value());
        final EndPoint ep = destHost != null ? RemoteHostEndPoint.getHypervisorHostEndPoint(destHost) : selector.select(srcForCopy, destData);
        if (ep == null) {
            final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
            s_logger.error(errMsg);
            answer = new Answer(cmd, false, errMsg);
        } else {
            answer = ep.sendMessage(cmd);
        }
        if (cacheData != null) {
            final Long cacheId = cacheData.getId();
            final String cacheType = cacheData.getType().toString();
            final String cacheUuid = cacheData.getUuid().toString();
            if (srcData.getType() == DataObjectType.VOLUME && (destData.getType() == DataObjectType.VOLUME || destData.getType() == DataObjectType.TEMPLATE)) {
                // volume transfer from primary to secondary. Volume transfer between primary pools are already handled by copyVolumeBetweenPools
                // Delete cache in order to certainly transfer a latest image.
                s_logger.debug("Delete " + cacheType + " cache(id: " + cacheId + ", uuid: " + cacheUuid + ")");
                cacheMgr.deleteCacheObject(srcForCopy);
            } else {
                // for template, we want to leave it on cache for performance reason
                if ((answer == null || !answer.getResult()) && srcForCopy.getRefCount() < 2) {
                    // cache object created by this copy, not already there
                    s_logger.warn("Copy may not be handled correctly by agent(id: " + (ep != null ? ep.getId() : "\"unspecified\"") + ")." + " Delete " + cacheType + " cache(id: " + cacheId + ", uuid: " + cacheUuid + ")");
                    cacheMgr.deleteCacheObject(srcForCopy);
                } else {
                    s_logger.debug("Decrease reference count of " + cacheType + " cache(id: " + cacheId + ", uuid: " + cacheUuid + ")");
                    cacheMgr.releaseCacheObject(srcForCopy);
                }
            }
        }
        return answer;
    } catch (final Exception e) {
        s_logger.debug("copy object failed: ", e);
        if (cacheData != null) {
            cacheMgr.deleteCacheObject(cacheData);
        }
        throw new CloudRuntimeException(e.toString());
    }
}
Also used : MigrateVolumeAnswer(com.cloud.agent.api.storage.MigrateVolumeAnswer) Answer(com.cloud.agent.api.Answer) DataObject(com.cloud.engine.subsystem.api.storage.DataObject) ClusterScope(com.cloud.engine.subsystem.api.storage.ClusterScope) Scope(com.cloud.engine.subsystem.api.storage.Scope) ZoneScope(com.cloud.engine.subsystem.api.storage.ZoneScope) HostScope(com.cloud.engine.subsystem.api.storage.HostScope) CopyCommand(com.cloud.storage.command.CopyCommand) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 13 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class DefaultEndPointSelector method select.

@Override
public EndPoint select(final DataObject object) {
    final DataStore store = object.getDataStore();
    final EndPoint ep = select(store);
    if (ep != null) {
        return ep;
    }
    if (object instanceof TemplateInfo) {
        final TemplateInfo tmplInfo = (TemplateInfo) object;
        if (store.getScope().getScopeType() == ScopeType.ZONE && store.getScope().getScopeId() == null && tmplInfo.getTemplateType() == TemplateType.SYSTEM) {
            // for bootstrap system vm template downloading to region image store
            return LocalHostEndpoint.getEndpoint();
        }
    }
    return null;
}
Also used : TemplateInfo(com.cloud.engine.subsystem.api.storage.TemplateInfo) DataStore(com.cloud.engine.subsystem.api.storage.DataStore) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint)

Example 14 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class VolumeServiceImpl method registerVolumeForPostUpload.

@Override
public Pair<EndPoint, DataObject> registerVolumeForPostUpload(final VolumeInfo volume, final DataStore store) {
    final EndPoint ep = _epSelector.select(store);
    if (ep == null) {
        final String errorMessage = "There is no secondary storage VM for image store " + store.getName();
        s_logger.warn(errorMessage);
        throw new CloudRuntimeException(errorMessage);
    }
    final DataObject volumeOnStore = store.create(volume);
    return new Pair<>(ep, volumeOnStore);
}
Also used : DataObject(com.cloud.engine.subsystem.api.storage.DataObject) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) Pair(com.cloud.utils.Pair)

Example 15 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class VolumeServiceImpl method listVolume.

private Map<Long, TemplateProp> listVolume(final DataStore store) {
    final ListVolumeCommand cmd = new ListVolumeCommand(store.getTO(), store.getUri());
    final EndPoint ep = _epSelector.select(store);
    Answer answer = null;
    if (ep == null) {
        final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
        s_logger.error(errMsg);
        answer = new Answer(cmd, false, errMsg);
    } else {
        answer = ep.sendMessage(cmd);
    }
    if (answer != null && answer.getResult()) {
        final ListVolumeAnswer tanswer = (ListVolumeAnswer) answer;
        return tanswer.getTemplateInfo();
    } else {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Can not list volumes for image store " + store.getId());
        }
    }
    return null;
}
Also used : Answer(com.cloud.agent.api.Answer) CopyCmdAnswer(com.cloud.storage.command.CopyCmdAnswer) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer) ListVolumeCommand(com.cloud.agent.api.storage.ListVolumeCommand) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer)

Aggregations

EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)36 Answer (com.cloud.agent.api.Answer)25 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)17 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)14 RemoteHostEndPoint (com.cloud.storage.RemoteHostEndPoint)12 DataObject (com.cloud.engine.subsystem.api.storage.DataObject)8 CopyCmdAnswer (com.cloud.storage.command.CopyCmdAnswer)8 CopyCommand (com.cloud.storage.command.CopyCommand)8 Date (java.util.Date)8 MigrateVolumeAnswer (com.cloud.agent.api.storage.MigrateVolumeAnswer)7 ZoneScope (com.cloud.engine.subsystem.api.storage.ZoneScope)6 ResizeVolumeAnswer (com.cloud.agent.api.storage.ResizeVolumeAnswer)5 CopyCommandResult (com.cloud.engine.subsystem.api.storage.CopyCommandResult)4 VolumeVO (com.cloud.storage.VolumeVO)4 CreateEntityDownloadURLCommand (com.cloud.agent.api.storage.CreateEntityDownloadURLCommand)3 ListVolumeAnswer (com.cloud.agent.api.storage.ListVolumeAnswer)3 VolumeInfo (com.cloud.engine.subsystem.api.storage.VolumeInfo)3 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)3 UploadVO (com.cloud.storage.UploadVO)3 CommandResult (com.cloud.storage.command.CommandResult)3