예제 #1
0
 @Override
 public boolean hostHasContainerLabel(long hostId, String labelKey, String labelValue) {
   return create()
           .select(LABEL.ID)
           .from(LABEL)
           .join(INSTANCE_LABEL_MAP)
           .on(LABEL.ID.eq(INSTANCE_LABEL_MAP.LABEL_ID))
           .join(INSTANCE_HOST_MAP)
           .on(INSTANCE_LABEL_MAP.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(LABEL.REMOVED.isNull())
           .and(INSTANCE_LABEL_MAP.REMOVED.isNull())
           .and(INSTANCE_HOST_MAP.REMOVED.isNull())
           .and(INSTANCE.REMOVED.isNull())
           .and(
               INSTANCE.STATE.notIn(
                   InstanceConstants.STATE_ERROR, InstanceConstants.STATE_ERRORING))
           .and(LABEL.KEY.equalIgnoreCase(labelKey))
           .and(LABEL.VALUE.equalIgnoreCase(labelValue))
           .and(SERVICE_EXPOSE_MAP.UPGRADE.eq(false).or(SERVICE_EXPOSE_MAP.UPGRADE.isNull()))
           .fetchInto(Long.class)
           .size()
       > 0;
 }
예제 #2
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);
 }