예제 #1
0
 @Override
 public List<? extends Host> findHosts(long accountId, long instanceId) {
   return create()
       .select(HOST.fields())
       .from(INSTANCE)
       .join(INSTANCE_HOST_MAP)
       .on(INSTANCE.ID.eq(INSTANCE_HOST_MAP.INSTANCE_ID))
       .join(HOST)
       .on(HOST.ID.eq(INSTANCE_HOST_MAP.HOST_ID))
       .where(
           HOST.REMOVED
               .isNull()
               .and(INSTANCE_HOST_MAP.REMOVED.isNull())
               .and(INSTANCE.ID.eq(instanceId)))
       .fetchInto(HostRecord.class);
 }
예제 #2
0
 @Override
 public List<? extends Host> getActiveHosts(long accountId) {
   return create()
       .select(HOST.fields())
       .from(HOST)
       .leftOuterJoin(AGENT)
       .on(AGENT.ID.eq(HOST.AGENT_ID))
       .where(
           AGENT
               .ID
               .isNull()
               .or(AGENT.STATE.eq(CommonStatesConstants.ACTIVE))
               .and(HOST.REMOVED.isNull())
               .and(HOST.ACCOUNT_ID.eq(accountId))
               .and(
                   HOST.STATE.in(
                       CommonStatesConstants.ACTIVE, CommonStatesConstants.UPDATING_ACTIVE)))
       .fetchInto(Host.class);
 }
예제 #3
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);
 }