use of com.cloud.engine.subsystem.api.storage.PrimaryDataStoreDriver in project cosmic by MissionCriticalCloud.
the class SnapshotServiceImpl method takeSnapshot.
@Override
public SnapshotResult takeSnapshot(final SnapshotInfo snap) {
final SnapshotObject snapshot = (SnapshotObject) snap;
SnapshotObject snapshotOnPrimary = null;
try {
snapshotOnPrimary = (SnapshotObject) snap.getDataStore().create(snapshot);
} catch (final Exception e) {
s_logger.debug("Failed to create snapshot state on data store due to " + e.getMessage());
throw new CloudRuntimeException(e);
}
try {
snapshotOnPrimary.processEvent(Snapshot.Event.CreateRequested);
} catch (final NoTransitionException e) {
s_logger.debug("Failed to change snapshot state: " + e.toString());
throw new CloudRuntimeException(e);
}
try {
snapshotOnPrimary.processEvent(Event.CreateOnlyRequested);
} catch (final Exception e) {
s_logger.debug("Failed to change snapshot state: " + e.toString());
try {
snapshotOnPrimary.processEvent(Snapshot.Event.OperationFailed);
} catch (final NoTransitionException e1) {
s_logger.debug("Failed to change snapshot state: " + e1.toString());
}
throw new CloudRuntimeException(e);
}
final AsyncCallFuture<SnapshotResult> future = new AsyncCallFuture<>();
try {
final CreateSnapshotContext<CommandResult> context = new CreateSnapshotContext<>(null, snap.getBaseVolume(), snapshotOnPrimary, future);
final AsyncCallbackDispatcher<SnapshotServiceImpl, CreateCmdResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().createSnapshotAsyncCallback(null, null)).setContext(context);
final PrimaryDataStoreDriver primaryStore = (PrimaryDataStoreDriver) snapshotOnPrimary.getDataStore().getDriver();
primaryStore.takeSnapshot(snapshot, caller);
} catch (final Exception e) {
s_logger.debug("Failed to take snapshot: " + snapshot.getId(), e);
try {
snapshot.processEvent(Snapshot.Event.OperationFailed);
snapshot.processEvent(Event.OperationFailed);
} catch (final NoTransitionException e1) {
s_logger.debug("Failed to change state for event: OperationFailed", e);
}
throw new CloudRuntimeException("Failed to take snapshot" + snapshot.getId());
}
final SnapshotResult result;
try {
result = future.get();
return result;
} catch (final InterruptedException e) {
s_logger.debug("Failed to create snapshot", e);
throw new CloudRuntimeException("Failed to create snapshot", e);
} catch (final ExecutionException e) {
s_logger.debug("Failed to create snapshot", e);
throw new CloudRuntimeException("Failed to create snapshot", e);
}
}
use of com.cloud.engine.subsystem.api.storage.PrimaryDataStoreDriver in project cosmic by MissionCriticalCloud.
the class CapacityManagerImpl method getUsedBytes.
@Override
public long getUsedBytes(final StoragePoolVO pool) {
final DataStoreProvider storeProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName());
final DataStoreDriver storeDriver = storeProvider.getDataStoreDriver();
if (storeDriver instanceof PrimaryDataStoreDriver) {
final PrimaryDataStoreDriver primaryStoreDriver = (PrimaryDataStoreDriver) storeDriver;
return primaryStoreDriver.getUsedBytes(pool);
}
throw new CloudRuntimeException("Storage driver in CapacityManagerImpl.getUsedBytes(StoragePoolVO) is not a PrimaryDataStoreDriver.");
}
use of com.cloud.engine.subsystem.api.storage.PrimaryDataStoreDriver in project cosmic by MissionCriticalCloud.
the class CapacityManagerImpl method getUsedIops.
@Override
public long getUsedIops(final StoragePoolVO pool) {
final DataStoreProvider storeProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName());
final DataStoreDriver storeDriver = storeProvider.getDataStoreDriver();
if (storeDriver instanceof PrimaryDataStoreDriver) {
final PrimaryDataStoreDriver primaryStoreDriver = (PrimaryDataStoreDriver) storeDriver;
return primaryStoreDriver.getUsedIops(pool);
}
throw new CloudRuntimeException("Storage driver in CapacityManagerImpl.getUsedIops(StoragePoolVO) is not a PrimaryDataStoreDriver.");
}
use of com.cloud.engine.subsystem.api.storage.PrimaryDataStoreDriver in project cosmic by MissionCriticalCloud.
the class StorageManagerImpl method getVolumeSizeIncludingHypervisorSnapshotReserve.
private long getVolumeSizeIncludingHypervisorSnapshotReserve(final Volume volume, final StoragePool pool) {
final DataStoreProvider storeProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName());
final DataStoreDriver storeDriver = storeProvider.getDataStoreDriver();
if (storeDriver instanceof PrimaryDataStoreDriver) {
final PrimaryDataStoreDriver primaryStoreDriver = (PrimaryDataStoreDriver) storeDriver;
return primaryStoreDriver.getVolumeSizeIncludingHypervisorSnapshotReserve(volume, pool);
}
return volume.getSize();
}
use of com.cloud.engine.subsystem.api.storage.PrimaryDataStoreDriver in project cosmic by MissionCriticalCloud.
the class SnapshotServiceImpl method revertSnapshot.
@Override
public boolean revertSnapshot(final SnapshotInfo snapshot) {
final SnapshotInfo snapshotOnPrimaryStore = _snapshotFactory.getSnapshot(snapshot.getId(), DataStoreRole.Primary);
if (snapshotOnPrimaryStore == null) {
throw new CloudRuntimeException("Cannot find an entry for snapshot " + snapshot.getId() + " on primary storage pools");
}
final PrimaryDataStore store = (PrimaryDataStore) snapshotOnPrimaryStore.getDataStore();
final AsyncCallFuture<SnapshotResult> future = new AsyncCallFuture<>();
final RevertSnapshotContext<CommandResult> context = new RevertSnapshotContext<>(null, snapshot, future);
final AsyncCallbackDispatcher<SnapshotServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().revertSnapshotCallback(null, null)).setContext(context);
((PrimaryDataStoreDriver) store.getDriver()).revertSnapshot(snapshot, snapshotOnPrimaryStore, caller);
SnapshotResult result = null;
try {
result = future.get();
if (result.isFailed()) {
throw new CloudRuntimeException(result.getResult());
}
return true;
} catch (final InterruptedException e) {
s_logger.debug("revert snapshot is failed: " + e.toString());
} catch (final ExecutionException e) {
s_logger.debug("revert snapshot is failed: " + e.toString());
}
return false;
}
Aggregations