use of com.cloud.engine.subsystem.api.storage.DataObject in project cosmic by MissionCriticalCloud.
the class DataObjectManagerImpl method copyCallback.
protected Void copyCallback(final AsyncCallbackDispatcher<DataObjectManagerImpl, CopyCommandResult> callback, final CopyContext<CreateCmdResult> context) {
final CopyCommandResult result = callback.getResult();
final DataObject destObj = context.destObj;
if (result.isFailed()) {
try {
objectInDataStoreMgr.update(destObj, Event.OperationFailed);
} catch (final NoTransitionException e) {
s_logger.debug("Failed to update copying state", e);
} catch (final ConcurrentOperationException e) {
s_logger.debug("Failed to update copying state", e);
}
final CreateCmdResult res = new CreateCmdResult(null, null);
res.setResult(result.getResult());
context.getParentCallback().complete(res);
}
try {
objectInDataStoreMgr.update(destObj, ObjectInDataStoreStateMachine.Event.OperationSuccessed);
} catch (final NoTransitionException | ConcurrentOperationException e) {
s_logger.debug("Failed to update copying state: ", e);
try {
objectInDataStoreMgr.update(destObj, ObjectInDataStoreStateMachine.Event.OperationFailed);
} catch (final Exception e1) {
s_logger.debug("failed to further change state to OperationFailed", e1);
}
final CreateCmdResult res = new CreateCmdResult(null, null);
res.setResult("Failed to update copying state: " + e.toString());
context.getParentCallback().complete(res);
}
final CreateCmdResult res = new CreateCmdResult(result.getPath(), null);
context.getParentCallback().complete(res);
return null;
}
use of com.cloud.engine.subsystem.api.storage.DataObject in project cosmic by MissionCriticalCloud.
the class VolumeServiceImpl method registerVolumeForPostUpload.
@Override
public Pair<EndPoint, DataObject> registerVolumeForPostUpload(final VolumeInfo volume, final DataStore store) {
final EndPoint ep = _epSelector.select(store);
if (ep == null) {
final String errorMessage = "There is no secondary storage VM for image store " + store.getName();
s_logger.warn(errorMessage);
throw new CloudRuntimeException(errorMessage);
}
final DataObject volumeOnStore = store.create(volume);
return new Pair<>(ep, volumeOnStore);
}
use of com.cloud.engine.subsystem.api.storage.DataObject in project cosmic by MissionCriticalCloud.
the class VolumeServiceImpl method createVolumeFromSnapshot.
@Override
public AsyncCallFuture<VolumeApiResult> createVolumeFromSnapshot(final VolumeInfo volume, final DataStore store, final SnapshotInfo snapshot) {
final AsyncCallFuture<VolumeApiResult> future = new AsyncCallFuture<>();
try {
final DataObject volumeOnStore = store.create(volume);
volumeOnStore.processEvent(Event.CreateOnlyRequested);
snapshot.processEvent(Event.CopyingRequested);
final CreateVolumeFromBaseImageContext<VolumeApiResult> context = new CreateVolumeFromBaseImageContext<>(null, volume, store, volumeOnStore, future, snapshot);
final AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().createVolumeFromSnapshotCallback(null, null)).setContext(context);
motionSrv.copyAsync(snapshot, volumeOnStore, caller);
} catch (final Exception e) {
s_logger.debug("create volume from snapshot failed", e);
final VolumeApiResult result = new VolumeApiResult(volume);
result.setResult(e.toString());
future.complete(result);
}
return future;
}
use of com.cloud.engine.subsystem.api.storage.DataObject in project cosmic by MissionCriticalCloud.
the class VolumeServiceImpl method createVolumeCallback.
protected Void createVolumeCallback(final AsyncCallbackDispatcher<VolumeServiceImpl, CreateCmdResult> callback, final CreateVolumeContext<VolumeApiResult> context) {
final CreateCmdResult result = callback.getResult();
final DataObject vo = context.getVolume();
String errMsg = null;
if (result.isSuccess()) {
vo.processEvent(Event.OperationSuccessed, result.getAnswer());
} else {
vo.processEvent(Event.OperationFailed);
errMsg = result.getResult();
}
final VolumeApiResult volResult = new VolumeApiResult((VolumeObject) vo);
if (errMsg != null) {
volResult.setResult(errMsg);
}
context.getFuture().complete(volResult);
return null;
}
use of com.cloud.engine.subsystem.api.storage.DataObject in project cosmic by MissionCriticalCloud.
the class VolumeServiceImpl method createVolumeFromBaseImageAsync.
@DB
protected void createVolumeFromBaseImageAsync(final VolumeInfo volume, final DataObject templateOnPrimaryStore, final PrimaryDataStore pd, final AsyncCallFuture<VolumeApiResult> future) {
final DataObject volumeOnPrimaryStorage = pd.create(volume);
volumeOnPrimaryStorage.processEvent(Event.CreateOnlyRequested);
final CreateVolumeFromBaseImageContext<VolumeApiResult> context = new CreateVolumeFromBaseImageContext<>(null, volumeOnPrimaryStorage, pd, templateOnPrimaryStore, future, null);
final AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().createVolumeFromBaseImageCallBack(null, null));
caller.setContext(context);
motionSrv.copyAsync(context.templateOnStore, volumeOnPrimaryStorage, caller);
return;
}
Aggregations