Package org.apache.cloudstack.engine.subsystem.api.storage

Examples of org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult


            }
        } catch (Exception e) {
            s_logger.debug("copy failed", e);
            errMsg = e.toString();
        }
        CopyCommandResult result = new CopyCommandResult(null, answer);
        result.setResult(errMsg);
        callback.complete(result);
        return null;
    }
View Full Code Here


    }

    @Override
    public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
        CopyCommandResult result = new CopyCommandResult(null, null);
        result.setResult("Unsupported operation requested for copying data.");
        callback.complete(result);

        return null;
    }
View Full Code Here

    }

    protected Void copySnapshotAsyncCallback(AsyncCallbackDispatcher<SnapshotServiceImpl, CopyCommandResult> callback,
            CopySnapshotContext<CommandResult> context) {
        CopyCommandResult result = callback.getResult();
        SnapshotInfo destSnapshot = context.destSnapshot;
        SnapshotObject srcSnapshot = (SnapshotObject) context.srcSnapshot;
        AsyncCallFuture<SnapshotResult> future = context.future;
        SnapshotResult snapResult = new SnapshotResult(destSnapshot, result.getAnswer());
        if (result.isFailed()) {
            try {
                destSnapshot.processEvent(Event.OperationFailed);
                //if backup snapshot failed, mark srcSnapshot in snapshot_store_ref as failed also
                srcSnapshot.processEvent(Event.DestroyRequested);
                srcSnapshot.processEvent(Event.OperationSuccessed);

                srcSnapshot.processEvent(Snapshot.Event.OperationFailed);
            } catch (NoTransitionException e) {
                s_logger.debug("Failed to update state: " + e.toString());
            }
            snapResult.setResult(result.getResult());
            future.complete(snapResult);
            return null;
        }

        try {
            CopyCmdAnswer answer = (CopyCmdAnswer) result.getAnswer();
            destSnapshot.processEvent(Event.OperationSuccessed, result.getAnswer());
            srcSnapshot.processEvent(Snapshot.Event.OperationSucceeded);
            snapResult = new SnapshotResult(_snapshotFactory.getSnapshot(destSnapshot.getId(),
                    destSnapshot.getDataStore()), answer);
            future.complete(snapResult);
        } catch (Exception e) {
View Full Code Here

        return future;
    }

    protected Void syncSnapshotCallBack(AsyncCallbackDispatcher<SnapshotServiceImpl, CopyCommandResult> callback,
            CopySnapshotContext<CommandResult> context) {
        CopyCommandResult result = callback.getResult();
        SnapshotInfo destSnapshot = context.destSnapshot;
        SnapshotResult res = new SnapshotResult(destSnapshot, null);
       
        AsyncCallFuture<SnapshotResult> future = context.future;
        try {
            if (result.isFailed()) {
                res.setResult(result.getResult());
                // no change to existing snapshot_store_ref, will try to re-sync later if other call triggers this sync operation
            } else {
                // this will update install path properly, next time it will not sync anymore.
                destSnapshot.processEvent(Event.OperationSuccessed, result.getAnswer());
            }
            future.complete(res);
        } catch (Exception e) {
            s_logger.debug("Failed to process sync snapshot callback", e);
            res.setResult(e.toString());
View Full Code Here

        }

        DataObject objOnCacheStore = store.create(data);

        AsyncCallFuture<CopyCommandResult> future = new AsyncCallFuture<CopyCommandResult>();
        CopyCommandResult result = null;
        try {
            objOnCacheStore.processEvent(Event.CreateOnlyRequested);

            dataMotionSvr.copyAsync(data, objOnCacheStore, future);
            result = future.get();

            if (result.isFailed()) {
                objOnCacheStore.processEvent(Event.OperationFailed);
            } else {
                objOnCacheStore.processEvent(Event.OperationSuccessed, result.getAnswer());
                objOnCacheStore.incRefCount();
                return objOnCacheStore;
            }
        } catch (InterruptedException e) {
            s_logger.debug("create cache storage failed: " + e.toString());
View Full Code Here

    }

    protected Void syncTemplateCallBack(AsyncCallbackDispatcher<TemplateServiceImpl, CopyCommandResult> callback,
            TemplateOpContext<TemplateApiResult> context) {
        TemplateInfo destTemplate = context.getTemplate();
        CopyCommandResult result = callback.getResult();
        AsyncCallFuture<TemplateApiResult> future = context.getFuture();
        TemplateApiResult res = new TemplateApiResult(destTemplate);
        try {
            if (result.isFailed()) {
                res.setResult(result.getResult());
                // no change to existing template_store_ref, will try to re-sync later if other call triggers this sync operation, like copy template
            } else {
                // this will update install path properly, next time it will not sync anymore.
                destTemplate.processEvent(Event.OperationSuccessed, result.getAnswer());
            }
            future.complete(res);
        } catch (Exception e) {
            s_logger.debug("Failed to process sync template callback", e);
            res.setResult(e.toString());
View Full Code Here

    }

    protected Void copyTemplateCallBack(AsyncCallbackDispatcher<TemplateServiceImpl, CopyCommandResult> callback,
            TemplateOpContext<TemplateApiResult> context) {
        TemplateInfo destTemplate = context.getTemplate();
        CopyCommandResult result = callback.getResult();
        AsyncCallFuture<TemplateApiResult> future = context.getFuture();
        TemplateApiResult res = new TemplateApiResult(destTemplate);
        try {
            if (result.isFailed()) {
                res.setResult(result.getResult());
                destTemplate.processEvent(Event.OperationFailed);
            } else {
                destTemplate.processEvent(Event.OperationSuccessed, result.getAnswer());
            }
            future.complete(res);
        } catch (Exception e) {
            s_logger.debug("Failed to process copy template callback", e);
            res.setResult(e.toString());
View Full Code Here

    }

    protected Void copyTemplateCallback(
            AsyncCallbackDispatcher<TemplateInstallStrategyImpl, CopyCommandResult> callback,
            CopyTemplateContext<CreateBaseImageResult> context) {
        CopyCommandResult result = callback.getResult();
        TemplateInfo templateOnPrimaryStoreObj = context.template;
        if (result.isFailed()) {
            CreateBaseImageResult res = new CreateBaseImageResult(
                    templateOnPrimaryStoreObj);
            res.setResult(result.getResult());
            context.getParentCallback().complete(res);
        }
        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
                templateOnPrimaryStoreObj.getId(), templateOnPrimaryStoreObj
                        .getType(), templateOnPrimaryStoreObj.getDataStore()
                        .getId(), templateOnPrimaryStoreObj.getDataStore()
                        .getRole());

        obj.setInstallPath(result.getPath());
        CreateBaseImageResult res = new CreateBaseImageResult(
                templateOnPrimaryStoreObj);
        try {
            objectInDataStoreMgr.update(obj,
                    ObjectInDataStoreStateMachine.Event.OperationSuccessed);
View Full Code Here

    public Void copyAsync(DataObject srcData, DataObject destData,
            AsyncCompletionCallback<CopyCommandResult> callback) {
        DataStore destStore = destData.getDataStore();
        DataStore srcStore = srcData.getDataStore();
        EndPoint ep = selector.select(srcData, destData);
        CopyCommandResult result = new CopyCommandResult("");
        if (ep == null) {
            result.setResult("can't find end point");
            callback.complete(result);
            return null;
        }
       
        String srcUri = srcStore.getDriver().grantAccess(srcData, ep);
View Full Code Here

   
    protected Void copyAsyncCallback(AsyncCallbackDispatcher<DefaultImageMotionStrategy, Answer> callback, CreateTemplateContext<CopyCommandResult> context) {
        AsyncCompletionCallback<CopyCommandResult> parentCall = context.getParentCallback();
        Answer answer = (Answer)callback.getResult();
        if (!answer.getResult()) {
            CopyCommandResult result = new CopyCommandResult("");
            result.setResult(answer.getDetails());
            parentCall.complete(result);
        } else {
            CopyCmdAnswer ans = (CopyCmdAnswer)answer;
            CopyCommandResult result = new CopyCommandResult(ans.getPath());
            parentCall.complete(result);
        }
        return null;
       
    }
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.