org.ovirt.engine.core.common.businessentities.Quota.setGlobalQuotaStorage()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(114)

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

Quota.setGlobalQuotaStorage介绍

暂无

代码示例

代码示例来源:origin: oVirt/ovirt-engine

/**
 * Returns initialized entity with quota result set.
 */
private RowMapper<Quota> getQuotaFromResultSet() {
  return (rs, rowNum) -> {
    Quota entity = getQuotaMetaDataFromResultSet(rs);
    // Check if memory size is not null, this is an indication if global limitation for vds group exists or
    // not, since global limitation must be for all the quota vds group parameters.
    if (rs.getObject("mem_size_mb") != null) {
      // Set global vds group quota.
      QuotaCluster clusterEntity = new QuotaCluster();
      clusterEntity.setMemSizeMB((Long) rs.getObject("mem_size_mb"));
      clusterEntity.setMemSizeMBUsage((Long) rs.getObject("mem_size_mb_usage"));
      clusterEntity.setVirtualCpu((Integer) rs.getObject("virtual_cpu"));
      clusterEntity.setVirtualCpuUsage((Integer) rs.getObject("virtual_cpu_usage"));
      entity.setGlobalQuotaCluster(clusterEntity);
    }
    // Check if storage limit size is not null, this is an indication if global limitation for storage
    // exists or
    // not.
    if (rs.getObject("storage_size_gb") != null) {
      // Set global storage quota.
      QuotaStorage storageEntity = new QuotaStorage();
      storageEntity.setStorageSizeGB((Long) rs.getObject("storage_size_gb"));
      storageEntity.setStorageSizeGBUsage((Double) rs.getObject("storage_size_gb_usage"));
      entity.setGlobalQuotaStorage(storageEntity);
    }
    return entity;
  };
}

代码示例来源:origin: oVirt/ovirt-engine

@Override
  protected void updateEntityForRemove(Quota entity, Guid id) {
    // since we're mocking remove using update, we'll throw 404 if the object isn't found
    boolean throw404 = false;
    // global storage (has same id as quota)
    if (entity.getId().equals(id)) {
      if (entity.getGlobalQuotaStorage() == null) {
        throw404 = true;
      } else {
        entity.setGlobalQuotaStorage(null);
      }
      // specific storage (has same id as storage domain)
    } else {
      if (entity.getQuotaStorages() != null) {
        for (int i = 0; i < entity.getQuotaStorages().size(); i++) {
          if (entity.getQuotaStorages().get(i).getStorageId().equals(id)) {
            entity.getQuotaStorages().remove(i);
            return;
          }
        }
        throw404 = true;
      }
    }
    if (throw404) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
  }
}

代码示例来源:origin: oVirt/ovirt-engine

if (quota != null) {
  if (quotaStorage.getStorageId() == null || quotaStorage.getStorageId().equals(Guid.Empty)) {
    quota.setGlobalQuotaStorage(quotaStorage);
  } else {
    if (quota.getQuotaStorages() == null) {

代码示例来源:origin: oVirt/ovirt-engine

@Mapping(from = QuotaStorageLimit.class, to = org.ovirt.engine.core.common.businessentities.Quota.class)
public static org.ovirt.engine.core.common.businessentities.Quota map(QuotaStorageLimit model,
    org.ovirt.engine.core.common.businessentities.Quota template) {
  org.ovirt.engine.core.common.businessentities.Quota entity =
      template != null ? template : new org.ovirt.engine.core.common.businessentities.Quota();
  QuotaStorage quotaStorage = new QuotaStorage();
  if (model.isSetLimit()) {
    quotaStorage.setStorageSizeGB(model.getLimit());
  }
  // specific SD
  if(model.isSetStorageDomain() && model.getStorageDomain().isSetId()) {
    quotaStorage.setStorageId(GuidUtils.asGuid(model.getStorageDomain().getId()));
    entity.getQuotaStorages().add(quotaStorage);
  } else { // global
    entity.setGlobalQuotaStorage(quotaStorage);
  }
  return entity;
}

代码示例来源:origin: oVirt/ovirt-engine

@Test
public void testListGlobalLimit() {
  Quota quota = getQuota();
  quota.setGlobalQuotaStorage(getStorageGlobalCpuLimit());
  setUpGetEntityExpectations(quota);
  QuotaStorageLimits storageLimits = collection.list();
  assertStorageLimitsFound(storageLimits, 1);
  QuotaStorageLimit storageLimit = storageLimits.getQuotaStorageLimits().get(0);
  assertEquals(STORAGE_SIZE_GB, storageLimit.getLimit());
}

代码示例来源:origin: oVirt/ovirt-engine

private static void setQuotaGlobalLimitations(Quota quota) {
  QuotaStorage quotaStorage = new QuotaStorage();
  QuotaCluster quotaCluster = new QuotaCluster();
  // Set Quota storage capacity definition.
  quotaStorage.setStorageSizeGB(10000L);
  quotaStorage.setStorageSizeGBUsage(0d);
  // Set Quota cluster virtual memory definition.
  quotaCluster.setMemSizeMB(16000000L);
  quotaCluster.setMemSizeMBUsage(0L);
  // Set Quota cluster virtual CPU definition.
  quotaCluster.setVirtualCpu(2880);
  quotaCluster.setVirtualCpuUsage(0);
  quota.setGlobalQuotaStorage(quotaStorage);
  quota.setGlobalQuotaCluster(quotaCluster);
}

代码示例来源:origin: oVirt/ovirt-engine

QuotaStorage quotaStorage;
for (QuotaStorage iter : model.getQuotaStorages().getItems()) {
  quota.setGlobalQuotaStorage(new QuotaStorage());
  quota.getGlobalQuotaStorage().setStorageSizeGB(iter.getStorageSizeGB());
  quota.getQuotaStorages().clear();
quota.setGlobalQuotaStorage(null);
ArrayList<QuotaStorage> quotaStorageList = new ArrayList<>();
QuotaStorage quotaStorage;

代码示例来源:origin: oVirt/ovirt-engine

@Test
public void testSpecificAndGeneralQuotaLimitations() {
  // Set new Quota definition.
  Quota quota = createGeneralQuota();
  quota.setQuotaClusters(getQuotaCluster(getSpecificQuotaCluster(quota.getId())));
  quota.setQuotaStorages(getQuotaStorage(null));
  quota.setGlobalQuotaStorage(new QuotaStorage(null, null, null, 10000L, 0d));
  dao.save(quota);
  Quota quotaEntity = dao.getById(quota.getId());
  assertNotNull(quotaEntity);
  assertEquals(quota, quotaEntity);
}

相关文章