Example #1
0
 @Override
 public boolean isVolumeInUseOnHost(long volumeId, long hostId) {
   return create()
           .select(INSTANCE.ID)
           .from(INSTANCE)
           .join(MOUNT)
           .on(MOUNT.INSTANCE_ID.eq(INSTANCE.ID).and(MOUNT.VOLUME_ID.eq(volumeId)))
           .join(INSTANCE_HOST_MAP)
           .on(
               INSTANCE_HOST_MAP
                   .INSTANCE_ID
                   .eq(INSTANCE.ID)
                   .and(INSTANCE_HOST_MAP.HOST_ID.eq(hostId)))
           .join(HOST)
           .on(HOST.ID.eq(INSTANCE_HOST_MAP.HOST_ID))
           .where(
               INSTANCE
                   .REMOVED
                   .isNull()
                   .and(INSTANCE_HOST_MAP.STATE.notIn(IHM_STATES))
                   .and(
                       (INSTANCE
                           .HEALTH_STATE
                           .isNull()
                           .or(
                               INSTANCE.HEALTH_STATE.eq(
                                   HealthcheckConstants.HEALTH_STATE_HEALTHY)))))
           .fetch()
           .size()
       > 0;
 }
Example #2
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);
 }
Example #3
0
 @Override
 public List<Long> getInstancesWithVolumeMounted(long volumeId, long currentInstanceId) {
   return create()
       .select(INSTANCE.ID)
       .from(INSTANCE)
       .join(MOUNT)
       .on(MOUNT.INSTANCE_ID.eq(INSTANCE.ID).and(MOUNT.VOLUME_ID.eq(volumeId)))
       .join(INSTANCE_HOST_MAP)
       .on(INSTANCE_HOST_MAP.INSTANCE_ID.eq(INSTANCE.ID))
       .where(
           INSTANCE
               .REMOVED
               .isNull()
               .and(INSTANCE.ID.ne(currentInstanceId))
               .and(INSTANCE_HOST_MAP.STATE.notIn(IHM_STATES))
               .and(
                   (INSTANCE
                       .HEALTH_STATE
                       .isNull()
                       .or(INSTANCE.HEALTH_STATE.eq(HealthcheckConstants.HEALTH_STATE_HEALTHY)))))
       .fetchInto(Long.class);
 }