static void _task_reload_m2_lb(gpointer p) { ADAPTIVE_PERIOD_DECLARE(); if (!PSRV(p)->nsinfo) return; if (ADAPTIVE_PERIOD_SKIP()) return; oio_lb_world__reload_pools(PSRV(p)->lb_world, PSRV(p)->lb, PSRV(p)->nsinfo); /* In meta2, we are only interrested in rawx services */ GSList *svctypes = g_slist_prepend(NULL, NAME_SRVTYPE_RAWX); GError *err = sqlx_reload_lb_service_types(PSRV(p)->lb_world, PSRV(p)->lb, svctypes); if (err) { GRID_WARN("Failed to reload "NAME_SRVTYPE_RAWX" services: %s", err->message); g_clear_error(&err); } else { ADAPTIVE_PERIOD_ONSUCCESS(10); } g_slist_free(svctypes); oio_lb_world__reload_storage_policies(PSRV(p)->lb_world, PSRV(p)->lb, PSRV(p)->nsinfo); oio_lb_world__debug(PSRV(p)->lb_world); }
static void _task_reconfigure_m2(gpointer p) { if (!PSRV(p)->nsinfo) return; meta2_backend_configure_nsinfo(m2, PSRV(p)->nsinfo); }
static void _task_reconfigure_events (gpointer p) { if (!grid_main_is_running ()) return; if (!p || !PSRV(p)->events_queue) return; struct namespace_info_s *ni = PSRV(p)->nsinfo; if (!ni || !ni->options) return; gint64 i64 = OIO_EVTQ_MAXPENDING; gchar *k; /* without the prefix */ i64 = gridcluster_get_nsinfo_int64 (ni, OIO_CFG_EVTQ_MAXPENDING, i64); GRID_TRACE("Looking for [%s]: %"G_GINT64_FORMAT, OIO_CFG_EVTQ_MAXPENDING, i64); /* with the prefix */ k = g_strconcat (PSRV(p)->service_config->srvtype, ".", OIO_CFG_EVTQ_MAXPENDING, NULL); i64 = gridcluster_get_nsinfo_int64 (ni, k, i64); GRID_TRACE("Looking for [%s]: %"G_GINT64_FORMAT, k, i64); g_free(k); if (i64 >= 0 && i64 < G_MAXUINT) { guint u = (guint) i64; oio_events_queue__set_max_pending (PSRV(p)->events_queue, u); } }
static void _task_expire_resolver(gpointer p) { hc_resolver_set_now(PSRV(p)->resolver, oio_ext_monotonic_time () / G_TIME_SPAN_SECOND); guint count = hc_resolver_expire(PSRV(p)->resolver); if (count) GRID_DEBUG("Expired %u entries from the resolver cache", count); }
static void _task_retry_elections(gpointer p) { if (!PSRV(p)->flag_replicable) return; guint count = election_manager_retry_elections(PSRV(p)->election_manager, 100, 500 * G_TIME_SPAN_MILLISECOND); if (count) GRID_DEBUG("Retried %u elections", count); }
static void _task_reload_workers(gpointer p) { if (!PSRV(p)->nsinfo) { GRID_DEBUG("NS info not yet loaded"); return; } gint64 max_workers = namespace_info_get_srv_param_i64 (PSRV(p)->nsinfo, NULL, PSRV(p)->service_config->srvtype, "max_workers", SRV.cfg_max_workers); network_server_set_max_workers(PSRV(p)->server, (guint) max_workers); }
static void _task_reload_workers(gpointer p) { if (!grid_main_is_running ()) return; if (!PSRV(p)->nsinfo) return; gint64 max_workers = namespace_info_get_srv_param_i64 (PSRV(p)->nsinfo, NULL, PSRV(p)->service_config->srvtype, "max_workers", SRV.cfg_max_workers); network_server_set_max_workers(PSRV(p)->server, (guint) max_workers); }
static void _task_zk_registration(gpointer p) { EXTRA_ASSERT(p != NULL); if (!zk_registered) zk_registered = _register_to_zookeeper(PSRV(p)); }
static void _task_reload_nsinfo(gpointer p) { struct namespace_info_s *ni = NULL, *old = NULL; GError *err = conscience_get_namespace(PSRV(p)->ns_name, &ni); EXTRA_ASSERT ((err != NULL) ^ (ni != NULL)); if (err) { GRID_WARN("NSINFO reload error [%s]: (%d) %s", PSRV(p)->ns_name, err->code, err->message); g_clear_error(&err); } else { old = PSRV(p)->nsinfo; PSRV(p)->nsinfo = ni; namespace_info_free(old); } }
static gpointer _worker_queue (gpointer p) { struct sqlx_service_s *ss = PSRV(p); if (ss && ss->events_queue) oio_events_queue__run_agent (ss->events_queue, grid_main_is_running); return p; }
static void _task_react_elections(gpointer p) { if (!grid_main_is_running ()) return; if (!PSRV(p)->flag_replicable) return; gint64 t = oio_ext_monotonic_time(); guint count = election_manager_play_timers (PSRV(p)->election_manager, PSRV(p)->max_elections_timers_per_round); t = t - oio_ext_monotonic_time(); if (count || t > (500*G_TIME_SPAN_MILLISECOND)) { GRID_DEBUG("Reacted %u elections in %"G_GINT64_FORMAT"ms", count, t / G_TIME_SPAN_MILLISECOND); } }
static gpointer _worker_queue (gpointer p) { metautils_ignore_signals(); struct sqlx_service_s *ss = PSRV(p); if (ss && ss->events_queue) oio_events_queue__run (ss->events_queue, _event_running); return p; }
static void meta2_on_close(struct sqlx_sqlite3_s *sq3, gboolean deleted, gpointer cb_data) { gint64 seq = 1; EXTRA_ASSERT(sq3 != NULL); if (!deleted) return; struct oio_url_s *u = oio_url_empty (); oio_url_set (u, OIOURL_NS, PSRV(cb_data)->ns_name); if (!sqlx_name_extract ((struct sqlx_name_s*)&sq3->name, u, NAME_SRVTYPE_META2, &seq)) { GRID_WARN("Invalid base name [%s]", sq3->name.base); return; } hc_decache_reference_service(PSRV(cb_data)->resolver, u, NAME_SRVTYPE_META2); oio_url_pclean(&u); }
static void _task_expire_bases(gpointer p) { struct sqlx_cache_s *cache = sqlx_repository_get_cache(PSRV(p)->repository); if (cache != NULL) { guint count = sqlx_cache_expire(cache, 100, 500 * G_TIME_SPAN_MILLISECOND); if (count) GRID_DEBUG("Expired %u bases", count); } }
static void _task_expire_resolver(gpointer p) { if (!grid_main_is_running ()) return; guint count = hc_resolver_expire(PSRV(p)->resolver); if (count) GRID_DEBUG("Expired %u entries from the resolver cache", count); }
static void _task_reconfigure_events (gpointer p) { if (!grid_main_is_running ()) return; if (!p || !PSRV(p)->events_queue) return; struct namespace_info_s *ni = PSRV(p)->nsinfo; if (!ni || !ni->options) return; gint64 i64 = namespace_info_get_srv_param_i64(ni, NULL, PSRV(p)->service_config->srvtype, OIO_CFG_EVTQ_MAXPENDING, OIO_EVTQ_MAXPENDING); GRID_TRACE("Looking for [%s]: %"G_GINT64_FORMAT, OIO_CFG_EVTQ_MAXPENDING, i64); if (i64 >= 0 && i64 < G_MAXUINT) { guint u = (guint) i64; oio_events_queue__set_max_pending (PSRV(p)->events_queue, u); } i64 = namespace_info_get_srv_param_i64(ni, NULL, PSRV(p)->service_config->srvtype, OIO_CFG_EVTQ_BUFFER_DELAY, OIO_EVTQ_BUFFER_DELAY); if (i64 >= 0 && i64 < 3600) { oio_events_queue__set_buffering(PSRV(p)->events_queue, i64 * G_TIME_SPAN_SECOND); } }
static gpointer _worker_clients(gpointer p) { metautils_ignore_signals(); while (grid_main_is_running()) { GError *err = gridd_client_pool_round(PSRV(p)->clients_pool, 1); if (err != NULL) { GRID_ERROR("Clients error : (%d) %s", err->code, err->message); g_clear_error(&err); grid_main_stop(); } } return p; }
static void _task_register(gpointer p) { if (PSRV(p)->flag_noregister) return; /* Computes the avg requests rate/time */ time_t now = oio_ext_monotonic_time () / G_TIME_SPAN_SECOND; grid_single_rrd_push (PSRV(p)->gsr_reqcounter, now, network_server_stat_getone(PSRV(p)->server, g_quark_from_static_string(OIO_STAT_PREFIX_REQ))); grid_single_rrd_push (PSRV(p)->gsr_reqtime, now, network_server_stat_getone(PSRV(p)->server, g_quark_from_static_string(OIO_STAT_PREFIX_TIME))); guint64 avg_counter = grid_single_rrd_get_delta(PSRV(p)->gsr_reqcounter, now, 4); guint64 avg_time = grid_single_rrd_get_delta(PSRV(p)->gsr_reqtime, now, 4); avg_counter = MACRO_COND(avg_counter != 0, avg_counter, 1); avg_time = MACRO_COND(avg_time != 0, avg_time, 1); service_tag_set_value_i64(service_info_ensure_tag(PSRV(p)->si->tags, "stat.total_reqpersec"), avg_counter / 4); service_tag_set_value_i64(service_info_ensure_tag(PSRV(p)->si->tags, "stat.total_avreqtime"), (avg_time)/(avg_counter)); /* send the registration now */ GError *err = register_namespace_service(PSRV(p)->si); if (err) { g_message("Service registration failed: (%d) %s", err->code, err->message); g_clear_error(&err); } }
static GError* _get_version(gpointer ctx, const struct sqlx_name_s *n, GTree **result) { EXTRA_ASSERT(ctx != NULL); return sqlx_repository_get_version2(PSRV(ctx)->repository, n, result); }
static const gchar * _get_url(gpointer ctx) { EXTRA_ASSERT(ctx != NULL); return PSRV(ctx)->announce->str; }