cache_t *lru_cache_load(void *arg, inip_file_t *fd, char *grp, data_attr_t *da, int timeout) { cache_t *c; cache_lru_t *cp; int dt; if (grp == NULL) grp = "cache-lru"; //** Create the default structure c = lru_cache_create(arg, da, timeout); cp = (cache_lru_t *)c->fn.priv; cache_lock(c); cp->max_bytes = inip_get_integer(fd, grp, "max_bytes", cp->max_bytes); cp->dirty_fraction = inip_get_double(fd, grp, "dirty_fraction", cp->dirty_fraction); cp->dirty_bytes_trigger = cp->dirty_fraction * cp->max_bytes; c->default_page_size = inip_get_integer(fd, grp, "default_page_size", c->default_page_size); dt = inip_get_integer(fd, grp, "dirty_max_wait", apr_time_sec(cp->dirty_max_wait)); cp->dirty_max_wait = apr_time_make(dt, 0); c->max_fetch_fraction = inip_get_double(fd, grp, "max_fetch_fraction", c->max_fetch_fraction); c->max_fetch_size = c->max_fetch_fraction * cp->max_bytes; c->write_temp_overflow_fraction = inip_get_double(fd, grp, "write_temp_overflow_fraction", c->write_temp_overflow_fraction); c->write_temp_overflow_size = c->write_temp_overflow_fraction * cp->max_bytes; c->n_ppages = inip_get_integer(fd, grp, "ppages", c->n_ppages); log_printf(0, "COP size=" XOT "\n", c->write_temp_overflow_size); cache_unlock(c); return(c); }
static jscctx_t *getctx (flux_t *h) { jscctx_t *ctx = (jscctx_t *)flux_aux_get (h, "jstatctrl"); if (!ctx) { ctx = xzmalloc (sizeof (*ctx)); if (!(ctx->active_jobs = zhash_new ())) oom (); if (!(ctx->kvs_paths = lru_cache_create (256))) oom (); lru_cache_set_free_f (ctx->kvs_paths, free); if (!(ctx->callbacks = zlist_new ())) oom (); ctx->first_time = 1; ctx->h = h; flux_aux_set (h, "jstatctrl", ctx, freectx); } return ctx; }