private Bucket getHostManagedByUs() { int qun = 10000; long amount = dbf.count(HostVO.class); int times = (int) (amount / qun) + (amount % qun != 0 ? 1 : 0); List<String> connected = new ArrayList<String>(); List<String> disconnected = new ArrayList<String>(); int start = 0; for (int i = 0; i < times; i++) { SimpleQuery<HostVO> q = dbf.createQuery(HostVO.class); q.select(HostVO_.uuid, HostVO_.status); q.setLimit(qun); q.setStart(start); List<Tuple> lst = q.listTuple(); start += qun; for (Tuple t : lst) { String huuid = t.get(0, String.class); if (!destMaker.isManagedByUs(huuid)) { continue; } HostStatus state = t.get(1, HostStatus.class); if (state == HostStatus.Connected) { connected.add(huuid); } else { // for Disconnected and Connecting, treat as Disconnected disconnected.add(huuid); } } } return Bucket.newBucket(connected, disconnected); }
private List<String> getHostManagedByUs() { int qun = 10000; long amount = dbf.count(HostVO.class); int times = (int) (amount / qun) + (amount % qun != 0 ? 1 : 0); List<String> hostUuids = new ArrayList<String>(); int start = 0; for (int i = 0; i < times; i++) { SimpleQuery<KVMHostVO> q = dbf.createQuery(KVMHostVO.class); q.select(HostVO_.uuid); // disconnected host will be handled by HostManager q.add(HostVO_.status, SimpleQuery.Op.EQ, HostStatus.Connected); q.setLimit(qun); q.setStart(start); List<String> lst = q.listValue(); start += qun; for (String huuid : lst) { if (!destMaker.isManagedByUs(huuid)) { continue; } hostUuids.add(huuid); } } return hostUuids; }
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; } }