@Override public List<? extends Service> getServicesOnHost(long hostId) { return create() .select(SERVICE.fields()) .from(SERVICE) .join(SERVICE_EXPOSE_MAP) .on(SERVICE_EXPOSE_MAP.SERVICE_ID.eq(SERVICE.ID)) .join(INSTANCE_HOST_MAP) .on(SERVICE_EXPOSE_MAP.INSTANCE_ID.eq(INSTANCE_HOST_MAP.INSTANCE_ID)) .where(INSTANCE_HOST_MAP.HOST_ID.eq(hostId)) .and(INSTANCE_HOST_MAP.REMOVED.isNull()) .and(SERVICE_EXPOSE_MAP.REMOVED.isNull()) .and(SERVICE.REMOVED.isNull()) .fetchInto(ServiceRecord.class); }
@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); }