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);
}
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;
}
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;
}
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());
}
}
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);
}
}
Aggregations