Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
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.");
   }
 }
Exemplo n.º 5
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);
 }