示例#1
0
 @Override
 public List<Port> getUsedPortsForHostExcludingInstance(long hostId, long instanceId) {
   return create()
       .select(PORT.fields())
       .from(PORT)
       .join(INSTANCE_HOST_MAP)
       .on(PORT.INSTANCE_ID.eq(INSTANCE_HOST_MAP.INSTANCE_ID))
       .join(INSTANCE)
       .on(INSTANCE_HOST_MAP.INSTANCE_ID.eq(INSTANCE.ID))
       .leftOuterJoin(SERVICE_EXPOSE_MAP)
       .on(SERVICE_EXPOSE_MAP.INSTANCE_ID.eq(INSTANCE.ID))
       .where(
           INSTANCE_HOST_MAP
               .HOST_ID
               .eq(hostId)
               .and(INSTANCE.REMOVED.isNull())
               .and(INSTANCE.ID.ne(instanceId))
               .and(
                   INSTANCE.STATE.in(
                       InstanceConstants.STATE_STARTING,
                       InstanceConstants.STATE_RESTARTING,
                       InstanceConstants.STATE_RUNNING))
               .and(INSTANCE_HOST_MAP.REMOVED.isNull())
               .and(PORT.REMOVED.isNull())
               .and(SERVICE_EXPOSE_MAP.UPGRADE.eq(false).or(SERVICE_EXPOSE_MAP.UPGRADE.isNull())))
       .fetchInto(Port.class);
 }
示例#2
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);
 }