gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-15 01:00:49 26 4
gpt4 key购买 nike

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

ZoneScope.<init>介绍

暂无

代码示例

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

private Scope getZoneScope(Scope scope) {
  ZoneScope zoneScope;
  if (scope instanceof ClusterScope) {
    ClusterScope clusterScope = (ClusterScope)scope;
    zoneScope = new ZoneScope(clusterScope.getZoneId());
  } else if (scope instanceof HostScope) {
    HostScope hostScope = (HostScope)scope;
    zoneScope = new ZoneScope(hostScope.getZoneId());
  } else {
    zoneScope = (ZoneScope)scope;
  }
  return zoneScope;
}

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

@Override
public Scope getScope() {
  return new ZoneScope(imageDataStoreVO.getDataCenterId());
}

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

private Scope getZoneScope(Scope destScope) {
  ZoneScope zoneScope = null;
  if (destScope instanceof ClusterScope) {
    ClusterScope clusterScope = (ClusterScope)destScope;
    zoneScope = new ZoneScope(clusterScope.getZoneId());
  } else if (destScope instanceof HostScope) {
    HostScope hostScope = (HostScope)destScope;
    zoneScope = new ZoneScope(hostScope.getZoneId());
  } else {
    zoneScope = (ZoneScope)destScope;
  }
  return zoneScope;
}

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

@Override
public DataStore getImageStore(long zoneId) {
  List<DataStore> stores = getImageStoresByScope(new ZoneScope(zoneId));
  if (stores == null || stores.size() == 0) {
    return null;
  }
  return imageDataStoreMgr.getImageStore(stores);
}

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

@Override
public DataStore getImageCacheStore(long zoneId) {
  List<DataStore> stores = getImageCacheStores(new ZoneScope(zoneId));
  if (stores == null || stores.size() == 0) {
    return null;
  }
  return imageDataStoreMgr.getImageStore(stores);
}

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

@Override
public TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId, Status... status) {
  // get all elgible image stores
  List<DataStore> imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId));
  if (imgStores != null) {
    for (DataStore store : imgStores) {
      List<TemplateDataStoreVO> sRes = listByTemplateStoreDownloadStatus(templateId, store.getId(), status);
      if (sRes != null && sRes.size() > 0) {
        Collections.shuffle(sRes);
        return sRes.get(0);
      }
    }
  }
  return null;
}

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

@Override
public List<DataStore> getImageStoreByTemplate(long templateId, Long zoneId) {
  // find all eligible image stores for this zone scope
  List<DataStore> imageStores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId));
  if (imageStores == null || imageStores.size() == 0) {
    return null;
  }
  List<DataStore> stores = new ArrayList<DataStore>();
  for (DataStore store : imageStores) {
    // check if the template is stored there
    List<TemplateDataStoreVO> storeTmpl = _tmplStoreDao.listByTemplateStore(templateId, store.getId());
    if (storeTmpl != null && storeTmpl.size() > 0) {
      stores.add(store);
    }
  }
  return stores;
}

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

@Override
public TemplateDataStoreVO findByTemplateZoneReady(long templateId, Long zoneId) {
  List<DataStore> imgStores = null;
  imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId));
  if (imgStores != null) {
    Collections.shuffle(imgStores);
    for (DataStore store : imgStores) {
      List<TemplateDataStoreVO> sRes = listByTemplateStoreStatus(templateId, store.getId(), State.Ready);
      if (sRes != null && sRes.size() > 0) {
        return sRes.get(0);
      }
    }
  }
  return null;
}

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

@Override
public TemplateDataStoreVO findByTemplateZoneStagingDownloadStatus(long templateId, Long zoneId, Status... status) {
  // get all elgible image stores
  List<DataStore> cacheStores = _storeMgr.getImageCacheStores(new ZoneScope(zoneId));
  if (cacheStores != null) {
    for (DataStore store : cacheStores) {
      List<TemplateDataStoreVO> sRes = listByTemplateStoreDownloadStatus(templateId, store.getId(),
          status);
      if (sRes != null && sRes.size() > 0) {
        Collections.shuffle(sRes);
        return sRes.get(0);
      }
    }
  }
  return null;
}

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

@Override
public List<TemplateDataStoreVO> listByTemplateZoneDownloadStatus(long templateId, Long zoneId, Status... status) {
  // get all elgible image stores
  List<DataStore> imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId));
  if (imgStores != null) {
    List<TemplateDataStoreVO> result = new ArrayList<TemplateDataStoreVO>();
    for (DataStore store : imgStores) {
      List<TemplateDataStoreVO> sRes = listByTemplateStoreDownloadStatus(templateId, store.getId(), status);
      if (sRes != null && sRes.size() > 0) {
        result.addAll(sRes);
      }
    }
    return result;
  }
  return null;
}

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

@Override
public TemplateDataStoreVO findByTemplateZone(long templateId, Long zoneId, DataStoreRole role) {
  // get all elgible image stores
  List<DataStore> imgStores = null;
  if (role == DataStoreRole.Image) {
    imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId));
  } else if (role == DataStoreRole.ImageCache) {
    imgStores = _storeMgr.getImageCacheStores(new ZoneScope(zoneId));
  }
  if (imgStores != null) {
    for (DataStore store : imgStores) {
      List<TemplateDataStoreVO> sRes = listByTemplateStore(templateId, store.getId());
      if (sRes != null && sRes.size() > 0) {
        return sRes.get(0);
      }
    }
  }
  return null;
}

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

@Override
public List<DataStore> listImageCacheStores(Scope scope) {
  if (scope.getScopeType() != ScopeType.ZONE) {
    s_logger.debug("only support zone wide image cache stores");
    return null;
  }
  List<ImageStoreVO> stores = dataStoreDao.findImageCacheByScope(new ZoneScope(scope.getScopeId()));
  List<DataStore> imageStores = new ArrayList<DataStore>();
  for (ImageStoreVO store : stores) {
    imageStores.add(getImageStore(store.getId()));
  }
  return imageStores;
}

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

@Override
public TemplateInfo prepareIso(long isoId, long dcId, Long hostId, Long poolId) {
  TemplateInfo tmplt;
  boolean bypassed = false;
  if (_tmplFactory.isTemplateMarkedForDirectDownload(isoId)) {
    tmplt = _tmplFactory.getReadyBypassedTemplateOnPrimaryStore(isoId, poolId, hostId);
    bypassed = true;
  } else {
    tmplt = _tmplFactory.getTemplate(isoId, DataStoreRole.Image, dcId);
  }
  if (tmplt == null || tmplt.getFormat() != ImageFormat.ISO) {
    s_logger.warn("ISO: " + isoId + " does not exist in vm_template table");
    return null;
  }
  if (!bypassed && tmplt.getDataStore() != null && !(tmplt.getDataStore().getTO() instanceof NfsTO)) {
    // if it is s3, need to download into cache storage first
    Scope destScope = new ZoneScope(dcId);
    TemplateInfo cacheData = (TemplateInfo)cacheMgr.createCacheObject(tmplt, destScope);
    if (cacheData == null) {
      s_logger.error("Failed in copy iso from S3 to cache storage");
      return null;
    }
    return cacheData;
  } else {
    return tmplt;
  }
}

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

@Override
public void handleSysTemplateDownload(HypervisorType hostHyper, Long dcId) {
  Set<VMTemplateVO> toBeDownloaded = new HashSet<VMTemplateVO>();
  List<DataStore> stores = _storeMgr.getImageStoresByScope(new ZoneScope(dcId));
  if (stores == null || stores.isEmpty()) {
    return;

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

private void addStorageMetrics(final List<Item> metricsList, final long dcId, final String zoneName, final String zoneUuid) {
  for (final StoragePoolJoinVO pool: storagePoolJoinDao.listAll()) {
    if (pool == null || pool.getZoneId() != dcId) {
      continue;
    }
    final String poolName = pool.getName();
    final String poolPath = pool.getHostAddress() + ":" + pool.getPath();
    long usedCapacity = 0L;
    long allocatedCapacity = pool.getUsedCapacity() + pool.getReservedCapacity();
    final long totalCapacity = pool.getCapacityBytes();
    final StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
    if (stats != null) {
      usedCapacity = stats.getByteUsed();
    }
    final BigDecimal poolOverProvisioningFactor = BigDecimal.valueOf(CapacityManager.StorageOverprovisioningFactor.valueIn(pool.getId()));
    final String poolFactor = poolOverProvisioningFactor.toString();
    metricsList.add(new ItemPool(zoneName, zoneUuid, poolName, poolPath, "primary", poolFactor, USED, usedCapacity));
    metricsList.add(new ItemPool(zoneName, zoneUuid, poolName, poolPath, "primary", poolFactor, ALLOCATED, allocatedCapacity));
    metricsList.add(new ItemPool(zoneName, zoneUuid, poolName, poolPath, "primary", poolFactor, UNALLOCATED, poolOverProvisioningFactor.multiply(BigDecimal.valueOf(totalCapacity)).longValue() - allocatedCapacity));
    metricsList.add(new ItemPool(zoneName, zoneUuid, poolName, poolPath, "primary", poolFactor, TOTAL, totalCapacity));
  }
  for (final ImageStore imageStore : imageStoreDao.findByScope(new ZoneScope(dcId))) {
    final StorageStats stats = ApiDBUtils.getSecondaryStorageStatistics(imageStore.getId());
    metricsList.add(new ItemPool(zoneName, zoneUuid, imageStore.getName(), imageStore.getUrl(), "secondary", null, USED, stats != null ? stats.getByteUsed() : 0));
    metricsList.add(new ItemPool(zoneName, zoneUuid, imageStore.getName(), imageStore.getUrl(), "secondary", null, TOTAL, stats != null ? stats.getCapacityBytes() : 0));
  }
}

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

@Override
public CapacityVO getSecondaryStorageUsedStats(Long hostId, Long zoneId) {
  SearchCriteria<HostVO> sc = _hostDao.createSearchCriteria();
  if (zoneId != null) {
    sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
  }
  List<Long> hosts = new ArrayList<Long>();
  if (hostId != null) {
    hosts.add(hostId);
  } else {
    List<DataStore> stores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId));
    if (stores != null) {
      for (DataStore store : stores) {
        hosts.add(store.getId());
      }
    }
  }
  CapacityVO capacity = new CapacityVO(hostId, zoneId, null, null, 0, 0, Capacity.CAPACITY_TYPE_SECONDARY_STORAGE);
  for (Long id : hosts) {
    StorageStats stats = ApiDBUtils.getSecondaryStorageStatistics(id);
    if (stats == null) {
      continue;
    }
    capacity.setUsedCapacity(stats.getByteUsed() + capacity.getUsedCapacity());
    capacity.setTotalCapacity(stats.getCapacityBytes() + capacity.getTotalCapacity());
  }
  return capacity;
}

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

if(!_imageStoreDao.findByScope(new ZoneScope(zoneId)).isEmpty()) {
  throw new CloudRuntimeException(errorMsg + "there are Secondary storages in this zone");

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

@Override
public Scope getScope() {
  StoragePoolVO vo = dataStoreDao.findById(pdsv.getId());
  if (vo.getScope() == ScopeType.CLUSTER) {
    return new ClusterScope(vo.getClusterId(), vo.getPodId(), vo.getDataCenterId());
  } else if (vo.getScope() == ScopeType.ZONE) {
    return new ZoneScope(vo.getDataCenterId());
  } else if (vo.getScope() == ScopeType.HOST) {
    List<StoragePoolHostVO> poolHosts = poolHostDao.listByPoolId(vo.getId());
    if (poolHosts.size() > 0) {
      return new HostScope(poolHosts.get(0).getHostId(), vo.getClusterId(), vo.getDataCenterId());
    }
    s_logger.debug("can't find a local storage in pool host table: " + vo.getId());
  }
  return null;
}

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

List<DataStore> imageStores = _storeMgr.getImageStoresByScope(new ZoneScope(agent.getDataCenterId()));
for (DataStore store : imageStores) {
  _volumeSrv.handleVolumeSync(store);

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

if (!(storTO instanceof NfsTO)) {
  srcData = cacheSnapshotChain(snapshot, new ZoneScope(pool.getDataCenterId()));

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com