Exemplo n.º 1
0
 @Override
 public List<? extends InstanceLink> findBadInstanceLinks(int count) {
   return create()
       .select(INSTANCE_LINK.fields())
       .from(INSTANCE_LINK)
       .join(INSTANCE)
       .on(INSTANCE.ID.eq(INSTANCE_LINK.TARGET_INSTANCE_ID))
       .where(INSTANCE.STATE.eq(CommonStatesConstants.PURGED))
       .limit(count)
       .fetchInto(InstanceLinkRecord.class);
 }
Exemplo n.º 2
0
 @Override
 public List<? extends Nic> findBadNics(int count) {
   return create()
       .select(NIC.fields())
       .from(NIC)
       .join(INSTANCE)
       .on(INSTANCE.ID.eq(NIC.INSTANCE_ID))
       .where(
           NIC.REMOVED
               .isNull()
               .and(INSTANCE.STATE.eq(CommonStatesConstants.PURGED))
               .and(
                   NIC.STATE.notIn(
                       CommonStatesConstants.DEACTIVATING, CommonStatesConstants.REMOVING)))
       .limit(count)
       .fetchInto(NicRecord.class);
 }
Exemplo n.º 3
0
 @Override
 public List<? extends InstanceHostMap> findBadInstanceHostMaps(int count) {
   return create()
       .select(INSTANCE_HOST_MAP.fields())
       .from(INSTANCE_HOST_MAP)
       .join(INSTANCE)
       .on(INSTANCE_HOST_MAP.INSTANCE_ID.eq(INSTANCE.ID))
       .where(
           INSTANCE_HOST_MAP
               .REMOVED
               .isNull()
               .and(INSTANCE.STATE.eq(CommonStatesConstants.PURGED))
               .and(
                   INSTANCE_HOST_MAP.STATE.notIn(
                       CommonStatesConstants.DEACTIVATING, CommonStatesConstants.REMOVING)))
       .limit(count)
       .fetchInto(InstanceHostMapRecord.class);
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
0
 @Override
 public List<? extends Instance> findInstanceByServiceName(long accountId, String serviceName) {
   return create()
       .select(INSTANCE.fields())
       .from(INSTANCE)
       .join(SERVICE_EXPOSE_MAP)
       .on(INSTANCE.ID.eq(SERVICE_EXPOSE_MAP.INSTANCE_ID))
       .join(SERVICE)
       .on(SERVICE.ID.eq(SERVICE_EXPOSE_MAP.SERVICE_ID))
       .where(
           INSTANCE
               .STATE
               .eq(InstanceConstants.STATE_RUNNING)
               .and(INSTANCE.ACCOUNT_ID.eq(accountId))
               .and(SERVICE_EXPOSE_MAP.REMOVED.isNull())
               .and(SERVICE.REMOVED.isNull())
               .and(SERVICE.NAME.eq(serviceName)))
       .fetchInto(InstanceRecord.class);
 }
Exemplo n.º 7
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);
 }
Exemplo n.º 8
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;
  }