static GError * _remote_ping (const char *to) { GByteArray *encoded = message_marshall_gba_and_clean ( metautils_message_create_named("REQ_PING")); return gridd_client_exec (to, 30.0, encoded); }
GError * conscience_remote_push_services(const char *cs, GSList *ls) { MESSAGE req = metautils_message_create_named (NAME_MSGNAME_CS_PUSH_SRV); metautils_message_add_body_unref (req, service_info_marshall_gba (ls, NULL)); return gridd_client_exec (cs, CS_CLIENT_TIMEOUT, message_marshall_gba_and_clean(req)); }
GError* conscience_remote_remove_services(const char *cs, const char *type, GSList *ls) { MESSAGE req = metautils_message_create_named (NAME_MSGNAME_CS_RM_SRV); if (ls) metautils_message_add_body_unref (req, service_info_marshall_gba (ls, NULL)); if (type) metautils_message_add_field_str (req, NAME_MSGKEY_TYPENAME, type); return gridd_client_exec (cs, CS_CLIENT_TIMEOUT, message_marshall_gba_and_clean(req)); }
GError * gcluster_push_services(addr_info_t * addr, long timeout, GSList *ls) { EXTRA_ASSERT (addr != NULL); gchar target[STRLEN_ADDRINFO]; grid_addrinfo_to_string (addr, target, sizeof(target)); MESSAGE req = metautils_message_create_named (NAME_MSGNAME_CS_PUSH_SRV); metautils_message_add_body_unref (req, service_info_marshall_gba (ls, NULL)); return gridd_client_exec (target, ((gdouble)timeout)/1000.0, message_marshall_gba_and_clean(req)); }
static int _ping(gchar *dest, gchar *to) { gdouble timeout = g_ascii_strtod(to, NULL); GByteArray *encoded = message_marshall_gba_and_clean ( metautils_message_create_named("REQ_PING")); gint64 start = oio_ext_monotonic_time(); GError *err = gridd_client_exec(dest, timeout, encoded); gint64 end = oio_ext_monotonic_time(); if (err) { g_print("KO (%d) %s\n", err->code, err->message); g_clear_error(&err); return 1; } else { g_print("OK %lfs\n", (end - start) / (gdouble)G_TIME_SPAN_SECOND); return 0; } }
GError* sqlx_remote_execute_RELOAD (const char *to) { return gridd_client_exec (to, COMMON_CLIENT_TIMEOUT, sqlx_pack_RELOAD()); }
enum http_rc_e action_forward (struct req_args_s *args) { const char *id = OPT("id"); const char *action = TOK("ACTION"); if (!id) return _reply_format_error (args, BADREQ("Missing SRVID")); if (!action) return _reply_format_error (args, BADREQ("Missing action")); GError *err = NULL; if (!g_ascii_strcasecmp (action, "flush")) { err = sqlx_remote_execute_FLUSH (id); if (!err) return _reply_success_json (args, NULL); return _reply_common_error (args, err); } if (!g_ascii_strcasecmp (action, "reload")) { err = sqlx_remote_execute_RELOAD (id); if (!err) return _reply_success_json (args, NULL); return _reply_common_error (args, err); } if (!g_ascii_strcasecmp (action, "kill")) { GByteArray *encoded = message_marshall_gba_and_clean ( metautils_message_create_named("REQ_KILL")); err = gridd_client_exec (id, 1.0, encoded); if (err) return _reply_common_error (args, err); return _reply_success_json (args, NULL); } if (!g_ascii_strcasecmp (action, "ping")) { args->rp->no_access(); GByteArray *encoded = message_marshall_gba_and_clean ( metautils_message_create_named("REQ_PING")); err = gridd_client_exec (id, 1.0, encoded); if (err) return _reply_common_error (args, err); return _reply_success_json (args, NULL); } if (!g_ascii_strcasecmp (action, "lean-glib")) { MESSAGE req = metautils_message_create_named("REQ_LEAN"); metautils_message_add_field_str(req, "LIBC", "1"); metautils_message_add_field_str(req, "THREADS", "1"); GByteArray *encoded = message_marshall_gba_and_clean (req); err = gridd_client_exec (id, 1.0, encoded); if (err) return _reply_common_error (args, err); return _reply_success_json (args, NULL); } if (!g_ascii_strcasecmp (action, "lean-sqlx")) { GByteArray *encoded = message_marshall_gba_and_clean ( metautils_message_create_named(NAME_MSGNAME_SQLX_LEANIFY)); err = gridd_client_exec (id, 1.0, encoded); if (err) return _reply_common_error (args, err); return _reply_success_json (args, NULL); } if (!g_ascii_strcasecmp (action, "version")) { args->rp->no_access(); MESSAGE req = metautils_message_create_named("REQ_VERSION"); GByteArray *encoded = message_marshall_gba_and_clean (req); gchar *packed = NULL; err = gridd_client_exec_and_concat_string (id, 1.0, encoded, &packed); if (err) { g_free0 (packed); return _reply_common_error (args, err); } /* TODO(jfs): quite duplicated from _reply_json() but the original was not suitable. */ args->rp->set_status (200, "OK"); args->rp->set_body_bytes (g_bytes_new_take((guint8*)packed, strlen(packed))); args->rp->finalize (); return HTTPRC_DONE; } if (!g_ascii_strcasecmp (action, "handlers")) { args->rp->no_access(); MESSAGE req = metautils_message_create_named("REQ_HANDLERS"); GByteArray *encoded = message_marshall_gba_and_clean (req); gchar *packed = NULL; err = gridd_client_exec_and_concat_string (id, 1.0, encoded, &packed); if (err) { g_free0 (packed); return _reply_common_error (args, err); } /* TODO(jfs): quite duplicated from _reply_json() but the original was not suitable. */ args->rp->set_status (200, "OK"); args->rp->set_body_bytes (g_bytes_new_take((guint8*)packed, strlen(packed))); args->rp->finalize (); return HTTPRC_DONE; } return _reply_common_error (args, BADREQ("unexpected action")); }
static GError * _m0_remote_no_return (const char *m0, GByteArray *req) { EXTRA_ASSERT (m0 != NULL); return gridd_client_exec (m0, M0V2_CLIENT_TIMEOUT, req); }