示例#1
0
static void* flush_thread_main(void *in) {
    hlld_config *config;
    hlld_setmgr *mgr;
    int *should_run;
    UNPACK_ARGS();

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

    syslog(LOG_INFO, "Flush thread started. Interval: %d seconds.", config->flush_interval);
    unsigned int ticks = 0;
    while (*should_run) {
        usleep(PERIODIC_TIME_USEC);
        setmgr_client_checkpoint(mgr);
        if ((++ticks % SEC_TO_TICKS(config->flush_interval)) == 0 && *should_run) {
            // Time how long this takes
            struct timeval start, end;
            gettimeofday(&start, NULL);

            // List all the sets
            syslog(LOG_INFO, "Scheduled flush started.");
            hlld_set_list_head *head;
            int res = setmgr_list_sets(mgr, NULL, &head);
            if (res != 0) {
                syslog(LOG_WARNING, "Failed to list sets for flushing!");
                continue;
            }

            // Flush all, ignore errors since
            // sets might get deleted in the process
            hlld_set_list *node = head->head;
            unsigned int cmds = 0;
            while (node) {
                setmgr_flush_set(mgr, node->set_name);
                if (!(++cmds % PERIODIC_CHECKPOINT)) setmgr_client_checkpoint(mgr);
                node = node->next;
            }

            // Compute the elapsed time
            gettimeofday(&end, NULL);
            syslog(LOG_INFO, "Flushed %d sets in %d msecs", head->size, timediff_msec(&start, &end));

            // Cleanup
            setmgr_cleanup_list(head);
        }
    }
    return NULL;
}
示例#2
0
static void* unmap_thread_main(void *in) {
    hlld_config *config;
    hlld_setmgr *mgr;
    int *should_run;
    UNPACK_ARGS();

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

    syslog(LOG_INFO, "Cold unmap thread started. Interval: %d seconds.", config->cold_interval);
    unsigned int ticks = 0;
    while (*should_run) {
        usleep(PERIODIC_TIME_USEC);
        setmgr_client_checkpoint(mgr);
        if ((++ticks % SEC_TO_TICKS(config->cold_interval)) == 0 && *should_run) {
            // Time how long this takes
            struct timeval start, end;
            gettimeofday(&start, NULL);

            // List the cold sets
            syslog(LOG_INFO, "Cold unmap started.");
            hlld_set_list_head *head;
            int res = setmgr_list_cold_sets(mgr, &head);
            if (res != 0) {
                continue;
            }

            // Close the sets, save memory
            hlld_set_list *node = head->head;
            unsigned int cmds = 0;
            while (node) {
                syslog(LOG_DEBUG, "Unmapping set '%s' for being cold.", node->set_name);
                setmgr_unmap_set(mgr, node->set_name);
                if (!(++cmds % PERIODIC_CHECKPOINT)) setmgr_client_checkpoint(mgr);
                node = node->next;
            }

            // Compute the elapsed time
            gettimeofday(&end, NULL);
            syslog(LOG_INFO, "Unmapped %d sets in %d msecs", head->size, timediff_msec(&start, &end));

            // Cleanup
            setmgr_cleanup_list(head);
        }
    }
    return NULL;
}
示例#3
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;
}
示例#4
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;
}