示例#1
0
 @Override
 public List<? extends Host> getNonPurgedHosts(long accountId) {
   return create()
       .select(HOST.fields())
       .from(HOST)
       .where(HOST.ACCOUNT_ID.eq(accountId).and(HOST.STATE.notEqual(CommonStatesConstants.PURGED)))
       .fetchInto(Host.class);
 }
示例#2
0
 @Override
 public List<? extends Host> getHosts(StoragePool pool) {
   return create()
       .select(HOST.fields())
       .from(HOST)
       .join(STORAGE_POOL_HOST_MAP)
       .on(STORAGE_POOL_HOST_MAP.HOST_ID.eq(HOST.ID))
       .where(
           STORAGE_POOL_HOST_MAP
               .REMOVED
               .isNull()
               .and(STORAGE_POOL_HOST_MAP.STORAGE_POOL_ID.eq(pool.getId())))
       .fetchInto(HostRecord.class);
 }
示例#3
0
 @Override
 public Host getHost(Instance instance) {
   Condition cond = getInstanceHostConstraint(instance);
   try {
     return create()
         .selectDistinct(HOST.fields())
         .from(HOST)
         .join(INSTANCE_HOST_MAP)
         .on(INSTANCE_HOST_MAP.HOST_ID.eq(HOST.ID))
         .join(INSTANCE)
         .on(INSTANCE_HOST_MAP.INSTANCE_ID.eq(INSTANCE.ID))
         .where(INSTANCE_HOST_MAP.REMOVED.isNull().and(cond))
         .fetchOneInto(HostRecord.class);
   } catch (InvalidResultException e) {
     throw new FailedToAllocate("Instances to allocate assigned to different hosts.");
   }
 }
示例#4
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);
 }