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 Host> findHosts(long accountId, long instanceId) {
   return create()
       .select(HOST.fields())
       .from(INSTANCE)
       .join(INSTANCE_HOST_MAP)
       .on(INSTANCE.ID.eq(INSTANCE_HOST_MAP.INSTANCE_ID))
       .join(HOST)
       .on(HOST.ID.eq(INSTANCE_HOST_MAP.HOST_ID))
       .where(
           HOST.REMOVED
               .isNull()
               .and(INSTANCE_HOST_MAP.REMOVED.isNull())
               .and(INSTANCE.ID.eq(instanceId)))
       .fetchInto(HostRecord.class);
 }
Example #3
0
 @Override
 public List<Long> getPhysicalHostsForSubnet(long subnetId, Long vnetId) {
   return create()
       .select(HOST.PHYSICAL_HOST_ID)
       .from(SUBNET_VNET_MAP)
       .join(VNET)
       .on(VNET.ID.eq(SUBNET_VNET_MAP.VNET_ID))
       .join(HOST_VNET_MAP)
       .on(HOST_VNET_MAP.VNET_ID.eq(VNET.ID))
       .join(HOST)
       .on(HOST.ID.eq(HOST_VNET_MAP.HOST_ID))
       .where(
           SUBNET_VNET_MAP
               .SUBNET_ID
               .eq(subnetId)
               .and(HOST_VNET_MAP.STATE.eq(CommonStatesConstants.ACTIVE))
               .and(vnetCondition(vnetId))
               .and(HOST.PHYSICAL_HOST_ID.isNotNull()))
       .fetchInto(Long.class);
 }