org.zstack.core.db.Q.count()方法的使用及代码示例

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

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

Q.count介绍

暂无

代码示例

代码示例来源:origin: zstackio/zstack

private boolean isNfsUnmounted(String psUuid) {
  long count = Q.New(PrimaryStorageClusterRefVO.class)
      .eq(PrimaryStorageClusterRefVO_.primaryStorageUuid, psUuid).count();
  return count == 0;
}

代码示例来源:origin: zstackio/zstack

private void eliminateErrors() {
  String time = ElaborateGlobalConfig.ELIMILATE_TIME.value();
  long count = Q.New(ElaborationVO.class).eq(ElaborationVO_.matched, false).lt(ElaborationVO_.lastOpDate, new Timestamp(new Date().getTime() - TimeUtils.parseTimeInMillis(time))).count();
  if (count > 0) {
    logger.debug(String.format("clean [%s] records which are not matched error code in db", count));
    UpdateQuery.New(ElaborationVO.class).eq(ElaborationVO_.matched, false).lt(ElaborationVO_.lastOpDate, new Timestamp(new Date().getTime() - TimeUtils.parseTimeInMillis(time))).delete();
  }
}

代码示例来源:origin: zstackio/zstack

public boolean isUnmounted() {
  long count = Q.New(PrimaryStorageClusterRefVO.class)
      .eq(PrimaryStorageClusterRefVO_.primaryStorageUuid, this.self.getUuid()).count();
  return count == 0;
}

代码示例来源:origin: zstackio/zstack

@Override
  public ServiceReference getServiceReference(String vipUuid) {
    long count = Q.New(PortForwardingRuleVO.class).eq(PortForwardingRuleVO_.vipUuid, vipUuid).count();
    return new VipGetServiceReferencePoint.ServiceReference(PortForwardingConstant.PORTFORWARDING_NETWORK_SERVICE_TYPE, count);
  }
}

代码示例来源:origin: zstackio/zstack

@Override
  public ServiceReference getServiceReference(String vipUuid) {
    long count = Q.New(LoadBalancerVO.class).eq(LoadBalancerVO_.vipUuid, vipUuid).count();
    return new VipGetServiceReferencePoint.ServiceReference(LoadBalancerConstants.LB_NETWORK_SERVICE_TYPE_STRING, count);
  }
}

代码示例来源:origin: zstackio/zstack

BigInteger end = IPv6NetworkUtils.ipv6AddressToBigInteger(vo.getEndIp());
long cnt = Q.New(UsedIpVO.class).eq(UsedIpVO_.ipRangeUuid, vo.getUuid()).count();
BigInteger num = start.add(new BigInteger(String.valueOf(cnt)));
if (num.compareTo(end) > 0) {

代码示例来源:origin: zstackio/zstack

@Transactional(readOnly = true)
private boolean noStorageAccessible(String hostUuid){
  // detach ps will delete PrimaryStorageClusterRefVO first.
  List<String> attachedPsUuids = SQL.New("select distinct ref.primaryStorageUuid" +
      " from PrimaryStorageClusterRefVO ref, HostVO h" +
      " where h.uuid =:hostUuid" +
      " and ref.clusterUuid = h.clusterUuid", String.class)
      .param("hostUuid", hostUuid)
      .list();
  long attachedPsCount = attachedPsUuids.size();
  long inaccessiblePsCount = attachedPsCount == 0 ? 0 : Q.New(PrimaryStorageHostRefVO.class)
      .eq(PrimaryStorageHostRefVO_.hostUuid, hostUuid)
      .eq(PrimaryStorageHostRefVO_.status, PrimaryStorageHostStatus.Disconnected)
      .in(PrimaryStorageHostRefVO_.primaryStorageUuid, attachedPsUuids)
      .count();
  return inaccessiblePsCount == attachedPsCount && attachedPsCount > 0;
}

代码示例来源:origin: zstackio/zstack

static void checkAttachIsoToVm(String vmUuid, String isoUuid) {
  List<String> isoList = getIsoUuidByVmUuid(vmUuid);
  if (isoList.contains(isoUuid)) {
    throw new OperationFailureException(operr("VM[uuid:%s] has attached ISO[uuid:%s]", vmUuid, isoUuid));
  }
  long emptyCdRomNum = Q.New(VmCdRomVO.class)
      .eq(VmCdRomVO_.vmInstanceUuid, vmUuid)
      .isNull(VmCdRomVO_.isoUuid)
      .count();
  if (emptyCdRomNum == 0) {
    throw new OperationFailureException(operr("All vm[uuid:%s] CD-ROMs have mounted ISO", vmUuid));
  }
}

代码示例来源:origin: zstackio/zstack

@Transactional(readOnly = true)
private boolean noStorageAccessible(){
  // detach ps will delete PrimaryStorageClusterRefVO first.
  List<String> attachedPsUuids = Q.New(PrimaryStorageClusterRefVO.class)
      .select(PrimaryStorageClusterRefVO_.primaryStorageUuid)
      .eq(PrimaryStorageClusterRefVO_.clusterUuid, self.getClusterUuid())
      .listValues();
  long attachedPsCount = attachedPsUuids.size();
  long inaccessiblePsCount = attachedPsCount == 0 ? 0 : Q.New(PrimaryStorageHostRefVO.class)
      .eq(PrimaryStorageHostRefVO_.hostUuid, self.getUuid())
      .eq(PrimaryStorageHostRefVO_.status, PrimaryStorageHostStatus.Disconnected)
      .in(PrimaryStorageHostRefVO_.primaryStorageUuid, attachedPsUuids)
      .count();
  return inaccessiblePsCount == attachedPsCount && attachedPsCount > 0;
}

代码示例来源:origin: zstackio/zstack

@Override
  protected SessionInventory scripts() {
    if (q(SessionVO.class).eq(SessionVO_.accountUuid, accountUuid)
        .eq(SessionVO_.userUuid, userUuid).count() > IdentityGlobalConfig.MAX_CONCURRENT_SESSION.value(Integer.class)) {
      throw new OperationFailureException(operr("Login sessions hit limit of max allowed concurrent login sessions"));
    }
    SessionVO vo = new SessionVO();
    vo.setUuid(Platform.getUuid());
    vo.setAccountUuid(accountUuid);
    vo.setUserUuid(userUuid);
    long expiredTime = getCurrentSqlDate().getTime() + TimeUnit.SECONDS.toMillis(IdentityGlobalConfig.SESSION_TIMEOUT.value(Long.class));
    vo.setExpiredDate(new Timestamp(expiredTime));
    persist(vo);
    reload(vo);
    SessionInventory inv = SessionInventory.valueOf(vo);
    sessions.put(inv.getUuid(), inv);
    return inv;
  }
}.execute();

代码示例来源:origin: zstackio/zstack

private void validate(APICreateVxlanVtepMsg msg) {
  long count = Q.New(VtepVO.class).eq(VtepVO_.hostUuid, msg.getHostUuid()).eq(VtepVO_.poolUuid, msg.getPoolUuid()).count();
  if (count > 0) {
    throw new ApiMessageInterceptionException(argerr("vxlan vtep address for host [uuid : %s] and pool [uuid : %s] pair already existed",
            msg.getHostUuid(), msg.getPoolUuid())
    );
  }
}

代码示例来源:origin: zstackio/zstack

private void check(APIRecoverDataVolumeMsg msg, Map<String, Quota.QuotaPair> pairs) {
  String resourceTargetOwnerUuid = new QuotaUtil().getResourceOwnerAccountUuid(msg.getVolumeUuid());
  long cnt = Q.New(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, msg.getVolumeUuid()).count();
  checkVolumeSnapshotNumQuota(msg.getSession().getAccountUuid(), resourceTargetOwnerUuid, cnt, pairs);
}

代码示例来源:origin: zstackio/zstack

.eq(HostVO_.clusterUuid, msg.getUuid())
    .eq(HostVO_.state, HostState.PreMaintenance)
    .count();
if (premaintain != 0) {
  throw new ApiMessageInterceptionException(Platform.argerr(
    .eq(HostVO_.clusterUuid, msg.getUuid())
    .notEq(HostVO_.status, HostStatus.Connected)
    .count();
if (notConnected != 0) {
  throw new ApiMessageInterceptionException(Platform.argerr(

代码示例来源:origin: zstackio/zstack

.eq(L2NetworkClusterRefVO_.l2NetworkUuid, msg.getL2NetworkUuid()).count();
if (count != 0) {
  evt.setInventory(self.toInventory());

代码示例来源:origin: zstackio/zstack

.eq(VolumeVO_.vmInstanceUuid, inv.getUuid()).count();
if (count != 0) {
  capabilities.setSupportVolumeMigration(false);

代码示例来源:origin: zstackio/zstack

private void doCreateVmCdRom(CreateVmCdRomMsg msg, ReturnValueCompletion<VmCdRomInventory> completion) {
  long vmCdRomNum = Q.New(VmCdRomVO.class)
      .eq(VmCdRomVO_.vmInstanceUuid, msg.getVmInstanceUuid())
      .count();
  int max = VmGlobalConfig.MAXIMUM_CD_ROM_NUM.value(Integer.class);
  if (max <= vmCdRomNum) {

代码示例来源:origin: zstackio/zstack

count = Q.New(VolumeVO.class).eq(VolumeVO_.type, VolumeType.Data).eq(VolumeVO_.vmInstanceUuid, msg.getVmInstanceUuid()).count();
if (count + 1 > maxDataVolumeNum) {
  throw new ApiMessageInterceptionException(operr("hypervisor[%s] only allows max %s data volumes to be attached to a single vm; there have been %s data volumes attached to vm[uuid:%s]",

代码示例来源:origin: zstackio/zstack

.eq(VolumeVO_.vmInstanceUuid,vol.getVmInstanceUuid()).count();
if (count != 0) {
  throw new ApiMessageInterceptionException(operr("the volume[uuid:%s] is the root volume of the vm[uuid:%s]. Currently the vm still" +

相关文章