Esempio n. 1
0
 @Override
 public List<? extends Instance> getNonRemovedInstanceOn(Long hostId) {
   return create()
       .select(INSTANCE.fields())
       .from(INSTANCE)
       .join(INSTANCE_HOST_MAP)
       .on(INSTANCE_HOST_MAP.HOST_ID.eq(hostId).and(INSTANCE_HOST_MAP.INSTANCE_ID.eq(INSTANCE.ID)))
       .where(
           INSTANCE
               .REMOVED
               .isNull()
               .and(
                   INSTANCE.STATE.notIn(
                       InstanceConstants.STATE_ERROR,
                       InstanceConstants.STATE_ERRORING,
                       CommonStatesConstants.REMOVING)))
       .fetchInto(InstanceRecord.class);
 }
Esempio n. 2
0
 @Override
 public List<? extends Instance> findBadInstances(int count) {
   return create()
       .select(INSTANCE.fields())
       .from(INSTANCE)
       .join(INSTANCE_HOST_MAP)
       .on(INSTANCE_HOST_MAP.INSTANCE_ID.eq(INSTANCE.ID))
       .join(HOST)
       .on(INSTANCE_HOST_MAP.HOST_ID.eq(HOST.ID))
       .where(
           HOST.REMOVED
               .isNotNull()
               .and(INSTANCE.REMOVED.isNull())
               .and(
                   INSTANCE.STATE.notIn(
                       InstanceConstants.STATE_STOPPING, CommonStatesConstants.REMOVING)))
       .limit(count)
       .fetchInto(InstanceRecord.class);
 }
Esempio n. 3
0
 @Override
 public List<? extends Instance> findInstancesFor(Service service) {
   return create()
       .select(INSTANCE.fields())
       .from(INSTANCE)
       .join(SERVICE_EXPOSE_MAP)
       .on(
           SERVICE_EXPOSE_MAP
               .INSTANCE_ID
               .eq(INSTANCE.ID)
               .and(SERVICE_EXPOSE_MAP.SERVICE_ID.eq(service.getId()))
               .and(
                   SERVICE_EXPOSE_MAP.STATE.in(
                       CommonStatesConstants.ACTIVATING,
                       CommonStatesConstants.ACTIVE,
                       CommonStatesConstants.REQUESTED))
               .and(
                   INSTANCE.STATE.notIn(
                       CommonStatesConstants.PURGING,
                       CommonStatesConstants.PURGED,
                       CommonStatesConstants.REMOVED,
                       CommonStatesConstants.REMOVING)))
       .fetchInto(InstanceRecord.class);
 }
Esempio n. 4
0
  @Override
  public Instance getInstanceByUuidOrExternalId(Long accountId, String uuid, String externalId) {
    Instance instance = null;
    Condition condition =
        INSTANCE
            .ACCOUNT_ID
            .eq(accountId)
            .and(INSTANCE.STATE.notIn(CommonStatesConstants.PURGED, CommonStatesConstants.PURGING));

    if (StringUtils.isNotEmpty(uuid)) {
      instance =
          create().selectFrom(INSTANCE).where(condition.and(INSTANCE.UUID.eq(uuid))).fetchAny();
    }

    if (instance == null && StringUtils.isNotEmpty(externalId)) {
      instance =
          create()
              .selectFrom(INSTANCE)
              .where(condition.and(INSTANCE.EXTERNAL_ID.eq(externalId)))
              .fetchAny();
    }

    return instance;
  }