Example #1
0
static void* flush_thread_main(void *in) {
    bloom_config *config;
    bloom_filtmgr *mgr;
    int *should_run;
    UNPACK_ARGS();

    // Perform the initial checkpoint with the manager
    filtmgr_client_checkpoint(mgr);

    syslog(LOG_INFO, "Flush thread started. Interval: %d seconds.", config->flush_interval);
    unsigned int ticks = 0;
    while (*should_run) {
        sleep(1);
        filtmgr_client_checkpoint(mgr);
        if ((++ticks % config->flush_interval) == 0 && *should_run) {
            // List all the filters
            syslog(LOG_INFO, "Scheduled flush started.");
            bloom_filter_list_head *head;
            int res = filtmgr_list_filters(mgr, &head);
            if (res != 0) {
                syslog(LOG_WARNING, "Failed to list filters for flushing!");
                continue;
            }

            // Flush all, ignore errors since
            // filters might get deleted in the process
            bloom_filter_list *node = head->head;
            while (node) {
                filtmgr_flush_filter(mgr, node->filter_name);
                node = node->next;
            }

            // Cleanup
            filtmgr_cleanup_list(head);
        }
    }
    return NULL;
}
Example #2
0
static void* unmap_thread_main(void *in) {
    bloom_config *config;
    bloom_filtmgr *mgr;
    int *should_run;
    UNPACK_ARGS();

    // Perform the initial checkpoint with the manager
    filtmgr_client_checkpoint(mgr);

    syslog(LOG_INFO, "Cold unmap thread started. Interval: %d seconds.", config->cold_interval);
    unsigned int ticks = 0;
    while (*should_run) {
        sleep(1);
        filtmgr_client_checkpoint(mgr);
        if ((++ticks % config->cold_interval) == 0 && *should_run) {
            // List the cold filters
            syslog(LOG_INFO, "Cold unmap started.");
            bloom_filter_list_head *head;
            int res = filtmgr_list_cold_filters(mgr, &head);
            if (res != 0) {
                continue;
            }

            // Close the filters, save memory
            syslog(LOG_INFO, "Cold filter count: %d", head->size);
            bloom_filter_list *node = head->head;
            while (node) {
                syslog(LOG_INFO, "Unmapping filter '%s' for being cold.", node->filter_name);
                filtmgr_unmap_filter(mgr, node->filter_name);
                node = node->next;
            }

            // Cleanup
            filtmgr_cleanup_list(head);
        }
    }
    return NULL;
}
Example #3
0
/**
 * Periodic update is used to update our checkpoint with
 * the filter manager, so that vacuum progress can be made.
 */
void periodic_update(bloom_conn_handler *handle) {
    filtmgr_client_checkpoint(handle->mgr);
}