Esempio n. 1
0
 @Override
 public List<? extends InstanceHostMap> findBadInstanceHostMaps(int count) {
   return create()
       .select(INSTANCE_HOST_MAP.fields())
       .from(INSTANCE_HOST_MAP)
       .join(INSTANCE)
       .on(INSTANCE_HOST_MAP.INSTANCE_ID.eq(INSTANCE.ID))
       .where(
           INSTANCE_HOST_MAP
               .REMOVED
               .isNull()
               .and(INSTANCE.STATE.eq(CommonStatesConstants.PURGED))
               .and(
                   INSTANCE_HOST_MAP.STATE.notIn(
                       CommonStatesConstants.DEACTIVATING, CommonStatesConstants.REMOVING)))
       .limit(count)
       .fetchInto(InstanceHostMapRecord.class);
 }
Esempio n. 2
0
  @Override
  public Map<String, List<InstanceHostMap>> getInstanceHostMapsWithHostUuid(long instanceId) {
    Map<Record, List<InstanceHostMap>> result =
        create()
            .select(INSTANCE_HOST_MAP.fields())
            .select(HOST.UUID)
            .from(INSTANCE_HOST_MAP)
            .join(HOST)
            .on(INSTANCE_HOST_MAP.HOST_ID.eq(HOST.ID))
            .where(
                INSTANCE_HOST_MAP
                    .INSTANCE_ID
                    .eq(instanceId)
                    .and(INSTANCE_HOST_MAP.REMOVED.isNull()))
            .fetchGroups(new Field[] {HOST.UUID}, InstanceHostMap.class);

    Map<String, List<InstanceHostMap>> maps = new HashMap<>();
    for (Map.Entry<Record, List<InstanceHostMap>> entry : result.entrySet()) {
      String uuid = (String) entry.getKey().getValue(0);
      maps.put(uuid, entry.getValue());
    }
    return maps;
  }