@Override public List<? extends ServiceConsumeMap> findConsumedServices(long serviceId) { return create() .selectFrom(SERVICE_CONSUME_MAP) .where( SERVICE_CONSUME_MAP.SERVICE_ID.eq(serviceId) .and(SERVICE_CONSUME_MAP.REMOVED.isNull()) .and(SERVICE_CONSUME_MAP.STATE.notIn(CommonStatesConstants.REMOVING))) .fetchInto(ServiceConsumeMapRecord.class); }
@Override public List<? extends Host> getHosts(Long accountId, List<String> uuids) { return create() .selectFrom(HOST) .where(HOST.ACCOUNT_ID.eq(accountId) .and(HOST.STATE.notIn(CommonStatesConstants.REMOVED, CommonStatesConstants.REMOVING)) .and(HOST.UUID.in(uuids))).fetch(); }
@Override public Instance getInstance(Agent agent) { return create() .selectFrom(INSTANCE) .where(INSTANCE.AGENT_ID.eq(agent.getId()) .and(INSTANCE.REMOVED.isNull()) .and(INSTANCE.STATE.notIn(InstanceConstants.STATE_ERROR, InstanceConstants.STATE_ERRORING, CommonStatesConstants.REMOVING))) .fetchOne(); }
@Override public List<? extends ServiceExposeMap> getNonRemovedServiceIpMaps(long serviceId) { return create() .select(SERVICE_EXPOSE_MAP.fields()) .from(SERVICE_EXPOSE_MAP) .where(SERVICE_EXPOSE_MAP.SERVICE_ID.eq(serviceId)) .and(SERVICE_EXPOSE_MAP.REMOVED.isNull() .and(SERVICE_EXPOSE_MAP.STATE.notIn(CommonStatesConstants.REMOVED, CommonStatesConstants.REMOVING)) .and(SERVICE_EXPOSE_MAP.IP_ADDRESS.isNotNull())) .fetchInto(ServiceExposeMapRecord.class); }
@Override public List<? extends ServiceExposeMap> getNonRemovedServiceHostnameMaps(long serviceId) { return create() .select(SERVICE_EXPOSE_MAP.fields()) .from(SERVICE_EXPOSE_MAP) .where(SERVICE_EXPOSE_MAP.SERVICE_ID.eq(serviceId)) .and(SERVICE_EXPOSE_MAP.REMOVED.isNull() .and(SERVICE_EXPOSE_MAP.STATE.notIn(CommonStatesConstants.REMOVED, CommonStatesConstants.REMOVING)) .and(SERVICE_EXPOSE_MAP.HOST_NAME.isNotNull())) .fetchInto(ServiceExposeMapRecord.class); }
@Override public List<? extends ProjectMember> findBadProjectMembers(int count) { return create().select(PROJECT_MEMBER.fields()) .from(PROJECT_MEMBER) .join(ACCOUNT) .on(ACCOUNT.ID.eq(PROJECT_MEMBER.PROJECT_ID)) .where(ACCOUNT.STATE.eq(CommonStatesConstants.PURGED) .and(PROJECT_MEMBER.REMOVED.isNull()) .and(PROJECT_MEMBER.STATE.notIn(CommonStatesConstants.DEACTIVATING, CommonStatesConstants.REMOVING))) .limit(count) .fetchInto(ProjectMemberRecord.class); }
@Override public List<? extends Volume> findBadVolumes(int count) { return create().select(VOLUME.fields()) .from(VOLUME) .join(ACCOUNT) .on(ACCOUNT.ID.eq(VOLUME.ACCOUNT_ID)) .where(VOLUME.REMOVED.isNull() .and(ACCOUNT.STATE.eq(CommonStatesConstants.PURGED)) .and(VOLUME.STATE.notIn(CommonStatesConstants.DEACTIVATING, CommonStatesConstants.REMOVING))) .limit(count) .fetchInto(VolumeRecord.class); }
@Override public List<? extends StoragePool> findBadPools(int count) { return create().select(STORAGE_POOL.fields()) .from(STORAGE_POOL) .join(ACCOUNT) .on(ACCOUNT.ID.eq(STORAGE_POOL.ACCOUNT_ID)) .where(STORAGE_POOL.REMOVED.isNull() .and(ACCOUNT.STATE.eq(CommonStatesConstants.PURGED)) .and(STORAGE_POOL.STATE.notIn(CommonStatesConstants.DEACTIVATING, CommonStatesConstants.REMOVING))) .limit(count) .fetchInto(StoragePoolRecord.class); }
@Override public List<? extends VolumeStoragePoolMap> findBandVolumeStoragePoolMap(int count) { return create().select(VOLUME_STORAGE_POOL_MAP.fields()) .from(VOLUME_STORAGE_POOL_MAP) .join(VOLUME) .on(VOLUME.ID.eq(VOLUME_STORAGE_POOL_MAP.VOLUME_ID)) .where(VOLUME.STATE.eq(CommonStatesConstants.PURGED) .and(VOLUME_STORAGE_POOL_MAP.REMOVED.isNull()) .and(VOLUME_STORAGE_POOL_MAP.STATE.notIn(CommonStatesConstants.DEACTIVATING, CommonStatesConstants.REMOVING))) .limit(count) .fetchInto(VolumeStoragePoolMapRecord.class); }
@Override public boolean isSchedulerServiceEnabled(Long accountId) { return create() .select(SERVICE.ID) .from(SERVICE) .where(SERVICE.ACCOUNT_ID.equal(accountId) .and(SERVICE.SYSTEM.isTrue()) .and(SERVICE.REMOVED.isNull()) .and(SERVICE.STATE.notIn(INACTIVE_STATES)) .and(SERVICE.DATA.like("%io.rancher.container.agent_service.scheduling%"))).fetch().size() > 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); }
@Override public List<? extends GenericObject> findBadGO(int count) { return create().select(GENERIC_OBJECT.fields()) .from(GENERIC_OBJECT) .join(ACCOUNT) .on(ACCOUNT.ID.eq(GENERIC_OBJECT.ACCOUNT_ID)) .where(GENERIC_OBJECT.REMOVED.isNull() .and(ACCOUNT.STATE.eq(CommonStatesConstants.PURGED)) .and(GENERIC_OBJECT.STATE.notIn(CommonStatesConstants.REMOVING, CommonStatesConstants.DEACTIVATING))) .limit(count) .fetchInto(GenericObjectRecord.class); }
@Override public List<? extends Mount> findBadMounts(int count) { return create().select(MOUNT.fields()) .from(MOUNT) .join(VOLUME) .on(VOLUME.ID.eq(MOUNT.VOLUME_ID)) .where(VOLUME.STATE.eq(CommonStatesConstants.PURGED) .and(MOUNT.REMOVED.isNull()) .and(MOUNT.STATE.notIn(CommonStatesConstants.DEACTIVATING, CommonStatesConstants.REMOVING))) .limit(count) .fetchInto(MountRecord.class); }
@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); }
@Override public List<? extends Network> findBadNetworks(int count) { return create().select(NETWORK.fields()) .from(NETWORK) .join(ACCOUNT) .on(ACCOUNT.ID.eq(NETWORK.ACCOUNT_ID)) .where(NETWORK.REMOVED.isNull() .and(ACCOUNT.STATE.eq(CommonStatesConstants.PURGED)) .and(NETWORK.STATE.notIn(CommonStatesConstants.REMOVING))) .limit(count) .fetchInto(NetworkRecord.class); }
@Override public List<? extends UserPreference> findBadUserPreference(int count) { return create().select(USER_PREFERENCE.fields()) .from(USER_PREFERENCE) .join(ACCOUNT) .on(ACCOUNT.ID.eq(USER_PREFERENCE.ACCOUNT_ID)) .where(USER_PREFERENCE.REMOVED.isNull() .and(ACCOUNT.STATE.eq(CommonStatesConstants.PURGED)) .and(USER_PREFERENCE.STATE.notIn(CommonStatesConstants.REMOVING, CommonStatesConstants.DEACTIVATING))) .limit(count) .fetchInto(UserPreferenceRecord.class); }
@Override public List<? extends HealthcheckInstance> findBadHealthcheckInstance(int limit) { return create() .select(HEALTHCHECK_INSTANCE.fields()) .from(HEALTHCHECK_INSTANCE) .join(INSTANCE) .on(INSTANCE.ID.eq(HEALTHCHECK_INSTANCE.INSTANCE_ID)) .where(INSTANCE.STATE.eq(CommonStatesConstants.PURGED) .and(HEALTHCHECK_INSTANCE.REMOVED.isNull()) .and(HEALTHCHECK_INSTANCE.STATE.notIn(CommonStatesConstants.DEACTIVATING, CommonStatesConstants.REMOVING))) .limit(limit) .fetchInto(HealthcheckInstanceRecord.class); }
@Override public List<? extends Image> findBadImages(int count) { return create().select(IMAGE.fields()) .from(IMAGE) .leftOuterJoin(INSTANCE) .on(IMAGE.ID.eq(INSTANCE.IMAGE_ID)) .where((INSTANCE.STATE.eq(CommonStatesConstants.PURGED).or(INSTANCE.ID.isNull())) .and(IMAGE.REMOVED.isNull()) .and(IMAGE.STATE.notIn(CommonStatesConstants.DEACTIVATING, CommonStatesConstants.REMOVING))) .limit(count) .fetchInto(ImageRecord.class); }
@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); }
@Override public List<? extends Stack> getStacksToUpgrade(Collection<String> currentIds) { return create().select(STACK.fields()) .from(STACK) .leftOuterJoin(SCHEDULED_UPGRADE) .on(SCHEDULED_UPGRADE.STACK_ID.eq(STACK.ID) .and(SCHEDULED_UPGRADE.REMOVED.isNull()) .and(SCHEDULED_UPGRADE.FINISHED.isNull())) .where(STACK.REMOVED.isNull() .and(STACK.SYSTEM.isTrue()) .and(STACK.EXTERNAL_ID.notIn(currentIds)) .and(SCHEDULED_UPGRADE.ID.isNull())) .fetchInto(StackRecord.class); }