org.apache.cloudstack.engine.subsystem.api.storage.DataStore.getDriver()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.9k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中org.apache.cloudstack.engine.subsystem.api.storage.DataStore.getDriver()方法的一些代码示例,展示了DataStore.getDriver()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataStore.getDriver()方法的具体详情如下:
包路径:org.apache.cloudstack.engine.subsystem.api.storage.DataStore
类名称:DataStore
方法名:getDriver

DataStore.getDriver介绍

暂无

代码示例

代码示例来源:origin: apache/cloudstack

@Override
public ChapInfo getChapInfo(DataObject dataObject, DataStore dataStore) {
  DataStoreDriver dataStoreDriver = dataStore.getDriver();
  if (dataStoreDriver instanceof PrimaryDataStoreDriver) {
    return ((PrimaryDataStoreDriver)dataStoreDriver).getChapInfo(dataObject);
  }
  return null;
}

代码示例来源:origin: apache/cloudstack

@Override
public void revokeAccess(DataObject dataObject, Host host, DataStore dataStore) {
  DataStoreDriver dataStoreDriver = dataStore != null ? dataStore.getDriver() : null;
  if (dataStoreDriver instanceof PrimaryDataStoreDriver) {
    ((PrimaryDataStoreDriver)dataStoreDriver).revokeAccess(dataObject, host, dataStore);
  }
}

代码示例来源:origin: apache/cloudstack

@Override
public void revokeAccess(DataObject dataObject, Host host, DataStore dataStore) {
  DataStoreDriver dataStoreDriver = dataStore != null ? dataStore.getDriver() : null;
  if (dataStoreDriver instanceof PrimaryDataStoreDriver) {
    ((PrimaryDataStoreDriver)dataStoreDriver).revokeAccess(dataObject, host, dataStore);
  }
}

代码示例来源:origin: apache/cloudstack

@Override
public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore) {
  DataStoreDriver dataStoreDriver = dataStore != null ? dataStore.getDriver() : null;
  if (dataStoreDriver instanceof PrimaryDataStoreDriver) {
    return ((PrimaryDataStoreDriver)dataStoreDriver).grantAccess(dataObject, host, dataStore);
  }
  return false;
}

代码示例来源:origin: apache/cloudstack

private boolean storageSystemSupportsCapability(long storagePoolId, String capability) {
  boolean supportsCapability = false;
  DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
  Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities();
  if (mapCapabilities != null) {
    String value = mapCapabilities.get(capability);
    supportsCapability = Boolean.valueOf(value);
  }
  return supportsCapability;
}

代码示例来源:origin: apache/cloudstack

private boolean storageSystemSupportsCapability(long storagePoolId, String capability) {
  boolean supportsCapability = false;
  DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
  Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities();
  if (mapCapabilities != null) {
    String value = mapCapabilities.get(capability);
    supportsCapability = Boolean.valueOf(value);
  }
  return supportsCapability;
}

代码示例来源:origin: apache/cloudstack

private void handleQualityOfServiceForVolumeMigration(VolumeInfo volumeInfo, PrimaryDataStoreDriver.QualityOfServiceState qualityOfServiceState) {
  try {
    ((PrimaryDataStoreDriver)volumeInfo.getDataStore().getDriver()).handleQualityOfServiceForVolumeMigration(volumeInfo, qualityOfServiceState);
  }
  catch (Exception ex) {
    LOGGER.warn(ex);
  }
}

代码示例来源:origin: apache/cloudstack

@Override
public DataTO getTO() {
  DataTO to = store.getDriver().getTO(this);
  if (to == null) {
    return new SnapshotObjectTO(this);
  }
  return to;
}

代码示例来源:origin: apache/cloudstack

@Override
public DataTO getTO() {
  DataTO to = getDataStore().getDriver().getTO(this);
  if (to == null) {
    to = new VolumeObjectTO(this);
  }
  return to;
}

代码示例来源:origin: apache/cloudstack

@Override
public DataTO getTO() {
  DataTO to = null;
  if (dataStore == null) {
    to = new TemplateObjectTO(this);
  } else {
    to = dataStore.getDriver().getTO(this);
    if (to == null) {
      to = new TemplateObjectTO(this);
    }
  }
  return to;
}

代码示例来源:origin: apache/cloudstack

private static DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStoreDao snapshotStoreDao, DataStoreManager dataStoreMgr) {
  SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary);
  if (snapshotStore == null) {
    return DataStoreRole.Image;
  }
  long storagePoolId = snapshotStore.getDataStoreId();
  DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
  Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities();
  if (mapCapabilities != null) {
    String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString());
    Boolean supportsStorageSystemSnapshots = new Boolean(value);
    if (supportsStorageSystemSnapshots) {
      return DataStoreRole.Primary;
    }
  }
  return DataStoreRole.Image;
}

代码示例来源:origin: apache/cloudstack

public DataStoreRole getDataStoreRole(Snapshot snapshot) {
  SnapshotDataStoreVO snapshotStore = _snapshotDataStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary);
  if (snapshotStore == null) {
    return DataStoreRole.Image;
  }
  long storagePoolId = snapshotStore.getDataStoreId();
  DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
  Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities();
  if (mapCapabilities != null) {
    String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString());
    Boolean supportsStorageSystemSnapshots = new Boolean(value);
    if (supportsStorageSystemSnapshots) {
      return DataStoreRole.Primary;
    }
  }
  return DataStoreRole.Image;
}

代码示例来源:origin: apache/cloudstack

public static DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStoreDao snapshotStoreDao, DataStoreManager dataStoreMgr) {
  SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary);
  if (snapshotStore == null) {
    return DataStoreRole.Image;
  }
  long storagePoolId = snapshotStore.getDataStoreId();
  DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
  if (dataStore == null) {
    return DataStoreRole.Image;
  }
  Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities();
  if (mapCapabilities != null) {
    String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString());
    Boolean supportsStorageSystemSnapshots = new Boolean(value);
    if (supportsStorageSystemSnapshots) {
      return DataStoreRole.Primary;
    }
  }
  return DataStoreRole.Image;
}

代码示例来源:origin: apache/cloudstack

/**
 * If the underlying storage system needed to create a volume from a snapshot for createVolumeFromSnapshot(SnapshotInfo), then
 * this is its opportunity to delete that temporary volume and restore properties in snapshot_details to the way they were before the
 * invocation of createVolumeFromSnapshot(SnapshotInfo).
 */
private void deleteVolumeFromSnapshot(SnapshotInfo snapshotInfo) {
  SnapshotDetailsVO snapshotDetails = handleSnapshotDetails(snapshotInfo.getId(), "delete");
  try {
    snapshotInfo.getDataStore().getDriver().createAsync(snapshotInfo.getDataStore(), snapshotInfo, null);
  }
  finally {
    _snapshotDetailsDao.remove(snapshotDetails.getId());
  }
}

代码示例来源:origin: apache/cloudstack

@Override
public ListResponse<StoragePoolResponse> searchForStoragePools(ListStoragePoolsCmd cmd) {
  Pair<List<StoragePoolJoinVO>, Integer> result = searchForStoragePoolsInternal(cmd);
  ListResponse<StoragePoolResponse> response = new ListResponse<StoragePoolResponse>();
  List<StoragePoolResponse> poolResponses = ViewResponseHelper.createStoragePoolResponse(result.first().toArray(new StoragePoolJoinVO[result.first().size()]));
  for (StoragePoolResponse poolResponse : poolResponses) {
    DataStore store = dataStoreManager.getPrimaryDataStore(poolResponse.getId());
    if (store != null) {
      DataStoreDriver driver = store.getDriver();
      if (driver != null && driver.getCapabilities() != null) {
        poolResponse.setCaps(driver.getCapabilities());
      }
    }
  }
  response.setResponses(poolResponses, result.second());
  return response;
}

代码示例来源:origin: apache/cloudstack

/**
 * If the underlying storage system is making use of read-only snapshots, this gives the storage system the opportunity to
 * create a volume from the snapshot so that we can copy the VHD file that should be inside of the snapshot to secondary storage.
 *
 * The resultant volume must be writable because we need to resign the SR and the VDI that should be inside of it before we copy
 * the VHD file to secondary storage.
 *
 * If the storage system is using writable snapshots, then nothing need be done by that storage system here because we can just
 * resign the SR and the VDI that should be inside of the snapshot before copying the VHD file to secondary storage.
 */
private void createVolumeFromSnapshot(SnapshotInfo snapshotInfo) {
  SnapshotDetailsVO snapshotDetails = handleSnapshotDetails(snapshotInfo.getId(), "create");
  try {
    snapshotInfo.getDataStore().getDriver().createAsync(snapshotInfo.getDataStore(), snapshotInfo, null);
  }
  finally {
    _snapshotDetailsDao.remove(snapshotDetails.getId());
  }
}

代码示例来源:origin: apache/cloudstack

@Override
public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
  try {
    objectInDataStoreMgr.update(data, Event.DestroyRequested);
  } catch (NoTransitionException e) {
    s_logger.debug("destroy failed", e);
    CreateCmdResult res = new CreateCmdResult(null, null);
    callback.complete(res);
  } catch (ConcurrentOperationException e) {
    s_logger.debug("destroy failed", e);
    CreateCmdResult res = new CreateCmdResult(null, null);
    callback.complete(res);
  }
  DeleteContext<CommandResult> context = new DeleteContext<CommandResult>(callback, data);
  AsyncCallbackDispatcher<DataObjectManagerImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this);
  caller.setCallback(caller.getTarget().deleteAsynCallback(null, null)).setContext(context);
  data.getDataStore().getDriver().deleteAsync(data.getDataStore(), data, caller);
  return;
}

代码示例来源:origin: apache/cloudstack

@Override
public AsyncCallFuture<TemplateApiResult> deleteTemplateAsync(TemplateInfo template) {
  TemplateObject to = (TemplateObject)template;
  // update template_store_ref status
  to.processEvent(ObjectInDataStoreStateMachine.Event.DestroyRequested);
  AsyncCallFuture<TemplateApiResult> future = new AsyncCallFuture<TemplateApiResult>();
  TemplateOpContext<TemplateApiResult> context = new TemplateOpContext<TemplateApiResult>(null, to, future);
  AsyncCallbackDispatcher<TemplateServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this);
  caller.setCallback(caller.getTarget().deleteTemplateCallback(null, null)).setContext(context);
  to.getDataStore().getDriver().deleteAsync(to.getDataStore(), to, caller);
  return future;
}

代码示例来源:origin: apache/cloudstack

private void handleManagedVolumePostMigration(VolumeInfo volumeInfo, Host srcHost, VolumeObjectTO volumeTO) {
  final Map<String, String> details = new HashMap<>();
  details.put(DeleteStoragePoolCommand.DATASTORE_NAME, volumeInfo.get_iScsiName());
  final DeleteStoragePoolCommand cmd = new DeleteStoragePoolCommand();
  cmd.setDetails(details);
  cmd.setRemoveDatastore(true);
  final Answer answer = agentMgr.easySend(srcHost.getId(), cmd);
  if (answer == null || !answer.getResult()) {
    String errMsg = "Error interacting with host (related to DeleteStoragePoolCommand)" +
        (StringUtils.isNotBlank(answer.getDetails()) ? ": " + answer.getDetails() : "");
    s_logger.error(errMsg);
    throw new CloudRuntimeException(errMsg);
  }
  final PrimaryDataStoreDriver pdsd = (PrimaryDataStoreDriver)volumeInfo.getDataStore().getDriver();
  pdsd.revokeAccess(volumeInfo, srcHost, volumeInfo.getDataStore());
  VolumeDetailVO volumeDetailVo = new VolumeDetailVO(volumeInfo.getId(), PrimaryDataStoreDriver.BASIC_DELETE, Boolean.TRUE.toString(), false);
  volumeDetailsDao.persist(volumeDetailVo);
  pdsd.deleteAsync(volumeInfo.getDataStore(), volumeInfo, null);
  VolumeVO volumeVO = volDao.findById(volumeInfo.getId());
  volumeVO.setPath(volumeTO.getPath());
  volDao.update(volumeVO.getId(), volumeVO);
}

代码示例来源:origin: apache/cloudstack

@Override
public AsyncCallFuture<TemplateApiResult> deleteTemplateOnPrimary(TemplateInfo template, StoragePool pool) {
  TemplateObject templateObject = (TemplateObject)_templateFactory.getTemplate(template.getId(), (DataStore)pool);
  templateObject.processEvent(ObjectInDataStoreStateMachine.Event.DestroyRequested);
  DataStore dataStore = _storeMgr.getPrimaryDataStore(pool.getId());
  AsyncCallFuture<TemplateApiResult> future = new AsyncCallFuture<>();
  TemplateOpContext<TemplateApiResult> context = new TemplateOpContext<>(null, templateObject, future);
  AsyncCallbackDispatcher<TemplateServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this);
  caller.setCallback(caller.getTarget().deleteTemplateCallback(null, null)).setContext(context);
  dataStore.getDriver().deleteAsync(dataStore, templateObject, caller);
  return future;
}

相关文章