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

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


        return future;
    }

    protected Void resizeVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CreateCmdResult> callback,
            CreateVolumeContext<VolumeApiResult> context) {
        CreateCmdResult result = callback.getResult();
        AsyncCallFuture<VolumeApiResult> future = context.future;
        VolumeInfo volume = (VolumeInfo) context.volume;

        if (result.isFailed()) {
            try {
                volume.processEvent(Event.OperationFailed);
            } catch (Exception e) {
                s_logger.debug("Failed to change state", e);
            }
            VolumeApiResult res = new VolumeApiResult(volume);
            res.setResult(result.getResult());
            future.complete(res);
            return null;
        }

        try {
            volume.processEvent(Event.OperationSuccessed);
        } catch (Exception e) {
            s_logger.debug("Failed to change state", e);
            VolumeApiResult res = new VolumeApiResult(volume);
            res.setResult(result.getResult());
            future.complete(res);
            return null;
        }

        VolumeApiResult res = new VolumeApiResult(volume);
View Full Code Here


        return volume.getSize();
    }

    @Override
    public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback) {
        CreateCmdResult result = new CreateCmdResult(null, null);
        if (snapshotResult) {
            SnapshotObjectTO newSnap = new SnapshotObjectTO();
            newSnap.setPath(UUID.randomUUID().toString());

            CreateObjectAnswer answer = new CreateObjectAnswer(newSnap);
            result.setAnswer(answer);
        } else {
            result.setResult("Failed to create snapshot");
        }
        callback.complete(result);
        return;
    }
View Full Code Here

                freshNewTemplate = true;
            } catch (Throwable e) {
                obj = objectInDataStoreMgr.findObject(data.getId(),
                        data.getType(), store.getId(), store.getRole());
                if (obj == null) {
                    CreateCmdResult result = new CreateCmdResult(
                            null, null);
                    result.setSucess(false);
                    result.setResult(e.toString());
                    callback.complete(result);
                    return;
                }
            }
        }

        if (!freshNewTemplate
                && obj.getState() != ObjectInDataStoreStateMachine.State.Ready) {
            try {
                objInStore = waitingForCreated(
                        data, store);
            } catch (Exception e) {
                CreateCmdResult result = new CreateCmdResult(null, null);
                result.setSucess(false);
                result.setResult(e.toString());
                callback.complete(result);
                return;
            }

            CreateCmdResult result = new CreateCmdResult(
                    null, null);
            callback.complete(result);
            return;
        }

        try {
            ObjectInDataStoreStateMachine.Event event = null;
            if (noCopy) {
                event = ObjectInDataStoreStateMachine.Event.CreateOnlyRequested;
            } else {
                event = ObjectInDataStoreStateMachine.Event.CreateRequested;
            }
            objectInDataStoreMgr.update(objInStore,
                    event);
        } catch (NoTransitionException e) {
            try {
                objectInDataStoreMgr.update(objInStore,
                        ObjectInDataStoreStateMachine.Event.OperationFailed);
            } catch (NoTransitionException e1) {
                s_logger.debug("state transation failed", e1);
            }
            CreateCmdResult result = new CreateCmdResult(null, null);
            result.setSucess(false);
            result.setResult(e.toString());
            callback.complete(result);
            return;
        }

        CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(
View Full Code Here

        return;
    }
   
    protected Void createAsynCallback(AsyncCallbackDispatcher<DataObjectManagerImpl, CreateCmdResult> callback,
            CreateContext<CreateCmdResult> context) {
        CreateCmdResult result = callback.getResult();
        DataObject objInStrore = context.objInStrore;
        CreateCmdResult upResult = new CreateCmdResult(
                null, null);
        if (result.isFailed()) {
            upResult.setResult(result.getResult());
            context.getParentCallback().complete(upResult);
            return null;
        }

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

        obj.setInstallPath(result.getPath());
        obj.setSize(result.getSize());
        try {
            objectInDataStoreMgr.update(obj,
                    ObjectInDataStoreStateMachine.Event.OperationSuccessed);
        } catch (NoTransitionException e) {
            try {
                objectInDataStoreMgr.update(obj,
                        ObjectInDataStoreStateMachine.Event.OperationFailed);
            } catch (NoTransitionException e1) {
                s_logger.debug("failed to change state", e1);
            }

            upResult.setResult(e.toString());
            context.getParentCallback().complete(upResult);
            return null;
        }
       
        context.getParentCallback().complete(result);
View Full Code Here

                objectInDataStoreMgr.update(destData,
                        ObjectInDataStoreStateMachine.Event.OperationFailed);
            } catch (NoTransitionException e1) {

            }
            CreateCmdResult res = new CreateCmdResult(null, null);
            res.setResult("Failed to change state: " + e.toString());
            callback.complete(res);
        }

        CopyContext<CreateCmdResult> anotherCall = new CopyContext<CreateCmdResult>(
                callback, srcData, destData);
View Full Code Here

            try {
                objectInDataStoreMgr.update(obj, Event.OperationFailed);
            } catch (NoTransitionException e) {
                s_logger.debug("Failed to update copying state", e);
            }
            CreateCmdResult res = new CreateCmdResult(
                    null, null);
            res.setResult(result.getResult());
            context.getParentCallback().complete(res);
        }

        obj.setInstallPath(result.getPath());

        try {
            objectInDataStoreMgr.update(obj,
                    ObjectInDataStoreStateMachine.Event.OperationSuccessed);
        } catch (NoTransitionException e) {
            s_logger.debug("Failed to update copying state: ", e);
            try {
                objectInDataStoreMgr.update(destObj,
                        ObjectInDataStoreStateMachine.Event.OperationFailed);
            } catch (NoTransitionException e1) {
            }
            CreateCmdResult res = new CreateCmdResult(
                    null, null);
            res.setResult("Failed to update copying state: " + e.toString());
            context.getParentCallback().complete(res);
        }
        CreateCmdResult res = new CreateCmdResult(
                result.getPath(), null);
        context.getParentCallback().complete(res);
        return null;
    }
View Full Code Here

                data.getDataStore().getRole());
        try {
            objectInDataStoreMgr.update(obj, Event.DestroyRequested);
        } catch (NoTransitionException e) {
            s_logger.debug("destroy failed", e);
            CreateCmdResult res = new CreateCmdResult(
                    null, null);
            callback.complete(res);
        }
       
        DeleteContext<CommandResult> context = new DeleteContext<CommandResult>(
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.