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

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

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

DataStore.getRole介绍

暂无

代码示例

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

protected boolean moveBetweenCacheAndImage(DataStore srcStore, DataStore destStore) {
  DataStoreRole srcRole = srcStore.getRole();
  DataStoreRole destRole = destStore.getRole();
  if (srcRole == DataStoreRole.Image && destRole == DataStoreRole.ImageCache || srcRole == DataStoreRole.ImageCache && destRole == DataStoreRole.Image) {
    return true;
  } else {
    return false;
  }
}

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

protected boolean moveBetweenImages(DataStore srcStore, DataStore destStore) {
  DataStoreRole srcRole = srcStore.getRole();
  DataStoreRole destRole = destStore.getRole();
  if (srcRole == DataStoreRole.Image && destRole == DataStoreRole.Image) {
    return true;
  } else {
    return false;
  }
}

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

protected boolean moveBetweenPrimaryImage(DataStore srcStore, DataStore destStore) {
  DataStoreRole srcRole = srcStore.getRole();
  DataStoreRole destRole = destStore.getRole();
  if ((srcRole == DataStoreRole.Primary && destRole.isImageStore()) || (srcRole.isImageStore() && destRole == DataStoreRole.Primary)) {
    return true;
  } else {
    return false;
  }
}

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

@Override
public Long getRefCount() {
  if (store == null) {
    return null;
  }
  if (store.getRole() == DataStoreRole.Image || store.getRole() == DataStoreRole.ImageCache) {
    SnapshotDataStoreVO store = snapshotStoreDao.findByStoreSnapshot(this.store.getRole(), this.store.getId(), getId());
    return store.getRefCnt();
  }
  return null;
}

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

@Override
public Long getRefCount() {
  if (dataStore == null) {
    return null;
  }
  if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
    TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId());
    return store.getRefCnt();
  }
  return null;
}

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

@Override
public Long getRefCount() {
  if (dataStore == null) {
    return null;
  }
  if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
    VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
    return store.getRefCnt();
  }
  return null;
}

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

@Override
public void decRefCount() {
  if (store == null) {
    return;
  }
  if (store.getRole() == DataStoreRole.Image || store.getRole() == DataStoreRole.ImageCache) {
    SnapshotDataStoreVO store = snapshotStoreDao.findByStoreSnapshot(this.store.getRole(), this.store.getId(), getId());
    store.decrRefCnt();
    store.setLastUpdated(new Date());
    snapshotStoreDao.update(store.getId(), store);
  }
}

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

@Override
public void incRefCount() {
  if (store == null) {
    return;
  }
  if (store.getRole() == DataStoreRole.Image || store.getRole() == DataStoreRole.ImageCache) {
    SnapshotDataStoreVO store = snapshotStoreDao.findByStoreSnapshot(this.store.getRole(), this.store.getId(), getId());
    store.incrRefCnt();
    store.setLastUpdated(new Date());
    snapshotStoreDao.update(store.getId(), store);
  }
}

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

@Override
public void decRefCount() {
  if (dataStore == null) {
    return;
  }
  if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
    TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId());
    store.decrRefCnt();
    store.setLastUpdated(new Date());
    templateStoreDao.update(store.getId(), store);
  }
}

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

@Override
public void decRefCount() {
  if (dataStore == null) {
    return;
  }
  if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
    VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
    store.decrRefCnt();
    store.setLastUpdated(new Date());
    volumeStoreDao.update(store.getId(), store);
  }
}

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

private void verifySnapshotType(SnapshotInfo snapshotInfo) {
  if (snapshotInfo.getHypervisorType() == HypervisorType.KVM && snapshotInfo.getDataStore().getRole() != DataStoreRole.Primary) {
    throw new CloudRuntimeException("For the KVM hypervisor type, you can only revert a volume to a snapshot state if the snapshot " +
      "resides on primary storage. For other snapshot types, create a volume from the snapshot to recover its data.");
  }
}

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

@Override
public void incRefCount() {
  if (dataStore == null) {
    return;
  }
  if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
    TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId());
    store.incrRefCnt();
    store.setLastUpdated(new Date());
    templateStoreDao.update(store.getId(), store);
  }
}

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

@Override
public void incRefCount() {
  if (dataStore == null) {
    return;
  }
  if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
    VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
    store.incrRefCnt();
    store.setLastUpdated(new Date());
    volumeStoreDao.update(store.getId(), store);
  }
}

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

@Override
public String getPath() {
  if (dataStore.getRole() == DataStoreRole.Primary) {
    return volumeVO.getPath();
  } else {
    DataObjectInStore objInStore = objectInStoreMgr.findObject(this, dataStore);
    if (objInStore != null) {
      return objInStore.getInstallPath();
    } else {
      return null;
    }
  }
}

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

private void handleCopyAsyncForSnapshot(SnapshotInfo srcSnapshotInfo, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
  verifyFormat(srcSnapshotInfo);
  boolean canHandleSrc = canHandle(srcSnapshotInfo);
  if (canHandleSrc && (destData instanceof TemplateInfo || destData instanceof SnapshotInfo) &&
      (destData.getDataStore().getRole() == DataStoreRole.Image || destData.getDataStore().getRole() == DataStoreRole.ImageCache)) {
    handleCopyAsyncToSecondaryStorage(srcSnapshotInfo, destData, callback);
  } else if (destData instanceof VolumeInfo) {
    handleCopyAsyncForSnapshotToVolume(srcSnapshotInfo, (VolumeInfo)destData, callback);
  } else {
    handleError(OPERATION_NOT_SUPPORTED, callback);
  }
}

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

private boolean isVolumeOnManagedStorage(VolumeInfo volumeInfo) {
  DataStore dataStore = volumeInfo.getDataStore();
  if (dataStore.getRole() == DataStoreRole.Primary) {
    long storagePooldId = dataStore.getId();
    StoragePoolVO storagePoolVO = _storagePoolDao.findById(storagePooldId);
    return storagePoolVO.isManaged();
  }
  return false;
}

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

@Override
public SnapshotInfo getParent() {
  SnapshotDataStoreVO snapStoreVO = snapshotStoreDao.findByStoreSnapshot(store.getRole(), store.getId(), snapshot.getId());
  Long parentId = null;
  if (snapStoreVO != null) {
    parentId = snapStoreVO.getParentSnapshotId();
    if (parentId != null && parentId != 0) {
      return snapshotFactory.getSnapshot(parentId, store);
    }
  }
  return null;
}

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

@Override
public DataStoreTO getStoreTO(DataStore store) {
  ImageStoreImpl nfsStore = (ImageStoreImpl)store;
  NfsTO nfsTO = new NfsTO();
  nfsTO.setRole(store.getRole());
  nfsTO.setUrl(nfsStore.getUri());
  nfsTO.setNfsVersion(getNfsVersion(nfsStore.getId()));
  return nfsTO;
}

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

@Override
public String getUri() {
  if (dataStore == null) {
    throw new CloudRuntimeException("datastore must be set before using this object");
  }
  DataObjectInStore obj = objectInStoreMgr.findObject(volumeVO.getId(), DataObjectType.VOLUME, dataStore.getId(), dataStore.getRole());
  if (obj.getState() != ObjectInDataStoreStateMachine.State.Ready) {
    return dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.SIZE + "=" + volumeVO.getSize() + "&" +
      EncodingType.NAME + "=" + volumeVO.getName();
  } else {
    return dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.PATH + "=" + obj.getInstallPath();
  }
}

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

@Override
public SnapshotInfo getChild() {
  QueryBuilder<SnapshotDataStoreVO> sc = QueryBuilder.create(SnapshotDataStoreVO.class);
  sc.and(sc.entity().getDataStoreId(), Op.EQ, store.getId());
  sc.and(sc.entity().getRole(), Op.EQ, store.getRole());
  sc.and(sc.entity().getState(), Op.NIN, State.Destroying, State.Destroyed, State.Error);
  sc.and(sc.entity().getParentSnapshotId(), Op.EQ, getId());
  SnapshotDataStoreVO vo = sc.find();
  if (vo == null) {
    return null;
  }
  return snapshotFactory.getSnapshot(vo.getId(), store);
}

相关文章