本文整理了Java中org.zstack.core.db.Q.listValues
方法的一些代码示例,展示了Q.listValues
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Q.listValues
方法的具体详情如下:
包路径:org.zstack.core.db.Q
类名称:Q
方法名:listValues
暂无
代码示例来源:origin: zstackio/zstack
public static Collection<String> queryVmInGC(final String hostUuid, final Collection<String> vmUuids) {
Collection<String> vmUuidsInGC = new HashSet<>();
List<String> gcNames = Q.New(GarbageCollectorVO.class).select(GarbageCollectorVO_.name)
.eq(GarbageCollectorVO_.runnerClass, DeleteVmGC.class.getName())
.like(GarbageCollectorVO_.name, String.format("%%on-host-%s%%", hostUuid))
.notEq(GarbageCollectorVO_.status, GCStatus.Done).listValues();
if (gcNames != null && !gcNames.isEmpty()) {
vmUuidsInGC = vmUuids.stream().filter(uuid ->
gcNames.contains(String.format("gc-vm-%s-on-host-%s", uuid, hostUuid))).collect(Collectors.toSet());
}
return vmUuidsInGC;
}
}
代码示例来源:origin: zstackio/zstack
private String getAvailableHostUuidForOperation() {
List<String> hostUuids = Q.New(PrimaryStorageHostRefVO.class).
eq(PrimaryStorageHostRefVO_.primaryStorageUuid, self.getUuid()).select(PrimaryStorageHostRefVO_.hostUuid).listValues();
if (hostUuids == null || hostUuids.size() == 0) {
return null;
}
return hostUuids.get(0);
}
代码示例来源:origin: zstackio/zstack
public static List<String> getVmUuidByIsoUuid(String isoUuid) {
List<String> result = Q.New(VmCdRomVO.class)
.select(VmCdRomVO_.vmInstanceUuid)
.eq(VmCdRomVO_.isoUuid, isoUuid)
.listValues();
return result;
}
代码示例来源:origin: zstackio/zstack
private void changeVmCdRomsOwner(String vmInstanceUuid, String newOwnerUuid) {
List<String> vmCdRomUuids = Q.New(VmCdRomVO.class)
.select(VmCdRomVO_.uuid)
.eq(VmCdRomVO_.vmInstanceUuid, vmInstanceUuid)
.listValues();
if (vmCdRomUuids.isEmpty()) {
return;
}
for (String uuid :vmCdRomUuids) {
acntMgr.changeResourceOwner(uuid, newOwnerUuid);
}
}
代码示例来源:origin: zstackio/zstack
private List<String> getNeedRefreshSizeVolumeUuids(){
Set<String> volUuids = new HashSet<>();
for (RefreshVolumeSizeExtensionPoint ext : pluginRgty.getExtensionList(RefreshVolumeSizeExtensionPoint.class)) {
volUuids.addAll(ext.getNeedRefreshVolumeSizeVolume());
}
return volUuids.isEmpty() ? new ArrayList<>() : Q.New(VolumeVO.class).in(VolumeVO_.uuid, volUuids)
.eq(VolumeVO_.state, VolumeState.Enabled)
.eq(VolumeVO_.status, VolumeStatus.Ready)
.select(VolumeVO_.uuid)
.listValues();
}
}
代码示例来源:origin: zstackio/zstack
@Override
public List<HostVO> filter(List<HostVO> candidates) {
List<String> toRemoveHuuids = Q.New(HostVO.class).notEq(KVMHostVO_.username, "root").select(KVMHostVO_.uuid).listValues();
if (!toRemoveHuuids.isEmpty()){
candidates = CollectionUtils.transformToList(candidates, new Function<HostVO, HostVO>() {
@Override
public HostVO call(HostVO arg) {
return toRemoveHuuids.contains(arg.getUuid()) ? null : arg;
}
});
}
return candidates;
}
}
代码示例来源:origin: zstackio/zstack
@Override
protected List<SecurityGroupDeletionMsg> scripts() {
List<String> uuids = q(AccountResourceRefVO.class)
.select(AccountResourceRefVO_.resourceUuid)
.eq(AccountResourceRefVO_.resourceType, SecurityGroupVO.class.getSimpleName())
.in(AccountResourceRefVO_.ownerAccountUuid, accountUuids)
.listValues();
if (uuids.isEmpty()) {
return null;
}
return uuids.stream().map(auuid -> {
SecurityGroupDeletionMsg msg = new SecurityGroupDeletionMsg();
msg.setUuid(auuid);
bus.makeTargetServiceIdByResourceUuid(msg, SecurityGroupConstant.SERVICE_ID, auuid);
return msg;
}).collect(Collectors.toList());
}
}.execute();
代码示例来源:origin: zstackio/zstack
@Transactional
protected List<String> getAvoidHost(VmInstanceSpec spec){
return Q.New(PrimaryStorageHostRefVO.class).select(PrimaryStorageHostRefVO_.hostUuid)
.eq(PrimaryStorageHostRefVO_.primaryStorageUuid, spec.getRequiredPrimaryStorageUuidForRootVolume())
.eq(PrimaryStorageHostRefVO_.status, PrimaryStorageHostStatus.Disconnected)
.listValues();
}
代码示例来源:origin: zstackio/zstack
@Transactional
private List<String> getAvoidHost(VmInstanceSpec spec){
return Q.New(PrimaryStorageHostRefVO.class).select(PrimaryStorageHostRefVO_.hostUuid)
.eq(PrimaryStorageHostRefVO_.primaryStorageUuid, spec.getRequiredPrimaryStorageUuidForRootVolume())
.eq(PrimaryStorageHostRefVO_.status, PrimaryStorageHostStatus.Disconnected)
.listValues();
}
}
代码示例来源:origin: zstackio/zstack
public static List<String> getIsoUuidByVmUuid(String vmUuid) {
List<String> isoUuids = Q.New(VmCdRomVO.class)
.select(VmCdRomVO_.isoUuid)
.eq(VmCdRomVO_.vmInstanceUuid, vmUuid)
.notNull(VmCdRomVO_.isoUuid)
.listValues();
return isoUuids;
}
代码示例来源:origin: zstackio/zstack
@Override
public void rollback(final FlowRollback chain, Map data) {
final VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString());
List<String> cdRomUuids = Q.New(VmCdRomVO.class)
.select(VmCdRomVO_.uuid)
.eq(VmCdRomVO_.vmInstanceUuid, spec.getVmInventory().getUuid())
.listValues();
if (!cdRomUuids.isEmpty()) {
dbf.removeByPrimaryKeys(cdRomUuids, VmCdRomVO.class);
}
chain.rollback();
}
}
代码示例来源:origin: zstackio/zstack
private List<String> getL3NetworkDns(String l3NetworkUuid){
List<String> dns = Q.New(L3NetworkDnsVO.class).eq(L3NetworkDnsVO_.l3NetworkUuid, l3NetworkUuid)
.select(L3NetworkDnsVO_.dns).orderBy(L3NetworkDnsVO_.id, SimpleQuery.Od.ASC).listValues();
if (dns == null) {
dns = new ArrayList<String>();
}
L3NetworkVO l3VO = Q.New(L3NetworkVO.class).eq(L3NetworkVO_.uuid, l3NetworkUuid).find();
if (FlatNetwordProviderGlobalConfig.ALLOW_DEFAULT_DNS.value(Boolean.class) && l3VO.getIpVersion() == IPv6Constants.IPv4) {
String dhcpIp = getDHCPServerIP(l3NetworkUuid);
if (dhcpIp != null) {
dns.add(dhcpIp);
}
}
return dns;
}
代码示例来源: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
private String getOverlapVniRangePool(String l2NetworkUuid, String clusterUuid) {
List<VniRangeVO> checkRanges = Q.New(VniRangeVO.class).eq(VniRangeVO_.l2NetworkUuid, l2NetworkUuid).list();
List<String> l2Uuids = Q.New(L2NetworkClusterRefVO.class).select(L2NetworkClusterRefVO_.l2NetworkUuid).eq(L2NetworkClusterRefVO_.clusterUuid, clusterUuid).listValues();
for (String l2Uuid : l2Uuids) {
List<VniRangeVO> ranges = Q.New(VniRangeVO.class).eq(VniRangeVO_.l2NetworkUuid, l2Uuid).list();
for (VniRangeVO range : ranges) {
Boolean result = checkRanges.stream()
.map(r -> isVniRangeOverlap(r.getStartVni(), r.getEndVni(), range.getStartVni(), range.getEndVni()))
.reduce(true, (l, r) -> l && r);
if (result.equals(true)) {
return l2Uuid;
}
}
}
return null;
}
代码示例来源:origin: zstackio/zstack
@Override
public void afterAttachPrimaryStorage(PrimaryStorageInventory inventory, String clusterUuid) {
if(inventory.getType().equals(NfsPrimaryStorageConstant.NFS_PRIMARY_STORAGE_TYPE)){
Q.New(HostVO.class).select(HostVO_.uuid)
.eq(HostVO_.clusterUuid, clusterUuid)
.eq(HostVO_.status, HostStatus.Connected)
.notIn(HostVO_.state, list(HostState.PreMaintenance, HostState.Maintenance))
.listValues()
.forEach(huuid ->
updateNfsHostStatus(inventory.getUuid(), (String)huuid, PrimaryStorageHostStatus.Connected));
logger.debug("succeed add PrimaryStorageHostRef record");
recalculateCapacity(inventory.getUuid());
}
}
代码示例来源:origin: zstackio/zstack
@Override
protected void scripts() {
List<String> huuids = Q.New(HostVO.class).select(HostVO_.uuid)
.eq(HostVO_.clusterUuid, clusterUuid)
.listValues();
SQL.New(PrimaryStorageHostRefVO.class)
.eq(PrimaryStorageHostRefVO_.primaryStorageUuid, inventory.getUuid())
.in(PrimaryStorageHostRefVO_.hostUuid, huuids)
.hardDelete();
}
}.execute();
代码示例来源:origin: zstackio/zstack
private void connect(String hostUuid, final ReturnValueCompletion<Boolean> completion) {
ConnectCmd cmd = new ConnectCmd();
cmd.uuid = self.getUuid();
cmd.mountPoint = self.getMountPath();
cmd.existUuids = Q.New(PrimaryStorageVO.class).select(PrimaryStorageVO_.uuid)
.eq(PrimaryStorageVO_.type, SMPConstants.SMP_TYPE)
.listValues();
httpCall(CONNECT_PATH, hostUuid, cmd, true, ConnectRsp.class, new ReturnValueCompletion<ConnectRsp>(completion) {
@Override
public void success(ConnectRsp rsp) {
completion.success(rsp.isFirst);
}
@Override
public void fail(ErrorCode errorCode) {
completion.fail(errorCode);
}
});
}
代码示例来源:origin: zstackio/zstack
private void takeOverLongJob() {
logger.debug("Starting to take over long jobs");
final int group = 1000;
long amount = dbf.count(LongJobVO.class);
int times = (int) ((amount + group - 1)/group);
int start = 0;
for (int i = 0; i < times; i++) {
List<String> uuids = Q.New(LongJobVO.class)
.select(LongJobVO_.uuid)
.isNull(LongJobVO_.managementNodeUuid)
.limit(group).start(start).listValues();
for (String uuid : uuids) {
if (destinationMaker.isManagedByUs(uuid)) {
retryTakeOverLongJob(uuid);
}
}
start += group;
}
}
代码示例来源:origin: zstackio/zstack
@Override
protected void scripts() {
if (!q(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, volumeUuid).isExists()) {
return;
}
List<String> treeUuids = q(VolumeSnapshotVO.class).select(VolumeSnapshotVO_.treeUuid).eq(VolumeSnapshotVO_.volumeUuid, volumeUuid).listValues();
sql(VolumeSnapshotTreeVO.class).in(VolumeSnapshotTreeVO_.uuid, treeUuids).delete();
sql(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, volumeUuid).delete();
}
}.execute();
代码示例来源:origin: zstackio/zstack
private void handle(APIGetCandidateLdapEntryForBindingMsg msg) {
APIGetLdapEntryReply reply = new APIGetLdapEntryReply();
AndFilter andFilter = new AndFilter();
andFilter.and(new HardcodedFilter(msg.getLdapFilter()));
List<String> boundLdapEntryList = Q.New(LdapAccountRefVO.class)
.select(LdapAccountRefVO_.ldapUid)
.listValues();
List<Object> result = this.searchLdapEntry(andFilter.toString(), msg.getLimit(), new ResultFilter() {
@Override
boolean needSelect(String dn) {
return !boundLdapEntryList.contains(dn);
}
});
reply.setInventories(result);
bus.reply(msg, reply);
}
内容来源于网络,如有侵权,请联系作者删除!