Search in sources :

Example 66 with ConcurrentOperationException

use of com.cloud.exception.ConcurrentOperationException in project cloudstack by apache.

the class DataObjectManagerImpl method copyAsync.

@Override
public void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CreateCmdResult> callback) {
    try {
        objectInDataStoreMgr.update(destData, ObjectInDataStoreStateMachine.Event.CopyingRequested);
    } catch (NoTransitionException e) {
        s_logger.debug("failed to change state", e);
        try {
            objectInDataStoreMgr.update(destData, ObjectInDataStoreStateMachine.Event.OperationFailed);
        } catch (Exception e1) {
            s_logger.debug("failed to further change state to OperationFailed", e1);
        }
        CreateCmdResult res = new CreateCmdResult(null, null);
        res.setResult("Failed to change state: " + e.toString());
        callback.complete(res);
    } catch (ConcurrentOperationException e) {
        s_logger.debug("failed to change state", e);
        try {
            objectInDataStoreMgr.update(destData, ObjectInDataStoreStateMachine.Event.OperationFailed);
        } catch (Exception e1) {
            s_logger.debug("failed to further change state to OperationFailed", 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);
    AsyncCallbackDispatcher<DataObjectManagerImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
    caller.setCallback(caller.getTarget().copyCallback(null, null)).setContext(anotherCall);
    motionSrv.copyAsync(srcData, destData, caller);
}
Also used : NoTransitionException(com.cloud.utils.fsm.NoTransitionException) CreateCmdResult(org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) CopyCommandResult(org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException)

Example 67 with ConcurrentOperationException

use of com.cloud.exception.ConcurrentOperationException in project cloudstack by apache.

the class DataObjectManagerImpl method createAsync.

@Override
public void createAsync(DataObject data, DataStore store, AsyncCompletionCallback<CreateCmdResult> callback, boolean noCopy) {
    DataObjectInStore obj = objectInDataStoreMgr.findObject(data, store);
    DataObject objInStore = null;
    boolean freshNewTemplate = false;
    if (obj == null) {
        try {
            objInStore = objectInDataStoreMgr.create(data, store);
            freshNewTemplate = true;
        } catch (Throwable e) {
            obj = objectInDataStoreMgr.findObject(data, store);
            if (obj == null) {
                CreateCmdResult result = new CreateCmdResult(null, null);
                result.setSuccess(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.setSuccess(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 (Exception e1) {
            s_logger.debug("state transation failed", e1);
        }
        CreateCmdResult result = new CreateCmdResult(null, null);
        result.setSuccess(false);
        result.setResult(e.toString());
        callback.complete(result);
        return;
    } catch (ConcurrentOperationException e) {
        try {
            objectInDataStoreMgr.update(objInStore, ObjectInDataStoreStateMachine.Event.OperationFailed);
        } catch (Exception e1) {
            s_logger.debug("state transation failed", e1);
        }
        CreateCmdResult result = new CreateCmdResult(null, null);
        result.setSuccess(false);
        result.setResult(e.toString());
        callback.complete(result);
        return;
    }
    CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, objInStore);
    AsyncCallbackDispatcher<DataObjectManagerImpl, CreateCmdResult> caller = AsyncCallbackDispatcher.create(this);
    caller.setCallback(caller.getTarget().createAsynCallback(null, null)).setContext(context);
    store.getDriver().createAsync(store, objInStore, caller);
    return;
}
Also used : DataObjectInStore(org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore) CreateCmdResult(org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) ObjectInDataStoreStateMachine(org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine) DataObject(org.apache.cloudstack.engine.subsystem.api.storage.DataObject) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) Event(org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event)

Example 68 with ConcurrentOperationException

use of com.cloud.exception.ConcurrentOperationException in project cloudstack by apache.

the class DataObjectManagerImpl method createInternalStateOnly.

@Override
public DataObject createInternalStateOnly(DataObject data, DataStore store) {
    DataObjectInStore obj = objectInDataStoreMgr.findObject(data, store);
    DataObject objInStore = null;
    if (obj == null) {
        objInStore = objectInDataStoreMgr.create(data, store);
    }
    try {
        ObjectInDataStoreStateMachine.Event event = null;
        event = ObjectInDataStoreStateMachine.Event.CreateRequested;
        objectInDataStoreMgr.update(objInStore, event);
        objectInDataStoreMgr.update(objInStore, ObjectInDataStoreStateMachine.Event.OperationSuccessed);
    } catch (NoTransitionException e) {
        s_logger.debug("Failed to update state", e);
        throw new CloudRuntimeException("Failed to update state", e);
    } catch (ConcurrentOperationException e) {
        s_logger.debug("Failed to update state", e);
        throw new CloudRuntimeException("Failed to update state", e);
    }
    return objInStore;
}
Also used : ObjectInDataStoreStateMachine(org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine) DataObject(org.apache.cloudstack.engine.subsystem.api.storage.DataObject) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) DataObjectInStore(org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) Event(org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event)

Example 69 with ConcurrentOperationException

use of com.cloud.exception.ConcurrentOperationException in project cloudstack by apache.

the class AssociateUcsProfileToBladeCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        UcsBladeResponse rsp = mgr.associateProfileToBlade(this);
        rsp.setResponseName(getCommandName());
        this.setResponseObject(rsp);
    } catch (Exception e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : UcsBladeResponse(org.apache.cloudstack.api.response.UcsBladeResponse) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException)

Example 70 with ConcurrentOperationException

use of com.cloud.exception.ConcurrentOperationException in project cloudstack by apache.

the class DeleteUcsManagerCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        mgr.deleteUcsManager(ucsManagerId);
        SuccessResponse rsp = new SuccessResponse();
        rsp.setResponseName(getCommandName());
        rsp.setObjectName("success");
        this.setResponseObject(rsp);
    } catch (Exception e) {
        logger.debug(e.getMessage(), e);
        throw new CloudRuntimeException(e);
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException)

Aggregations

ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)153 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)96 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)80 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)71 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)46 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)43 ServerApiException (org.apache.cloudstack.api.ServerApiException)32 Account (com.cloud.user.Account)24 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)23 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)21 DB (com.cloud.utils.db.DB)21 AsyncJobExecutionContext (org.apache.cloudstack.framework.jobs.AsyncJobExecutionContext)20 VmWorkJobVO (org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO)20 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)17 ConfigurationException (javax.naming.ConfigurationException)17 ArrayList (java.util.ArrayList)16 ActionEvent (com.cloud.event.ActionEvent)14 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)14 UserVm (com.cloud.uservm.UserVm)14 ManagementServerException (com.cloud.exception.ManagementServerException)13