예제 #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 Map<String, String[]> getLabelsForHost(long hostId) {
    final Map<String, String[]> labelKeyValueStatusMap = new HashMap<String, String[]>();

    create()
        .select(LABEL.KEY, LABEL.VALUE, HOST_LABEL_MAP.STATE)
        .from(LABEL)
        .join(HOST_LABEL_MAP)
        .on(LABEL.ID.eq(HOST_LABEL_MAP.LABEL_ID))
        .where(HOST_LABEL_MAP.HOST_ID.eq(hostId))
        .and(LABEL.REMOVED.isNull())
        .and(HOST_LABEL_MAP.REMOVED.isNull())
        .fetchInto(
            new RecordHandler<Record3<String, String, String>>() {
              @Override
              public void next(Record3<String, String, String> record) {
                labelKeyValueStatusMap.put(
                    StringUtils.lowerCase(record.value1()),
                    new String[] {StringUtils.lowerCase(record.value2()), record.value3()});
              }
            });

    return labelKeyValueStatusMap;
  }