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

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


    protected Void copyTemplateCrossZoneCallBack(AsyncCallbackDispatcher<TemplateServiceImpl, CreateCmdResult> callback, TemplateOpContext<TemplateApiResult> context) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Performing copy template cross zone callback after completion");
        }
        TemplateInfo destTemplate = context.getTemplate();
        CreateCmdResult 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 cross zones callback", e);
            res.setResult(e.toString());
View Full Code Here


        dataObjectMgr.createAsync(volume, dataStore, caller, true);
        return future;
    }
   
    protected Void createVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CreateCmdResult> callback, CreateVolumeContext<VolumeApiResult> context) {
        CreateCmdResult result = callback.getResult();
        VolumeObject vo = context.getVolume();
        VolumeApiResult volResult = new VolumeApiResult(vo);
        if (result.isSuccess()) {
            vo.stateTransit(Volume.Event.OperationSucceeded);
        } else {
            vo.stateTransit(Volume.Event.OperationFailed);
            volResult.setResult(result.getResult());
        }
       
        context.getFuture().complete(volResult);
        return null;
    }
View Full Code Here

        return;
    }
   
    @DB
    protected Void copyBaseImageCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CreateCmdResult> callback, CreateBaseImageContext<VolumeApiResult> context) {
        CreateCmdResult result = callback.getResult();
        VolumeApiResult res = new VolumeApiResult(context.getVolume());
       
        AsyncCallFuture<VolumeApiResult> future = context.getFuture();
        if (!result.isSuccess()) {
            res.setResult(result.getResult());
            future.complete(res);
            return null;
        }
        DataObject templateOnPrimaryStoreObj = objectInDataStoreMgr.get(context.srcTemplate, context.dataStore);
View Full Code Here

    }
   
    @DB
    public Void copyBaseImageCallBack(AsyncCallbackDispatcher<VolumeServiceImpl, CreateCmdResult> callback, CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
        VolumeObject vo = context.getVolumeObject();
        CreateCmdResult result = callback.getResult();
        VolumeApiResult volResult = new VolumeApiResult(vo);
      
        if (result.isSuccess()) {
            if (result.getPath() != null) {
                vo.setPath(result.getPath());
            }
            vo.stateTransit(Volume.Event.OperationSucceeded);
        } else {
            vo.stateTransit(Volume.Event.OperationFailed);
            volResult.setResult(result.getResult());
        }
       
        AsyncCallFuture<VolumeApiResult> future = context.getFuture();
        future.complete(volResult);
        return null;
View Full Code Here

        }
       
    }
   
    public Void createAsyncCallback(AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> callback, CreateVolumeContext<CreateCmdResult> context) {
        CreateCmdResult result = null;
        CreateObjectAnswer volAnswer = (CreateObjectAnswer) callback.getResult();
        if (volAnswer.getResult()) {
            result = new CreateCmdResult(volAnswer.getPath(), volAnswer.getSize());
        } else {
            result = new CreateCmdResult("", null);
            result.setResult(volAnswer.getDetails());
        }
       
        context.getParentCallback().complete(result);
        return null;
    }
View Full Code Here

    }

    protected Void installTemplateCallback(
            AsyncCallbackDispatcher<TemplateInstallStrategyImpl, CreateCmdResult> callback,
            InstallContext<CreateBaseImageResult> context) {
        CreateCmdResult result = callback.getResult();
        TemplateInfo templateOnPrimaryStoreObj = context.destTemplate;
        CreateBaseImageResult upResult = new CreateBaseImageResult(
                templateOnPrimaryStoreObj);
        if (result.isFailed()) {
            upResult.setResult(result.getResult());
            context.getParentCallback().complete(upResult);
            return null;
        }

        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
                templateOnPrimaryStoreObj.getId(), templateOnPrimaryStoreObj
                        .getType(), templateOnPrimaryStoreObj.getDataStore()
                        .getId(), templateOnPrimaryStoreObj.getDataStore()
                        .getRole());

        obj.setInstallPath(result.getPath());
        obj.setSize(result.getSize());
        try {
            objectInDataStoreMgr.update(obj,
                    ObjectInDataStoreStateMachine.Event.OperationSuccessed);
        } catch (NoTransitionException e) {
            try {
View Full Code Here

        TemplateInfo templateOnStore = context.templateOnStore;
        TemplateObject template = (TemplateObject)context.srcTemplate;
        AsyncCallFuture<CommandResult> future = context.future;
        CommandResult result = new CommandResult();
       
        CreateCmdResult callbackResult = callback.getResult();
        if (callbackResult.isFailed()) {
            try {
                objectInDataStoreMgr.update(templateOnStore, Event.OperationFailed);
            } catch (NoTransitionException e) {
                s_logger.debug("failed to transit state", e);
            }
            result.setResult(callbackResult.getResult());
            future.complete(result);
            return null;
        }
        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(templateOnStore.getId(), templateOnStore.getType(), templateOnStore.getDataStore().getId(), templateOnStore.getDataStore().getRole());
        obj.setInstallPath(callbackResult.getPath());
       
        if (callbackResult.getSize() != null) {
            obj.setSize(callbackResult.getSize());
        }
       
        try {
            objectInDataStoreMgr.update(obj, Event.OperationSuccessed);
        } catch (NoTransitionException e) {
            s_logger.debug("Failed to transit state", e);
            result.setResult(e.toString());
            future.complete(result);
            return null;
        }
       
        template.setImageStoreId(templateOnStore.getDataStore().getId());
        template.setSize(callbackResult.getSize());
        try {
            template.stateTransit(TemplateEvent.OperationSucceeded);
        } catch (NoTransitionException e) {
            s_logger.debug("Failed to transit state", e);
            result.setResult(e.toString());
View Full Code Here

    @Override
    public void createAsync(DataObject data,
            AsyncCompletionCallback<CreateCmdResult> callback) {
        //for default http data store, can create http based template/iso
        CreateCmdResult result = new CreateCmdResult("", null);
        if (!data.getUri().startsWith("http")) {
            result.setResult("can't register an image which is not a http link");
            callback.complete(result);
            return;
        }
       
        if (data.getSize() == null && data.getType() == DataObjectType.TEMPLATE) {
            //the template size is unknown during registration, need to find out the size of template
            EndPoint ep = selector.select(data);
            if (ep == null) {
                result.setResult("can't find storage client for:" + data.getId() + "," + data.getType());
                callback.complete(result);
                return;
            }
            CreateObjectCommand createCmd = new CreateObjectCommand(data.getUri());
            CreateObjectAnswer answer = (CreateObjectAnswer)ep.sendMessage(createCmd);
            if (answer.getResult()) {
                //update imagestorevo
              
                result = new CreateCmdResult(answer.getPath(), answer.getSize());
            } else {
                result.setResult(answer.getDetails());
            }
           
        }
       
        callback.complete(result);
View Full Code Here

        return future;
    }

    protected Void createVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CreateCmdResult> callback,
            CreateVolumeContext<VolumeApiResult> context) {
        CreateCmdResult result = callback.getResult();
        DataObject vo = context.getVolume();
        String errMsg = null;
        if (result.isSuccess()) {
            vo.processEvent(Event.OperationSuccessed, result.getAnswer());
        } else {
            vo.processEvent(Event.OperationFailed);
            errMsg = result.getResult();
        }
        VolumeApiResult volResult = new VolumeApiResult((VolumeObject) vo);
        if (errMsg != null) {
            volResult.setResult(errMsg);
        }
View Full Code Here

        return future;
    }

    protected Void registerVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CreateCmdResult> callback,
            CreateVolumeContext<VolumeApiResult> context) {
        CreateCmdResult result = callback.getResult();
        try {
            VolumeObject vo = (VolumeObject) context.volume;
            if (result.isFailed()) {
                vo.processEvent(Event.OperationFailed);
            } else {
                vo.processEvent(Event.OperationSuccessed, result.getAnswer());

                if (vo.getSize() != null) {
                    // publish usage events
                    // get physical size from volume_store_ref table
                    long physicalSize = 0;
View Full Code Here

TOP

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

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.