private void cleanupMountTable(Date cutoff) { log.debug("Cleaning up mount table [cutoff={}]", cutoff); Query q = create().query(MOUNT_DELETE_QUERY, cutoff, QUERY_LIMIT_ROWS.getValue()); int rowsAffected = 0; int total = 0; do { rowsAffected = q.execute(); if (rowsAffected > 0) { log.debug("Deleted {} unneeded rows from mount table", rowsAffected); } total += rowsAffected; } while (rowsAffected > 0); if (total > 0) { log.debug("[Rows Deleted] mount={}", total); } }
.and(idField.gt(DSL.param(ID_GREATER_THAN_PARAM, 0L)))) .orderBy(idField) .limit(QUERY_LIMIT_ROWS.getValue()); Param<?> idGreaterThanParam = idsToDeleteQuery.getParam(ID_GREATER_THAN_PARAM);
private void cleanupServiceEventTable(Date cutoff) { ResultQuery<Record1<Long>> ids = create() .select(SERVICE_EVENT.ID) .from(SERVICE_EVENT) .where(SERVICE_EVENT.CREATED.lt(cutoff)) .and(SERVICE_EVENT.STATE.eq(CommonStatesConstants.CREATED)) .limit(QUERY_LIMIT_ROWS.getValue()); List<Long> toDelete = null; int rowsDeleted = 0; while ((toDelete = ids.fetch().into(Long.class)).size() > 0) { rowsDeleted += create().delete(SERVICE_EVENT) .where(SERVICE_EVENT.ID.in(toDelete)).execute(); } if (rowsDeleted > 0) { log.info("[Rows Deleted] service_event={}", rowsDeleted); } }
private void cleanupExternalHandlerExternalHandlerProcessMapTables(Date cutoff) { ResultQuery<Record1<Long>> ids = create() .select(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP.ID) .from(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP) .join(EXTERNAL_HANDLER) .on(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP.EXTERNAL_HANDLER_ID.eq(EXTERNAL_HANDLER.ID)) .where(EXTERNAL_HANDLER.REMOVED.lt(cutoff)) .limit(QUERY_LIMIT_ROWS.getValue()); List<Long> toDelete = null; int rowsDeleted = 0; while ((toDelete = ids.fetch().into(Long.class)).size() > 0) { rowsDeleted += create().delete(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP) .where(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP.ID.in(toDelete)).execute(); } if (rowsDeleted > 0) { log.info("[Rows Deleted] external_handler_external_handler_process_map={}", rowsDeleted); } }
.join(INSTANCE).on(INSTANCE_LABEL_MAP.INSTANCE_ID.eq(INSTANCE.ID)) .where(INSTANCE.REMOVED.lt(cutoff)) .limit(QUERY_LIMIT_ROWS.getValue()); List<Long> toDelete = null; int ilmRowsDeleted = 0; .join(HOST).on(HOST_LABEL_MAP.HOST_ID.eq(HOST.ID)) .where(HOST.REMOVED.lt(cutoff)) .limit(QUERY_LIMIT_ROWS.getValue()); .and(HOST_LABEL_MAP.ID.isNull()) .and(LABEL.CREATED.lt(cutoff)) .limit(QUERY_LIMIT_ROWS.getValue());