Beispiel #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;
 }
Beispiel #2
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;
 }
Beispiel #3
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);
 }
Beispiel #4
0
  public List<Instance> getUnmappedDeploymentUnitInstances(String deploymentUnitUuid) {
    List<? extends Instance> instanceRecords =
        create()
            .select(INSTANCE.fields())
            .from(INSTANCE)
            .leftOuterJoin(INSTANCE_HOST_MAP)
            .on(
                INSTANCE_HOST_MAP
                    .INSTANCE_ID
                    .eq(INSTANCE.ID)
                    .and(INSTANCE_HOST_MAP.REMOVED.isNull()))
            .where(INSTANCE.REMOVED.isNull())
            .and(INSTANCE.DEPLOYMENT_UNIT_UUID.eq(deploymentUnitUuid))
            .and(INSTANCE_HOST_MAP.ID.isNull())
            .fetchInto(InstanceRecord.class);

    List<Instance> instances = new ArrayList<Instance>();
    for (Instance i : instanceRecords) {
      instances.add(i);
    }
    return instances;
  }
Beispiel #5
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);
 }